tech-net archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[PATCH] Setting IPv6 route advertisement accepting interfaces



Salut,

This is the first part of my series of patches concerning IPv6 route
advertisements. It simply moves the variable deciding whether or not
to accept IPv6 route advertisements on a specific interface to be
specific to that interface.

A second patch is going to separate the setting of when to accept
a default route (which is why there are more bits left on the
autoconf integer. However, it would have been really cool had there
still been 2 bits of space left on if_flags.)

Either way, here's it. If your mailer doesn't like PGP signed
attachments, go to
http://www.netbsd.org/~tonnerre/patches/src/2009/netinet6-rtadv-per-interface.patch
to find a copy of said patch.

Any opinions?

                                Tonnerre
? tooldir.NetBSD-4.0-sparc64
? tooldir.NetBSD-4.0_wrstuden_fixsa_t1-sparc64
? sys/arch/amd64/conf/JULES
Index: etc/rc.d/network
===================================================================
RCS file: /cvsroot/src/etc/rc.d/network,v
retrieving revision 1.57.2.1
diff -u -r1.57.2.1 network
--- etc/rc.d/network    18 May 2009 19:30:48 -0000      1.57.2.1
+++ etc/rc.d/network    12 Jul 2009 19:57:48 -0000
@@ -127,7 +127,7 @@
                /sbin/route -q add -inet6 ::0.0.0.0 -prefixlen 96 ::1 -reject
 
                /sbin/sysctl -qw net.inet6.ip6.forwarding=0
-               /sbin/sysctl -qw net.inet6.ip6.accept_rtadv=0
+               /sbin/sysctl -qw net.inet6.ip6.accept_rtadv.default=0
 
                case $ip6mode in
                router)
@@ -144,7 +144,11 @@
 
                autohost)
                        echo 'IPv6 mode: autoconfigured host'
-                       /sbin/sysctl -qw net.inet6.ip6.accept_rtadv=1
+                       /sbin/sysctl -qw net.inet6.ip6.accept_rtadv.default=1
+
+                       for int in `/sbin/ifconfig -l`; do
+                               /sbin/sysctl -qw 
net.inet6.ip6.accept_rtadv."$int"=1
+                       done
                        ;;
 
                host)   
Index: sys/net/if.h
===================================================================
RCS file: /cvsroot/src/sys/net/if.h,v
retrieving revision 1.140
diff -u -r1.140 if.h
--- sys/net/if.h        24 Oct 2008 17:07:33 -0000      1.140
+++ sys/net/if.h        12 Jul 2009 19:59:05 -0000
@@ -275,6 +275,7 @@
        struct pfil_head if_pfil;       /* filtering point */
        uint64_t if_capabilities;       /* interface capabilities */
        uint64_t if_capenable;          /* capabilities enabled */
+       int     if_autoconf;            /* IPv6 autoconfiguration */
        union {
                void *          carp_s; /* carp structure (used by !carp ifs) */
                struct ifnet    *carp_d;/* ptr to carpdev (used by carp ifs) */
@@ -290,6 +291,7 @@
 
        void    *if_afdata[AF_MAX];
        struct  mowner *if_mowner;      /* who owns mbufs for this interface */
+       struct sysctllog *if_clog;
 
        void    *if_agrprivate;         /* used only when #if NAGR > 0 */
 
Index: sys/netinet6/in6_ifattach.c
===================================================================
RCS file: /cvsroot/src/sys/netinet6/in6_ifattach.c,v
retrieving revision 1.80
diff -u -r1.80 in6_ifattach.c
--- sys/netinet6/in6_ifattach.c 24 Apr 2008 11:38:38 -0000      1.80
+++ sys/netinet6/in6_ifattach.c 12 Jul 2009 19:59:06 -0000
@@ -42,6 +42,7 @@
 #include <sys/syslog.h>
 #include <sys/md5.h>
 #include <sys/socketvar.h>
+#include <sys/sysctl.h>
 
 #include <net/if.h>
 #include <net/if_dl.h>
@@ -833,6 +834,19 @@
                            ifp->if_xname);
                }
        }
