From 7c85225cf503ef14c96f50d925491d44862efa4f Mon Sep 17 00:00:00 2001 From: Anuradha Karuppiah Date: Tue, 26 Mar 2019 13:47:54 -0700 Subject: [PATCH] pimd: hidden command to set MLAG parameters The MLAG component on the switch is expected to provide some properties (such as peerlink-rif) to bootstrap the anycast-VTEP functionality. The final interface for this is being defined as a part of the pim-mlag functionality. This commit provides a hidden command to test the anycast-VTEP functionality independent of the MLAG component. Signed-off-by: Anuradha Karuppiah --- pimd/pim_cmd.c | 85 ++++++++++++++++++++++++++++++++++++++++++++++++ pimd/pim_vty.c | 3 ++ pimd/pim_vxlan.c | 21 ++++++++++++ pimd/pim_vxlan.h | 1 + 4 files changed, 110 insertions(+) diff --git a/pimd/pim_cmd.c b/pimd/pim_cmd.c index c7791ad086..736d348292 100644 --- a/pimd/pim_cmd.c +++ b/pimd/pim_cmd.c @@ -9005,6 +9005,89 @@ DEFUN_HIDDEN (show_ip_pim_vxlan_sg_work, return CMD_SUCCESS; } +DEFUN_HIDDEN (no_ip_pim_mlag, + no_ip_pim_mlag_cmd, + "no ip pim mlag", + NO_STR + IP_STR + PIM_STR + "MLAG\n") +{ + struct in_addr addr; + + addr.s_addr = 0; + pim_vxlan_mlag_update(TRUE /*mlag_enable*/, + FALSE /*peer_state*/, PIM_VXLAN_MLAG_ROLE_SECONDARY, + NULL/*peerlink*/, &addr); + + return CMD_SUCCESS; +} + +DEFUN_HIDDEN (ip_pim_mlag, + ip_pim_mlag_cmd, + "ip pim mlag INTERFACE role [primary|secondary] state [up|down] addr A.B.C.D", + IP_STR + PIM_STR + "MLAG\n" + "peerlink sub interface\n" + "MLAG role\n" + "MLAG role primary\n" + "MLAG role secondary\n" + "peer session state\n" + "peer session state up\n" + "peer session state down\n" + "configure PIP\n" + "unique ip address\n") +{ + struct interface *ifp; + const char *peerlink; + uint32_t role; + int idx; + bool peer_state; + int result; + struct in_addr reg_addr; + + idx = 3; + peerlink = argv[idx]->arg; + ifp = if_lookup_by_name(peerlink, VRF_DEFAULT); + if (!ifp) { + vty_out(vty, "No such interface name %s\n", peerlink); + return CMD_WARNING; + } + + idx += 2; + if (!strcmp(argv[idx]->arg, "primary")) { + role = PIM_VXLAN_MLAG_ROLE_PRIMARY; + } else if (!strcmp(argv[idx]->arg, "secondary")) { + role = PIM_VXLAN_MLAG_ROLE_SECONDARY; + } else { + vty_out(vty, "unknown MLAG role %s\n", argv[idx]->arg); + return CMD_WARNING; + } + + idx += 2; + if (!strcmp(argv[idx]->arg, "up")) { + peer_state = TRUE; + } else if (strcmp(argv[idx]->arg, "down")) { + peer_state = FALSE; + } else { + vty_out(vty, "unknown MLAG state %s\n", argv[idx]->arg); + return CMD_WARNING; + } + + idx += 2; + result = inet_pton(AF_INET, argv[idx]->arg, ®_addr); + if (result <= 0) { + vty_out(vty, "%% Bad reg address %s: errno=%d: %s\n", + argv[idx]->arg, + errno, safe_strerror(errno)); + return CMD_WARNING_CONFIG_FAILED; + } + pim_vxlan_mlag_update(TRUE, peer_state, role, ifp, ®_addr); + + return CMD_SUCCESS; +} + void pim_cmd_init(void) { install_node(&interface_node, @@ -9078,6 +9161,8 @@ void pim_cmd_init(void) install_element(VRF_NODE, &ip_pim_ecmp_rebalance_cmd); install_element(CONFIG_NODE, &no_ip_pim_ecmp_rebalance_cmd); install_element(VRF_NODE, &no_ip_pim_ecmp_rebalance_cmd); + install_element(CONFIG_NODE, &ip_pim_mlag_cmd); + install_element(CONFIG_NODE, &no_ip_pim_mlag_cmd); install_element(INTERFACE_NODE, &interface_ip_igmp_cmd); install_element(INTERFACE_NODE, &interface_no_ip_igmp_cmd); diff --git a/pimd/pim_vty.c b/pimd/pim_vty.c index 9e677958d5..2654ebc588 100644 --- a/pimd/pim_vty.c +++ b/pimd/pim_vty.c @@ -39,6 +39,7 @@ #include "pim_msdp.h" #include "pim_ssm.h" #include "pim_bfd.h" +#include "pim_vxlan.h" int pim_debug_config_write(struct vty *vty) { @@ -239,6 +240,8 @@ int pim_global_config_write_worker(struct pim_instance *pim, struct vty *vty) } } + pim_vxlan_config_write(vty, spaces, &writes); + return writes; } diff --git a/pimd/pim_vxlan.c b/pimd/pim_vxlan.c index 43269b74a1..fbc9adaf27 100644 --- a/pimd/pim_vxlan.c +++ b/pimd/pim_vxlan.c @@ -808,6 +808,27 @@ void pim_vxlan_mlag_update(bool enable, bool peer_state, uint32_t role, } /****************************** misc callbacks *******************************/ +void pim_vxlan_config_write(struct vty *vty, char *spaces, int *writes) +{ + char addr_buf[INET_ADDRSTRLEN]; + + if ((vxlan_mlag.flags & PIM_VXLAN_MLAGF_ENABLED) && + vxlan_mlag.peerlink_rif) { + + inet_ntop(AF_INET, &vxlan_mlag.reg_addr, + addr_buf, sizeof(addr_buf)); + vty_out(vty, + "%sip pim mlag %s role %s state %s addr %s\n", + spaces, + vxlan_mlag.peerlink_rif->name, + (vxlan_mlag.role == PIM_VXLAN_MLAG_ROLE_PRIMARY) ? + "primary":"secondary", + vxlan_mlag.peer_state ? "up" : "down", + addr_buf); + *writes += 1; + } +} + static void pim_vxlan_set_default_iif(struct pim_instance *pim, struct interface *ifp) { diff --git a/pimd/pim_vxlan.h b/pimd/pim_vxlan.h index 49c5b64af1..f0a66e6b77 100644 --- a/pimd/pim_vxlan.h +++ b/pimd/pim_vxlan.h @@ -134,5 +134,6 @@ extern bool pim_vxlan_get_register_src(struct pim_instance *pim, extern void pim_vxlan_mlag_update(bool enable, bool peer_state, uint32_t role, struct interface *peerlink_rif, struct in_addr *reg_addr); +extern void pim_vxlan_config_write(struct vty *vty, char *spaces, int *writes); #endif /* PIM_VXLAN_H */ -- 2.39.5