Date: Tue, 17 Jul 2001 15:43:10 +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: <20010717154310.A90705@sunbay.com> In-Reply-To: <200107171122.MAA08522@mailhost2.dircon.co.uk>; from mark.blackman@netscalibur.co.uk on Tue, Jul 17, 2001 at 12:22:39PM %2B0100 References: <ru@FreeBSD.ORG> <200107171122.MAA08522@mailhost2.dircon.co.uk>
next in thread | previous in thread | raw e-mail | index | archive | help
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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20010717154310.A90705>