Author: melifaro
Date: Sat Sep 19 11:50:02 2015
New Revision: 287985
URL: https://svnweb.freebsd.org/changeset/base/287985

Log:
  Cleanup nd6_cache_lladdr(). No functional changes.
  
  * Since new extries are now allocated explicitly, fill in
    all the necessary fields for lle _before_ attaching it to the table.
  * Remove ND6_LLINFO_INCOMPLETE check which was unused even in
    first KAME merge (r53541).
  * After that, the only new state that function can set, was
    ND6_LLINFO_STALE. Given everything above, simplify logic besides
    do_update and is_newentry.
  * Fix nd_resolve() comment.

Modified:
  head/sys/netinet6/nd6.c

Modified: head/sys/netinet6/nd6.c
==============================================================================
--- head/sys/netinet6/nd6.c     Sat Sep 19 03:58:31 2015        (r287984)
+++ head/sys/netinet6/nd6.c     Sat Sep 19 11:50:02 2015        (r287985)
@@ -1689,7 +1689,6 @@ nd6_cache_lladdr(struct ifnet *ifp, stru
        int olladdr;
        int llchange;
        int flags;
-       int newstate = 0;
        uint16_t router = 0;
        struct sockaddr_in6 sin6;
        struct mbuf *chain = NULL;
@@ -1722,6 +1721,16 @@ nd6_cache_lladdr(struct ifnet *ifp, stru
                ln = nd6_alloc(from, 0, ifp);
                if (ln == NULL)
                        return;
+
+               /*
+                * Since we already know all the data for the new entry,
+                * fill it before insertion.
+                */
+               if (lladdr != NULL) {
+                       bcopy(lladdr, &ln->ll_addr, ifp->if_addrlen);
+                       ln->la_flags |= LLE_VALID;
+                       ln->ln_state = ND6_LLINFO_STALE;
+               }
                IF_AFDATA_WLOCK(ifp);
                LLE_WLOCK(ln);
                /* Prefer any existing lle over newly-created one */
@@ -1767,6 +1776,10 @@ nd6_cache_lladdr(struct ifnet *ifp, stru
         *      1       --      y       --      (7) * STALE
         */
 
+       do_update = 0;
+       if (!is_newentry && llchange != 0)
+               do_update = 1;  /* (3,5) */
+
        if (lladdr) {           /* (3-5) and (7) */
                /*
                 * Record source link-layer address
@@ -1774,35 +1787,13 @@ nd6_cache_lladdr(struct ifnet *ifp, stru
                 */
                bcopy(lladdr, &ln->ll_addr, ifp->if_addrlen);
                ln->la_flags |= LLE_VALID;
-               EVENTHANDLER_INVOKE(lle_event, ln, LLENTRY_RESOLVED);
-       }
+               ln->ln_state = ND6_LLINFO_STALE;
 
-       if (!is_newentry) {
-               if (llchange != 0) {                    /* (3,5) */
-                       do_update = 1;
-                       newstate = ND6_LLINFO_STALE;
-               } else                                  /* (1-2,4) */
-                       do_update = 0;
-       } else {
-               do_update = 1;
-               if (lladdr == NULL)                     /* (6) */
-                       newstate = ND6_LLINFO_NOSTATE;
-               else                                    /* (7) */
-                       newstate = ND6_LLINFO_STALE;
-       }
-
-       if (do_update) {
-               /*
-                * Update the state of the neighbor cache.
-                */
-               ln->ln_state = newstate;
+               EVENTHANDLER_INVOKE(lle_event, ln, LLENTRY_RESOLVED);
 
-               if (ln->ln_state == ND6_LLINFO_STALE) {
+               if (do_update) {
                        if (ln->la_hold != NULL)
                                nd6_grab_holdchain(ln, &chain, &sin6);
-               } else if (ln->ln_state == ND6_LLINFO_INCOMPLETE) {
-                       /* probe right away */
-                       nd6_llinfo_settimer_locked((void *)ln, 0);
                }
        }
 
@@ -1838,7 +1829,7 @@ nd6_cache_lladdr(struct ifnet *ifp, stru
         * for those are not autoconfigured hosts, we explicitly avoid such
         * cases for safety.
         */
-       if (do_update && router &&
+       if ((do_update || is_newentry) && router &&
            ND_IFINFO(ifp)->flags & ND6_IFF_ACCEPT_RTADV) {
                /*
                 * guaranteed recursion
@@ -2005,7 +1996,7 @@ nd6_resolve(struct ifnet *ifp, int is_gw
        /*
         * Perform fast path for the following cases:
         * 1) lle state is REACHABLE
-        * 2) lle state is DELAY (NS message sentNS message sent)
+        * 2) lle state is DELAY (NS message sent)
         *
         * Every other case involves lle modification, so we handle
         * them separately.
_______________________________________________
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"

Reply via email to