zebra: nb rpc cb for clear evpn dup addr cmd

Signed-off-by: Chirag Shah <chirag@cumulusnetworks.com>
This commit is contained in:
Chirag Shah 2020-01-29 12:05:35 -08:00 committed by Santosh P K
parent e20755b23e
commit c37c6fd818

View File

@ -22,6 +22,64 @@
#include "libfrr.h"
#include "zebra/zebra_nb.h"
#include "zebra/zebra_router.h"
#include "zebra/zebra_vrf.h"
#include "zebra/zebra_vxlan.h"
/*
* XPath: /frr-zebra:clear-evpn-dup-addr
*/
int clear_evpn_dup_addr_rpc(const char *xpath, const struct list *input,
struct list *output)
{
struct zebra_vrf *zvrf;
int ret = NB_OK;
struct yang_data *yang_dup_choice = NULL, *yang_dup_vni = NULL,
*yang_dup_ip = NULL, *yang_dup_mac = NULL;
yang_dup_choice = yang_data_list_find(input, "%s/%s", xpath,
"input/clear-dup-choice");
zvrf = zebra_vrf_get_evpn();
if (yang_dup_choice
&& strcmp(yang_dup_choice->value, "all-case") == 0) {
zebra_vxlan_clear_dup_detect_vni_all(NULL, zvrf);
} else {
vni_t vni;
struct ipaddr host_ip = {.ipa_type = IPADDR_NONE};
struct ethaddr mac;
yang_dup_vni = yang_data_list_find(
input, "%s/%s", xpath,
"input/clear-dup-choice/single-case/vni-id");
if (yang_dup_vni) {
vni = yang_str2uint32(yang_dup_vni->value);
yang_dup_mac = yang_data_list_find(
input, "%s/%s", xpath,
"input/clear-dup-choice/single-case/vni-id/mac-addr");
yang_dup_ip = yang_data_list_find(
input, "%s/%s", xpath,
"input/clear-dup-choice/single-case/vni-id/vni-ipaddr");
if (yang_dup_mac) {
yang_str2mac(value, &mac);
ret = zebra_vxlan_clear_dup_detect_vni_mac(
zvrf, vni, &mac);
} else if (yang_dup_ip) {
yang_str2ip(yang_dup_ip->value, &host_ip);
ret = zebra_vxlan_clear_dup_detect_vni_ip(
zvrf, vni, &host_ip);
} else
ret = zebra_vxlan_clear_dup_detect_vni(zvrf,
vni);
}
}
ret = (ret != CMD_SUCCESS) ? NB_ERR : NB_OK;
return ret;
}
/*
* XPath: /frr-zebra:get-route-information
@ -103,16 +161,6 @@ int get_evpn_vni_nexthops_rpc(const char *xpath, const struct list *input,
return NB_ERR_NOT_FOUND;
}
/*
* XPath: /frr-zebra:clear-evpn-dup-addr
*/
int clear_evpn_dup_addr_rpc(const char *xpath, const struct list *input,
struct list *output)
{
/* TODO: implement me. */
return NB_ERR_NOT_FOUND;
}
/*
* XPath: /frr-zebra:get-evpn-macs
*/