Date: Mon, 16 Jul 2001 18:19:28 +0300 From: Ruslan Ermilov <ru@FreeBSD.ORG> To: Mark Blackman <mark.blackman@netscalibur.co.uk> Cc: freebsd-bugs@FreeBSD.ORG Subject: Re: bin/28833: ifconfig if0 netmask xxx.xxx.xxx.0 doesn't change the netmask Message-ID: <20010716181928.B51681@sunbay.com> In-Reply-To: <200107091640.f69Ge2S92309@freefall.freebsd.org>; from mark.blackman@netscalibur.co.uk on Mon, Jul 09, 2001 at 09:40:02AM -0700 References: <200107091640.f69Ge2S92309@freefall.freebsd.org>
next in thread | previous in thread | raw e-mail | index | archive | help
--7AUc2qLy4jB3hD7Z Content-Type: text/plain; charset=us-ascii Content-Disposition: inline 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 <ru@FreeBSD.org> To: Brian Somers <brian@Awfulhak.org> Cc: Mark Blackman <mark.blackman@netscalibur.co.uk>, 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 <brian@Awfulhak.org>, Mark Blackman <mark.blackman@netscalibur.co.uk>, freebsd-net@FreeBSD.ORG References: <mark.blackman@netscalibur.co.uk> <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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20010716181928.B51681>