]> git.proxmox.com Git - mirror_frr.git/commitdiff
zebra: add knob to accept lower seq in evpn
authorStephen Worley <sworley@nvidia.com>
Tue, 6 Jul 2021 14:59:35 +0000 (10:59 -0400)
committerStephen Worley <sworley@nvidia.com>
Fri, 7 Oct 2022 19:36:57 +0000 (15:36 -0400)
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 <sworley@nvidia.com>
zebra/zebra_evpn_mac.c
zebra/zebra_evpn_neigh.c
zebra/zebra_vty.c
zebra/zebra_vxlan.c
zebra/zebra_vxlan.h

index cbdc17653b9a26e7c864a2b5d323bf10382eb3b1..c58b55abdffb2aff294e935648fbda454a97c2a5 100644 (file)
@@ -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;
        }
 
index 6d90a603f7b80c02f485c3ef0548cee6be9cd6c6..c187b5947f14bd37cd7cb0b6bbc34fea83791566 100644 (file)
@@ -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(
index 525e0366e78263381b31abe98bfd8d5f63665e43..a95e07d95236a6d0d1a063bab663acc1eedc2034 100644 (file)
@@ -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);
 
index 34cce71cd75d7e519b7b60e5674eeb97b086a26c..6954c63af04913d2143184d503052a14c55423bd 100644 (file)
@@ -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)
 {
index 757c65d185bf6b3273f9e2f5d5508517bac429b5..1d777e39f89a4d226e86a60adc0673e4d4af8f99 100644 (file)
@@ -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