From owner-freebsd-bugs Tue Jul 17 1:20:10 2001 Delivered-To: freebsd-bugs@freebsd.org Received: from mailhost2.dircon.co.uk (mailhost2.dircon.co.uk [194.112.32.66]) by hub.freebsd.org (Postfix) with ESMTP id 62B6237B403 for ; Tue, 17 Jul 2001 01:19:59 -0700 (PDT) (envelope-from mark.blackman@netscalibur.co.uk) Received: from localhost.ch.dircon.net (desk99.ch.dircon.net [195.157.3.99]) by mailhost2.dircon.co.uk (8.9.3/8.9.3) with ESMTP id JAA41860 for ; Tue, 17 Jul 2001 09:19:47 +0100 (BST) Message-Id: <200107170819.JAA41860@mailhost2.dircon.co.uk> From: "Mark Blackman" To: freebsd-bugs@FreeBSD.ORG Subject: Re: bin/28833: ifconfig if0 netmask xxx.xxx.xxx.0 doesn't change the netmask In-Reply-To: Message from Ruslan Ermilov of "Mon, 16 Jul 2001 18:19:28 +0300." <20010716181928.B51681@sunbay.com> Date: Tue, 17 Jul 2001 09:19:56 +0100 Sender: owner-freebsd-bugs@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.org nope, would you like me to try this patch? does this mean one could do netmask changes without losing the default route (unless the default route was outside the netmask)? - Mark > > On Mon, Jul 09, 2001 at 09:40:02AM -0700, Mark Blackman wrote: > > > > 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. > > > Did you try my patch on -net (attached here as well)? > > > Cheers, > -- > Ruslan Ermilov Oracle Developer/DBA, > ru@sunbay.com Sunbay Software AG, > ru@FreeBSD.org FreeBSD committer, > +380.652.512.251 Simferopol, Ukraine > > http://www.FreeBSD.org The Power To Serve > http://www.oracle.com Enabling The Information Age > > > --7AUc2qLy4jB3hD7Z > Content-Type: message/rfc822 > Content-Disposition: inline > > Date: Wed, 11 Jul 2001 20:34:55 +0300 > From: Ruslan Ermilov > To: Brian Somers > Cc: Mark Blackman , > freebsd-net@FreeBSD.ORG > Subject: Re: default route disappears on address changes for interface. > Message-ID: <20010711203455.A99297@sunbay.com> > Mail-Followup-To: Brian Somers , > Mark Blackman , > freebsd-net@FreeBSD.ORG > References: <200107091041.f69AfbQ61858@hak.lan.Awfulhak.org> > Mime-Version: 1.0 > Content-Type: text/plain; charset=us-ascii > Content-Disposition: inline > User-Agent: Mutt/1.2.5i > In-Reply-To: <200107091041.f69AfbQ61858@hak.lan.Awfulhak.org>; from brian@Awfulhak.org on Mon, > Jul 09, 2001 at 11:41:37AM +0100 > > On Mon, Jul 09, 2001 at 11:41:37AM +0100, Brian Somers wrote: > > ifconfig(8) deletes and re-adds the given address. When the delete > > happens, the route (now) disappears. > > > > IMHO, ifconfig(8) should be smart enough to optimise out no-ops. > > > I found that using SIOCSIFADDR (though deprecated) to be beneficial > in this case. It simply "changes" the interface's address rather > than deleting an old address and adding a new one. This preserves > all routes holding on this address. Here is the hackish code that > does this. > > Index: ifconfig.c > =================================================================== > RCS file: /home/ncvs/src/sbin/ifconfig/ifconfig.c,v > retrieving revision 1.64 > diff -u -p -r1.64 ifconfig.c > --- ifconfig.c 2001/07/02 20:52:34 1.64 > +++ ifconfig.c 2001/07/11 17:30:36 > @@ -707,6 +707,12 @@ ifconfig(argc, argv, afp) > Perror("Encapsulation Routing"); > } > #endif > + if (clearaddr && newaddr && setaddr && afp->af_af == AF_INET) { > + strncpy(afp->af_addreq, name, sizeof ifr.ifr_name); > + if (ioctl(s, SIOCSIFADDR, afp->af_addreq) < 0) > + Perror("ioctl (SIOCSIFADDR)"); > + goto out; > + } > if (clearaddr) { > if (afp->af_ridreq == NULL || afp->af_difaddr == 0) { > warnx("interface %s cannot change %s addresses!", > @@ -736,6 +742,7 @@ ifconfig(argc, argv, afp) > if (ioctl(s, afp->af_aifaddr, afp->af_addreq) < 0) > Perror("ioctl (SIOCAIFADDR)"); > } > +out: > close(s); > return(0); > } > > > Cheers, > -- > Ruslan Ermilov Oracle Developer/DBA, > ru@sunbay.com Sunbay Software AG, > ru@FreeBSD.org FreeBSD committer, > +380.652.512.251 Simferopol, Ukraine > > http://www.FreeBSD.org The Power To Serve > http://www.oracle.com Enabling The Information Age > > --7AUc2qLy4jB3hD7Z-- To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-bugs" in the body of the message