Extended nameif matching
Nico Erfurth
masta at perlgolf.de
Tue Dec 11 16:06:08 PST 2007
Hi,
for my current project we needed a tool to rename interfaces by their
used usb-slot. While udev and ifrename (from the wireless-tools package)
can manage this, they both would require additional space. After
watching at the nameif applet of busybox I decided to implement the
needed features here by extending its syntax a bit. The new feature can
be disabled in the config.
The new syntax for /etc/mactab looks like this:
eth3 bus=usb-0000:00:08.2-2 mac=00:80:C8:38:91:B5
eth4 bus=usb-0000:00:10.4-5 driver=asix
eth5 bus=usb-0000:00:08.2-1
eth7 00:80:C8:38:91:B5
the mac= selector is optional, everything unknown will be parsed as a
mac-address by default. So this should be backward compatible.
I've also changed the way nameif uses to discover devices. The used
method wasn't stable, because on a hotplug-system the if_index could
have "holes". Lets say you unplug an usb-device that previously had
if_index 4, if you replug it, it will get the next available, while
if_index 4 is unused. The old discovery method would stop scanning here
and not see interfaces beyond if_index 4. The new method relies on
parsing /proc/net/dev.
By refactoring the existing code I could keep the added size down.
w/o extended matching:
function old new delta
new_ch - 157 +157
.rodata 1031 1023 -8
nameif_main 630 602 -28
cc_macaddr 51 - -51
------------------------------------------------------------------------------
(add/remove: 1/1 grow/shrink: 0/2 up/down: 157/-87) Total: 70
bytes
text data bss dec hex filename
8233 413 60 8706 2202 busybox_old
8469 425 60 8954 22fa busybox_unstripped
with extended matching:
function old new delta
new_ch - 316 +316
nameif_main 630 764 +134
.rodata 1031 1066 +35
cc_macaddr 51 - -51
------------------------------------------------------------------------------
(add/remove: 1/1 grow/shrink: 2/0 up/down: 485/-51) Total: 434
bytes
text data bss dec hex filename
8233 413 60 8706 2202 busybox_old
8833 425 60 9318 2466 busybox_unstripped
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: busybox-1.8.2.nameif_extended.patch
Url: http://busybox.net/lists/busybox/attachments/20071212/7a88ba71/attachment.diff
More information about the busybox
mailing list