git: baa7ab7f484b - stable/15 - ip_mroute: Don't assume that a multicast router is running

From: Mark Johnston <markj_at_FreeBSD.org>
Date: Mon, 17 Aug 2026 12:10:15 UTC
The branch stable/15 has been updated by markj:

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

commit baa7ab7f484bb8895d42900c74bc63d5e92e0266
Author:     Mark Johnston <markj@FreeBSD.org>
AuthorDate: 2026-08-03 20:44:14 +0000
Commit:     Mark Johnston <markj@FreeBSD.org>
CommitDate: 2026-08-17 12:07:40 +0000

    ip_mroute: Don't assume that a multicast router is running
    
    The SIOCGETSGCNT handler may be invoked in this scenario, and if no
    router has initialized the lookup table, we'll have
    mfct->mfchashtbl == NULL.
    
    PR:             297148
    Reported by:    Robert Morris
    MFC after:      1 week
    Sponsored by:   The FreeBSD Foundation
    
    (cherry picked from commit 1c0d2f0b1a98526e4f1f5a051ce6904b4c3164e1)
---
 sys/netinet/ip_mroute.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/sys/netinet/ip_mroute.c b/sys/netinet/ip_mroute.c
index 18d26735e339..96bc86bbac08 100644
--- a/sys/netinet/ip_mroute.c
+++ b/sys/netinet/ip_mroute.c
@@ -384,6 +384,8 @@ mfc_find(const struct mfctable *mfct, const struct in_addr *o,
 
 	MRW_LOCK_ASSERT();
 
+	if (mfct->mfchashtbl == NULL)
+		return (NULL);
 	LIST_FOREACH(rt, &mfct->mfchashtbl[MFCHASH(*o, *g)], mfc_hash) {
 		if (in_hosteq(rt->mfc_origin, *o) &&
 		    in_hosteq(rt->mfc_mcastgrp, *g) &&