Consider
route add -inet6 -prefixlen 64 2a00:cafe:aaaa:: -prefixlen 56 ::1
This currently works (sets the route with /56), as does
route add -inet6 -prefixlen 56 2a00:cafe:aaaa:: ::1
(sets the route with /64).
patch:
* dissallow use of argument -prefixlen twice
* when -prefixlen is given before an ipv6 destination,
the prefixlen argument is is used instead of implicit /64
/Benno
Index: route.c
===================================================================
RCS file: /cvs/src/sbin/route/route.c,v
retrieving revision 1.156
diff -u -p -r1.156 route.c
--- route.c 17 Mar 2012 10:16:40 -0000 1.156
+++ route.c 8 Jul 2012 18:10:01 -0000
@@ -71,6 +71,7 @@ int rtm_addrs, s;
int forcehost, forcenet, Fflag, nflag, af, qflag, tflag, Tflag;
int iflag, verbose, aflen = sizeof(struct sockaddr_in);
int locking, lockrest, debugonly;
+int seenprefixlen = 0;
u_long mpls_flags = MPLS_OP_LOCAL;
u_long rtm_inits;
uid_t uid;
@@ -550,6 +551,9 @@ newroute(int argc, char **argv)
case K_PREFIXLEN:
if (!--argc)
usage(1+*argv);
+ if (seenprefixlen)
+ errx(1, "cannot set prefixlen twice");
+ seenprefixlen = 1;
ishost = prefixlen(*++argv);
break;
case K_MPATH:
@@ -755,6 +759,9 @@ inet6_makenetandmask(struct sockaddr_in6
if (!plen || strcmp(plen, "128") == 0)
return (1);
else {
+ if (rtm_addrs & RTA_NETMASK) {
+ return (0);
+ }
rtm_addrs |= RTA_NETMASK;
prefixlen(plen);
return (0);