From owner-freebsd-net Wed Jul 11 10:36:51 2001 Delivered-To: freebsd-net@freebsd.org Received: from whale.sunbay.crimea.ua (whale.sunbay.crimea.ua [212.110.138.65]) by hub.freebsd.org (Postfix) with ESMTP id DDE0D37B403 for ; Wed, 11 Jul 2001 10:36:43 -0700 (PDT) (envelope-from ru@whale.sunbay.crimea.ua) Received: (from ru@localhost) by whale.sunbay.crimea.ua (8.11.2/8.11.2) id f6BHYtL02811; Wed, 11 Jul 2001 20:34:55 +0300 (EEST) (envelope-from ru) 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 Sender: owner-freebsd-net@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.org 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 To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-net" in the body of the message