Strange behaviour of ``ifconfig -alias''

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Strange behaviour of ``ifconfig -alias''

Alexander Hall
Hi!

I just noticed (the hard way) a strange behaviour of ifconfig. In short,
if I supply a netmask when removing an alias with ``-alias <address>'',
it is not, as one would expect, ignored, but rather used as the netmask
for the primary address of the interface.

While it would not be necessary to supply the netmask when removing an
alias, I cannot see that this behaviour would be expected. I would
rather expect an error or that the netmask was ignored.

Or am I totally wrong?

Example follows:

$ ifconfig xl0
xl0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 1500
         lladdr 00:06:5b:36:f8:e1
         groups: egress
         media: Ethernet autoselect (100baseTX full-duplex)
         status: active
         inet6 fe80::206:5bff:fe36:f8e1%xl0 prefixlen 64 scopeid 0x1
         inet 192.168.2.130 netmask 0xffffff00 broadcast 192.168.2.255
$ sudo ifconfig xl0 inet alias 192.168.2.140 netmask 255.255.255.255
$ ifconfig xl0
xl0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 1500
         lladdr 00:06:5b:36:f8:e1
         groups: egress
         media: Ethernet autoselect (100baseTX full-duplex)
         status: active
         inet6 fe80::206:5bff:fe36:f8e1%xl0 prefixlen 64 scopeid 0x1
         inet 192.168.2.130 netmask 0xffffff00 broadcast 192.168.2.255
         inet 192.168.2.140 netmask 0xffffffff broadcast 192.168.2.140
$ sudo ifconfig xl0 inet -alias 192.168.2.140 netmask 255.255.255.255
ifconfig: SIOCAIFADDR: File exists
$ ifconfig xl0
xl0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 1500
         lladdr 00:06:5b:36:f8:e1
         groups: egress
         media: Ethernet autoselect (100baseTX full-duplex)
         status: active
         inet6 fe80::206:5bff:fe36:f8e1%xl0 prefixlen 64 scopeid 0x1
         inet 192.168.2.130 netmask 0xffffffff broadcast 192.168.2.130
                                    ^^^^^^^^^^
                                      madness

/Alexander

Reply | Threaded
Open this post in threaded view
|

Re: Strange behaviour of ``ifconfig -alias''

Otto Moerbeek
On Fri, 27 Jan 2006, Alexander Hall wrote:

> Hi!
>
> I just noticed (the hard way) a strange behaviour of ifconfig. In short, if I
> supply a netmask when removing an alias with ``-alias <address>'', it is not,
> as one would expect, ignored, but rather used as the netmask for the primary
> address of the interface.
>
> While it would not be necessary to supply the netmask when removing an alias,
> I cannot see that this behaviour would be expected. I would rather expect an
> error or that the netmask was ignored.
>
> Or am I totally wrong?

alias/-alias is a _parameter_ and should come after the address.
It would be better if ifconfig would be more strict, but its argument
parsing code is a nightmare....

        -Otto

>
> Example follows:
>
> $ ifconfig xl0
> xl0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 1500
>         lladdr 00:06:5b:36:f8:e1
>         groups: egress
>         media: Ethernet autoselect (100baseTX full-duplex)
>         status: active
>         inet6 fe80::206:5bff:fe36:f8e1%xl0 prefixlen 64 scopeid 0x1
>         inet 192.168.2.130 netmask 0xffffff00 broadcast 192.168.2.255
> $ sudo ifconfig xl0 inet alias 192.168.2.140 netmask 255.255.255.255
> $ ifconfig xl0
> xl0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 1500
>         lladdr 00:06:5b:36:f8:e1
>         groups: egress
>         media: Ethernet autoselect (100baseTX full-duplex)
>         status: active
>         inet6 fe80::206:5bff:fe36:f8e1%xl0 prefixlen 64 scopeid 0x1
>         inet 192.168.2.130 netmask 0xffffff00 broadcast 192.168.2.255
>         inet 192.168.2.140 netmask 0xffffffff broadcast 192.168.2.140
> $ sudo ifconfig xl0 inet -alias 192.168.2.140 netmask 255.255.255.255
> ifconfig: SIOCAIFADDR: File exists
> $ ifconfig xl0
> xl0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 1500
>         lladdr 00:06:5b:36:f8:e1
>         groups: egress
>         media: Ethernet autoselect (100baseTX full-duplex)
>         status: active
>         inet6 fe80::206:5bff:fe36:f8e1%xl0 prefixlen 64 scopeid 0x1
>         inet 192.168.2.130 netmask 0xffffffff broadcast 192.168.2.130
>                                    ^^^^^^^^^^
>                                      madness
>
> /Alexander