+
+       /*
+        * attach the IPv6 address autoconfiguration ioctl.
+        */
+       ifp->if_autoconf = ip6_accept_rtadv;
+
+       sysctl_createv(&ifp->if_clog, 0, NULL, NULL,
+               CTLFLAG_PERMANENT|CTLFLAG_READWRITE,
+               CTLTYPE_INT, ifp->if_xname,
+               SYSCTL_DESCR("Accept router advertisements"),
+               NULL, 0, &ifp->if_autoconf, 0,
+               CTL_NET, PF_INET6, IPPROTO_IPV6, IPV6CTL_ACCEPT_RTADV,
+               ifp->if_index + 1, CTL_EOL);
 }
 
 /*
Index: sys/netinet6/ip6_input.c
===================================================================
RCS file: /cvsroot/src/sys/netinet6/ip6_input.c,v
retrieving revision 1.122.4.1
diff -u -r1.122.4.1 ip6_input.c
--- sys/netinet6/ip6_input.c    3 May 2009 13:22:22 -0000       1.122.4.1
+++ sys/netinet6/ip6_input.c    12 Jul 2009 19:59:09 -0000
@@ -1765,12 +1765,19 @@
                       IPV6CTL_SOURCECHECK_LOGINT, CTL_EOL);
 #endif
        sysctl_createv(clog, 0, NULL, NULL,
+                      CTLFLAG_PERMANENT,
+                      CTLTYPE_NODE, "accept_rtadv",
+                      SYSCTL_DESCR("Accept router advertisements"),
+                      NULL, 0, NULL, 0,
+                      CTL_NET, PF_INET6, IPPROTO_IPV6,
+                      IPV6CTL_ACCEPT_RTADV, CTL_EOL);
+       sysctl_createv(clog, 0, NULL, NULL,
                       CTLFLAG_PERMANENT|CTLFLAG_READWRITE,
-                      CTLTYPE_INT, "accept_rtadv",
+                      CTLTYPE_INT, "default",
                       SYSCTL_DESCR("Accept router advertisements"),
                       NULL, 0, &ip6_accept_rtadv, 0,
                       CTL_NET, PF_INET6, IPPROTO_IPV6,
-                      IPV6CTL_ACCEPT_RTADV, CTL_EOL);
+                      IPV6CTL_ACCEPT_RTADV, 0, CTL_EOL);
        sysctl_createv(clog, 0, NULL, NULL,
                       CTLFLAG_PERMANENT|CTLFLAG_READWRITE,
                       CTLTYPE_INT, "keepfaith",
Index: sys/netinet6/nd6_rtr.c
===================================================================
RCS file: /cvsroot/src/sys/netinet6/nd6_rtr.c,v
retrieving revision 1.76
diff -u -r1.76 nd6_rtr.c
--- sys/netinet6/nd6_rtr.c      24 Oct 2008 21:30:34 -0000      1.76
+++ sys/netinet6/nd6_rtr.c      12 Jul 2009 19:59:16 -0000
@@ -121,7 +121,7 @@
        union nd_opts ndopts;
 
        /* If I'm not a router, ignore it. */
-       if (ip6_accept_rtadv != 0 || !ip6_forwarding)
+       if (ifp->if_autoconf != 0 || !ip6_forwarding)
                goto freeit;
 
        /* Sanity checks */
@@ -209,7 +209,7 @@
         * the system-wide variable allows the acceptance, and
         * per-interface variable allows RAs on the receiving interface.
         */
-       if (ip6_accept_rtadv == 0)
+       if (ifp->if_autoconf == 0)
                goto freeit;
        if (!(ndi->flags & ND6_IFF_ACCEPT_RTADV))
                goto freeit;
@@ -488,6 +488,8 @@
        /*
         * Flush all the routing table entries that use the router
         * as a next hop.
+        *
+        * XXX: Check interface specific flags
         */
        if (!ip6_forwarding && ip6_accept_rtadv) /* XXX: better condition? */
                rt6_flush(&dr->rtaddr, dr->ifp);
@@ -618,6 +620,8 @@
         * host.  Although the remaining part of this function is not effective
         * if the node is not an autoconfigured host, we explicitly exclude
         * such cases here for safety.
+        *
+        * XXX: Check interface specific flags
         */
        if (ip6_forwarding || !ip6_accept_rtadv) {
                nd6log((LOG_WARNING,

Attachment: pgpADCrjOrL7J.pgp
Description: PGP signature



Home | Main Index | Thread Index | Old Index