From owner-freebsd-bugs Tue Jul 17 5:43:59 2001 Delivered-To: freebsd-bugs@freebsd.org Received: from whale.sunbay.crimea.ua (whale.sunbay.crimea.ua [212.110.138.65]) by hub.freebsd.org (Postfix) with ESMTP id 31AC537B401 for ; Tue, 17 Jul 2001 05:43:46 -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 f6HChB496923; Tue, 17 Jul 2001 15:43:11 +0300 (EEST) (envelope-from ru) Date: Tue, 17 Jul 2001 15:43:10 +0300 From: Ruslan Ermilov To: Mark Blackman Cc: freebsd-bugs@FreeBSD.ORG Subject: Re: bin/28833: ifconfig if0 netmask xxx.xxx.xxx.0 doesn't change the netmask Message-ID: <20010717154310.A90705@sunbay.com> Mail-Followup-To: Mark Blackman , freebsd-bugs@FreeBSD.ORG References: <200107171122.MAA08522@mailhost2.dircon.co.uk> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5i In-Reply-To: <200107171122.MAA08522@mailhost2.dircon.co.uk>; from mark.blackman@netscalibur.co.uk on Tue, Jul 17, 2001 at 12:22:39PM +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 On Tue, Jul 17, 2001 at 12:22:39PM +0100, Mark Blackman wrote: > > ok. I'll wait for updates. > Regarding my previous patch. Using SIOCSIFADDR is inappropriate for the initial interface configuration, as it doesn't allow one to set non-standard netmasks. Also, SIOCSIFDSTADDR was missing. But SIOCSIFADDR can still be used as a `change' operation, to change the address of an interface without removing the old address and installing the new one. Even if it's implemented, its use would be limited to a primary address of an interface. You can still "change" the netmask, without losing any static routes (including the "default"), using the following: ifconfig ep0 inet 10.0.0.1 netmask 255.255.240.0 alias Note the `alias' keyword. ifconfig(8) documents this as a method to "establishment an additional network address", but the actual code allows to use it to modify the characteristics (e.g., netmask) of an already existing address. What happens here is if you don't use `alias', the old address is deleted first with SIOCDIFADDR, then the new address (probably the same one) is installed with SIOCAIFADDR. If you use the `alias' keyword, the "deletion" part is skipped, and the kernel SIOCAIFADDR code checks to see if it should "add" or "change" the already existing address. > would you expect that 'ifconfig if0 netmask 255.255.255.0' > would work (i.e. no explicit address/inet option). > Yes, but this got broken in rev. 1.59. The following patch removes this delta and fixes this: Index: ifconfig.c =================================================================== RCS file: /home/ncvs/src/sbin/ifconfig/ifconfig.c,v retrieving revision 1.51.2.9 diff -u -p -r1.51.2.9 ifconfig.c --- ifconfig.c 2001/07/04 20:49:20 1.51.2.9 +++ ifconfig.c 2001/07/17 12:17:40 @@ -689,7 +689,7 @@ ifconfig(argc, argv, afp) newaddr = 0; } } - if (newaddr && setaddr) { + if (newaddr) { strncpy(afp->af_addreq, name, sizeof ifr.ifr_name); if (ioctl(s, afp->af_aifaddr, afp->af_addreq) < 0) Perror("ioctl (SIOCAIFADDR)"); 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-bugs" in the body of the message