]> git.puffer.fish Git - matthieu/frr.git/commitdiff
bgpd: hidden commands to add/del a local mac
authorAnuradha Karuppiah <anuradhak@cumulusnetworks.com>
Wed, 10 Oct 2018 21:28:32 +0000 (14:28 -0700)
committerDonald Sharp <sharpd@cumulusnetworks.com>
Wed, 31 Oct 2018 10:23:32 +0000 (06:23 -0400)
local mac add/del comes from zebra. the hidden commands help verify
various race conditions between bgp and zebra.

Ticket: CM-22687
Reviewed By: CCR-7939

Signed-off-by: Anuradha Karuppiah <anuradhak@cumulusnetworks.com>
bgpd/bgp_vty.c
bgpd/bgp_vty.h

index ecbe33ff8c51759ed393174add66746990638524..70e49a90da0ef673857e8bbd1f82f58dc611eff7 100644 (file)
@@ -822,6 +822,87 @@ DEFUN_HIDDEN (no_bgp_multiple_instance,
        return CMD_SUCCESS;
 }
 
+DEFUN_HIDDEN (bgp_local_mac,
+              bgp_local_mac_cmd,
+              "bgp local-mac vni " BGP_CMD_VNI_RANGE " mac WORD seq (0-4294967295)",
+              BGP_STR
+              "Local MAC config\n"
+              "VxLAN Network Identifier\n"
+              "VNI number\n"
+              "local mac\n"
+              "mac address\n"
+              "mac-mobility sequence\n"
+              "seq number\n")
+{
+       int rv;
+       vni_t vni;
+       struct ethaddr mac;
+       struct ipaddr ip;
+       uint32_t seq;
+       struct bgp *bgp;
+
+       vni = strtoul(argv[3]->arg, NULL, 10);
+       if (!prefix_str2mac(argv[5]->arg, &mac)) {
+               vty_out(vty, "%% Malformed MAC address\n");
+               return CMD_WARNING;
+       }
+       memset(&ip, 0, sizeof(ip));
+       seq = strtoul(argv[7]->arg, NULL, 10);
+
+       bgp = bgp_get_default();
+       if (!bgp) {
+               vty_out(vty, "Default BGP instance is not there\n");
+               return CMD_WARNING;
+       }
+
+       rv = bgp_evpn_local_macip_add(bgp, vni, &mac, &ip, 0 /* flags */, seq);
+       if (rv < 0) {
+               vty_out(vty, "Internal error\n");
+               return CMD_WARNING;
+       }
+
+       return CMD_SUCCESS;
+}
+
+DEFUN_HIDDEN (no_bgp_local_mac,
+              no_bgp_local_mac_cmd,
+              "no bgp local-mac vni " BGP_CMD_VNI_RANGE " mac WORD",
+              NO_STR
+              BGP_STR
+              "Local MAC config\n"
+              "VxLAN Network Identifier\n"
+              "VNI number\n"
+              "local mac\n"
+              "mac address\n")
+{
+       int rv;
+       vni_t vni;
+       struct ethaddr mac;
+       struct ipaddr ip;
+       struct bgp *bgp;
+
+       vni = strtoul(argv[4]->arg, NULL, 10);
+       if (!prefix_str2mac(argv[6]->arg, &mac)) {
+               vty_out(vty, "%% Malformed MAC address\n");
+               return CMD_WARNING;
+       }
+       memset(&ip, 0, sizeof(ip));
+
+       bgp = bgp_get_default();
+       if (!bgp) {
+               vty_out(vty, "Default BGP instance is not there\n");
+               return CMD_WARNING;
+       }
+
+       rv = bgp_evpn_local_macip_del(bgp, vni, &mac, &ip);
+       if (rv < 0) {
+               vty_out(vty, "Internal error\n");
+               return CMD_WARNING;
+       }
+
+       return CMD_SUCCESS;
+}
+
 #if (CONFDATE > 20190601)
 CPP_NOTICE("bgpd: time to remove deprecated cli bgp config-type cisco")
 CPP_NOTICE("This includes BGP_OPT_CISCO_CONFIG")
@@ -12579,6 +12660,10 @@ void bgp_vty_init(void)
        install_element(CONFIG_NODE, &bgp_config_type_cmd);
        install_element(CONFIG_NODE, &no_bgp_config_type_cmd);
 
+       /* "bgp local-mac" hidden commands. */
+       install_element(CONFIG_NODE, &bgp_local_mac_cmd);
+       install_element(CONFIG_NODE, &no_bgp_local_mac_cmd);
+
        /* bgp route-map delay-timer commands. */
        install_element(CONFIG_NODE, &bgp_set_route_map_delay_timer_cmd);
        install_element(CONFIG_NODE, &no_bgp_set_route_map_delay_timer_cmd);
index d9df2b4cfedab1771e36836ea954ebc21a3029e3..efb8902d97e90767d7b4596d802fdb80dc545532 100644 (file)
@@ -44,6 +44,8 @@ struct bgp;
        "Address Family modifier\n"                                            \
        "Address Family modifier\n"
 
+#define BGP_CMD_VNI_RANGE "(1-16777215)"
+
 extern void bgp_vty_init(void);
 extern const char *afi_safi_print(afi_t afi, safi_t safi);
 extern const char *afi_safi_json(afi_t afi, safi_t safi);