Commit c883c113a5 for frr

commit c883c113a53afaaad2c6cc80fcec05ad393e929e
Author: Donald Sharp <sharpd@nvidia.com>
Date:   Thu Nov 12 10:46:26 2026 -0500

    bgpd: add accessors for the MAC mobility sequence

    Add bgp_attr_get_mm_seqnum() and bgp_attr_set_mm_seqnum() and use
    them for every read and write of the EVPN MAC mobility sequence on
    a route attribute. Replace mac_mobility_seqnum() with the getter.

    Signed-off-by: Donald Sharp <sharpd@nvidia.com>

diff --git a/bgpd/bgp_attr.c b/bgpd/bgp_attr.c
index 9c7769c1fd..c768ab66f4 100644
--- a/bgpd/bgp_attr.c
+++ b/bgpd/bgp_attr.c
@@ -1410,7 +1410,7 @@ unsigned int attrhash_key_make(const void *p)
 	MIX3(attr->nh_ifindex, attr->nh_lla_ifindex, attr->distance);
 	MIX(attr->bh_type);
 	MIX(bgp_attr_get_otc(attr));
-	MIX3(attr->mm_seqnum, bgp_attr_get_df_alg(attr), bgp_attr_get_df_pref(attr));
+	MIX3(bgp_attr_get_mm_seqnum(attr), bgp_attr_get_df_alg(attr), bgp_attr_get_df_pref(attr));
 	MIX(attr->encap_tunneltype);
 	MIX(bgp_attr_get_pmsi_tnl_type(attr));
 	if (bgp_attr_get_pmsi_tnl_type(attr) == PMSI_TNLTYPE_INGR_REPL)
@@ -1461,7 +1461,7 @@ bool attrhash_cmp(const void *p1, const void *p2)
 		    overlay_index_same(attr1, attr2) &&
 		    !memcmp(&attr1->esi, &attr2->esi, sizeof(esi_t)) &&
 		    bgp_attr_get_es_flags(attr1) == bgp_attr_get_es_flags(attr2) &&
-		    attr1->mm_seqnum == attr2->mm_seqnum &&
+		    bgp_attr_get_mm_seqnum(attr1) == bgp_attr_get_mm_seqnum(attr2) &&
 		    attr1->mm_sync_seqnum == attr2->mm_sync_seqnum &&
 		    bgp_attr_get_df_pref(attr1) == bgp_attr_get_df_pref(attr2) &&
 		    bgp_attr_get_df_alg(attr1) == bgp_attr_get_df_alg(attr2) &&
@@ -3530,7 +3530,7 @@ bgp_attr_ext_communities(struct bgp_attr_parser_args *args)
 	bgp_attr_set_df_alg(attr, df_alg);

 	/* Extract MAC mobility sequence number, if any. */
-	attr->mm_seqnum = bgp_attr_mac_mobility_seqnum(attr);
+	bgp_attr_set_mm_seqnum(attr, bgp_attr_mac_mobility_seqnum(attr));

 	/* Check if this is a Gateway MAC-IP advertisement */
 	bgp_attr_default_gw(attr);
diff --git a/bgpd/bgp_attr.h b/bgpd/bgp_attr.h
index 8962fb419e..dba9cafe44 100644
--- a/bgpd/bgp_attr.h
+++ b/bgpd/bgp_attr.h
@@ -546,11 +546,6 @@ static inline bool bgp_rmap_nhop_changed(uint32_t out_rmap_flags)
 			: false);
 }

-static inline uint32_t mac_mobility_seqnum(struct attr *attr)
-{
-	return (attr) ? attr->mm_seqnum : 0;
-}
-
 static inline enum pta_type bgp_attr_get_pmsi_tnl_type(const struct attr *attr)
 {
 	return attr->extra ? attr->extra->pmsi_tnl_type : PMSI_TNLTYPE_NO_INFO;
@@ -880,6 +875,16 @@ static inline void bgp_attr_set_df_pref(struct attr *attr, uint16_t df_pref)
 	attr->df_pref = df_pref;
 }

