From nobody@FreeBSD.org  Mon Jul  9 08:16:16 2001
Return-Path: <nobody@FreeBSD.org>
Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21])
	by hub.freebsd.org (Postfix) with ESMTP id BB17C37B406
	for <freebsd-gnats-submit@FreeBSD.org>; Mon,  9 Jul 2001 08:16:15 -0700 (PDT)
	(envelope-from nobody@FreeBSD.org)
Received: (from nobody@localhost)
	by freefall.freebsd.org (8.11.3/8.11.3) id f69FGFD80111;
	Mon, 9 Jul 2001 08:16:15 -0700 (PDT)
	(envelope-from nobody)
Message-Id: <200107091516.f69FGFD80111@freefall.freebsd.org>
Date: Mon, 9 Jul 2001 08:16:15 -0700 (PDT)
From: Mark Blackman <mark.blackman@netscalibur.co.uk>
To: freebsd-gnats-submit@FreeBSD.org
Subject: ifconfig if0 netmask xxx.xxx.xxx.0 doesn't change the netmask
X-Send-Pr-Version: www-1.0
X-GNATS-Notify: ru

>Number:         28833
>Category:       bin
>Synopsis:       ifconfig if0 netmask xxx.xxx.xxx.0 doesn't change the netmask
>Confidential:   no
>Severity:       serious
>Priority:       low
>Responsible:    ume
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Mon Jul 09 08:20:01 PDT 2001
>Closed-Date:    Thu Jul 26 09:45:24 PDT 2001
>Last-Modified:  Thu Jul 26 09:47:17 PDT 2001
>Originator:     Mark Blackman
>Release:        4.3-STABLE
>Organization:
Netscalibur UK
>Environment:
System: FreeBSD amoeba.ch.dircon.net 4.3-STABLE FreeBSD 4.3-STABLE #1: Thu May 24 13:03:35 BST 2001 root@admi
n4.dircon.net:/usr/obj/usr/src/sys/AMOEBA i386
>Description:
"ifconfig ep0 netmask 255.255.240.0" has no effect on the netmask for ep0

This did work in FreeBSD-4.2 RELEASE. I suspect this is connnected with ifconfig changes, but I couldn't track it down. It looked like it shouldn't work in 4.2 either, but it does. 

The get_inaddr function seems not to do anything with which==MASK
        (http://www.freebsd.org/cgi/cvsweb.cgi/src/sbin/ifconfig/ifconfig.c?rev=1.51.2.6&content-type=text/x-
cvsweb-markup)


>How-To-Repeat:
 see description
>Fix:
only way to change netmask is via address setting as well

fconfig ep0 inet 10.0.0.1 netmask 255.255.240.0 

then you lose your default route.
>Release-Note:
>Audit-Trail:

From: Peter Pentchev <roam@orbitel.bg>
To: Mark Blackman <mark.blackman@netscalibur.co.uk>
Cc: freebsd-gnats-submit@FreeBSD.org
Subject: Re: bin/28833: ifconfig if0 netmask xxx.xxx.xxx.0 doesn't change the netmask
Date: Mon, 9 Jul 2001 18:39:50 +0300

 On Mon, Jul 09, 2001 at 08:16:15AM -0700, Mark Blackman wrote:
 > 
 > >Number:         28833
 > >Category:       bin
 > >Synopsis:       ifconfig if0 netmask xxx.xxx.xxx.0 doesn't change the netmask
 > >Environment:
 > System: FreeBSD amoeba.ch.dircon.net 4.3-STABLE FreeBSD 4.3-STABLE #1: Thu May 24 13:03:35 BST 2001 root@admi
 > n4.dircon.net:/usr/obj/usr/src/sys/AMOEBA i386
 > >Description:
 > "ifconfig ep0 netmask 255.255.240.0" has no effect on the netmask for ep0
 > 
 > This did work in FreeBSD-4.2 RELEASE. I suspect this is connnected with ifconfig changes, but I couldn't track it down. It looked like it shouldn't work in 4.2 either, but it does. 
 
 It works for me, if I also specify the IP address to change the netmask for.
 Consider a case where there are multiple IP addresses on a single interface;
 ifconfig should probably spit out an error instead of doing nothing, but
 it should most definitely not change the netmask on *all* addresses, and
 I guess it was considered unsafe to make it just change the netmask on
 the first address.
 
 Demonstration:
 
 # clean start
 [root@ringworld:v0 ~]# ifconfig rl0
 rl0: flags=8802<BROADCAST,SIMPLEX,MULTICAST> mtu 1500
         ether 00:e0:18:18:f2:0e
         media: Ethernet autoselect (none)
         status: active
 
 # add an IP address (with an erroneous netmask)
 [root@ringworld:v0 ~]# ifconfig rl0 195.24.48.13 netmask 255.255.0.0
 [root@ringworld:v0 ~]# ifconfig rl0
 rl0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 1500
         inet 195.24.48.13 netmask 0xffff0000 broadcast 195.24.255.255
         ether 00:e0:18:18:f2:0e
         media: Ethernet autoselect (none)
         status: active
 
 # attempt to change the netmask without specifying the address
 [root@ringworld:v0 ~]# ifconfig rl0 netmask 255.255.255.0
 [root@ringworld:v0 ~]# ifconfig rl0
 rl0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 1500
         inet 195.24.48.13 netmask 0xffff0000 broadcast 195.24.255.255
         ether 00:e0:18:18:f2:0e
         media: Ethernet autoselect (none)
         status: active
 
 # now do it "the right way"
 [root@ringworld:v0 ~]# ifconfig rl0 195.24.48.13 netmask 255.255.255.0
 [root@ringworld:v0 ~]# ifconfig rl0
 rl0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 1500
         inet 195.24.48.13 netmask 0xffffff00 broadcast 195.24.48.255
         ether 00:e0:18:18:f2:0e
         media: Ethernet autoselect (none)
         status: active
 
 Does that work for you?
 
 G'luck,
 Peter
 
 -- 
 This would easier understand fewer had omitted.

