On Thu, Nov 14, 2019 at 11:14:45PM +0100, Sebastian Benoit wrote:
> The alternative is to not allow netmask for ipv6 and only /<prefixlen> and 
> prefixlen
> <prefixlen>. Why support such a crazy way of specifying the mask?

We can also do it the other way around and forbid ifconfig inet6
netmask.

> In route we removed a few quirks like that with notice in current.html , why 
> not here?

route(8) still accepts netmask.
route add -inet6 1234:: -netmask ffff:: ::1

Ignoring options silently is bad.  So either use or reject netmask.
If ifconfig(8) uses it, it would be consistent to route(8).

bluhm

Index: sbin/ifconfig/ifconfig.8
===================================================================
RCS file: /data/mirror/openbsd/cvs/src/sbin/ifconfig/ifconfig.8,v
retrieving revision 1.343
diff -u -p -r1.343 ifconfig.8
--- sbin/ifconfig/ifconfig.8    10 Nov 2019 09:10:44 -0000      1.343
+++ sbin/ifconfig/ifconfig.8    18 Nov 2019 13:57:18 -0000
@@ -429,7 +429,7 @@ output from
 .Cm hwfeatures
 shows the maximum supported MTU.
 .It Cm netmask Ar mask
-(inet and inet6 only)
+(inet only)
 Specify how much of the address to reserve for subdividing
 networks into subnetworks.
 The mask includes the network part of the local address
Index: sbin/ifconfig/ifconfig.c
===================================================================
RCS file: /data/mirror/openbsd/cvs/src/sbin/ifconfig/ifconfig.c,v
retrieving revision 1.414
diff -u -p -r1.414 ifconfig.c
--- sbin/ifconfig/ifconfig.c    24 Oct 2019 18:54:10 -0000      1.414
+++ sbin/ifconfig/ifconfig.c    18 Nov 2019 13:56:31 -0000
@@ -6151,6 +6151,9 @@ in6_getaddr(const char *s, int which)
        char buf[HOST_NAME_MAX+1 + sizeof("/128")], *pfxlen;
        int error;

+       if (which == MASK)
+               errx(1, "inet6 needs prefixlen, not netmask");
+
        memset(&hints, 0, sizeof(hints));
        hints.ai_family = AF_INET6;
        hints.ai_socktype = SOCK_DGRAM; /*dummy*/

Reply via email to