summaryrefslogtreecommitdiffstats
path: root/zebra/zebra_nb_rpcs.c
diff options
context:
space:
mode:
Diffstat (limited to 'zebra/zebra_nb_rpcs.c')
-rw-r--r--zebra/zebra_nb_rpcs.c63
1 files changed, 29 insertions, 34 deletions
diff --git a/zebra/zebra_nb_rpcs.c b/zebra/zebra_nb_rpcs.c
index 083ab3f..744ba62 100644
--- a/zebra/zebra_nb_rpcs.c
+++ b/zebra/zebra_nb_rpcs.c
@@ -12,6 +12,8 @@
#include "zebra/zebra_router.h"
#include "zebra/zebra_vrf.h"
#include "zebra/zebra_vxlan.h"
+#include "zebra/zebra_vxlan_if.h"
+#include "zebra/zebra_evpn.h"
/*
* XPath: /frr-zebra:clear-evpn-dup-addr
@@ -20,48 +22,41 @@ int clear_evpn_dup_addr_rpc(struct nb_cb_rpc_args *args)
{
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(args->input, "%s/%s", args->xpath,
- "input/clear-dup-choice");
+ if (!is_evpn_enabled()) {
+ snprintf(args->errmsg, args->errmsg_len,
+ "%% EVPN not enabled\n");
+ return NB_ERR_VALIDATION;
+ }
zvrf = zebra_vrf_get_evpn();
- if (yang_dup_choice
- && strcmp(yang_dup_choice->value, "all-case") == 0) {
+ if (yang_dnode_exists(args->input, "all-vnis")) {
zebra_vxlan_clear_dup_detect_vni_all(zvrf);
} else {
- vni_t vni;
+ vni_t vni = yang_dnode_get_uint32(args->input, "vni-id");
struct ipaddr host_ip = {.ipa_type = IPADDR_NONE};
struct ethaddr mac;
- yang_dup_vni = yang_data_list_find(
- args->input, "%s/%s", args->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(
- args->input, "%s/%s", args->xpath,
- "input/clear-dup-choice/single-case/vni-id/mac-addr");
- yang_dup_ip = yang_data_list_find(
- args->input, "%s/%s", args->xpath,
- "input/clear-dup-choice/single-case/vni-id/vni-ipaddr");
-
- if (yang_dup_mac) {
- yang_str2mac(yang_dup_mac->value, &mac);
- ret = zebra_vxlan_clear_dup_detect_vni_mac(
- zvrf, vni, &mac, args->errmsg,
- args->errmsg_len);
- } 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, args->errmsg,
- args->errmsg_len);
- } else
- ret = zebra_vxlan_clear_dup_detect_vni(zvrf,
- vni);
+ if (!zebra_evpn_lookup(vni)) {
+ snprintf(args->errmsg, args->errmsg_len,
+ "%% VNI %u does not exist\n", vni);
+ return NB_ERR_VALIDATION;
+ }
+
+ if (yang_dnode_exists(args->input, "mac-addr")) {
+ yang_dnode_get_mac(&mac, args->input, "mac-addr");
+ ret = zebra_vxlan_clear_dup_detect_vni_mac(zvrf, vni,
+ &mac,
+ args->errmsg,
+ args->errmsg_len);
+ } else if (yang_dnode_exists(args->input, "vni-ipaddr")) {
+ yang_dnode_get_ip(&host_ip, args->input, "vni-ipaddr");
+ ret = zebra_vxlan_clear_dup_detect_vni_ip(zvrf, vni,
+ &host_ip,
+ args->errmsg,
+ args->errmsg_len);
+ } else {
+ ret = zebra_vxlan_clear_dup_detect_vni(zvrf, vni);
}
}
if (ret < 0)