From owner-svn-src-all@freebsd.org Tue May 3 23:46:02 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id E450CB2CCA1; Tue, 3 May 2016 23:46:02 +0000 (UTC) (envelope-from markj@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id A5FC71E13; Tue, 3 May 2016 23:46:02 +0000 (UTC) (envelope-from markj@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u43Nk1bd035299; Tue, 3 May 2016 23:46:01 GMT (envelope-from markj@FreeBSD.org) Received: (from markj@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u43Nk19F035296; Tue, 3 May 2016 23:46:01 GMT (envelope-from markj@FreeBSD.org) Message-Id: <201605032346.u43Nk19F035296@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: markj set sender to markj@FreeBSD.org using -f From: Mark Johnston Date: Tue, 3 May 2016 23:46:01 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r299014 - stable/10/sys/netinet6 X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 03 May 2016 23:46:03 -0000 Author: markj Date: Tue May 3 23:46:01 2016 New Revision: 299014 URL: https://svnweb.freebsd.org/changeset/base/299014 Log: MFC r295575, r295576, r295578, r295579, r295580: Various NDP cleanups. No functional change intended. Modified: stable/10/sys/netinet6/nd6.c stable/10/sys/netinet6/nd6_nbr.c stable/10/sys/netinet6/nd6_rtr.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/netinet6/nd6.c ============================================================================== --- stable/10/sys/netinet6/nd6.c Tue May 3 23:39:41 2016 (r299013) +++ stable/10/sys/netinet6/nd6.c Tue May 3 23:46:01 2016 (r299014) @@ -112,11 +112,6 @@ VNET_DEFINE(int, nd6_debug) = 1; VNET_DEFINE(int, nd6_debug) = 0; #endif -/* for debugging? */ -#if 0 -static int nd6_inuse, nd6_allocated; -#endif - VNET_DEFINE(struct nd_drhead, nd_defrouter); VNET_DEFINE(struct nd_prhead, nd_prefix); @@ -175,7 +170,7 @@ nd6_ifattach(struct ifnet *ifp) { struct nd_ifinfo *nd; - nd = (struct nd_ifinfo *)malloc(sizeof(*nd), M_IP6NDP, M_WAITOK|M_ZERO); + nd = malloc(sizeof(*nd), M_IP6NDP, M_WAITOK | M_ZERO); nd->initialized = 1; nd->chlim = IPV6_DEFHLIM; @@ -2182,7 +2177,6 @@ clear_llinfo_pqueue(struct llentry *ln) } ln->la_hold = NULL; - return; } static int nd6_sysctl_drlist(SYSCTL_HANDLER_ARGS); Modified: stable/10/sys/netinet6/nd6_nbr.c ============================================================================== --- stable/10/sys/netinet6/nd6_nbr.c Tue May 3 23:39:41 2016 (r299013) +++ stable/10/sys/netinet6/nd6_nbr.c Tue May 3 23:46:01 2016 (r299014) @@ -623,7 +623,6 @@ nd6_ns_output_fib(struct ifnet *ifp, con RTFREE(ro.ro_rt); } m_freem(m); - return; } #ifndef BURN_BRIDGES @@ -901,12 +900,6 @@ nd6_na_input(struct mbuf *m, int off, in in6 = &L3_ADDR_SIN6(ln)->sin6_addr; - /* - * Lock to protect the default router list. - * XXX: this might be unnecessary, since this function - * is only called under the network software interrupt - * context. However, we keep it just for safety. - */ dr = defrouter_lookup(in6, ln->lle_tbl->llt_ifp); if (dr) defrtrlist_del(dr); @@ -1127,7 +1120,6 @@ nd6_na_output_fib(struct ifnet *ifp, con RTFREE(ro.ro_rt); } m_freem(m); - return; } #ifndef BURN_BRIDGES Modified: stable/10/sys/netinet6/nd6_rtr.c ============================================================================== --- stable/10/sys/netinet6/nd6_rtr.c Tue May 3 23:39:41 2016 (r299013) +++ stable/10/sys/netinet6/nd6_rtr.c Tue May 3 23:46:01 2016 (r299014) @@ -501,7 +501,6 @@ defrouter_addreq(struct nd_defrouter *ne } if (error == 0) new->installed = 1; - return; } struct nd_defrouter * @@ -700,8 +699,6 @@ defrouter_select(void) defrouter_delreq(installed_dr); defrouter_addreq(selected_dr); } - - return; } /* @@ -735,53 +732,47 @@ static struct nd_defrouter * defrtrlist_update(struct nd_defrouter *new) { struct nd_defrouter *dr, *n; + int oldpref; if ((dr = defrouter_lookup(&new->rtaddr, new->ifp)) != NULL) { /* entry exists */ if (new->rtlifetime == 0) { defrtrlist_del(dr); - dr = NULL; - } else { - int oldpref = rtpref(dr); + return (NULL); + } - /* override */ - dr->flags = new->flags; /* xxx flag check */ - dr->rtlifetime = new->rtlifetime; - dr->expire = new->expire; + oldpref = rtpref(dr); - /* - * If the preference does not change, there's no need - * to sort the entries. Also make sure the selected - * router is still installed in the kernel. - */ - if (dr->installed && rtpref(new) == oldpref) - return (dr); + /* override */ + dr->flags = new->flags; /* xxx flag check */ + dr->rtlifetime = new->rtlifetime; + dr->expire = new->expire; - /* - * preferred router may be changed, so relocate - * this router. - * XXX: calling TAILQ_REMOVE directly is a bad manner. - * However, since defrtrlist_del() has many side - * effects, we intentionally do so here. - * defrouter_select() below will handle routing - * changes later. - */ - TAILQ_REMOVE(&V_nd_defrouter, dr, dr_entry); - n = dr; - goto insert; - } - return (dr); + /* + * If the preference does not change, there's no need + * to sort the entries. Also make sure the selected + * router is still installed in the kernel. + */ + if (dr->installed && rtpref(new) == oldpref) + return (dr); + + /* + * The preferred router may have changed, so relocate this + * router. + */ + TAILQ_REMOVE(&V_nd_defrouter, dr, dr_entry); + n = dr; + goto insert; } /* entry does not exist */ if (new->rtlifetime == 0) return (NULL); - n = (struct nd_defrouter *)malloc(sizeof(*n), M_IP6NDP, M_NOWAIT); + n = malloc(sizeof(*n), M_IP6NDP, M_NOWAIT | M_ZERO); if (n == NULL) return (NULL); - bzero(n, sizeof(*n)); - *n = *new; + memcpy(n, new, sizeof(*n)); insert: /* @@ -824,10 +815,9 @@ pfxrtr_add(struct nd_prefix *pr, struct { struct nd_pfxrouter *new; - new = (struct nd_pfxrouter *)malloc(sizeof(*new), M_IP6NDP, M_NOWAIT); + new = malloc(sizeof(*new), M_IP6NDP, M_NOWAIT | M_ZERO); if (new == NULL) return; - bzero(new, sizeof(*new)); new->router = dr; LIST_INSERT_HEAD(&pr->ndpr_advrtrs, new, pfr_entry); @@ -868,10 +858,9 @@ nd6_prelist_add(struct nd_prefixctl *pr, int i; char ip6buf[INET6_ADDRSTRLEN]; - new = (struct nd_prefix *)malloc(sizeof(*new), M_IP6NDP, M_NOWAIT); + new = malloc(sizeof(*new), M_IP6NDP, M_NOWAIT | M_ZERO); if (new == NULL) - return(ENOMEM); - bzero(new, sizeof(*new)); + return (ENOMEM); new->ndpr_ifp = pr->ndpr_ifp; new->ndpr_prefix = pr->ndpr_prefix; new->ndpr_plen = pr->ndpr_plen;