+static inline uint32_t bgp_attr_get_mm_seqnum(const struct attr *attr)
+{
+	return attr->mm_seqnum;
+}
+
+static inline void bgp_attr_set_mm_seqnum(struct attr *attr, uint32_t mm_seqnum)
+{
+	attr->mm_seqnum = mm_seqnum;
+}
+
 static inline struct bgp_route_evpn *
 bgp_attr_get_evpn_overlay(const struct attr *attr)
 {
diff --git a/bgpd/bgp_evpn.c b/bgpd/bgp_evpn.c
index 4f3bc8a67e..b94c2b3f73 100644
--- a/bgpd/bgp_evpn.c
+++ b/bgpd/bgp_evpn.c
@@ -1561,7 +1561,7 @@ enum zclient_send_status evpn_zebra_install(struct bgp *bgp, struct bgpevpn *vpn
 			    CHECK_FLAG(bgp_attr_get_evpn_flags(pi->attr), ATTR_EVPN_FLAG_ROUTER))
 				SET_FLAG(flags, ZEBRA_MACIP_TYPE_ROUTER_FLAG);

-			seq = mac_mobility_seqnum(pi->attr);
+			seq = bgp_attr_get_mm_seqnum(pi->attr);
 			/* If local ES notify zebra that this is a sync path.
 			 * ES is non-local while in LACP Bypass.
 			 */
@@ -1601,7 +1601,7 @@ enum zclient_send_status evpn_zebra_install(struct bgp *bgp, struct bgpevpn *vpn
 						ATTR_ES_PEER_ACTIVE))
 					SET_FLAG(flags, ZEBRA_MACIP_TYPE_PROXY_ADVERT);
 			} else
-				seq = mac_mobility_seqnum(pi->attr);
+				seq = bgp_attr_get_mm_seqnum(pi->attr);
 		}

 		uint8_t nhfamily = NEXTHOP_FAMILY(pi->attr->mp_nexthop_len);
