netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Alexander Clouter <alex@digriz.org.uk>
To: netdev@vger.kernel.org
Subject: Re: [iproute2] iproute2:  Allow 'ip addr flush' to loop more than 10 times.
Date: Tue, 29 Jun 2010 16:48:51 +0100	[thread overview]
Message-ID: <38hpf7-map.ln1@chipmunk.wormnet.eu> (raw)
In-Reply-To: 4C2A0B82.7020701@candelatech.com

Ben Greear <greearb@candelatech.com> wrote:
>
>>> This is useful for getting rid of large numbers of IP
>>> addresses in scripts.
>>>
>> Maybe I am missing a trick, but what is wrong with putting this trivial
>> logic into the script:
>>
>> ip addr show ${DEV} | awk '/inet6? / { print $2 }' | xargs -I{} ip addr del '{}' dev ${DEV}
> 
> This isn't going to be fast if you have thousands of addresses.
>
Obviously not like-for-like but:
----
maru:/home/alex# cat /proc/cpuinfo
Processor       : Feroceon 88FR131 rev 1 (v5l)
BogoMIPS        : 1192.75
Features        : swp half thumb fastmult edsp
CPU implementer : 0x56
CPU architecture: 5TE
CPU variant     : 0x2
CPU part        : 0x131
CPU revision    : 1

Hardware        : Marvell SheevaPlug Reference Board
Revision        : 0000
Serial          : 0000000000000000

maru:/home/alex# ip route show realm filthpit | wc
   8464   76176  533812

maru:/home/alex# time ip route list realm filthpit | xargs -I{} sh -c 'ip route del {}'

real    1m7.590s
user    0m0.650s
sys     0m3.010s
----

>> You can probably speed things up with '-P' too, '-P 2' gives me a huge
>> huge speed up for the work I do with 'ip route'.
> 
> Where are you using the -P at?  It's not a supported option of 'ip'
> as far as I can tell.
>
xargs, it works well on SMP systems, on my SheevaPlug you do not get 
much gain.
 
>> Why the need to cram more functionality and options into iproute when
>> it is something that can be pushed into the wrapper script?
> 
> Speed and ease of use.
> 
Annoying 'ip addr show dev dummy0' craps out after 54 assignments in 
it's output (bug?), however ifconfig works so:
----
truffle:/home/ac56# cat /proc/cpuinfo 
processor       : 0
vendor_id       : GenuineIntel
cpu family      : 15
model           : 4
model name      : Intel(R) Xeon(TM) CPU 2.80GHz
stepping        : 3
cpu MHz         : 2793.177
cache size      : 2048 KB
physical id     : 0
siblings        : 2
core id         : 0
cpu cores       : 1
apicid          : 0
initial apicid  : 0
fpu             : yes
fpu_exception   : yes
cpuid level     : 5
wp              : yes
flags           : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx lm constant_tsc pebs bts pni monitor ds_cpl cid cx16 xtpr
bogomips        : 5591.21
clflush size    : 64
cache_alignment : 128
address sizes   : 36 bits physical, 48 bits virtual
power management:

[snipped other real and two ht cpus]

truffle:/home/ac56# time for I in $(seq 1 4085); do ip -6 addr add fe80::$(printf "%x" ${I})/64 dev dummy0; done

real    0m17.013s
user    0m4.004s
sys     0m11.417s
truffle:/home/ac56# ifconfig dummy0 | awk '/inet6? / { print $3 }' | wc
   4085    4085   52835
truffle:/home/ac56# time ifconfig dummy0 | awk '/inet6? / { print $3 }' | xargs -I{} ip addr del {} dev dummy0

real    0m5.897s
user    0m1.272s
sys     0m4.456s

# no idea why but, only 24 entries, re-running the above cleans up 
# properly in 4ms
truffle:/home/ac56# ifconfig dummy0 | awk '/inet6? / { print $3 }' | wc 
     24      24     310

# from the top again (but for '-P2' action):
truffle:/home/ac56# time ifconfig dummy0 | awk '/inet6? / { print $3 }' | xargs -I{} -P2 ip addr del {} dev dummy0

real    0m4.013s
user    0m1.268s
sys     0m5.072s

truffle:/home/ac56# ifconfig dummy0 | awk '/inet6? / { print $3 }' | wc
     40      40     516
----

Apart from the cleanup glitches in both cases, things are rather fast 
already?  Probably worth focusing at the 'ip (route|addr) add' slowness?

Bah, just my £0.02.

Cheers

[1] and anything more than 4085 for the sequence gives 'RTNETLINK 
	answers: Cannot allocate memory'

-- 
Alexander Clouter
.sigmonster says: Someone is speaking well of you.


  reply	other threads:[~2010-06-29 15:49 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-06-29  5:55 [iproute2] iproute2: Allow 'ip addr flush' to loop more than 10 times greearb
2010-06-29  6:12 ` David Miller
2010-06-29  6:27   ` Ben Greear
2010-06-29  6:36     ` David Miller
2010-06-29  9:58       ` Andreas Henriksson
2010-06-29 14:59         ` Ben Greear
2010-06-29 15:10       ` Ben Greear
2010-06-29 17:02         ` David Miller
2010-06-29  8:03 ` Alexander Clouter
2010-06-29 15:04   ` Ben Greear
2010-06-29 15:48     ` Alexander Clouter [this message]
2010-06-29 16:30       ` Ben Greear
2010-08-04 21:00 ` Stephen Hemminger
2010-08-04 21:13   ` Ben Greear

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=38hpf7-map.ln1@chipmunk.wormnet.eu \
    --to=alex@digriz.org.uk \
    --cc=netdev@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).