]> xenbits.xensource.com Git - people/julieng/freebsd.git/commitdiff
Simplify if (lladdr) condition in nd6_cache_lladdr():
authormelifaro <melifaro@FreeBSD.org>
Sun, 4 Oct 2015 12:42:07 +0000 (12:42 +0000)
committermelifaro <melifaro@FreeBSD.org>
Sun, 4 Oct 2015 12:42:07 +0000 (12:42 +0000)
  For case (7) (new entry) nothing has to be done except lle_event.
  Invoke this event directly from "create new lle" code block.
  For case (4) (existing entry, same mac) useless mac update was performed,
  along with LLENTRY_RESOLVED lle_event. There was no sense in doing that,
  since nothing really had changed. Simply avoid this condition instead.
  Given that, condition was simplified to (3),(5) states which can be merged
  with previous block.

sys/netinet6/nd6.c

index 6cbe618ae30d352e3bbb482c64e36d7deaeab835..474457493a502297506ec7a90626bcd784db1380 100644 (file)
@@ -1753,6 +1753,7 @@ nd6_cache_lladdr(struct ifnet *ifp, struct in6_addr *from, char *lladdr,
                        /* No existing lle, mark as new entry */
                        is_newentry = 1;
                        nd6_llinfo_setstate(ln, ND6_LLINFO_STALE);
+                       EVENTHANDLER_INVOKE(lle_event, ln, LLENTRY_RESOLVED);
                } else {
                        lltable_free_entry(LLTABLE6(ifp), ln);
                        ln = ln_tmp;
@@ -1789,25 +1790,21 @@ nd6_cache_lladdr(struct ifnet *ifp, struct in6_addr *from, char *lladdr,
         */
 
        do_update = 0;
-       if (!is_newentry && llchange != 0)
+       if (is_newentry == 0 && llchange != 0) {
                do_update = 1;  /* (3,5) */
 
-       if (lladdr) {           /* (3-5) and (7) */
                /*
                 * Record source link-layer address
                 * XXX is it dependent to ifp->if_type?
                 */
                bcopy(lladdr, &ln->ll_addr, ifp->if_addrlen);
                ln->la_flags |= LLE_VALID;
-               if (do_update != 0)     /* 3,5,7 */
-                       nd6_llinfo_setstate(ln, ND6_LLINFO_STALE);
+               nd6_llinfo_setstate(ln, ND6_LLINFO_STALE);
 
                EVENTHANDLER_INVOKE(lle_event, ln, LLENTRY_RESOLVED);
 
-               if (do_update) {
-                       if (ln->la_hold != NULL)
-                               nd6_grab_holdchain(ln, &chain, &sin6);
-               }
+               if (ln->la_hold != NULL)
+                       nd6_grab_holdchain(ln, &chain, &sin6);
        }
 
        /* Calculates new router status */