tech-net archive

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

Re: [PATCH] Setting IPv6 route advertisement accepting interfaces



Salut,

On Sun, Jul 12, 2009 at 10:49:52PM +0200, Tonnerre LOMBARD wrote:
> 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.

Updated patch, now using the preexisting flags. Seems to work so far
on my workstation.

                                Tonnerre
Index: sys/netinet6/nd6.c
===================================================================
RCS file: /cvsroot/src/sys/netinet6/nd6.c,v
retrieving revision 1.130
diff -u -r1.130 nd6.c
--- sys/netinet6/nd6.c  24 Oct 2008 17:07:33 -0000      1.130
+++ sys/netinet6/nd6.c  13 Jul 2009 22:00:27 -0000
@@ -176,7 +176,8 @@
         * we won't accept RAs by default even if we set ND6_IFF_ACCEPT_RTADV
         * here.
         */
-       nd->flags = (ND6_IFF_PERFORMNUD | ND6_IFF_ACCEPT_RTADV);
+       nd->flags = (ND6_IFF_PERFORMNUD |
+               ip6_accept_rtadv ? ND6_IFF_ACCEPT_RTADV : 0);
 
        /* XXX: we cannot call nd6_setmtu since ifp is not fully initialized */
        nd6_setmtu0(ifp, nd);
@@ -710,6 +711,7 @@
 void
 nd6_purge(struct ifnet *ifp)
 {
+       struct nd_ifinfo *ndi = ND_IFINFO(ifp);
        struct llinfo_nd6 *ln, *nln;
        struct nd_defrouter *dr, *ndr;
        struct nd_prefix *pr, *npr;
@@ -764,7 +766,8 @@
        if (nd6_defifindex == ifp->if_index)
                nd6_setdefaultiface(0);
 
-       if (!ip6_forwarding && ip6_accept_rtadv) { /* XXX: too restrictive? */
+       /* XXX: too restrictive? */
+       if (!ip6_forwarding && (ndi->flags & ND6_IFF_ACCEPT_RTADV)) {
                /* refresh default router list */
                defrouter_select();
        }
@@ -1643,6 +1646,7 @@
     int code   /* type dependent information */
 )
 {
+       struct nd_ifinfo *ndi = ND_IFINFO(ifp);
        struct rtentry *rt = NULL;
        struct llinfo_nd6 *ln = NULL;
        int is_newentry;
@@ -1851,7 +1855,8 @@
         * for those are not autoconfigured hosts, we explicitly avoid such
         * cases for safety.
         */
-       if (do_update && ln->ln_router && !ip6_forwarding && ip6_accept_rtadv)
+       if (do_update && ln->ln_router && !ip6_forwarding &&
+               (ndi->flags & ND6_IFF_ACCEPT_RTADV))
                defrouter_select();
 
        return rt;
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      13 Jul 2009 22:00:45 -0000
@@ -113,6 +113,7 @@
 nd6_rs_input(struct mbuf *m, int off, int icmp6len)
 {
        struct ifnet *ifp = m->m_pkthdr.rcvif;
+       struct nd_ifinfo *ndi = ND_IFINFO(ifp);
        struct ip6_hdr *ip6 = mtod(m, struct ip6_hdr *);
        struct nd_router_solicit *nd_rs;
        struct in6_addr saddr6 = ip6->ip6_src;
@@ -121,7 +122,7 @@
        union nd_opts ndopts;
 
        /* If I'm not a router, ignore it. */
-       if (ip6_accept_rtadv != 0 || !ip6_forwarding)
+       if ((ndi->flags & ND6_IFF_ACCEPT_RTADV) || !ip6_forwarding)
                goto freeit;
 
        /* Sanity checks */
@@ -209,8 +210,6 @@
         * the system-wide variable allows the acceptance, and
         * per-interface variable allows RAs on the receiving interface.
         */
-       if (ip6_accept_rtadv == 0)
-               goto freeit;
        if (!(ndi->flags & ND6_IFF_ACCEPT_RTADV))
                goto freeit;
 
@@ -482,6 +481,7 @@
 void
 defrtrlist_del(struct nd_defrouter *dr)
 {
+       struct nd_ifinfo *ndi = ND_IFINFO(dr->ifp);
        struct nd_defrouter *deldr = NULL;
        struct nd_prefix *pr;
 
@@ -489,7 +489,8 @@
         * Flush all the routing table entries that use the router
         * as a next hop.
         */
-       if (!ip6_forwarding && ip6_accept_rtadv) /* XXX: better condition? */
+       /* XXX: better condition? */
+       if (!ip6_forwarding && (ndi->flags & ND6_IFF_ACCEPT_RTADV))
                rt6_flush(&dr->rtaddr, dr->ifp);
 
        if (dr->installed) {
@@ -608,6 +609,7 @@
 void
 defrouter_select(void)
 {
+       struct nd_ifinfo *ndi;
        int s = splsoftnet();
        struct nd_defrouter *dr, *selected_dr = NULL, *installed_dr = NULL;
        struct rtentry *rt = NULL;
@@ -619,7 +621,7 @@
         * if the node is not an autoconfigured host, we explicitly exclude
         * such cases here for safety.
         */
-       if (ip6_forwarding || !ip6_accept_rtadv) {
+       if (ip6_forwarding) {
                nd6log((LOG_WARNING,
                    "defrouter_select: called unexpectedly (forwarding=%d, "
                    "accept_rtadv=%d)\n", ip6_forwarding, ip6_accept_rtadv));
@@ -643,6 +645,10 @@
         */
        for (dr = TAILQ_FIRST(&nd_defrouter); dr;
             dr = TAILQ_NEXT(dr, dr_entry)) {
+               ndi = ND_IFINFO(dr->ifp);
+               if ((ndi->flags & ND6_IFF_ACCEPT_RTADV))
+                       continue;
+
                if (selected_dr == NULL &&
                    (rt = nd6_lookup(&dr->rtaddr, 0, dr->ifp)) != NULL &&
                    (ln = (struct llinfo_nd6 *)rt->rt_llinfo) != NULL &&

Attachment: pgpPf5FCvbR9m.pgp
Description: PGP signature



Home | Main Index | Thread Index | Old Index