Hi,

When "::/0" is used as "default",

  # route add ::/0 fe80::1%em0
  add net ::/0: gateway fe80::1%em0: Invalid argument

route command trims the sockaddr to { .len = 2, .family = AF_INET6 }
for "::/0", but rtable_satoplen() refuses it.  I think it should be
accepted.

ok?

Allow sockaddr for prefix length be trimmed before the key(address)
field.  Actually "route" command trims at the address family field for
"::/0"

Index: sys/net/rtable.c
===================================================================
RCS file: /cvs/src/sys/net/rtable.c,v
retrieving revision 1.69
diff -u -p -r1.69 rtable.c
--- sys/net/rtable.c    21 Jun 2019 17:11:42 -0000      1.69
+++ sys/net/rtable.c    28 Jun 2020 11:30:54 -0000
@@ -887,8 +887,8 @@ rtable_satoplen(sa_family_t af, struct s
 
        ap = (uint8_t *)((uint8_t *)mask) + dp->dom_rtoffset;
        ep = (uint8_t *)((uint8_t *)mask) + mlen;
-       if (ap > ep)
-               return (-1);
+       if (ap >= ep)
+               return (0);
 
        /* Trim trailing zeroes. */
        while (ap < ep && ep[-1] == 0)

Reply via email to