git: c3a456defaf2 - main - Always use inp fib in the inp_lookup_mcast_ifp().

Alexander V. Chernikov melifaro at FreeBSD.org
Sat Apr 10 13:47:54 UTC 2021


The branch main has been updated by melifaro:

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

commit c3a456defaf28df8d6f47704d606248f6c22146c
Author:     Alexander V. Chernikov <melifaro at FreeBSD.org>
AuthorDate: 2021-04-05 19:58:57 +0000
Commit:     Alexander V. Chernikov <melifaro at FreeBSD.org>
CommitDate: 2021-04-10 13:47:49 +0000

    Always use inp fib in the inp_lookup_mcast_ifp().
    
    inp_lookup_mcast_ifp() is static and is only used in the inp_join_group().
    The latter function is also static, and is only used in the inp_setmoptions(),
     which relies on inp being non-NULL.
    
    As a result, in the current code, inp_lookup_mcast_ifp() is always called
     with non-NULL inp. Eliminate unused RT_DEFAULT_FIB condition and always
     use inp fib instead.
    
    Differential Revision:  https://reviews.freebsd.org/D29594
    Reviewed by:            kp
    MFC after:              2 weeks
---
 sys/netinet/in_mcast.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/sys/netinet/in_mcast.c b/sys/netinet/in_mcast.c
index 392856785dd2..f0827fcf3451 100644
--- a/sys/netinet/in_mcast.c
+++ b/sys/netinet/in_mcast.c
@@ -1865,8 +1865,7 @@ inp_getmoptions(struct inpcb *inp, struct sockopt *sopt)
  * specific physical links in the networking stack, or which need
  * to join link-scope groups before IPv4 addresses are configured.
  *
- * If inp is non-NULL, use this socket's current FIB number for any
- * required FIB lookup.
+ * Use this socket's current FIB number for any required FIB lookup.
  * If ina is INADDR_ANY, look up the group address in the unicast FIB,
  * and use its ifp; usually, this points to the default next-hop.
  *
@@ -1887,8 +1886,8 @@ inp_lookup_mcast_ifp(const struct inpcb *inp,
 	struct rm_priotracker in_ifa_tracker;
 	struct ifnet *ifp;
 	struct nhop_object *nh;
-	uint32_t fibnum;
 
+	KASSERT(inp != NULL, ("%s: inp must not be NULL", __func__));
 	KASSERT(gsin->sin_family == AF_INET, ("%s: not AF_INET", __func__));
 	KASSERT(IN_MULTICAST(ntohl(gsin->sin_addr.s_addr)),
 	    ("%s: not multicast", __func__));
@@ -1901,8 +1900,7 @@ inp_lookup_mcast_ifp(const struct inpcb *inp,
 			if_ref(ifp);
 		IN_IFADDR_RUNLOCK(&in_ifa_tracker);
 	} else {
-		fibnum = inp ? inp->inp_inc.inc_fibnum : RT_DEFAULT_FIB;
-		nh = fib4_lookup(fibnum, gsin->sin_addr, 0, NHR_NONE, 0);
+		nh = fib4_lookup(inp->inp_inc.inc_fibnum, gsin->sin_addr, 0, NHR_NONE, 0);
 		if (nh != NULL) {
 			ifp = nh->nh_ifp;
 			if_ref(ifp);


More information about the dev-commits-src-all mailing list