Author: markj
Date: Sat May  7 03:41:29 2016
New Revision: 299213
URL: https://svnweb.freebsd.org/changeset/base/299213

Log:
  Clean up callers of nd6_prelist_add().
  
  nd6_prelist_add() sets *newp if and only if it is successful, so there's no
  need for code that handles the case where the return value is 0 and
  *newp == NULL. Fix some style bugs in nd6_prelist_add() while here.
  
  MFC after:    1 week

Modified:
  head/sys/netinet6/in6.c
  head/sys/netinet6/nd6_rtr.c

Modified: head/sys/netinet6/in6.c
==============================================================================
--- head/sys/netinet6/in6.c     Sat May  7 03:32:29 2016        (r299212)
+++ head/sys/netinet6/in6.c     Sat May  7 03:41:29 2016        (r299213)
@@ -669,14 +669,6 @@ in6_control(struct socket *so, u_long cm
                                        (*carp_detach_p)(&ia->ia_ifa);
                                goto out;
                        }
-                       if (pr == NULL) {
-                               if (carp_attached)
-                                       (*carp_detach_p)(&ia->ia_ifa);
-                               log(LOG_ERR, "nd6_prelist_add succeeded but "
-                                   "no prefix\n");
-                               error = EINVAL;
-                               goto out;
-                       }
                }
 
                /* relate the address to the prefix */

Modified: head/sys/netinet6/nd6_rtr.c
==============================================================================
--- head/sys/netinet6/nd6_rtr.c Sat May  7 03:32:29 2016        (r299212)
+++ head/sys/netinet6/nd6_rtr.c Sat May  7 03:41:29 2016        (r299213)
@@ -993,11 +993,9 @@ nd6_prelist_add(struct nd_prefixctl *pr,
        new->ndpr_flags = pr->ndpr_flags;
        if ((error = in6_init_prefix_ltimes(new)) != 0) {
                free(new, M_IP6NDP);
-               return(error);
+               return (error);
        }
        new->ndpr_lastupdate = time_uptime;
-       if (newp != NULL)
-               *newp = new;
 
        /* initialization */
        LIST_INIT(&new->ndpr_advrtrs);
@@ -1021,10 +1019,11 @@ nd6_prelist_add(struct nd_prefixctl *pr,
                }
        }
 
-       if (dr)
+       if (dr != NULL)
                pfxrtr_add(new, dr);
-
-       return 0;
+       if (newp != NULL)
+               *newp = new;
+       return (0);
 }
 
 void
@@ -1144,13 +1143,11 @@ prelist_update(struct nd_prefixctl *new,
                        goto end;
 
                error = nd6_prelist_add(new, dr, &pr);
-               if (error != 0 || pr == NULL) {
+               if (error != 0) {
                        nd6log((LOG_NOTICE, "prelist_update: "
-                           "nd6_prelist_add failed for %s/%d on %s "
-                           "errno=%d, returnpr=%p\n",
+                           "nd6_prelist_add failed for %s/%d on %s errno=%d\n",
                            ip6_sprintf(ip6buf, &new->ndpr_prefix.sin6_addr),
-                           new->ndpr_plen, if_name(new->ndpr_ifp),
-                           error, pr));
+                           new->ndpr_plen, if_name(new->ndpr_ifp), error));
                        goto end; /* we should just give up in this case. */
                }
 
_______________________________________________
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