Summary: | sys-apps/net-tools: ifconfig eth0:3 0.0.0.0 -> SIOCSIFFLAGS: Cannot assign requested address | ||
---|---|---|---|
Product: | Gentoo Linux | Reporter: | Joakim Tjernlund <joakim.tjernlund> |
Component: | [OLD] Core system | Assignee: | Gentoo's Team for Core System packages <base-system> |
Status: | RESOLVED FIXED | ||
Severity: | normal | ||
Priority: | Normal | ||
Version: | unspecified | ||
Hardware: | All | ||
OS: | Linux | ||
URL: | https://sourceforge.net/p/net-tools/mailman/message/34846744/ | ||
Whiteboard: | |||
Package list: | Runtime testing required: | --- |
doesn't look like a regression to me. the 2011/2012/2013 snapshots do the same thing. (In reply to SpanKY from comment #1) > doesn't look like a regression to me. the 2011/2012/2013 snapshots do the > same thing. Agreed, not a regression. I noted that adding a - sign removed the error: ifconfig eth0:3- 0.0.0.0 this can be deduced by looking at the source. I have no idea as to why this - sign is needed. I would just remove the - check (In reply to Joakim Tjernlund from comment #0) > This sequence reports an error: > > # ifconfig eth0:3 1.2.3.4 > > # ifconfig eth0:3 0.0.0.0 > SIOCSIFFLAGS: Cannot assign requested address > > stracing reveals this: > strace ifconfig eth0:3 0.0.0.0 > .... > ioctl(4, SIOCSIFADDR, {ifr_name="eth0:3", ifr_addr={AF_INET, > inet_addr("0.0.0.0")}}) = 0 > ioctl(4, SIOCGIFFLAGS, {ifr_name="eth0:3", > ifr_flags=IFF_UP|IFF_BROADCAST|IFF_RUNNING|IFF_MULTICAST}) = 0 > ioctl(4, SIOCSIFFLAGS, {ifr_name="eth0:3", ???}) = -1 EADDRNOTAVAIL (Cannot > assign requested address) > > 1.60_p2015112414 has the same error Forgot to mention that the alias is still deleted, so this error msg is just wrong. looks like it's WAI: /* * Don't do the set_flag() if the address is an alias with a - at the * end, since it's deleted already! - Roman * * Should really use regex.h here, not sure though how well it'll go * with the cross-platform support etc. */ { char *ptr; short int found_colon = 0; for (ptr = ifr.ifr_name; *ptr; ptr++ ) if (*ptr == ':') found_colon++; if (!(found_colon && *(ptr - 1) == '-')) goterr |= set_flag(ifr.ifr_name, (IFF_UP | IFF_RUNNING)); } basically, when you run `ifconfig eth0:x`, you're operating on an alias. when you pass 0.0.0.0, you're implicitly destroying the alias (just how the kernel works). but ifconfig also has this long standing behavior: up This flag causes the interface to be activated. It is implicitly specified if an address is assigned to the interface. so when you run `ifconfig eth0:x 0.0.0.0`, it first uses SIOCSIFADDR to assign the address 0.0.0.0 to eth0:x, and the kernel uses that to delete the alias. when ifconfig continues to try to bring it up, the kernel returns an error because that alias no longer exists. this is why the alias concept is deprecated. if you use `ip addr`, you can correctly manipulate multiple addresses on a single interface. we can add a special check to ifconfig to treat the special address 0.0.0.0 to not try and bring up the iface. if you want to destroy an alias, the docs have always said to do: ifconfig eth0:3 down i've documented & made the behavior smoother here: https://sourceforge.net/p/net-tools/mailman/message/34846744/ (In reply to SpanKY from comment #6) > i've documented & made the behavior smoother here: > https://sourceforge.net/p/net-tools/mailman/message/34846744/ Nice, thanks for digging into this :) i've pushed these changes upstream. they'll be in the next release. |
This sequence reports an error: > # ifconfig eth0:3 1.2.3.4 > # ifconfig eth0:3 0.0.0.0 SIOCSIFFLAGS: Cannot assign requested address stracing reveals this: strace ifconfig eth0:3 0.0.0.0 .... ioctl(4, SIOCSIFADDR, {ifr_name="eth0:3", ifr_addr={AF_INET, inet_addr("0.0.0.0")}}) = 0 ioctl(4, SIOCGIFFLAGS, {ifr_name="eth0:3", ifr_flags=IFF_UP|IFF_BROADCAST|IFF_RUNNING|IFF_MULTICAST}) = 0 ioctl(4, SIOCSIFFLAGS, {ifr_name="eth0:3", ???}) = -1 EADDRNOTAVAIL (Cannot assign requested address) 1.60_p2015112414 has the same error