From: Peter Pentchev <roam@orbitel.bg>
To: Mark Blackman <mark.blackman@netscalibur.co.uk>
Cc: freebsd-gnats-submit@FreeBSD.org
Subject: Re: bin/28833: ifconfig if0 netmask xxx.xxx.xxx.0 doesn't change the netmask
Date: Mon, 9 Jul 2001 18:43:38 +0300

 On Mon, Jul 09, 2001 at 06:39:50PM +0300, Peter Pentchev wrote:
 > On Mon, Jul 09, 2001 at 08:16:15AM -0700, Mark Blackman wrote:
 > > 
 > > >Number:         28833
 > > >Category:       bin
 > > >Synopsis:       ifconfig if0 netmask xxx.xxx.xxx.0 doesn't change the netmask
 > > >Environment:
 > > System: FreeBSD amoeba.ch.dircon.net 4.3-STABLE FreeBSD 4.3-STABLE #1: Thu May 24 13:03:35 BST 2001 root@admi
 > > n4.dircon.net:/usr/obj/usr/src/sys/AMOEBA i386
 > > >Description:
 > > "ifconfig ep0 netmask 255.255.240.0" has no effect on the netmask for ep0
 > > 
 > > This did work in FreeBSD-4.2 RELEASE. I suspect this is connnected with ifconfig changes, but I couldn't track it down. It looked like it shouldn't work in 4.2 either, but it does. 
 > 
 > It works for me, if I also specify the IP address to change the netmask for.
 > Consider a case where there are multiple IP addresses on a single interface;
 > ifconfig should probably spit out an error instead of doing nothing, but
 > it should most definitely not change the netmask on *all* addresses, and
 > I guess it was considered unsafe to make it just change the netmask on
 > the first address.
 
 Ah; I actually see that you already knew that - 'only way to change
 netmask is via address setting as well'.  Well, once again, I don't
 think it would be safe to change just the netmask on the first address,
 or on all of them.  Think aliases - several IP addresses on the same
 network on the same NIC; or think subnets - several logical networks
 on the same physical network, and a machine on more than one of
 the logical nets.
 
 Though I guess ifconfig(8) could somehow error out, instead of failing
 silently.  I'll look into this.
 
 G'luck,
 Peter
 
 -- 
 I am the meaning of this sentence.

