Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 568446 - sys-apps/net-tools: ifconfig eth0:3 0.0.0.0 -> SIOCSIFFLAGS: Cannot assign requested address
Summary: sys-apps/net-tools: ifconfig eth0:3 0.0.0.0 -> SIOCSIFFLAGS: Cannot assign re...
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: [OLD] Core system (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: Gentoo's Team for Core System packages
URL: https://sourceforge.net/p/net-tools/m...
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-12-16 16:28 UTC by Joakim Tjernlund
Modified: 2016-02-15 14:44 UTC (History)
0 users

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Joakim Tjernlund 2015-12-16 16:28:28 UTC
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
Comment 1 SpanKY gentoo-dev 2015-12-17 17:59:38 UTC
doesn't look like a regression to me.  the 2011/2012/2013 snapshots do the same thing.
Comment 2 Joakim Tjernlund 2015-12-17 18:51:48 UTC
(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
Comment 3 Joakim Tjernlund 2016-02-10 10:21:36 UTC
(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.
Comment 4 SpanKY gentoo-dev 2016-02-13 05:31:04 UTC
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.
Comment 5 SpanKY gentoo-dev 2016-02-13 05:59:49 UTC
if you want to destroy an alias, the docs have always said to do:
  ifconfig eth0:3 down
Comment 6 SpanKY gentoo-dev 2016-02-13 06:11:03 UTC
i've documented & made the behavior smoother here:
https://sourceforge.net/p/net-tools/mailman/message/34846744/
Comment 7 Joakim Tjernlund 2016-02-13 13:02:32 UTC
(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 :)
Comment 8 SpanKY gentoo-dev 2016-02-15 14:44:50 UTC
i've pushed these changes upstream.  they'll be in the next release.