Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 14 Feb 2021 10:13:39 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: 1bd44b11e59f - main - Do not reference returned ifa in in6_ifawithifp().
Message-ID:  <202102141013.11EADdlq071495@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=1bd44b11e59f1e9ee7245f8de1f823bc5287b9ef

commit 1bd44b11e59f1e9ee7245f8de1f823bc5287b9ef
Author:     Alexander V. Chernikov <melifaro@FreeBSD.org>
AuthorDate: 2021-02-14 10:11:06 +0000
Commit:     Alexander V. Chernikov <melifaro@FreeBSD.org>
CommitDate: 2021-02-14 10:11:18 +0000

    Do not reference returned ifa in in6_ifawithifp().
    
    The only place where in6_ifawithifp() is used is ip6_output(),
     which uses the returned ifa to bump traffic counters.
    Given ifa stability guarantees is provided by epoch, do not refcount ifa.
    
    This eliminates 2 atomic ops from IPv6 fast path.
    
    Reviewed By:    rstone
    MFC after:      1 week
    Differential Revision:  https://reviews.freebsd.org/D28649
---
 sys/netinet6/in6.c        | 14 +++-----------
 sys/netinet6/ip6_output.c |  1 -
 2 files changed, 3 insertions(+), 12 deletions(-)

diff --git a/sys/netinet6/in6.c b/sys/netinet6/in6.c
index 48fa8dd2efc6..057c0ee91e02 100644
--- a/sys/netinet6/in6.c
+++ b/sys/netinet6/in6.c
@@ -1921,10 +1921,8 @@ in6_ifawithifp(struct ifnet *ifp, struct in6_addr *dst)
 				besta = (struct in6_ifaddr *)ifa;
 		}
 	}
-	if (besta) {
-		ifa_ref(&besta->ia_ifa);
+	if (besta)
 		return (besta);
-	}
 
 	CK_STAILQ_FOREACH(ifa, &ifp->if_addrhead, ifa_link) {
 		if (ifa->ifa_addr->sa_family != AF_INET6)
@@ -1941,20 +1939,14 @@ in6_ifawithifp(struct ifnet *ifp, struct in6_addr *dst)
 			continue;
 		}
 
-		if (ifa != NULL)
-			ifa_ref(ifa);
 		return (struct in6_ifaddr *)ifa;
 	}
 
 	/* use the last-resort values, that are, deprecated addresses */
-	if (dep[0]) {
-		ifa_ref((struct ifaddr *)dep[0]);
+	if (dep[0])
 		return dep[0];
-	}
-	if (dep[1]) {
-		ifa_ref((struct ifaddr *)dep[1]);
+	if (dep[1])
 		return dep[1];
-	}
 
 	return NULL;
 }
diff --git a/sys/netinet6/ip6_output.c b/sys/netinet6/ip6_output.c
index df1e9e6f2dcd..58334788b05b 100644
--- a/sys/netinet6/ip6_output.c
+++ b/sys/netinet6/ip6_output.c
@@ -1177,7 +1177,6 @@ passout:
 			counter_u64_add(ia6->ia_ifa.ifa_opackets, 1);
 			counter_u64_add(ia6->ia_ifa.ifa_obytes,
 			    m->m_pkthdr.len);
-			ifa_free(&ia6->ia_ifa);
 		}
 		error = ip6_output_send(inp, ifp, origifp, m, dst, ro,
 		    (flags & IP_NO_SND_TAG_RL) ? false : true);



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