git: abab84cfac60 - stable/13 - mld: always commit state changes on leaving

From: Kristof Provost <kp_at_FreeBSD.org>
Date: Mon, 31 Jul 2023 12:45:47 UTC
The branch stable/13 has been updated by kp:

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

commit abab84cfac60e7e5a78d43cc4b0cfdd49f361989
Author:     Kristof Provost <kp@FreeBSD.org>
AuthorDate: 2023-07-20 07:41:45 +0000
Commit:     Kristof Provost <kp@FreeBSD.org>
CommitDate: 2023-07-31 12:43:14 +0000

    mld: always commit state changes on leaving
    
    Resolve a race condition where we'd lose the Solicited-node multicast
    group subscription if we assigned the same IPv6 address twice.
    
    PR:             233683
    Reviewed by:    ae
    MFC after:      1 week
    Sponsored by:   Rubicon Communications, LLC ("Netgate")
    Differential Revision: https://reviews.freebsd.org/D41124
    
    (cherry picked from commit 9c9a76dc6873427b14f6c84397dd60ea8e529d8d)
---
 sys/netinet6/mld6.c | 20 +++++++-------------
 1 file changed, 7 insertions(+), 13 deletions(-)

diff --git a/sys/netinet6/mld6.c b/sys/netinet6/mld6.c
index 1c984db70e93..fffd37738244 100644
--- a/sys/netinet6/mld6.c
+++ b/sys/netinet6/mld6.c
@@ -2162,13 +2162,10 @@ static void
 mld_final_leave(struct in6_multi *inm, struct mld_ifsoftc *mli)
 {
 	struct epoch_tracker     et;
-	int syncstates;
 #ifdef KTR
 	char ip6tbuf[INET6_ADDRSTRLEN];
 #endif
 
-	syncstates = 1;
-
 	CTR4(KTR_MLD, "%s: final leave %s on ifp %p(%s)",
 	    __func__, ip6_sprintf(ip6tbuf, &inm->in6m_addr),
 	    inm->in6m_ifp, if_name(inm->in6m_ifp));
@@ -2232,7 +2229,6 @@ mld_final_leave(struct in6_multi *inm, struct mld_ifsoftc *mli)
 				inm->in6m_state = MLD_LEAVING_MEMBER;
 				inm->in6m_sctimer = 1;
 				V_state_change_timers_running6 = 1;
-				syncstates = 0;
 			}
 			break;
 		}
@@ -2244,15 +2240,13 @@ mld_final_leave(struct in6_multi *inm, struct mld_ifsoftc *mli)
 		break;
 	}
 
-	if (syncstates) {
-		in6m_commit(inm);
-		CTR3(KTR_MLD, "%s: T1 -> T0 for %s/%s", __func__,
-		    ip6_sprintf(ip6tbuf, &inm->in6m_addr),
-		    if_name(inm->in6m_ifp));
-		inm->in6m_st[1].iss_fmode = MCAST_UNDEFINED;
-		CTR3(KTR_MLD, "%s: T1 now MCAST_UNDEFINED for %p/%s",
-		    __func__, &inm->in6m_addr, if_name(inm->in6m_ifp));
-	}
+	in6m_commit(inm);
+	CTR3(KTR_MLD, "%s: T1 -> T0 for %s/%s", __func__,
+	    ip6_sprintf(ip6tbuf, &inm->in6m_addr),
+	    if_name(inm->in6m_ifp));
+	inm->in6m_st[1].iss_fmode = MCAST_UNDEFINED;
+	CTR3(KTR_MLD, "%s: T1 now MCAST_UNDEFINED for %p/%s",
+	    __func__, &inm->in6m_addr, if_name(inm->in6m_ifp));
 }
 
 /*