From: "Mark Blackman" <mark.blackman@netscalibur.co.uk>
To: Peter Pentchev <roam@orbitel.bg>
Cc: freebsd-gnats-submit@FreeBSD.org
Subject: Re: bin/28833: ifconfig if0 netmask xxx.xxx.xxx.0 doesn't change the netmask 
Date: Mon, 09 Jul 2001 16:50:56 +0100

 you're right, the correct behaviour is that the netmask change must be allied 
 to a specific address as aliases are very common.
 
 Although, generally most aliases are have netmask of 255.255.255.255 and
 so the new netmask is logically applied to the "first".
 
 The fundamental problem is that changing the netmask loses the default
 route if you use an address as well as .. using an address causes the default
 route to go away.
 
 I just think its a violation of POLA that changing the netmask only
 causes your default route to disappear
 
 I posted a related message on freebsd-net.
 
 If you feel its semantically inappropriate to get away without
 using an address then fine, but this did work in the past and so
 there is some POLA violation.
 
 - Mark
 
 POLA --> principle of least astonishment.
 
 > On Mon, Jul 09, 2001 at 06:39:50PM +0300, Peter Pentchev wrote:
 > > On Mon, Jul 09, 2001 at 08:16:15AM -0700, Mark Blackman wrote:
 > > > 
 > > > >Number:         28833
 > > > >Category:       bin
 > > > >Synopsis:       ifconfig if0 netmask xxx.xxx.xxx.0 doesn't change the ne
 > tmask
 > > > >Environment:
 > > > System: FreeBSD amoeba.ch.dircon.net 4.3-STABLE FreeBSD 4.3-STABLE #1: Th
 > u May 24 13:03:35 BST 2001 root@admi
 > > > n4.dircon.net:/usr/obj/usr/src/sys/AMOEBA i386
 > > > >Description:
 > > > "ifconfig ep0 netmask 255.255.240.0" has no effect on the netmask for ep0
 > > > 
 > > > This did work in FreeBSD-4.2 RELEASE. I suspect this is connnected with i
 > fconfig changes, but I couldn't track it down. It looked like it shouldn't wo
 > rk in 4.2 either, but it does. 
 > > 
 > > It works for me, if I also specify the IP address to change the netmask for
 > .
 > > Consider a case where there are multiple IP addresses on a single interface
 > ;
 > > ifconfig should probably spit out an error instead of doing nothing, but
 > > it should most definitely not change the netmask on *all* addresses, and
 > > I guess it was considered unsafe to make it just change the netmask on
 > > the first address.
 > 
 > Ah; I actually see that you already knew that - 'only way to change
 > netmask is via address setting as well'.  Well, once again, I don't
 > think it would be safe to change just the netmask on the first address,
 > or on all of them.  Think aliases - several IP addresses on the same
 > network on the same NIC; or think subnets - several logical networks
 > on the same physical network, and a machine on more than one of
 > the logical nets.
 > 
 > Though I guess ifconfig(8) could somehow error out, instead of failing
 > silently.  I'll look into this.
 > 
 > G'luck,
 > Peter
 > 
 > -- 
 > I am the meaning of this sentence.