@@ -2194,7 +2194,7 @@ static void bgp_evpn_get_sync_info(struct bgp *bgp, esi_t *esi,
 	 * it is a sync path
 	 */
 	if (!memcmp(esi, tmp_esi, sizeof(esi_t))) {
-		tmp_mm_seq = mac_mobility_seqnum(second_best_path->attr);
+		tmp_mm_seq = bgp_attr_get_mm_seqnum(second_best_path->attr);
 		if (tmp_mm_seq < loc_seq)
 			return;

@@ -2364,7 +2364,7 @@ static int update_evpn_route_entry(struct bgp *bgp, struct bgpevpn *vpn,
 		bgp_attr_dup_into(&local_attr, attr);

 		/* Extract MAC mobility sequence number, if any. */
-		local_attr.mm_seqnum = bgp_attr_mac_mobility_seqnum(&local_attr);
+		bgp_attr_set_mm_seqnum(&local_attr, bgp_attr_mac_mobility_seqnum(&local_attr));

 		/* Add (or update) attribute to hash. */
 		attr_new = bgp_attr_intern(&local_attr);
@@ -2455,8 +2455,8 @@ static int update_evpn_route_entry(struct bgp *bgp, struct bgpevpn *vpn,
 					       BGP_PATH_ATTR_CHANGED);

 			/* Extract MAC mobility sequence number, if any. */
-			local_attr.mm_seqnum =
-				bgp_attr_mac_mobility_seqnum(&local_attr);
+			bgp_attr_set_mm_seqnum(&local_attr,
+					       bgp_attr_mac_mobility_seqnum(&local_attr));

 			attr_new = bgp_attr_intern(&local_attr);

@@ -2956,7 +2956,7 @@ void bgp_evpn_update_type2_route_entry(struct bgp *bgp, struct bgpevpn *vpn,

 	/* Set up extended community. */
 	build_evpn_route_extcomm(vpn, &attr, add_l3_attrs, macvrf_soo);
-	seq = mac_mobility_seqnum(local_pi->attr);
+	seq = bgp_attr_get_mm_seqnum(local_pi->attr);

 	if (bgp_debug_zebra(NULL)) {
 		char buf3[ESI_STR_LEN];
@@ -3028,11 +3028,10 @@ void bgp_evpn_update_type2_route_entry(struct bgp *bgp, struct bgpevpn *vpn,
 		global_dest = bgp_evpn_global_node_get(
 			bgp->rib[afi][safi], afi, safi, &evp, &vpn->prd, NULL);
 		assert(global_dest);
-		update_evpn_route_entry(
-			bgp, vpn, afi, safi, global_dest, attr_new,
-			NULL /* mac */, NULL /* ip */, 0, &global_pi, 0,
-			mac_mobility_seqnum(attr_new), false /* setup_sync */,
-			NULL /* old_is_sync */);
+		update_evpn_route_entry(bgp, vpn, afi, safi, global_dest, attr_new, NULL /* mac */,
+					NULL /* ip */, 0, &global_pi, 0,
+					bgp_attr_get_mm_seqnum(attr_new), false /* setup_sync */,
+					NULL /* old_is_sync */);

 		/* Schedule for processing and unlock node. */
 		bgp_process(bgp, global_dest, global_pi, afi, safi);
@@ -5257,11 +5256,10 @@ static void update_advertise_vni_route(struct bgp *bgp, struct bgpevpn *vpn,

 	if (evp->prefix.route_type == BGP_EVPN_MAC_IP_ROUTE) {
 		/* Type-2 route */
-		update_evpn_route_entry(
-			bgp, vpn, afi, safi, global_dest, attr, NULL /* mac */,
-			NULL /* ip */, 1, &global_pi, 0,
-			mac_mobility_seqnum(attr), false /* setup_sync */,
-			NULL /* old_is_sync */);
+		update_evpn_route_entry(bgp, vpn, afi, safi, global_dest, attr, NULL /* mac */,
+					NULL /* ip */, 1, &global_pi, 0,
+					bgp_attr_get_mm_seqnum(attr), false /* setup_sync */,
+					NULL /* old_is_sync */);
 	} else {
 		/* Type-1 route */
 		struct bgp_evpn_es *es;
@@ -5313,10 +5311,9 @@ static void update_advertise_vni_routes(struct bgp *bgp, struct bgpevpn *vpn)

 		global_dest = bgp_evpn_global_node_get(
 			bgp->rib[afi][safi], afi, safi, &p, &vpn->prd, NULL);
-		update_evpn_route_entry(
-			bgp, vpn, afi, safi, global_dest, attr, NULL /* mac */,
-			NULL /* ip */, 1, &pi, 0, mac_mobility_seqnum(attr),
-			false /* setup_sync */, NULL /* old_is_sync */);
+		update_evpn_route_entry(bgp, vpn, afi, safi, global_dest, attr, NULL /* mac */,
+					NULL /* ip */, 1, &pi, 0, bgp_attr_get_mm_seqnum(attr),
+					false /* setup_sync */, NULL /* old_is_sync */);

 		/* Schedule for processing and unlock node. */
 		bgp_process(bgp, global_dest, pi, afi, safi);
diff --git a/bgpd/bgp_route.c b/bgpd/bgp_route.c
index 2aa3040cc2..9ca0494570 100644
--- a/bgpd/bgp_route.c
+++ b/bgpd/bgp_route.c
@@ -1209,8 +1209,8 @@ int bgp_path_info_cmp(struct bgp *bgp, struct bgp_path_info *new,
 			}
 		}

-		new_mm_seq = mac_mobility_seqnum(newattr);
-		exist_mm_seq = mac_mobility_seqnum(existattr);
+		new_mm_seq = bgp_attr_get_mm_seqnum(newattr);
+		exist_mm_seq = bgp_attr_get_mm_seqnum(existattr);

 		if (new_mm_seq > exist_mm_seq) {
 			*reason = bgp_path_selection_evpn_seq;