Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 22 Aug 2021 08:49:26 GMT
From:      "Alexander V. Chernikov" <melifaro@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org
Subject:   git: f8c1b1a92966 - main - lltable: fix crash introduced in c541bd368f86.
Message-ID:  <202108220849.17M8nQGH000104@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch main has been updated by melifaro:

URL: https://cgit.FreeBSD.org/src/commit/?id=f8c1b1a9296696f70ac209612a00ae0722d07ed9

commit f8c1b1a9296696f70ac209612a00ae0722d07ed9
Author:     Alexander V. Chernikov <melifaro@FreeBSD.org>
AuthorDate: 2021-08-22 08:47:49 +0000
Commit:     Alexander V. Chernikov <melifaro@FreeBSD.org>
CommitDate: 2021-08-22 08:49:18 +0000

    lltable: fix crash introduced in c541bd368f86.
    
    Reported by:    cy
    MFC after:      2 weeks
---
 sys/netinet6/in6.c     | 7 ++++---
 sys/netinet6/nd6_rtr.c | 5 +++--
 2 files changed, 7 insertions(+), 5 deletions(-)

diff --git a/sys/netinet6/in6.c b/sys/netinet6/in6.c
index 142a05ded2b6..d54aba58edb6 100644
--- a/sys/netinet6/in6.c
+++ b/sys/netinet6/in6.c
@@ -2323,6 +2323,7 @@ in6_lltable_lookup(struct lltable *llt, u_int flags,
 	const struct sockaddr *l3addr)
 {
 	const struct sockaddr_in6 *sin6 = (const struct sockaddr_in6 *)l3addr;
+	int family = flags >> 16;
 	struct llentry *lle;
 
 	IF_AFDATA_LOCK_ASSERT(llt->llt_ifp);
@@ -2333,13 +2334,13 @@ in6_lltable_lookup(struct lltable *llt, u_int flags,
 	    ("wrong lle request flags: %#x", flags));
 
 	lle = in6_lltable_find_dst(llt, &sin6->sin6_addr);
-	if (lle == NULL)
-		return (NULL);
 
-	int family = flags >> 16;
 	if (__predict_false(family != AF_INET6))
 		lle = llentry_lookup_family(lle, family);
 
+	if (lle == NULL)
+		return (NULL);
+
 	if (flags & LLE_UNLOCKED)
 		return (lle);
 
diff --git a/sys/netinet6/nd6_rtr.c b/sys/netinet6/nd6_rtr.c
index 2960b6cad951..cec9fccd63c4 100644
--- a/sys/netinet6/nd6_rtr.c
+++ b/sys/netinet6/nd6_rtr.c
@@ -972,7 +972,7 @@ defrouter_select_fib(int fibnum)
 	TAILQ_FOREACH(dr, &V_nd6_defrouter, dr_entry) {
 		NET_EPOCH_ENTER(et);
 		if (selected_dr == NULL && dr->ifp->if_fib == fibnum &&
-		    (ln = nd6_lookup(&dr->rtaddr, 0, dr->ifp)) &&
+		    (ln = nd6_lookup(&dr->rtaddr, LLE_SF(AF_INET6, 0), dr->ifp)) &&
 		    ND6_IS_LLINFO_PROBREACH(ln)) {
 			selected_dr = dr;
 			defrouter_ref(selected_dr);
@@ -1814,7 +1814,8 @@ find_pfxlist_reachable_router(struct nd_prefix *pr)
 
 	NET_EPOCH_ENTER(et);
 	LIST_FOREACH(pfxrtr, &pr->ndpr_advrtrs, pfr_entry) {
-		ln = nd6_lookup(&pfxrtr->router->rtaddr, 0, pfxrtr->router->ifp);
+		ln = nd6_lookup(&pfxrtr->router->rtaddr, LLE_SF(AF_INET6, 0),
+		    pfxrtr->router->ifp);
 		if (ln == NULL)
 			continue;
 		canreach = ND6_IS_LLINFO_PROBREACH(ln);



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202108220849.17M8nQGH000104>