From: Peter Pentchev <roam@orbitel.bg>
To: Mark Blackman <mark.blackman@netscalibur.co.uk>
Cc: freebsd-gnats-submit@FreeBSD.org
Subject: Re: bin/28833: ifconfig if0 netmask xxx.xxx.xxx.0 doesn't change the netmask
Date: Mon, 9 Jul 2001 19:19:14 +0300

 On Mon, Jul 09, 2001 at 09:00:05AM -0700, Mark Blackman wrote:
 >  you're right, the correct behaviour is that the netmask change must be allied 
 >  to a specific address as aliases are very common.
 >  
 >  Although, generally most aliases are have netmask of 255.255.255.255 and
 >  so the new netmask is logically applied to the "first".
 
 Yep, but there's still the case of more than one non-alias IP address..
 
 >  The fundamental problem is that changing the netmask loses the default
 >  route if you use an address as well as .. using an address causes the default
 >  route to go away.
 >  
 >  I just think its a violation of POLA that changing the netmask only
 >  causes your default route to disappear
 >  
 >  I posted a related message on freebsd-net.
 
 Unfortunately, I am not on -net :(
 
 Causing the default route to disappear is a side effect of a change
 that was very much needed indeed - namely, that all routes associated
 with an interface should disappear once that interface is brought down.
 (Strictly speaking, this is more of 'all routes associated with an IP
 address of a non-alias interface' or some such, but you get the drift..)
 This is really important in the case of dynamically-configurable and
 oft-changing networks on, say, a laptop.  If you bring down an interface
 address, and then bring up a new one, many programs expect setting
 a default route via the new net to 'just work', without having to replace
 an existing default route; many programs even complain if there is
 an existing default route, and leave it there, leaving the laptop
 in a kind of unusable state - with a default gateway on the old network,
 unreachable from the present one.
 
 >  If you feel its semantically inappropriate to get away without
 >  using an address then fine, but this did work in the past and so
 >  there is some POLA violation.
 
 Yes, this is a POLA violation, but I prefer to think of it as a fix
 for a problem that has annoyed quite a lot of people.  Maybe there
 could be a better solution, like adding an 'ifconfig change'..
 but then again, no - when you change an interface address's netmask,
 you actually delete a route for the old network, and add a route
 to the new one.  Keeping all the routes which have addresses on
 the old network as gateways, and whose gateway addresses are still
 reachable via the new network, and removing all others, might require
 a bit more work.
 
 G'luck,
 Peter
 
 -- 
 If I were you, who would be reading this sentence?

From: "Mark Blackman" <mark.blackman@netscalibur.co.uk>
To: Peter Pentchev <roam@orbitel.bg>
Cc: freebsd-gnats-submit@FreeBSD.org
Subject: Re: bin/28833: ifconfig if0 netmask xxx.xxx.xxx.0 doesn't change the netmask 
Date: Mon, 09 Jul 2001 17:32:26 +0100

 all things considered, I'm quite convinced that the current behaviour
 is much closer to correct and consistent, but it still strikes me as 
 non-intuitive that address changes that aren't lead to default route 
 disappearance.
 
 I think, as Brian Somers suggested, that ifconfig could be a bit smarter
 and for the special case that
 
 1) the new address is within the old netmask and the new netmask
         or
    the new address is identical to the old address
 
 and 
 
 2) the default route is still within the new netmask 
 
 then only a 
 
 SIOCSIFNETMASK ioctl is performed, 
 
 although I'm happy to insist that an address be specified for 
 netmask changes unless there is only one address bound to the interface.
 
 this does possibly make 'ifconfig' a bit too clever.
 
 In any case, I just wanted to know what the expected behaviour
 was currently, so I can educate people locally.
 
 - Mark
 
 > On Mon, Jul 09, 2001 at 09:00:05AM -0700, Mark Blackman wrote:
 > >  you're right, the correct behaviour is that the netmask change must be all
 > ied 
 > >  to a specific address as aliases are very common.
 > >  
 > >  Although, generally most aliases are have netmask of 255.255.255.255 and
 > >  so the new netmask is logically applied to the "first".
 > 
 > Yep, but there's still the case of more than one non-alias IP address..
 > 
 > >  The fundamental problem is that changing the netmask loses the default
 > >  route if you use an address as well as .. using an address causes the defa
 > ult
 > >  route to go away.
 > >  
 > >  I just think its a violation of POLA that changing the netmask only
 > >  causes your default route to disappear
 > >  
 > >  I posted a related message on freebsd-net.
 > 
 > Unfortunately, I am not on -net :(
 > 
 > Causing the default route to disappear is a side effect of a change
 > that was very much needed indeed - namely, that all routes associated
 > with an interface should disappear once that interface is brought down.
 > (Strictly speaking, this is more of 'all routes associated with an IP
 > address of a non-alias interface' or some such, but you get the drift..)
 > This is really important in the case of dynamically-configurable and
 > oft-changing networks on, say, a laptop.  If you bring down an interface
 > address, and then bring up a new one, many programs expect setting
 > a default route via the new net to 'just work', without having to replace
 > an existing default route; many programs even complain if there is
 > an existing default route, and leave it there, leaving the laptop
 > in a kind of unusable state - with a default gateway on the old network,
 > unreachable from the present one.
 > 
 > >  If you feel its semantically inappropriate to get away without
 > >  using an address then fine, but this did work in the past and so
 > >  there is some POLA violation.
 > 
 > Yes, this is a POLA violation, but I prefer to think of it as a fix
 > for a problem that has annoyed quite a lot of people.  Maybe there
 > could be a better solution, like adding an 'ifconfig change'..
 > but then again, no - when you change an interface address's netmask,
 > you actually delete a route for the old network, and add a route
 > to the new one.  Keeping all the routes which have addresses on
 > the old network as gateways, and whose gateway addresses are still
 > reachable via the new network, and removing all others, might require
 > a bit more work.
 > 
 > G'luck,
 > Peter
 > 
 > -- 
 > If I were you, who would be reading this sentence?
Responsible-Changed-From-To: freebsd-bugs->ume 
Responsible-Changed-By: ru 
Responsible-Changed-When: Tue Jul 17 05:44:41 PDT 2001 
Responsible-Changed-Why:  
Umemoto san, rev. 1.59 of ifconfig.c broke this feature. 

http://www.FreeBSD.org/cgi/query-pr.cgi?pr=28833 
State-Changed-From-To: open->closed 
State-Changed-By: ume 
State-Changed-When: Thu Jul 26 09:45:24 PDT 2001 
State-Changed-Why:  
Thank you for your report.  I just committed the fix. 
http://www.freebsd.org/cgi/cvsweb.cgi/src/sbin/ifconfig/ifconfig.c.diff?r1=1.65&r2=1.66 

http://www.FreeBSD.org/cgi/query-pr.cgi?pr=28833 
>Unformatted:
