Commit e1ce9420 authored by Mike Frysinger's avatar Mike Frysinger

ifconfig: do not try to bring up interfaces implicitly w/IPv4 0.0.0.0

The kernel will delete alias interfaces when you assign it an address
of 0.0.0.0.  i.e. These two commands will both destroy eth0:0:
  ifconfig eth0:0 0.0.0.0
  ifconfig eth0:0 del

Omit the implicit "up" behavior when this addr is given as the kernel
will always throw an error.  Distros/people have long gotten into the
habit of deleting addresses by assigning 0.0.0.0.

URL: https://bugs.gentoo.org/568446Reported-by: default avatarJoakim Tjernlund <joakim.tjernlund@infinera.com>
parent 2529b5d4
......@@ -1008,6 +1008,8 @@ int main(int argc, char **argv)
/*
* Don't do the set_flag() if the address is an alias with a - at the
* end, since it's deleted already! - Roman
* Same goes if they used address 0.0.0.0 as the kernel uses this to
* destroy aliases.
*
* Should really use regex.h here, not sure though how well it'll go
* with the cross-platform support etc.
......@@ -1015,10 +1017,18 @@ int main(int argc, char **argv)
{
char *ptr;
short int found_colon = 0;
short int bring_up = 1;
for (ptr = ifr.ifr_name; *ptr; ptr++ )
if (*ptr == ':') found_colon++;
if (!(found_colon && *(ptr - 1) == '-'))
if (found_colon) {
if (ptr[-1] == '-')
bring_up = 0;
else if (ap->af == AF_INET && sin->sin_addr.s_addr == 0)
bring_up = 0;
}
if (bring_up)
goterr |= set_flag(ifr.ifr_name, (IFF_UP | IFF_RUNNING));
}
......
......@@ -75,6 +75,8 @@ behavior when using an alias interface by appending an
.BR "-"
to the alias (e.g.
.BR "eth0:0-" ).
It is also suppressed when using the IPv4 0.0.0.0 address as the kernel will
use this to implicitly delete alias interfaces.
.TP
.B down
This flag causes the driver for this interface to be shut down.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment