git: 0bc82e4fbbe9 - main - ip_mroute: allow MRT_DEL_MFC even if there are pending upcalls

From: Kristof Provost <kp_at_FreeBSD.org>
Date: Thu, 14 Dec 2023 21:59:59 UTC
The branch main has been updated by kp:

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

commit 0bc82e4fbbe9d1eb72b6be512ff92a4908f85fef
Author:     Kristof Provost <kp@FreeBSD.org>
AuthorDate: 2023-12-12 18:17:40 +0000
Commit:     Kristof Provost <kp@FreeBSD.org>
CommitDate: 2023-12-14 21:04:43 +0000

    ip_mroute: allow MRT_DEL_MFC even if there are pending upcalls
    
    In del_mfc() we try to find the forwarding entry, but that fails to find
    the entry if mfc_stall_ring is not empty.
    
    We should find the entry anyway, and destroy it (and any pending
    messages) on delete.
    
    Reviewed by:    glebius
    Sponsored by:   Rubicon Communications, LLC ("Netgate")
    Differential Revision:  https://reviews.freebsd.org/D43031
---
 sys/netinet/ip_mroute.c | 17 ++++++-----------
 1 file changed, 6 insertions(+), 11 deletions(-)

diff --git a/sys/netinet/ip_mroute.c b/sys/netinet/ip_mroute.c
index 10ac13d7d582..b864a4db5abc 100644
--- a/sys/netinet/ip_mroute.c
+++ b/sys/netinet/ip_mroute.c
@@ -1250,22 +1250,17 @@ del_mfc(struct mfcctl2 *mfccp)
 
 	MRW_WLOCK();
 
-	rt = mfc_find(&origin, &mcastgrp);
+	LIST_FOREACH(rt, &V_mfchashtbl[MFCHASH(origin, mcastgrp)], mfc_hash) {
+		if (in_hosteq(rt->mfc_origin, origin) &&
+		    in_hosteq(rt->mfc_mcastgrp, mcastgrp))
+			break;
+	}
 	if (rt == NULL) {
 		MRW_WUNLOCK();
 		return EADDRNOTAVAIL;
 	}
 
-	/*
-	 * free the bw_meter entries
-	 */
-	free_bw_list(rt->mfc_bw_meter_leq);
-	rt->mfc_bw_meter_leq = NULL;
-	free_bw_list(rt->mfc_bw_meter_geq);
-	rt->mfc_bw_meter_geq = NULL;
-
-	LIST_REMOVE(rt, mfc_hash);
-	free(rt, M_MRTABLE);
+	expire_mfc(rt);
 
 	MRW_WUNLOCK();