From: Stephen Worley Date: Tue, 6 Jul 2021 14:59:35 +0000 (-0400) Subject: zebra: add knob to accept lower seq in evpn X-Git-Tag: base_8.5~239^2~14 X-Git-Url: https://git.puffer.fish/?a=commitdiff_plain;h=7d99ad7f93e42ca2f58023374843d70039a8310f;p=matthieu%2Ffrr.git zebra: add knob to accept lower seq in evpn Add a knob to accept lower seq number in evpn updates from BGP in Zebra. Note: Knob is enabled by default Signed-off-by: Stephen Worley --- diff --git a/zebra/zebra_evpn_mac.c b/zebra/zebra_evpn_mac.c index cbdc17653b..c58b55abdf 100644 --- a/zebra/zebra_evpn_mac.c +++ b/zebra/zebra_evpn_mac.c @@ -1597,6 +1597,7 @@ static inline bool zebra_evpn_mac_is_bgp_seq_ok(struct zebra_evpn *zevpn, bool sync) { char ipbuf[INET6_ADDRSTRLEN]; + char mac_buf[MAC_BUF_SIZE]; uint32_t tmp_seq; const char *n_type; @@ -1611,19 +1612,14 @@ static inline bool zebra_evpn_mac_is_bgp_seq_ok(struct zebra_evpn *zevpn, if (seq < tmp_seq) { /* if the mac was never advertised to bgp we must accept * whatever sequence number bgp sends - * XXX - check with Vivek */ - if (CHECK_FLAG(mac->flags, ZEBRA_MAC_LOCAL) - && !zebra_evpn_mac_is_ready_for_bgp(mac->flags)) { - if (IS_ZEBRA_DEBUG_EVPN_MH_MAC - || IS_ZEBRA_DEBUG_VXLAN) { - char mac_buf[MAC_BUF_SIZE]; - + if (zebra_vxlan_accept_bgp_seq()) { + if (IS_ZEBRA_DEBUG_EVPN_MH_MAC || + IS_ZEBRA_DEBUG_VXLAN) { zlog_debug( "%s-macip accept vni %u %s-mac %pEA%s%s lower seq %u f %s", sync ? "sync" : "rem", zevpn->vni, - n_type, - &mac->macaddr, + n_type, &mac->macaddr, ipa_len ? " IP " : "", ipa_len ? ipaddr2str(ipaddr, ipbuf, sizeof(ipbuf)) @@ -1637,8 +1633,6 @@ static inline bool zebra_evpn_mac_is_bgp_seq_ok(struct zebra_evpn *zevpn, } if (IS_ZEBRA_DEBUG_EVPN_MH_MAC || IS_ZEBRA_DEBUG_VXLAN) { - char mac_buf[MAC_BUF_SIZE]; - zlog_debug( "%s-macip ignore vni %u %s-mac %pEA%s%s as existing has higher seq %u f %s", sync ? "sync" : "rem", zevpn->vni, n_type, @@ -1651,6 +1645,7 @@ static inline bool zebra_evpn_mac_is_bgp_seq_ok(struct zebra_evpn *zevpn, zebra_evpn_zebra_mac_flag_dump( mac, mac_buf, sizeof(mac_buf))); } + return false; } diff --git a/zebra/zebra_evpn_neigh.c b/zebra/zebra_evpn_neigh.c index 6d90a603f7..c187b5947f 100644 --- a/zebra/zebra_evpn_neigh.c +++ b/zebra/zebra_evpn_neigh.c @@ -513,10 +513,8 @@ bool zebra_evpn_neigh_is_bgp_seq_ok(struct zebra_evpn *zevpn, if (seq < tmp_seq) { /* if the neigh was never advertised to bgp we must accept * whatever sequence number bgp sends - * XXX - check with Vivek */ - if (CHECK_FLAG(n->flags, ZEBRA_NEIGH_LOCAL) - && !zebra_evpn_neigh_is_ready_for_bgp(n)) { + if (zebra_vxlan_accept_bgp_seq()) { if (IS_ZEBRA_DEBUG_EVPN_MH_NEIGH || IS_ZEBRA_DEBUG_VXLAN) zlog_debug( diff --git a/zebra/zebra_vty.c b/zebra/zebra_vty.c index 525e0366e7..a95e07d952 100644 --- a/zebra/zebra_vty.c +++ b/zebra/zebra_vty.c @@ -3740,6 +3740,27 @@ DEFPY (clear_evpn_dup_addr, return ret; } +DEFPY_HIDDEN (evpn_accept_bgp_seq, + evpn_accept_bgp_seq_cmd, + "evpn accept-bgp-seq", + "EVPN\n" + "Accept all sequence numbers from BGP\n") +{ + zebra_vxlan_set_accept_bgp_seq(true); + return CMD_SUCCESS; +} + +DEFPY_HIDDEN (no_evpn_accept_bgp_seq, + no_evpn_accept_bgp_seq_cmd, + "no evpn accept-bgp-seq", + NO_STR + "EVPN\n" + "Accept all sequence numbers from BGP\n") +{ + zebra_vxlan_set_accept_bgp_seq(false); + return CMD_SUCCESS; +} + /* Static ip route configuration write function. */ static int zebra_ip_config(struct vty *vty) { @@ -3945,6 +3966,9 @@ static int config_write_protocol(struct vty *vty) zebra_pbr_config_write(vty); + if (!zebra_vxlan_accept_bgp_seq()) + vty_out(vty, "no evpn accept-bgp-seq\n"); + /* Include nexthop-group config */ if (!zebra_nhg_kernel_nexthops_enabled()) vty_out(vty, "no zebra nexthop kernel enable\n"); @@ -4582,6 +4606,8 @@ void zebra_vty_init(void) install_element(VIEW_NODE, &show_evpn_neigh_vni_dad_cmd); install_element(VIEW_NODE, &show_evpn_neigh_vni_all_dad_cmd); install_element(ENABLE_NODE, &clear_evpn_dup_addr_cmd); + install_element(CONFIG_NODE, &evpn_accept_bgp_seq_cmd); + install_element(CONFIG_NODE, &no_evpn_accept_bgp_seq_cmd); install_element(VIEW_NODE, &show_neigh_cmd); diff --git a/zebra/zebra_vxlan.c b/zebra/zebra_vxlan.c index 34cce71cd7..6954c63af0 100644 --- a/zebra/zebra_vxlan.c +++ b/zebra/zebra_vxlan.c @@ -69,6 +69,9 @@ DEFINE_HOOK(zebra_rmac_update, const char *reason), (rmac, zl3vni, delete, reason)); +/* config knobs */ +static bool accept_bgp_seq = true; + /* static function declarations */ static void zevpn_print_neigh_hash_all_evpn(struct hash_bucket *bucket, void **args); @@ -6284,6 +6287,17 @@ extern void zebra_vxlan_handle_result(struct zebra_dplane_ctx *ctx) return; } +/* Config knob for accepting lower sequence numbers */ +void zebra_vxlan_set_accept_bgp_seq(bool set) +{ + accept_bgp_seq = set; +} + +bool zebra_vxlan_accept_bgp_seq(void) +{ + return accept_bgp_seq; +} + /* Cleanup BGP EVPN configuration upon client disconnect */ extern void zebra_evpn_init(void) { diff --git a/zebra/zebra_vxlan.h b/zebra/zebra_vxlan.h index 757c65d185..1d777e39f8 100644 --- a/zebra/zebra_vxlan.h +++ b/zebra/zebra_vxlan.h @@ -225,6 +225,9 @@ extern int zebra_vxlan_dp_network_mac_del(struct interface *ifp, struct ethaddr *macaddr, vlanid_t vid); +extern void zebra_vxlan_set_accept_bgp_seq(bool set); +extern bool zebra_vxlan_accept_bgp_seq(void); + #ifdef __cplusplus } #endif