Reply | Threaded
Open this post in threaded view
|

Re: Strange behaviour of ``ifconfig -alias''

Marco Pfatschbacher
In reply to this post by Alexander Hall
On Fri, Jan 27, 2006 at 02:18:10PM +0100, Alexander Hall wrote:

> Hi!
>
> I just noticed (the hard way) a strange behaviour of ifconfig. In short,
> if I supply a netmask when removing an alias with ``-alias <address>'',
> it is not, as one would expect, ignored, but rather used as the netmask
> for the primary address of the interface.
>
> While it would not be necessary to supply the netmask when removing an
> alias, I cannot see that this behaviour would be expected. I would
> rather expect an error or that the netmask was ignored.
>
> Or am I totally wrong?
>
> Example follows:
>
> $ ifconfig xl0
> xl0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 1500
>         lladdr 00:06:5b:36:f8:e1
>         groups: egress
>         media: Ethernet autoselect (100baseTX full-duplex)
>         status: active
>         inet6 fe80::206:5bff:fe36:f8e1%xl0 prefixlen 64 scopeid 0x1
>         inet 192.168.2.130 netmask 0xffffff00 broadcast 192.168.2.255
> $ sudo ifconfig xl0 inet alias 192.168.2.140 netmask 255.255.255.255
> $ ifconfig xl0
> xl0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 1500
>         lladdr 00:06:5b:36:f8:e1
>         groups: egress
>         media: Ethernet autoselect (100baseTX full-duplex)
>         status: active
>         inet6 fe80::206:5bff:fe36:f8e1%xl0 prefixlen 64 scopeid 0x1
>         inet 192.168.2.130 netmask 0xffffff00 broadcast 192.168.2.255
>         inet 192.168.2.140 netmask 0xffffffff broadcast 192.168.2.140
> $ sudo ifconfig xl0 inet -alias 192.168.2.140 netmask 255.255.255.255
> ifconfig: SIOCAIFADDR: File exists
> $ ifconfig xl0
> xl0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 1500
>         lladdr 00:06:5b:36:f8:e1
>         groups: egress
>         media: Ethernet autoselect (100baseTX full-duplex)
>         status: active
>         inet6 fe80::206:5bff:fe36:f8e1%xl0 prefixlen 64 scopeid 0x1
>         inet 192.168.2.130 netmask 0xffffffff broadcast 192.168.2.130
>                                    ^^^^^^^^^^
>                                      madness

http://marc.theaimsgroup.com/?l=openbsd-misc&m=111852853930931

Reply | Threaded
Open this post in threaded view
|

Re: Strange behaviour of ``ifconfig -alias''

Alexander Hall
Marco Pfatschbacher wrote:
> On Fri, Jan 27, 2006 at 02:18:10PM +0100, Alexander Hall wrote:
>>Hi!
>>
>>I just noticed (the hard way) a strange behaviour of ifconfig. In short,
>>if I supply a netmask when removing an alias with ``-alias <address>'',
>>it is not, as one would expect, ignored, but rather used as the netmask
>>for the primary address of the interface.

>
> http://marc.theaimsgroup.com/?l=openbsd-misc&m=111852853930931
>

Thanks. A combination of being upset and that too often ocurring
sensation of "I have followed misc for so long now and I sure have not
seen this issue" made me overlook the archives.

Now I see the syntax error (ip address should be prior to [-]alias), and
although I would have expected an error message rather than some
undocumented behaviour, I suppose I'll learn to live with it since I do
not have the time or skills to fix it.

/Alexander

Reply | Threaded
Open this post in threaded view
|

Re: Strange behaviour of ``ifconfig -alias''

Alexander Hall
In reply to this post by Otto Moerbeek
Otto Moerbeek wrote:
> On Fri, 27 Jan 2006, Alexander Hall wrote:

>>I just noticed (the hard way) a strange behaviour of ifconfig. In short, if I
>>supply a netmask when removing an alias with ``-alias <address>'', it is not,
>>as one would expect, ignored, but rather used as the netmask for the primary
>>address of the interface.

> alias/-alias is a _parameter_ and should come after the address.
> It would be better if ifconfig would be more strict, but its argument
> parsing code is a nightmare....
>
> -Otto

Ah. Got it. I agree on the strict parsing. Would have saved me from a
headache last night. :-/

Thanks,
Alexander