weirdness in interface.c routine get_name()

Robert P. J. Day rpjday at mindspring.com
Tue Jun 20 03:24:45 PDT 2006


  i'm still digging thru the networking code and i found something a
bit puzzling about the routine get_name() in interface.c.  as i read
it, the purpose of that routine is to extract and return the name of
an interface from a larger line of text, ostensibly a line read from
the file /proc/net/dev.

  in a simple case, a line from that file would look like:

    lo: 2463046 ...

and that routine looks for a ":" to delimit the interface name.  but
it also looks beyond that first colon in case this is an alias, such
as, i'm guessing, "eth0:1:", at which point the returned interface
name would be "eth0:1".  is this correct so far?

  in the first place, the code in get_name() appears to be
overly-complicated.  wouldn't it be easier to use a regular expression
that would extract everything from the beginning of the name up to but
not including the final colon, as long as the string contained only
alphanumeric characters and colons?  that would certainly seem to
work, no?

  also, will the file /proc/net/dev actually contain interface alias
names?  on my FC system, i used ifconfig to create a totally bogus
alias name, eth0:1, but that name never appeared in that file.  can
anyone else confirm that interface aliases will really show up there?

  in any event, i would thing that using a regex would still make that
routine *way* shorter.

rday


More information about the busybox mailing list