Author: markj
Date: Fri Oct  7 00:34:57 2016
New Revision: 306793
URL: https://svnweb.freebsd.org/changeset/base/306793

Log:
  Shorten and simplify some of the loops in pfxlist_onlink_check().
  
  No functional change intended.
  
  MFC after:    1 week

Modified:
  head/sys/netinet6/nd6_rtr.c

Modified: head/sys/netinet6/nd6_rtr.c
==============================================================================
--- head/sys/netinet6/nd6_rtr.c Fri Oct  7 00:26:36 2016        (r306792)
+++ head/sys/netinet6/nd6_rtr.c Fri Oct  7 00:34:57 2016        (r306793)
@@ -1485,40 +1485,26 @@ pfxlist_onlink_check(void)
                 */
                LIST_FOREACH(pr, &V_nd_prefix, ndpr_entry) {
                        /* XXX: a link-local prefix should never be detached */
-                       if (IN6_IS_ADDR_LINKLOCAL(&pr->ndpr_prefix.sin6_addr))
-                               continue;
-
-                       /*
-                        * we aren't interested in prefixes without the L bit
-                        * set.
-                        */
-                       if (pr->ndpr_raf_onlink == 0)
-                               continue;
-
-                       if (pr->ndpr_raf_auto == 0)
+                       if (IN6_IS_ADDR_LINKLOCAL(&pr->ndpr_prefix.sin6_addr) ||
+                           pr->ndpr_raf_onlink == 0 ||
+                           pr->ndpr_raf_auto == 0)
                                continue;
 
                        if ((pr->ndpr_stateflags & NDPRF_DETACHED) == 0 &&
                            find_pfxlist_reachable_router(pr) == NULL)
                                pr->ndpr_stateflags |= NDPRF_DETACHED;
-                       if ((pr->ndpr_stateflags & NDPRF_DETACHED) != 0 &&
+                       else if ((pr->ndpr_stateflags & NDPRF_DETACHED) != 0 &&
                            find_pfxlist_reachable_router(pr) != NULL)
                                pr->ndpr_stateflags &= ~NDPRF_DETACHED;
                }
        } else {
                /* there is no prefix that has a reachable router */
                LIST_FOREACH(pr, &V_nd_prefix, ndpr_entry) {
-                       if (IN6_IS_ADDR_LINKLOCAL(&pr->ndpr_prefix.sin6_addr))
-                               continue;
-
-                       if (pr->ndpr_raf_onlink == 0)
-                               continue;
-
-                       if (pr->ndpr_raf_auto == 0)
+                       if (IN6_IS_ADDR_LINKLOCAL(&pr->ndpr_prefix.sin6_addr) ||
+                           pr->ndpr_raf_onlink == 0 ||
+                           pr->ndpr_raf_auto == 0)
                                continue;
-
-                       if ((pr->ndpr_stateflags & NDPRF_DETACHED) != 0)
-                               pr->ndpr_stateflags &= ~NDPRF_DETACHED;
+                       pr->ndpr_stateflags &= ~NDPRF_DETACHED;
                }
        }
 
@@ -1531,16 +1517,12 @@ pfxlist_onlink_check(void)
         * so we don't have to care about them.
         */
        LIST_FOREACH(pr, &V_nd_prefix, ndpr_entry) {
-               int e;
                char ip6buf[INET6_ADDRSTRLEN];
+               int e;
 
-               if (IN6_IS_ADDR_LINKLOCAL(&pr->ndpr_prefix.sin6_addr))
-                       continue;
-
-               if (pr->ndpr_raf_onlink == 0)
-                       continue;
-
-               if (pr->ndpr_raf_auto == 0)
+               if (IN6_IS_ADDR_LINKLOCAL(&pr->ndpr_prefix.sin6_addr) ||
+                   pr->ndpr_raf_onlink == 0 ||
+                   pr->ndpr_raf_auto == 0)
                        continue;
 
                if ((pr->ndpr_stateflags & NDPRF_DETACHED) != 0 &&
_______________________________________________
[email protected] mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "[email protected]"

Reply via email to