summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIgor Ryzhov <iryzhov@nfware.com>2021-03-31 01:26:51 +0200
committerGitHub <noreply@github.com>2021-03-31 01:26:51 +0200
commitfb639375cb2ca062f350c56c51367f2d8d5b2514 (patch)
treed44973b74fd06e63dbf6419c4a7acea659fc4353
parentMerge pull request #8058 from rgirada/ospf-ecmp (diff)
parentbgpd: North-bound implementation for bgp rmaps (diff)
downloadfrr-fb639375cb2ca062f350c56c51367f2d8d5b2514.tar.xz
frr-fb639375cb2ca062f350c56c51367f2d8d5b2514.zip
Merge pull request #7419 from patrasar/routemap_nb
Routemap nb
-rw-r--r--bgpd/bgp_main.c2
-rw-r--r--bgpd/bgp_routemap.c2855
-rw-r--r--bgpd/bgp_routemap_nb.c376
-rw-r--r--bgpd/bgp_routemap_nb.h138
-rw-r--r--bgpd/bgp_routemap_nb_config.c2637
-rw-r--r--bgpd/bgp_rpki.c56
-rw-r--r--bgpd/subdir.am5
-rw-r--r--lib/routemap.c296
-rw-r--r--lib/routemap.h529
-rw-r--r--lib/routemap_cli.c795
-rw-r--r--lib/routemap_northbound.c212
-rw-r--r--ospf6d/ospf6_asbr.c127
-rw-r--r--ospf6d/ospf6_main.c3
-rw-r--r--ospf6d/ospf6_routemap_nb.c55
-rw-r--r--ospf6d/ospf6_routemap_nb.h40
-rw-r--r--ospf6d/ospf6_routemap_nb_config.c129
-rw-r--r--ospf6d/subdir.am8
-rw-r--r--ospfd/ospf_main.c2
-rw-r--r--ospfd/ospf_routemap.c25
-rw-r--r--ospfd/ospf_routemap_nb.c39
-rw-r--r--ospfd/ospf_routemap_nb.h37
-rw-r--r--ospfd/ospf_routemap_nb_config.c63
-rw-r--r--ospfd/ospfd.h1
-rw-r--r--ospfd/subdir.am7
-rw-r--r--yang/frr-bgp-filter.yang329
-rw-r--r--yang/frr-bgp-route-map.yang820
-rw-r--r--yang/frr-ospf-route-map.yang52
-rw-r--r--yang/frr-ospf6-route-map.yang47
-rw-r--r--yang/frr-route-map.yang598
-rw-r--r--yang/frr-zebra-route-map.yang126
-rw-r--r--yang/frr-zebra.yang61
-rw-r--r--yang/subdir.am5
-rw-r--r--zebra/main.c1
-rw-r--r--zebra/subdir.am4
-rw-r--r--zebra/zebra_nb.c42
-rw-r--r--zebra/zebra_nb.h24
-rw-r--r--zebra/zebra_nb_config.c320
-rw-r--r--zebra/zebra_routemap.c74
-rw-r--r--zebra/zebra_routemap.h2
-rw-r--r--zebra/zebra_routemap_nb.c74
-rw-r--r--zebra/zebra_routemap_nb.h45
-rw-r--r--zebra/zebra_routemap_nb_config.c396
42 files changed, 8759 insertions, 2698 deletions
diff --git a/bgpd/bgp_main.c b/bgpd/bgp_main.c
index 2ddafd9a0..ea74a82ce 100644
--- a/bgpd/bgp_main.c
+++ b/bgpd/bgp_main.c
@@ -65,6 +65,7 @@
#include "bgpd/bgp_nb.h"
#include "bgpd/bgp_evpn_mh.h"
#include "bgpd/bgp_nht.h"
+#include "bgpd/bgp_routemap_nb.h"
#ifdef ENABLE_BGP_VNC
#include "bgpd/rfapi/rfapi_backend.h"
@@ -388,6 +389,7 @@ static const struct frr_yang_module_info *const bgpd_yang_modules[] = {
&frr_route_map_info,
&frr_routing_info,
&frr_vrf_info,
+ &frr_bgp_route_map_info,
};
FRR_DAEMON_INFO(bgpd, BGP, .vty_port = BGP_VTY_PORT,
diff --git a/bgpd/bgp_routemap.c b/bgpd/bgp_routemap.c
index b7f3289ff..a43b76da7 100644
--- a/bgpd/bgp_routemap.c
+++ b/bgpd/bgp_routemap.c
@@ -40,6 +40,7 @@
#include "queue.h"
#include "frrstr.h"
#include "network.h"
+#include "lib/northbound_cli.h"
#include "bgpd/bgpd.h"
#include "bgpd/bgp_table.h"
@@ -3429,81 +3430,6 @@ static const struct route_map_rule_cmd route_set_originator_id_cmd = {
route_set_originator_id_free,
};
-/* Add bgp route map rule. */
-static int bgp_route_match_add(struct vty *vty, const char *command,
- const char *arg, route_map_event_t type)
-{
- VTY_DECLVAR_CONTEXT(route_map_index, index);
- int retval = CMD_SUCCESS;
- enum rmap_compile_rets ret;
-
- ret = route_map_add_match(index, command, arg, type);
- switch (ret) {
- case RMAP_RULE_MISSING:
- vty_out(vty, "%% BGP Can't find rule.\n");
- retval = CMD_WARNING_CONFIG_FAILED;
- break;
- case RMAP_COMPILE_ERROR:
- vty_out(vty, "%% BGP Argument is malformed.\n");
- retval = CMD_WARNING_CONFIG_FAILED;
- break;
- case RMAP_COMPILE_SUCCESS:
- /*
- * Intentionally doing nothing here.
- */
- break;
- }
-
- return retval;
-}
-
-/* Delete bgp route map rule. */
-static int bgp_route_match_delete(struct vty *vty, const char *command,
- const char *arg, route_map_event_t type)
-{
- VTY_DECLVAR_CONTEXT(route_map_index, index);
- enum rmap_compile_rets ret;
- int retval = CMD_SUCCESS;
- char *dep_name = NULL;
- const char *tmpstr;
- char *rmap_name = NULL;
-
- if (type != RMAP_EVENT_MATCH_DELETED) {
- /* ignore the mundane, the types without any dependency */
- if (arg == NULL) {
- if ((tmpstr = route_map_get_match_arg(index, command))
- != NULL)
- dep_name =
- XSTRDUP(MTYPE_ROUTE_MAP_RULE, tmpstr);
- } else {
- dep_name = XSTRDUP(MTYPE_ROUTE_MAP_RULE, arg);
- }
- rmap_name = XSTRDUP(MTYPE_ROUTE_MAP_NAME, index->map->name);
- }
-
- ret = route_map_delete_match(index, command, dep_name, type);
- switch (ret) {
- case RMAP_RULE_MISSING:
- vty_out(vty, "%% BGP Can't find rule.\n");
- retval = CMD_WARNING_CONFIG_FAILED;
- break;
- case RMAP_COMPILE_ERROR:
- vty_out(vty, "%% BGP Argument is malformed.\n");
- retval = CMD_WARNING_CONFIG_FAILED;
- break;
- case RMAP_COMPILE_SUCCESS:
- /*
- * Nothing to do here
- */
- break;
- }
-
- XFREE(MTYPE_ROUTE_MAP_RULE, dep_name);
- XFREE(MTYPE_ROUTE_MAP_NAME, rmap_name);
-
- return retval;
-}
-
/*
* This is the workhorse routine for processing in/out routemap
* modifications.
@@ -3914,29 +3840,40 @@ static void bgp_route_map_event(const char *rmap_name)
route_map_notify_dependencies(rmap_name, RMAP_EVENT_MATCH_ADDED);
}
-DEFUN (match_mac_address,
- match_mac_address_cmd,
- "match mac address WORD",
- MATCH_STR
- "mac address\n"
- "Match address of route\n"
- "MAC Access-list name\n")
+DEFUN_YANG (match_mac_address,
+ match_mac_address_cmd,
+ "match mac address WORD",
+ MATCH_STR
+ "mac address\n"
+ "Match address of route\n"
+ "MAC Access-list name\n")
{
- return bgp_route_match_add(vty, "mac address", argv[3]->arg,
- RMAP_EVENT_FILTER_ADDED);
+ const char *xpath =
+ "./match-condition[condition='frr-bgp-route-map:mac-address-list']";
+ char xpath_value[XPATH_MAXLEN];
+
+ nb_cli_enqueue_change(vty, xpath, NB_OP_CREATE, NULL);
+ snprintf(xpath_value, sizeof(xpath_value),
+ "%s/rmap-match-condition/frr-bgp-route-map:list-name", xpath);
+ nb_cli_enqueue_change(vty, xpath_value, NB_OP_MODIFY, argv[3]->arg);
+
+ return nb_cli_apply_changes(vty, NULL);
}
-DEFUN (no_match_mac_address,
- no_match_mac_address_cmd,
- "no match mac address WORD",
- NO_STR
- MATCH_STR
- "mac\n"
- "Match address of route\n"
- "MAC acess-list name\n")
+DEFUN_YANG (no_match_mac_address,
+ no_match_mac_address_cmd,
+ "no match mac address WORD",
+ NO_STR
+ MATCH_STR
+ "mac\n"
+ "Match address of route\n"
+ "MAC acess-list name\n")
{
- return bgp_route_match_delete(vty, "mac address", argv[4]->arg,
- RMAP_EVENT_FILTER_DELETED);
+ const char *xpath =
+ "./match-condition[condition='frr-bgp-route-map:mac-address-list']";
+
+ nb_cli_enqueue_change(vty, xpath, NB_OP_DESTROY, NULL);
+ return nb_cli_apply_changes(vty, NULL);
}
/*
@@ -3963,241 +3900,377 @@ static const char *parse_evpn_rt_type(const char *num_rt_type)
return num_rt_type;
}
-DEFUN (match_evpn_route_type,
- match_evpn_route_type_cmd,
- "match evpn route-type <macip|2|multicast|3|prefix|5>",
- MATCH_STR
- EVPN_HELP_STR
- EVPN_TYPE_HELP_STR
- EVPN_TYPE_2_HELP_STR
- EVPN_TYPE_2_HELP_STR
- EVPN_TYPE_3_HELP_STR
- EVPN_TYPE_3_HELP_STR
- EVPN_TYPE_5_HELP_STR
- EVPN_TYPE_5_HELP_STR)
-{
- return bgp_route_match_add(vty, "evpn route-type",
- parse_evpn_rt_type(argv[3]->arg),
- RMAP_EVENT_MATCH_ADDED);
-}
-
-DEFUN (no_match_evpn_route_type,
- no_match_evpn_route_type_cmd,
- "no match evpn route-type <macip|2|multicast|3|prefix|5>",
- NO_STR
- MATCH_STR
- EVPN_HELP_STR
- EVPN_TYPE_HELP_STR
- EVPN_TYPE_2_HELP_STR
- EVPN_TYPE_2_HELP_STR
- EVPN_TYPE_3_HELP_STR
- EVPN_TYPE_3_HELP_STR
- EVPN_TYPE_5_HELP_STR
- EVPN_TYPE_5_HELP_STR)
+DEFUN_YANG (match_evpn_route_type,
+ match_evpn_route_type_cmd,
+ "match evpn route-type <macip|2|multicast|3|prefix|5>",
+ MATCH_STR
+ EVPN_HELP_STR
+ EVPN_TYPE_HELP_STR
+ EVPN_TYPE_2_HELP_STR
+ EVPN_TYPE_2_HELP_STR
+ EVPN_TYPE_3_HELP_STR
+ EVPN_TYPE_3_HELP_STR
+ EVPN_TYPE_5_HELP_STR
+ EVPN_TYPE_5_HELP_STR)
{
- return bgp_route_match_delete(vty, "evpn route-type",
- parse_evpn_rt_type(argv[4]->arg),
- RMAP_EVENT_MATCH_DELETED);
-}
+ const char *xpath =
+ "./match-condition[condition='frr-bgp-route-map:evpn-route-type']";
+ char xpath_value[XPATH_MAXLEN];
+ nb_cli_enqueue_change(vty, xpath, NB_OP_CREATE, NULL);
+ snprintf(xpath_value, sizeof(xpath_value),
+ "%s/rmap-match-condition/frr-bgp-route-map:evpn-route-type",
+ xpath);
+ nb_cli_enqueue_change(vty, xpath_value, NB_OP_MODIFY,
+ parse_evpn_rt_type(argv[3]->arg));
-DEFUN (match_evpn_vni,
- match_evpn_vni_cmd,
- "match evpn vni " CMD_VNI_RANGE,
- MATCH_STR
- EVPN_HELP_STR
- "Match VNI\n"
- "VNI ID\n")
+ return nb_cli_apply_changes(vty, NULL);
+}
+
+DEFUN_YANG (no_match_evpn_route_type,
+ no_match_evpn_route_type_cmd,
+ "no match evpn route-type <macip|2|multicast|3|prefix|5>",
+ NO_STR
+ MATCH_STR
+ EVPN_HELP_STR
+ EVPN_TYPE_HELP_STR
+ EVPN_TYPE_2_HELP_STR
+ EVPN_TYPE_2_HELP_STR
+ EVPN_TYPE_3_HELP_STR
+ EVPN_TYPE_3_HELP_STR
+ EVPN_TYPE_5_HELP_STR
+ EVPN_TYPE_5_HELP_STR)
{
- return bgp_route_match_add(vty, "evpn vni", argv[3]->arg,
- RMAP_EVENT_MATCH_ADDED);
+ const char *xpath =
+ "./match-condition[condition='frr-bgp-route-map:evpn-route-type']";
+
+ nb_cli_enqueue_change(vty, xpath, NB_OP_DESTROY, NULL);
+
+ return nb_cli_apply_changes(vty, NULL);
}
-DEFUN (no_match_evpn_vni,
- no_match_evpn_vni_cmd,
- "no match evpn vni " CMD_VNI_RANGE,
- NO_STR
- MATCH_STR
- EVPN_HELP_STR
- "Match VNI\n"
- "VNI ID\n")
+
+DEFUN_YANG (match_evpn_vni,
+ match_evpn_vni_cmd,
+ "match evpn vni " CMD_VNI_RANGE,
+ MATCH_STR
+ EVPN_HELP_STR
+ "Match VNI\n"
+ "VNI ID\n")
+{
+ const char *xpath =
+ "./match-condition[condition='frr-bgp-route-map:evpn-vni']";
+ char xpath_value[XPATH_MAXLEN];
+
+ nb_cli_enqueue_change(vty, xpath, NB_OP_CREATE, NULL);
+ snprintf(xpath_value, sizeof(xpath_value),
+ "%s/rmap-match-condition/frr-bgp-route-map:evpn-vni", xpath);
+ nb_cli_enqueue_change(vty, xpath_value, NB_OP_MODIFY, argv[3]->arg);
+
+ return nb_cli_apply_changes(vty, NULL);
+}
+
+DEFUN_YANG (no_match_evpn_vni,
+ no_match_evpn_vni_cmd,
+ "no match evpn vni " CMD_VNI_RANGE,
+ NO_STR
+ MATCH_STR
+ EVPN_HELP_STR
+ "Match VNI\n"
+ "VNI ID\n")
{
- return bgp_route_match_delete(vty, "evpn vni", argv[4]->arg,
- RMAP_EVENT_MATCH_DELETED);
+ const char *xpath =
+ "./match-condition[condition='frr-bgp-route-map:evpn-vni']";
+ char xpath_value[XPATH_MAXLEN];
+
+ nb_cli_enqueue_change(vty, xpath, NB_OP_DESTROY, NULL);
+ snprintf(xpath_value, sizeof(xpath_value),
+ "%s/rmap-match-condition/frr-bgp-route-map:evpn-vni", xpath);
+ nb_cli_enqueue_change(vty, xpath_value, NB_OP_DESTROY, argv[3]->arg);
+
+ return nb_cli_apply_changes(vty, NULL);
}
-DEFUN (match_evpn_default_route,
- match_evpn_default_route_cmd,
- "match evpn default-route",
- MATCH_STR
- EVPN_HELP_STR
- "default EVPN type-5 route\n")
+DEFUN_YANG (match_evpn_default_route,
+ match_evpn_default_route_cmd,
+ "match evpn default-route",
+ MATCH_STR
+ EVPN_HELP_STR
+ "default EVPN type-5 route\n")
{
- return bgp_route_match_add(vty, "evpn default-route", NULL,
- RMAP_EVENT_MATCH_ADDED);
+ const char *xpath =
+ "./match-condition[condition='frr-bgp-route-map:evpn-default-route']";
+ char xpath_value[XPATH_MAXLEN];
+
+ nb_cli_enqueue_change(vty, xpath, NB_OP_CREATE, NULL);
+
+ snprintf(xpath_value, sizeof(xpath_value),
+ "%s/rmap-match-condition/frr-bgp-route-map:evpn-default-route",
+ xpath);
+ nb_cli_enqueue_change(vty, xpath_value, NB_OP_MODIFY, NULL);
+
+ return nb_cli_apply_changes(vty, NULL);
}
-DEFUN (no_match_evpn_default_route,
- no_match_evpn_default_route_cmd,
- "no match evpn default-route",
- NO_STR
- MATCH_STR
- EVPN_HELP_STR
- "default EVPN type-5 route\n")
+DEFUN_YANG (no_match_evpn_default_route,
+ no_match_evpn_default_route_cmd,
+ "no match evpn default-route",
+ NO_STR
+ MATCH_STR
+ EVPN_HELP_STR
+ "default EVPN type-5 route\n")
{
- return bgp_route_match_delete(vty, "evpn default-route", NULL,
- RMAP_EVENT_MATCH_DELETED);
+ const char *xpath =
+ "./match-condition[condition='frr-bgp-route-map:evpn-default-route']";
+
+ nb_cli_enqueue_change(vty, xpath, NB_OP_DESTROY, NULL);
+
+ return nb_cli_apply_changes(vty, NULL);
}
-DEFUN (match_evpn_rd,
- match_evpn_rd_cmd,
- "match evpn rd ASN:NN_OR_IP-ADDRESS:NN",
- MATCH_STR
- EVPN_HELP_STR
- "Route Distinguisher\n"
- "ASN:XX or A.B.C.D:XX\n")
+DEFUN_YANG (match_evpn_rd,
+ match_evpn_rd_cmd,
+ "match evpn rd ASN:NN_OR_IP-ADDRESS:NN",
+ MATCH_STR
+ EVPN_HELP_STR
+ "Route Distinguisher\n"
+ "ASN:XX or A.B.C.D:XX\n")
{
- return bgp_route_match_add(vty, "evpn rd", argv[3]->arg,
- RMAP_EVENT_MATCH_ADDED);
+ const char *xpath =
+ "./match-condition[condition='frr-bgp-route-map:evpn-rd']";
+ char xpath_value[XPATH_MAXLEN];
+
+ nb_cli_enqueue_change(vty, xpath, NB_OP_CREATE, NULL);
+ snprintf(
+ xpath_value, sizeof(xpath_value),
+ "%s/rmap-match-condition/frr-bgp-route-map:route-distinguisher",
+ xpath);
+ nb_cli_enqueue_change(vty, xpath_value, NB_OP_MODIFY, argv[3]->arg);
+
+ return nb_cli_apply_changes(vty, NULL);
}
-DEFUN (no_match_evpn_rd,
- no_match_evpn_rd_cmd,
- "no match evpn rd ASN:NN_OR_IP-ADDRESS:NN",
- NO_STR
- MATCH_STR
- EVPN_HELP_STR
- "Route Distinguisher\n"
- "ASN:XX or A.B.C.D:XX\n")
+DEFUN_YANG (no_match_evpn_rd,
+ no_match_evpn_rd_cmd,
+ "no match evpn rd ASN:NN_OR_IP-ADDRESS:NN",
+ NO_STR
+ MATCH_STR
+ EVPN_HELP_STR
+ "Route Distinguisher\n"
+ "ASN:XX or A.B.C.D:XX\n")
{
- return bgp_route_match_delete(vty, "evpn rd", argv[4]->arg,
- RMAP_EVENT_MATCH_DELETED);
+ const char *xpath =
+ "./match-condition[condition='frr-bgp-route-map:evpn-rd']";
+
+ nb_cli_enqueue_change(vty, xpath, NB_OP_DESTROY, NULL);
+ return nb_cli_apply_changes(vty, NULL);
}
-DEFPY(match_vrl_source_vrf,
+DEFPY_YANG(match_vrl_source_vrf,
match_vrl_source_vrf_cmd,
"match source-vrf NAME$vrf_name",
MATCH_STR
"source vrf\n"
"The VRF name\n")
{
- return bgp_route_match_add(vty, "source-vrf", vrf_name,
- RMAP_EVENT_MATCH_ADDED);
+ const char *xpath =
+ "./match-condition[condition='frr-bgp-route-map:source-vrf']";
+ char xpath_value[XPATH_MAXLEN];
+
+ nb_cli_enqueue_change(vty, xpath, NB_OP_CREATE, NULL);
+ snprintf(xpath_value, sizeof(xpath_value),
+ "%s/rmap-match-condition/frr-bgp-route-map:source-vrf", xpath);
+ nb_cli_enqueue_change(vty, xpath_value, NB_OP_MODIFY, vrf_name);
+
+ return nb_cli_apply_changes(vty, NULL);
}
-DEFPY(no_match_vrl_source_vrf,
+DEFPY_YANG(no_match_vrl_source_vrf,
no_match_vrl_source_vrf_cmd,
"no match source-vrf NAME$vrf_name",
- NO_STR
- MATCH_STR
+ NO_STR MATCH_STR
"source vrf\n"
"The VRF name\n")
{
- return bgp_route_match_delete(vty, "source-vrf", vrf_name,
- RMAP_EVENT_MATCH_DELETED);
+ const char *xpath =
+ "./match-condition[condition='frr-bgp-route-map:source-vrf']";
+
+ nb_cli_enqueue_change(vty, xpath, NB_OP_DESTROY, NULL);
+ return nb_cli_apply_changes(vty, NULL);
}
-DEFUN (match_peer,
+DEFPY_YANG (match_peer,
match_peer_cmd,
- "match peer <A.B.C.D|X:X::X:X|WORD>",
+ "match peer <A.B.C.D$addrv4|X:X::X:X$addrv6|WORD$intf>",
MATCH_STR
"Match peer address\n"
"IP address of peer\n"
"IPv6 address of peer\n"
"Interface name of peer\n")
{
- int idx_ip = 2;
- return bgp_route_match_add(vty, "peer", argv[idx_ip]->arg,
- RMAP_EVENT_MATCH_ADDED);
+ const char *xpath =
+ "./match-condition[condition='frr-bgp-route-map:peer']";
+ char xpath_value[XPATH_MAXLEN];
+
+ nb_cli_enqueue_change(vty, xpath, NB_OP_CREATE, NULL);
+
+ if (addrv4_str) {
+ snprintf(
+ xpath_value, sizeof(xpath_value),
+ "%s/rmap-match-condition/frr-bgp-route-map:peer-ipv4-address",
+ xpath);
+ nb_cli_enqueue_change(vty, xpath_value, NB_OP_MODIFY,
+ addrv4_str);
+ } else if (addrv6_str) {
+ snprintf(
+ xpath_value, sizeof(xpath_value),
+ "%s/rmap-match-condition/frr-bgp-route-map:peer-ipv6-address",
+ xpath);
+ nb_cli_enqueue_change(vty, xpath_value, NB_OP_MODIFY,
+ addrv6_str);
+ } else {
+ snprintf(
+ xpath_value, sizeof(xpath_value),
+ "%s/rmap-match-condition/frr-bgp-route-map:peer-interface",
+ xpath);
+ nb_cli_enqueue_change(vty, xpath_value, NB_OP_MODIFY, intf);
+ }
+
+ return nb_cli_apply_changes(vty, NULL);
}
-DEFUN (match_peer_local,
- match_peer_local_cmd,
- "match peer local",
- MATCH_STR
- "Match peer address\n"
- "Static or Redistributed routes\n")
+DEFUN_YANG (match_peer_local,
+ match_peer_local_cmd,
+ "match peer local",
+ MATCH_STR
+ "Match peer address\n"
+ "Static or Redistributed routes\n")
{
- return bgp_route_match_add(vty, "peer", "local",
- RMAP_EVENT_MATCH_DELETED);
+ const char *xpath =
+ "./match-condition[condition='frr-bgp-route-map:peer']";
+ char xpath_value[XPATH_MAXLEN];
+
+ nb_cli_enqueue_change(vty, xpath, NB_OP_CREATE, NULL);
+
+ snprintf(xpath_value, sizeof(xpath_value),
+ "%s/rmap-match-condition/frr-bgp-route-map:peer-local", xpath);
+ nb_cli_enqueue_change(vty, xpath_value, NB_OP_MODIFY, "true");
+
+ return nb_cli_apply_changes(vty, NULL);
}
-DEFUN (no_match_peer,
- no_match_peer_cmd,
- "no match peer [<local|A.B.C.D|X:X::X:X|WORD>]",
- NO_STR
- MATCH_STR
- "Match peer address\n"
- "Static or Redistributed routes\n"
- "IP address of peer\n"
- "IPv6 address of peer\n"
- "Interface name of peer\n")
+DEFUN_YANG (no_match_peer,
+ no_match_peer_cmd,
+ "no match peer [<local|A.B.C.D|X:X::X:X|WORD>]",
+ NO_STR
+ MATCH_STR
+ "Match peer address\n"
+ "Static or Redistributed routes\n"
+ "IP address of peer\n"
+ "IPv6 address of peer\n"
+ "Interface name of peer\n")
{
- int idx_peer = 3;
+ const char *xpath =
+ "./match-condition[condition='frr-bgp-route-map:peer']";
+
+ nb_cli_enqueue_change(vty, xpath, NB_OP_DESTROY, NULL);
- if (argc <= idx_peer)
- return bgp_route_match_delete(vty, "peer", NULL,
- RMAP_EVENT_MATCH_DELETED);
- return bgp_route_match_delete(vty, "peer", argv[idx_peer]->arg,
- RMAP_EVENT_MATCH_DELETED);
+ return nb_cli_apply_changes(vty, NULL);
}
#ifdef HAVE_SCRIPTING
-DEFUN (match_script,
- match_script_cmd,
- "[no] match script WORD",
- NO_STR
- MATCH_STR
- "Execute script to determine match\n"
- "The script name to run, without .lua; e.g. 'myroutemap' to run myroutemap.lua\n")
+DEFUN_YANG (match_script,
+ match_script_cmd,
+ "[no] match script WORD",
+ NO_STR
+ MATCH_STR
+ "Execute script to determine match\n"
+ "The script name to run, without .lua; e.g. 'myroutemap' to run myroutemap.lua\n")
{
bool no = strmatch(argv[0]->text, "no");
int i = 0;
argv_find(argv, argc, "WORD", &i);
const char *script = argv[i]->arg;
+ const char *xpath =
+ "./match-condition[condition='frr-bgp-route-map:match-script']";
+ char xpath_value[XPATH_MAXLEN];
if (no) {
- return bgp_route_match_delete(vty, "script", script,
- RMAP_EVENT_FILTER_DELETED);
- } else {
- return bgp_route_match_add(vty, "script", script,
- RMAP_EVENT_FILTER_ADDED);
+ nb_cli_enqueue_change(vty, xpath, NB_OP_DESTROY, NULL);
+ snprintf(xpath_value, sizeof(xpath_value),
+ "%s/rmap-match-condition/frr-bgp-route-map:script",
+ xpath);
+ nb_cli_enqueue_change(vty, xpath_value, NB_OP_DESTROY,
+ script);
+
+ return nb_cli_apply_changes(vty, NULL);
}
+
+ nb_cli_enqueue_change(vty, xpath, NB_OP_CREATE, NULL);
+ snprintf(xpath_value, sizeof(xpath_value),
+ "%s/rmap-match-condition/frr-bgp-route-map:script",
+ xpath);
+ nb_cli_enqueue_change(vty, xpath_value, NB_OP_MODIFY,
+ script);
+
+ return nb_cli_apply_changes(vty, NULL);
}
#endif /* HAVE_SCRIPTING */
/* match probability */
-DEFUN (match_probability,
- match_probability_cmd,
- "match probability (0-100)",
- MATCH_STR
- "Match portion of routes defined by percentage value\n"
- "Percentage of routes\n")
+DEFUN_YANG (match_probability,
+ match_probability_cmd,
+ "match probability (0-100)",
+ MATCH_STR
+ "Match portion of routes defined by percentage value\n"
+ "Percentage of routes\n")
{
int idx_number = 2;
- return bgp_route_match_add(vty, "probability", argv[idx_number]->arg,
- RMAP_EVENT_MATCH_ADDED);
+
+ const char *xpath =
+ "./match-condition[condition='frr-bgp-route-map:probability']";
+ char xpath_value[XPATH_MAXLEN];
+
+ nb_cli_enqueue_change(vty, xpath, NB_OP_CREATE, NULL);
+ snprintf(xpath_value, sizeof(xpath_value),
+ "%s/rmap-match-condition/frr-bgp-route-map:probability",
+ xpath);
+ nb_cli_enqueue_change(vty, xpath_value, NB_OP_MODIFY,
+ argv[idx_number]->arg);
+
+ return nb_cli_apply_changes(vty, NULL);
}
-DEFUN (no_match_probability,
- no_match_probability_cmd,
- "no match probability [(1-99)]",
- NO_STR
- MATCH_STR
- "Match portion of routes defined by percentage value\n"
- "Percentage of routes\n")
+DEFUN_YANG (no_match_probability,
+ no_match_probability_cmd,
+ "no match probability [(1-99)]",
+ NO_STR
+ MATCH_STR
+ "Match portion of routes defined by percentage value\n"
+ "Percentage of routes\n")
{
int idx_number = 3;
+ const char *xpath =
+ "./match-condition[condition='frr-bgp-route-map:probability']";
+ char xpath_value[XPATH_MAXLEN];
+
+ nb_cli_enqueue_change(vty, xpath, NB_OP_DESTROY, NULL);
+
if (argc <= idx_number)
- return bgp_route_match_delete(vty, "probability", NULL,
- RMAP_EVENT_MATCH_DELETED);
- return bgp_route_match_delete(vty, "probability", argv[idx_number]->arg,
- RMAP_EVENT_MATCH_DELETED);
+ return nb_cli_apply_changes(vty, NULL);
+
+ snprintf(xpath_value, sizeof(xpath_value),
+ "%s/rmap-match-condition/frr-bgp-route-map:probability",
+ xpath);
+ nb_cli_enqueue_change(vty, xpath_value, NB_OP_DESTROY,
+ argv[idx_number]->arg);
+
+ return nb_cli_apply_changes(vty, NULL);
}
-DEFUN (match_ip_route_source,
+DEFPY_YANG (match_ip_route_source,
match_ip_route_source_cmd,
"match ip route-source <(1-199)|(1300-2699)|WORD>",
MATCH_STR
@@ -4207,102 +4280,134 @@ DEFUN (match_ip_route_source,
"IP access-list number (expanded range)\n"
"IP standard access-list name\n")
{
+ const char *xpath =
+ "./match-condition[condition='frr-bgp-route-map:ip-route-source']";
+ char xpath_value[XPATH_MAXLEN + 32];
int idx_acl = 3;
- return bgp_route_match_add(vty, "ip route-source", argv[idx_acl]->arg,
- RMAP_EVENT_FILTER_ADDED);
+
+ nb_cli_enqueue_change(vty, xpath, NB_OP_CREATE, NULL);
+ snprintf(xpath_value, sizeof(xpath_value),
+ "%s/rmap-match-condition/frr-bgp-route-map:list-name",
+ xpath);
+ nb_cli_enqueue_change(vty, xpath_value, NB_OP_MODIFY,
+ argv[idx_acl]->arg);
+
+ return nb_cli_apply_changes(vty, NULL);
}
-DEFUN (no_match_ip_route_source,
- no_match_ip_route_source_cmd,
- "no match ip route-source [<(1-199)|(1300-2699)|WORD>]",
- NO_STR
- MATCH_STR
- IP_STR
- "Match advertising source address of route\n"
- "IP access-list number\n"
- "IP access-list number (expanded range)\n"
- "IP standard access-list name\n")
+DEFUN_YANG (no_match_ip_route_source,
+ no_match_ip_route_source_cmd,
+ "no match ip route-source [<(1-199)|(1300-2699)|WORD>]",
+ NO_STR
+ MATCH_STR
+ IP_STR
+ "Match advertising source address of route\n"
+ "IP access-list number\n"
+ "IP access-list number (expanded range)\n"
+ "IP standard access-list name\n")
{
- int idx_number = 4;
- if (argc <= idx_number)
- return bgp_route_match_delete(vty, "ip route-source", NULL,
- RMAP_EVENT_FILTER_DELETED);
- return bgp_route_match_delete(vty, "ip route-source",
- argv[idx_number]->arg,
- RMAP_EVENT_FILTER_DELETED);
-}
+ const char *xpath =
+ "./match-condition[condition='frr-bgp-route-map:ip-route-source']";
+ nb_cli_enqueue_change(vty, xpath, NB_OP_DESTROY, NULL);
+ return nb_cli_apply_changes(vty, NULL);
+}
-DEFUN (match_ip_route_source_prefix_list,
- match_ip_route_source_prefix_list_cmd,
- "match ip route-source prefix-list WORD",
- MATCH_STR
- IP_STR
- "Match advertising source address of route\n"
- "Match entries of prefix-lists\n"
- "IP prefix-list name\n")
+DEFUN_YANG (match_ip_route_source_prefix_list,
+ match_ip_route_source_prefix_list_cmd,
+ "match ip route-source prefix-list WORD",
+ MATCH_STR
+ IP_STR
+ "Match advertising source address of route\n"
+ "Match entries of prefix-lists\n"
+ "IP prefix-list name\n")
{
int idx_word = 4;
- return bgp_route_match_add(vty, "ip route-source prefix-list",
- argv[idx_word]->arg, RMAP_EVENT_PLIST_ADDED);
+ const char *xpath =
+ "./match-condition[condition='frr-bgp-route-map:ip-route-source-prefix-list']";
+ char xpath_value[XPATH_MAXLEN + 32];
+
+ nb_cli_enqueue_change(vty, xpath, NB_OP_CREATE, NULL);
+ snprintf(xpath_value, sizeof(xpath_value),
+ "%s/rmap-match-condition/frr-bgp-route-map:list-name", xpath);
+ nb_cli_enqueue_change(vty, xpath_value, NB_OP_MODIFY,
+ argv[idx_word]->arg);
+
+ return nb_cli_apply_changes(vty, NULL);
}
-DEFUN (no_match_ip_route_source_prefix_list,
- no_match_ip_route_source_prefix_list_cmd,
- "no match ip route-source prefix-list [WORD]",
- NO_STR
- MATCH_STR
- IP_STR
- "Match advertising source address of route\n"
- "Match entries of prefix-lists\n"
- "IP prefix-list name\n")
+DEFUN_YANG (no_match_ip_route_source_prefix_list,
+ no_match_ip_route_source_prefix_list_cmd,
+ "no match ip route-source prefix-list [WORD]",
+ NO_STR
+ MATCH_STR
+ IP_STR
+ "Match advertising source address of route\n"
+ "Match entries of prefix-lists\n"
+ "IP prefix-list name\n")
{
- int idx_word = 5;
- if (argc <= idx_word)
- return bgp_route_match_delete(vty,
- "ip route-source prefix-list",
- NULL, RMAP_EVENT_PLIST_DELETED);
- return bgp_route_match_delete(vty, "ip route-source prefix-list",
- argv[idx_word]->arg,
- RMAP_EVENT_PLIST_DELETED);
-}
+ const char *xpath =
+ "./match-condition[condition='frr-bgp-route-map:ip-route-source-prefix-list']";
+ nb_cli_enqueue_change(vty, xpath, NB_OP_DESTROY, NULL);
+ return nb_cli_apply_changes(vty, NULL);
+}
-DEFUN (match_local_pref,
- match_local_pref_cmd,
- "match local-preference (0-4294967295)",
- MATCH_STR
- "Match local-preference of route\n"
- "Metric value\n")
+DEFUN_YANG (match_local_pref,
+ match_local_pref_cmd,
+ "match local-preference (0-4294967295)",
+ MATCH_STR
+ "Match local-preference of route\n"
+ "Metric value\n")
{
int idx_number = 2;
- return bgp_route_match_add(vty, "local-preference",
- argv[idx_number]->arg,
- RMAP_EVENT_MATCH_ADDED);
+
+ const char *xpath =
+ "./match-condition[condition='frr-bgp-route-map:match-local-preference']";
+ char xpath_value[XPATH_MAXLEN];
+
+ nb_cli_enqueue_change(vty, xpath, NB_OP_CREATE, NULL);
+ snprintf(xpath_value, sizeof(xpath_value),
+ "%s/rmap-match-condition/frr-bgp-route-map:local-preference",
+ xpath);
+ nb_cli_enqueue_change(vty, xpath_value, NB_OP_MODIFY,
+ argv[idx_number]->arg);
+
+ return nb_cli_apply_changes(vty, NULL);
}
-DEFUN (no_match_local_pref,
- no_match_local_pref_cmd,
- "no match local-preference [(0-4294967295)]",
- NO_STR
- MATCH_STR
- "Match local preference of route\n"
- "Local preference value\n")
+DEFUN_YANG (no_match_local_pref,
+ no_match_local_pref_cmd,
+ "no match local-preference [(0-4294967295)]",
+ NO_STR
+ MATCH_STR
+ "Match local preference of route\n"
+ "Local preference value\n")
{
int idx_localpref = 3;
+ const char *xpath =
+ "./match-condition[condition='frr-bgp-route-map:match-local-preference']";
+ char xpath_value[XPATH_MAXLEN];
+
+ nb_cli_enqueue_change(vty, xpath, NB_OP_DESTROY, NULL);
+
if (argc <= idx_localpref)
- return bgp_route_match_delete(vty, "local-preference", NULL,
- RMAP_EVENT_MATCH_DELETED);
- return bgp_route_match_delete(vty, "local-preference",
- argv[idx_localpref]->arg,
- RMAP_EVENT_MATCH_DELETED);
+ return nb_cli_apply_changes(vty, NULL);
+
+ snprintf(xpath_value, sizeof(xpath_value),
+ "%s/rmap-match-condition/frr-bgp-route-map:local-preference",
+ xpath);
+ nb_cli_enqueue_change(vty, xpath_value, NB_OP_DESTROY,
+ argv[idx_localpref]->arg);
+
+ return nb_cli_apply_changes(vty, NULL);
}
-DEFUN (match_community,
+DEFPY_YANG (match_community,
match_community_cmd,
"match community <(1-99)|(100-500)|WORD> [exact-match]",
MATCH_STR
@@ -4312,478 +4417,608 @@ DEFUN (match_community,
"Community-list name\n"
"Do exact matching of communities\n")
{
+ const char *xpath =
+ "./match-condition[condition='frr-bgp-route-map:match-community']";
+ char xpath_value[XPATH_MAXLEN];
+ char xpath_match[XPATH_MAXLEN];
int idx_comm_list = 2;
- int ret;
- char *argstr;
- size_t argstr_len;
- if (argc == 4) {
- argstr_len = strlen(argv[idx_comm_list]->arg)
- + strlen("exact-match") + 2;
- argstr = XMALLOC(MTYPE_ROUTE_MAP_COMPILED, argstr_len);
+ nb_cli_enqueue_change(vty, xpath, NB_OP_CREATE, NULL);
- snprintf(argstr, argstr_len, "%s exact-match",
- argv[idx_comm_list]->arg);
- } else
- argstr = argv[idx_comm_list]->arg;
-
- ret = bgp_route_match_add(vty, "community", argstr,
- RMAP_EVENT_CLIST_ADDED);
+ snprintf(
+ xpath_value, sizeof(xpath_value),
+ "%s/rmap-match-condition/frr-bgp-route-map:comm-list/comm-list-name",
+ xpath);
+ nb_cli_enqueue_change(vty, xpath_value, NB_OP_MODIFY, argv[idx_comm_list]->arg);
- if (argstr != argv[idx_comm_list]->arg)
- XFREE(MTYPE_ROUTE_MAP_COMPILED, argstr);
-
- return ret;
-}
-
-DEFUN (no_match_community,
- no_match_community_cmd,
- "no match community [<(1-99)|(100-500)|WORD> [exact-match]]",
- NO_STR
- MATCH_STR
- "Match BGP community list\n"
- "Community-list number (standard)\n"
- "Community-list number (expanded)\n"
- "Community-list name\n"
- "Do exact matching of communities\n")
-{
- return bgp_route_match_delete(vty, "community", NULL,
- RMAP_EVENT_CLIST_DELETED);
-}
+ if (argc == 4) {
+ snprintf(
+ xpath_match, sizeof(xpath_match),
+ "%s/rmap-match-condition/frr-bgp-route-map:comm-list/comm-list-name-exact-match",
+ xpath);
+ nb_cli_enqueue_change(vty, xpath_match, NB_OP_MODIFY,
+ "true");
+ } else {
+ snprintf(
+ xpath_match, sizeof(xpath_match),
+ "%s/rmap-match-condition/frr-bgp-route-map:comm-list/comm-list-name-exact-match",
+ xpath);
+ nb_cli_enqueue_change(vty, xpath_match, NB_OP_MODIFY,
+ "false");
+ }
-DEFUN (match_lcommunity,
- match_lcommunity_cmd,
- "match large-community <(1-99)|(100-500)|WORD> [exact-match]",
- MATCH_STR
- "Match BGP large community list\n"
- "Large Community-list number (standard)\n"
- "Large Community-list number (expanded)\n"
- "Large Community-list name\n"
- "Do exact matching of communities\n")
-{
+ return nb_cli_apply_changes(vty, NULL);
+}
+
+DEFUN_YANG (no_match_community,
+ no_match_community_cmd,
+ "no match community [<(1-99)|(100-500)|WORD> [exact-match]]",
+ NO_STR
+ MATCH_STR
+ "Match BGP community list\n"
+ "Community-list number (standard)\n"
+ "Community-list number (expanded)\n"
+ "Community-list name\n"
+ "Do exact matching of communities\n")
+{
+ const char *xpath =
+ "./match-condition[condition='frr-bgp-route-map:match-community']";
+
+ nb_cli_enqueue_change(vty, xpath, NB_OP_DESTROY, NULL);
+ return nb_cli_apply_changes(vty, NULL);
+}
+
+DEFPY_YANG (match_lcommunity,
+ match_lcommunity_cmd,
+ "match large-community <(1-99)|(100-500)|WORD> [exact-match]",
+ MATCH_STR
+ "Match BGP large community list\n"
+ "Large Community-list number (standard)\n"
+ "Large Community-list number (expanded)\n"
+ "Large Community-list name\n"
+ "Do exact matching of communities\n")
+{
+ const char *xpath =
+ "./match-condition[condition='frr-bgp-route-map:match-large-community']";
+ char xpath_value[XPATH_MAXLEN];
+ char xpath_match[XPATH_MAXLEN];
int idx_lcomm_list = 2;
- int ret;
- char *argstr;
- size_t argstr_len;
- if (argc == 4) {
- argstr_len = strlen(argv[idx_lcomm_list]->arg)
- + strlen("exact-match") + 2;
- argstr = XMALLOC(MTYPE_ROUTE_MAP_COMPILED, argstr_len);
+ nb_cli_enqueue_change(vty, xpath, NB_OP_CREATE, NULL);
- snprintf(argstr, argstr_len, "%s exact-match",
- argv[idx_lcomm_list]->arg);
- } else
- argstr = argv[idx_lcomm_list]->arg;
+ snprintf(
+ xpath_value, sizeof(xpath_value),
+ "%s/rmap-match-condition/frr-bgp-route-map:comm-list/comm-list-name",
+ xpath);
+ nb_cli_enqueue_change(vty, xpath_value, NB_OP_MODIFY, argv[idx_lcomm_list]->arg);
- ret = bgp_route_match_add(vty, "large-community", argstr,
- RMAP_EVENT_LLIST_ADDED);
- if (argstr != argv[idx_lcomm_list]->arg)
- XFREE(MTYPE_ROUTE_MAP_COMPILED, argstr);
+ if (argc == 4) {
+ snprintf(
+ xpath_match, sizeof(xpath_match),
+ "%s/rmap-match-condition/frr-bgp-route-map:comm-list/comm-list-name-exact-match",
+ xpath);
+ nb_cli_enqueue_change(vty, xpath_match, NB_OP_MODIFY,
+ "true");
+ } else {
+ snprintf(
+ xpath_match, sizeof(xpath_match),
+ "%s/rmap-match-condition/frr-bgp-route-map:comm-list/comm-list-name-exact-match",
+ xpath);
+ nb_cli_enqueue_change(vty, xpath_match, NB_OP_MODIFY,
+ "false");
+ }
- return ret;
+ return nb_cli_apply_changes(vty, NULL);
}
-DEFUN (no_match_lcommunity,
- no_match_lcommunity_cmd,
- "no match large-community [<(1-99)|(100-500)|WORD> [exact-match]]",
- NO_STR
- MATCH_STR
- "Match BGP large community list\n"
- "Large Community-list number (standard)\n"
- "Large Community-list number (expanded)\n"
- "Large Community-list name\n"
- "Do exact matching of communities\n")
+DEFUN_YANG (no_match_lcommunity,
+ no_match_lcommunity_cmd,
+ "no match large-community [<(1-99)|(100-500)|WORD> [exact-match]]",
+ NO_STR
+ MATCH_STR
+ "Match BGP large community list\n"
+ "Large Community-list number (standard)\n"
+ "Large Community-list number (expanded)\n"
+ "Large Community-list name\n"
+ "Do exact matching of communities\n")
{
- return bgp_route_match_delete(vty, "large-community", NULL,
- RMAP_EVENT_LLIST_DELETED);
+ const char *xpath =
+ "./match-condition[condition='frr-bgp-route-map:match-large-community']";
+
+ nb_cli_enqueue_change(vty, xpath, NB_OP_DESTROY, NULL);
+ return nb_cli_apply_changes(vty, NULL);
}
-DEFUN (match_ecommunity,
- match_ecommunity_cmd,
- "match extcommunity <(1-99)|(100-500)|WORD>",
- MATCH_STR
- "Match BGP/VPN extended community list\n"
- "Extended community-list number (standard)\n"
- "Extended community-list number (expanded)\n"
- "Extended community-list name\n")
+DEFPY_YANG (match_ecommunity,
+ match_ecommunity_cmd,
+ "match extcommunity <(1-99)|(100-500)|WORD>",
+ MATCH_STR
+ "Match BGP/VPN extended community list\n"
+ "Extended community-list number (standard)\n"
+ "Extended community-list number (expanded)\n"
+ "Extended community-list name\n")
{
+ const char *xpath =
+ "./match-condition[condition='frr-bgp-route-map:match-extcommunity']";
+ char xpath_value[XPATH_MAXLEN];
int idx_comm_list = 2;
- return bgp_route_match_add(vty, "extcommunity",
- argv[idx_comm_list]->arg,
- RMAP_EVENT_ECLIST_ADDED);
+
+ nb_cli_enqueue_change(vty, xpath, NB_OP_CREATE, NULL);
+
+ snprintf(
+ xpath_value, sizeof(xpath_value),
+ "%s/rmap-match-condition/frr-bgp-route-map:comm-list/comm-list-name",
+ xpath);
+ nb_cli_enqueue_change(vty, xpath_value, NB_OP_MODIFY, argv[idx_comm_list]->arg);
+
+ return nb_cli_apply_changes(vty, NULL);
}
-DEFUN (no_match_ecommunity,
- no_match_ecommunity_cmd,
- "no match extcommunity [<(1-99)|(100-500)|WORD>]",
- NO_STR
- MATCH_STR
- "Match BGP/VPN extended community list\n"
- "Extended community-list number (standard)\n"
- "Extended community-list number (expanded)\n"
- "Extended community-list name\n")
+DEFUN_YANG (no_match_ecommunity,
+ no_match_ecommunity_cmd,
+ "no match extcommunity [<(1-99)|(100-500)|WORD>]",
+ NO_STR
+ MATCH_STR
+ "Match BGP/VPN extended community list\n"
+ "Extended community-list number (standard)\n"
+ "Extended community-list number (expanded)\n"
+ "Extended community-list name\n")
{
- return bgp_route_match_delete(vty, "extcommunity", NULL,
- RMAP_EVENT_ECLIST_DELETED);
+ const char *xpath =
+ "./match-condition[condition='frr-bgp-route-map:match-extcommunity']";
+
+ nb_cli_enqueue_change(vty, xpath, NB_OP_DESTROY, NULL);
+ return nb_cli_apply_changes(vty, NULL);
}
-DEFUN (match_aspath,
- match_aspath_cmd,
- "match as-path WORD",
- MATCH_STR
- "Match BGP AS path list\n"
- "AS path access-list name\n")
+DEFUN_YANG (match_aspath,
+ match_aspath_cmd,
+ "match as-path WORD",
+ MATCH_STR
+ "Match BGP AS path list\n"
+ "AS path access-list name\n")
{
int idx_word = 2;
- return bgp_route_match_add(vty, "as-path", argv[idx_word]->arg,
- RMAP_EVENT_ASLIST_ADDED);
+
+ const char *xpath =
+ "./match-condition[condition='frr-bgp-route-map:as-path-list']";
+ char xpath_value[XPATH_MAXLEN];
+
+ nb_cli_enqueue_change(vty, xpath, NB_OP_CREATE, NULL);
+ snprintf(xpath_value, sizeof(xpath_value),
+ "%s/rmap-match-condition/frr-bgp-route-map:list-name", xpath);
+ nb_cli_enqueue_change(vty, xpath_value, NB_OP_MODIFY,
+ argv[idx_word]->arg);
+
+ return nb_cli_apply_changes(vty, NULL);
}
-DEFUN (no_match_aspath,
- no_match_aspath_cmd,
- "no match as-path [WORD]",
- NO_STR
- MATCH_STR
- "Match BGP AS path list\n"
- "AS path access-list name\n")
+DEFUN_YANG (no_match_aspath,
+ no_match_aspath_cmd,
+ "no match as-path [WORD]",
+ NO_STR
+ MATCH_STR
+ "Match BGP AS path list\n"
+ "AS path access-list name\n")
{
- return bgp_route_match_delete(vty, "as-path", NULL,
- RMAP_EVENT_ASLIST_DELETED);
-}
+ const char *xpath =
+ "./match-condition[condition='frr-bgp-route-map:as-path-list']";
+ nb_cli_enqueue_change(vty, xpath, NB_OP_DESTROY, NULL);
-DEFUN (match_origin,
- match_origin_cmd,
- "match origin <egp|igp|incomplete>",
- MATCH_STR
- "BGP origin code\n"
- "remote EGP\n"
- "local IGP\n"
- "unknown heritage\n")
+ return nb_cli_apply_changes(vty, NULL);
+}
+
+DEFUN_YANG (match_origin,
+ match_origin_cmd,
+ "match origin <egp|igp|incomplete>",
+ MATCH_STR
+ "BGP origin code\n"
+ "remote EGP\n"
+ "local IGP\n"
+ "unknown heritage\n")
{
int idx_origin = 2;
+ const char *origin_type;
+ const char *xpath =
+ "./match-condition[condition='frr-bgp-route-map:match-origin']";
+ char xpath_value[XPATH_MAXLEN];
+
if (strncmp(argv[idx_origin]->arg, "igp", 2) == 0)
- return bgp_route_match_add(vty, "origin", "igp",
- RMAP_EVENT_MATCH_ADDED);
- if (strncmp(argv[idx_origin]->arg, "egp", 1) == 0)
- return bgp_route_match_add(vty, "origin", "egp",
- RMAP_EVENT_MATCH_ADDED);
- if (strncmp(argv[idx_origin]->arg, "incomplete", 2) == 0)
- return bgp_route_match_add(vty, "origin", "incomplete",
- RMAP_EVENT_MATCH_ADDED);
+ origin_type = "igp";
+ else if (strncmp(argv[idx_origin]->arg, "egp", 1) == 0)
+ origin_type = "egp";
+ else if (strncmp(argv[idx_origin]->arg, "incomplete", 2) == 0)
+ origin_type = "incomplete";
+ else {
+ vty_out(vty, "%% Invalid match origin type\n");
+ return CMD_WARNING_CONFIG_FAILED;
+ }
+
+ nb_cli_enqueue_change(vty, xpath, NB_OP_CREATE, NULL);
+ snprintf(xpath_value, sizeof(xpath_value),
+ "%s/rmap-match-condition/frr-bgp-route-map:origin", xpath);
+ nb_cli_enqueue_change(vty, xpath_value, NB_OP_MODIFY, origin_type);
- vty_out(vty, "%% Invalid match origin type\n");
- return CMD_WARNING_CONFIG_FAILED;
+ return nb_cli_apply_changes(vty, NULL);
}
-DEFUN (no_match_origin,
- no_match_origin_cmd,
- "no match origin [<egp|igp|incomplete>]",
- NO_STR
- MATCH_STR
- "BGP origin code\n"
- "remote EGP\n"
- "local IGP\n"
- "unknown heritage\n")
+DEFUN_YANG (no_match_origin,
+ no_match_origin_cmd,
+ "no match origin [<egp|igp|incomplete>]",
+ NO_STR
+ MATCH_STR
+ "BGP origin code\n"
+ "remote EGP\n"
+ "local IGP\n"
+ "unknown heritage\n")
{
- return bgp_route_match_delete(vty, "origin", NULL,
- RMAP_EVENT_MATCH_DELETED);
+ const char *xpath =
+ "./match-condition[condition='frr-bgp-route-map:match-origin']";
+ nb_cli_enqueue_change(vty, xpath, NB_OP_DESTROY, NULL);
+ return nb_cli_apply_changes(vty, NULL);
}
-DEFUN (set_table_id,
- set_table_id_cmd,
- "set table (1-4294967295)",
- SET_STR
- "export route to non-main kernel table\n"
- "Kernel routing table id\n")
+DEFUN_YANG (set_table_id,
+ set_table_id_cmd,
+ "set table (1-4294967295)",
+ SET_STR
+ "export route to non-main kernel table\n"
+ "Kernel routing table id\n")
{
- int idx_id = 2;
-
- VTY_DECLVAR_CONTEXT(route_map_index, index);
-
- return generic_set_add(vty, index, "table", argv[idx_id]->arg);
+ int idx_number = 2;
+ const char *xpath = "./set-action[action='frr-bgp-route-map:table']";
+ char xpath_value[XPATH_MAXLEN];
+
+ nb_cli_enqueue_change(vty, xpath, NB_OP_CREATE, NULL);
+ snprintf(xpath_value, sizeof(xpath_value),
+ "%s/rmap-set-action/frr-bgp-route-map:table", xpath);
+ nb_cli_enqueue_change(vty, xpath_value, NB_OP_MODIFY,
+ argv[idx_number]->arg);
+ return nb_cli_apply_changes(vty, NULL);
+}
+
+DEFUN_YANG (no_set_table_id,
+ no_set_table_id_cmd,
+ "no set table",
+ NO_STR
+ SET_STR
+ "export route to non-main kernel table\n")
+{
+ const char *xpath = "./set-action[action='frr-bgp-route-map:table']";
+ nb_cli_enqueue_change(vty, xpath, NB_OP_DESTROY, NULL);
+ return nb_cli_apply_changes(vty, NULL);
+}
+
+DEFUN_YANG (set_ip_nexthop_peer,
+ set_ip_nexthop_peer_cmd,
+ "[no] set ip next-hop peer-address",
+ NO_STR
+ SET_STR
+ IP_STR
+ "Next hop address\n"
+ "Use peer address (for BGP only)\n")
+{
+ char xpath_value[XPATH_MAXLEN];
+ const char *xpath =
+ "./set-action[action='frr-bgp-route-map:set-ipv4-nexthop']";
+
+ if (strmatch(argv[0]->text, "no"))
+ nb_cli_enqueue_change(vty, xpath, NB_OP_DESTROY, NULL);
+ else {
+ nb_cli_enqueue_change(vty, xpath, NB_OP_CREATE, NULL);
+ snprintf(xpath_value, sizeof(xpath_value),
+ "%s/rmap-set-action/frr-bgp-route-map:ipv4-nexthop",
+ xpath);
+ nb_cli_enqueue_change(vty, xpath_value, NB_OP_MODIFY,
+ "peer-address");
+ }
+ return nb_cli_apply_changes(vty, NULL);
}
-DEFUN (no_set_table_id,
- no_set_table_id_cmd,
- "no set table",
- NO_STR
- SET_STR
- "export route to non-main kernel table\n")
+DEFUN_YANG (set_ip_nexthop_unchanged,
+ set_ip_nexthop_unchanged_cmd,
+ "[no] set ip next-hop unchanged",
+ NO_STR
+ SET_STR
+ IP_STR
+ "Next hop address\n"
+ "Don't modify existing Next hop address\n")
{
- VTY_DECLVAR_CONTEXT(route_map_index, index);
+ char xpath_value[XPATH_MAXLEN];
+ const char *xpath =
+ "./set-action[action='frr-bgp-route-map:set-ipv4-nexthop']";
- return generic_set_delete(vty, index, "table", NULL);
+ if (strmatch(argv[0]->text, "no"))
+ nb_cli_enqueue_change(vty, xpath, NB_OP_DESTROY, NULL);
+ else {
+ nb_cli_enqueue_change(vty, xpath, NB_OP_CREATE, NULL);
+ snprintf(xpath_value, sizeof(xpath_value),
+ "%s/rmap-set-action/frr-bgp-route-map:ipv4-nexthop",
+ xpath);
+ nb_cli_enqueue_change(vty, xpath_value, NB_OP_MODIFY,
+ "unchanged");
+ }
+ return nb_cli_apply_changes(vty, NULL);
}
-DEFUN (set_ip_nexthop_peer,
- set_ip_nexthop_peer_cmd,
- "[no] set ip next-hop peer-address",
- NO_STR
- SET_STR
- IP_STR
- "Next hop address\n"
- "Use peer address (for BGP only)\n")
+DEFUN_YANG (set_distance,
+ set_distance_cmd,
+ "set distance (0-255)",
+ SET_STR
+ "BGP Administrative Distance to use\n"
+ "Distance value\n")
{
- int (*func)(struct vty *, struct route_map_index *, const char *,
- const char *) = strmatch(argv[0]->text, "no")
- ? generic_set_delete
- : generic_set_add;
+ int idx_number = 2;
+ const char *xpath = "./set-action[action='frr-bgp-route-map:distance']";
+ char xpath_value[XPATH_MAXLEN];
- return func(vty, VTY_GET_CONTEXT(route_map_index), "ip next-hop",
- "peer-address");
+ nb_cli_enqueue_change(vty, xpath, NB_OP_CREATE, NULL);
+ snprintf(xpath_value, sizeof(xpath_value),
+ "%s/rmap-set-action/frr-bgp-route-map:distance", xpath);
+ nb_cli_enqueue_change(vty, xpath_value, NB_OP_MODIFY,
+ argv[idx_number]->arg);
+ return nb_cli_apply_changes(vty, NULL);
}
-DEFUN (set_ip_nexthop_unchanged,
- set_ip_nexthop_unchanged_cmd,
- "[no] set ip next-hop unchanged",
- NO_STR
- SET_STR
- IP_STR
- "Next hop address\n"
- "Don't modify existing Next hop address\n")
+DEFUN_YANG (no_set_distance,
+ no_set_distance_cmd,
+ "no set distance [(0-255)]",
+ NO_STR SET_STR
+ "BGP Administrative Distance to use\n"
+ "Distance value\n")
{
- int (*func)(struct vty *, struct route_map_index *, const char *,
- const char *) = strmatch(argv[0]->text, "no")
- ? generic_set_delete
- : generic_set_add;
+ const char *xpath = "./set-action[action='frr-bgp-route-map:distance']";
- return func(vty, VTY_GET_CONTEXT(route_map_index), "ip next-hop",
- "unchanged");
+ nb_cli_enqueue_change(vty, xpath, NB_OP_DESTROY, NULL);
+ return nb_cli_apply_changes(vty, NULL);
}
-DEFUN (set_distance,
- set_distance_cmd,
- "set distance (0-255)",
- SET_STR
- "BGP Administrative Distance to use\n"
- "Distance value\n")
+DEFUN_YANG (set_local_pref,
+ set_local_pref_cmd,
+ "set local-preference WORD",
+ SET_STR
+ "BGP local preference path attribute\n"
+ "Preference value (0-4294967295)\n")
{
int idx_number = 2;
+ const char *xpath =
+ "./set-action[action='frr-bgp-route-map:set-local-preference']";
+ char xpath_value[XPATH_MAXLEN];
- return generic_set_add(vty, VTY_GET_CONTEXT(route_map_index),
- "distance", argv[idx_number]->arg);
+ nb_cli_enqueue_change(vty, xpath, NB_OP_CREATE, NULL);
+ snprintf(xpath_value, sizeof(xpath_value),
+ "%s/rmap-set-action/frr-bgp-route-map:local-pref", xpath);
+ nb_cli_enqueue_change(vty, xpath_value, NB_OP_MODIFY,
+ argv[idx_number]->arg);
+ return nb_cli_apply_changes(vty, NULL);
}
-DEFUN (no_set_distance,
- no_set_distance_cmd,
- "no set distance [(0-255)]",
- NO_STR SET_STR
- "BGP Administrative Distance to use\n"
- "Distance value\n")
+DEFUN_YANG (no_set_local_pref,
+ no_set_local_pref_cmd,
+ "no set local-preference [WORD]",
+ NO_STR
+ SET_STR
+ "BGP local preference path attribute\n"
+ "Preference value (0-4294967295)\n")
{
- return generic_set_delete(vty, VTY_GET_CONTEXT(route_map_index),
- "distance", NULL);
+ const char *xpath =
+ "./set-action[action='frr-bgp-route-map:set-local-preference']";
+
+ nb_cli_enqueue_change(vty, xpath, NB_OP_DESTROY, NULL);
+ return nb_cli_apply_changes(vty, NULL);
}
-DEFUN (set_local_pref,
- set_local_pref_cmd,
- "set local-preference WORD",
- SET_STR
- "BGP local preference path attribute\n"
- "Preference value (0-4294967295)\n")
+DEFUN_YANG (set_weight,
+ set_weight_cmd,
+ "set weight (0-4294967295)",
+ SET_STR
+ "BGP weight for routing table\n"
+ "Weight value\n")
{
int idx_number = 2;
- return generic_set_add(vty, VTY_GET_CONTEXT(route_map_index),
- "local-preference", argv[idx_number]->arg);
-}
-
+ const char *xpath = "./set-action[action='frr-bgp-route-map:weight']";
+ char xpath_value[XPATH_MAXLEN];
-DEFUN (no_set_local_pref,
- no_set_local_pref_cmd,
- "no set local-preference [WORD]",
- NO_STR
- SET_STR
- "BGP local preference path attribute\n"
- "Preference value (0-4294967295)\n")
-{
- int idx_localpref = 3;
- if (argc <= idx_localpref)
- return generic_set_delete(vty, VTY_GET_CONTEXT(route_map_index),
- "local-preference", NULL);
- return generic_set_delete(vty, VTY_GET_CONTEXT(route_map_index),
- "local-preference", argv[idx_localpref]->arg);
+ nb_cli_enqueue_change(vty, xpath, NB_OP_CREATE, NULL);
+ snprintf(xpath_value, sizeof(xpath_value),
+ "%s/rmap-set-action/frr-bgp-route-map:weight", xpath);
+ nb_cli_enqueue_change(vty, xpath_value, NB_OP_MODIFY,
+ argv[idx_number]->arg);
+ return nb_cli_apply_changes(vty, NULL);
}
-
-DEFUN (set_weight,
- set_weight_cmd,
- "set weight (0-4294967295)",
- SET_STR
- "BGP weight for routing table\n"
- "Weight value\n")
+DEFUN_YANG (no_set_weight,
+ no_set_weight_cmd,
+ "no set weight [(0-4294967295)]",
+ NO_STR
+ SET_STR
+ "BGP weight for routing table\n"
+ "Weight value\n")
{
- int idx_number = 2;
- return generic_set_add(vty, VTY_GET_CONTEXT(route_map_index), "weight",
- argv[idx_number]->arg);
-}
+ const char *xpath = "./set-action[action='frr-bgp-route-map:weight']";
-
-DEFUN (no_set_weight,
- no_set_weight_cmd,
- "no set weight [(0-4294967295)]",
- NO_STR
- SET_STR
- "BGP weight for routing table\n"
- "Weight value\n")
-{
- int idx_weight = 3;
- if (argc <= idx_weight)
- return generic_set_delete(vty, VTY_GET_CONTEXT(route_map_index),
- "weight", NULL);
- return generic_set_delete(vty, VTY_GET_CONTEXT(route_map_index),
- "weight", argv[idx_weight]->arg);
+ nb_cli_enqueue_change(vty, xpath, NB_OP_DESTROY, NULL);
+ return nb_cli_apply_changes(vty, NULL);
}
-DEFUN (set_label_index,
- set_label_index_cmd,
- "set label-index (0-1048560)",
- SET_STR
- "Label index to associate with the prefix\n"
- "Label index value\n")
+DEFUN_YANG (set_label_index,
+ set_label_index_cmd,
+ "set label-index (0-1048560)",
+ SET_STR
+ "Label index to associate with the prefix\n"
+ "Label index value\n")
{
int idx_number = 2;
- return generic_set_add(vty, VTY_GET_CONTEXT(route_map_index),
- "label-index", argv[idx_number]->arg);
+ const char *xpath =
+ "./set-action[action='frr-bgp-route-map:label-index']";
+ char xpath_value[XPATH_MAXLEN];
+
+ nb_cli_enqueue_change(vty, xpath, NB_OP_CREATE, NULL);
+ snprintf(xpath_value, sizeof(xpath_value),
+ "%s/rmap-set-action/frr-bgp-route-map:label-index", xpath);
+ nb_cli_enqueue_change(vty, xpath_value, NB_OP_MODIFY,
+ argv[idx_number]->arg);
+ return nb_cli_apply_changes(vty, NULL);
}
-DEFUN (no_set_label_index,
- no_set_label_index_cmd,
- "no set label-index [(0-1048560)]",
- NO_STR
- SET_STR
- "Label index to associate with the prefix\n"
- "Label index value\n")
+DEFUN_YANG (no_set_label_index,
+ no_set_label_index_cmd,
+ "no set label-index [(0-1048560)]",
+ NO_STR
+ SET_STR
+ "Label index to associate with the prefix\n"
+ "Label index value\n")
{
- int idx_label_index = 3;
- if (argc <= idx_label_index)
- return generic_set_delete(vty, VTY_GET_CONTEXT(route_map_index),
- "label-index", NULL);
- return generic_set_delete(vty, VTY_GET_CONTEXT(route_map_index),
- "label-index", argv[idx_label_index]->arg);
+ const char *xpath =
+ "./set-action[action='frr-bgp-route-map:label-index']";
+
+ nb_cli_enqueue_change(vty, xpath, NB_OP_DESTROY, NULL);
+ return nb_cli_apply_changes(vty, NULL);
}
-DEFUN (set_aspath_prepend_asn,
- set_aspath_prepend_asn_cmd,
- "set as-path prepend (1-4294967295)...",
- SET_STR
- "Transform BGP AS_PATH attribute\n"
- "Prepend to the as-path\n"
- "AS number\n")
+DEFUN_YANG (set_aspath_prepend_asn,
+ set_aspath_prepend_asn_cmd,
+ "set as-path prepend (1-4294967295)...",
+ SET_STR
+ "Transform BGP AS_PATH attribute\n"
+ "Prepend to the as-path\n"
+ "AS number\n")
{
int idx_asn = 3;
int ret;
char *str;
str = argv_concat(argv, argc, idx_asn);
- ret = generic_set_add(vty, VTY_GET_CONTEXT(route_map_index),
- "as-path prepend", str);
- XFREE(MTYPE_TMP, str);
+ const char *xpath =
+ "./set-action[action='frr-bgp-route-map:as-path-prepend']";
+ char xpath_value[XPATH_MAXLEN];
+
+ nb_cli_enqueue_change(vty, xpath, NB_OP_CREATE, NULL);
+ snprintf(xpath_value, sizeof(xpath_value),
+ "%s/rmap-set-action/frr-bgp-route-map:prepend-as-path", xpath);
+ nb_cli_enqueue_change(vty, xpath_value, NB_OP_MODIFY, str);
+ ret = nb_cli_apply_changes(vty, NULL);
+ XFREE(MTYPE_TMP, str);
return ret;
}
-DEFUN (set_aspath_prepend_lastas,
- set_aspath_prepend_lastas_cmd,
- "set as-path prepend last-as (1-10)",
- SET_STR
- "Transform BGP AS_PATH attribute\n"
- "Prepend to the as-path\n"
- "Use the peer's AS-number\n"
- "Number of times to insert\n")
+DEFUN_YANG (set_aspath_prepend_lastas,
+ set_aspath_prepend_lastas_cmd,
+ "set as-path prepend last-as (1-10)",
+ SET_STR
+ "Transform BGP AS_PATH attribute\n"
+ "Prepend to the as-path\n"
+ "Use the peer's AS-number\n"
+ "Number of times to insert\n")
{
- return set_aspath_prepend_asn(self, vty, argc, argv);
+ int idx_num = 4;
+
+ const char *xpath =
+ "./set-action[action='frr-bgp-route-map:as-path-prepend']";
+ char xpath_value[XPATH_MAXLEN];
+
+ nb_cli_enqueue_change(vty, xpath, NB_OP_CREATE, NULL);
+ snprintf(xpath_value, sizeof(xpath_value),
+ "%s/rmap-set-action/frr-bgp-route-map:last-as", xpath);
+ nb_cli_enqueue_change(vty, xpath_value, NB_OP_MODIFY,
+ argv[idx_num]->arg);
+ return nb_cli_apply_changes(vty, NULL);
}
-DEFUN (no_set_aspath_prepend,
- no_set_aspath_prepend_cmd,
- "no set as-path prepend [(1-4294967295)]",
- NO_STR
- SET_STR
- "Transform BGP AS_PATH attribute\n"
- "Prepend to the as-path\n"
- "AS number\n")
+DEFUN_YANG (no_set_aspath_prepend,
+ no_set_aspath_prepend_cmd,
+ "no set as-path prepend [(1-4294967295)]",
+ NO_STR
+ SET_STR
+ "Transform BGP AS_PATH attribute\n"
+ "Prepend to the as-path\n"
+ "AS number\n")
{
- int idx_asn = 4;
- int ret;
- char *str;
+ const char *xpath =
+ "./set-action[action='frr-bgp-route-map:as-path-prepend']";
- str = argv_concat(argv, argc, idx_asn);
- ret = generic_set_delete(vty, VTY_GET_CONTEXT(route_map_index),
- "as-path prepend", str);
- XFREE(MTYPE_TMP, str);
- return ret;
+ nb_cli_enqueue_change(vty, xpath, NB_OP_DESTROY, NULL);
+ return nb_cli_apply_changes(vty, NULL);
}
-DEFUN (no_set_aspath_prepend_lastas,
- no_set_aspath_prepend_lastas_cmd,
- "no set as-path prepend last-as [(1-10)]",
- NO_STR
- SET_STR
- "Transform BGP AS_PATH attribute\n"
- "Prepend to the as-path\n"
- "Use the peers AS-number\n"
- "Number of times to insert\n")
+DEFUN_YANG (no_set_aspath_prepend_lastas,
+ no_set_aspath_prepend_lastas_cmd,
+ "no set as-path prepend last-as [(1-10)]",
+ NO_STR
+ SET_STR
+ "Transform BGP AS_PATH attribute\n"
+ "Prepend to the as-path\n"
+ "Use the peers AS-number\n"
+ "Number of times to insert\n")
{
- return no_set_aspath_prepend(self, vty, argc, argv);
+ const char *xpath =
+ "./set-action[action='frr-bgp-route-map:as-path-prepend']";
+
+ nb_cli_enqueue_change(vty, xpath, NB_OP_DESTROY, NULL);
+ return nb_cli_apply_changes(vty, NULL);
}
-DEFUN (set_aspath_exclude,
- set_aspath_exclude_cmd,
- "set as-path exclude (1-4294967295)...",
- SET_STR
- "Transform BGP AS-path attribute\n"
- "Exclude from the as-path\n"
- "AS number\n")
+DEFUN_YANG (set_aspath_exclude,
+ set_aspath_exclude_cmd,
+ "set as-path exclude (1-4294967295)...",
+ SET_STR
+ "Transform BGP AS-path attribute\n"
+ "Exclude from the as-path\n"
+ "AS number\n")
{
int idx_asn = 3;
int ret;
char *str;
str = argv_concat(argv, argc, idx_asn);
- ret = generic_set_add(vty, VTY_GET_CONTEXT(route_map_index),
- "as-path exclude", str);
+
+ const char *xpath =
+ "./set-action[action='frr-bgp-route-map:as-path-exclude']";
+ char xpath_value[XPATH_MAXLEN];
+
+ nb_cli_enqueue_change(vty, xpath, NB_OP_CREATE, NULL);
+ snprintf(xpath_value, sizeof(xpath_value),
+ "%s/rmap-set-action/frr-bgp-route-map:exclude-as-path", xpath);
+ nb_cli_enqueue_change(vty, xpath_value, NB_OP_MODIFY, str);
+ ret = nb_cli_apply_changes(vty, NULL);
XFREE(MTYPE_TMP, str);
return ret;
}
-DEFUN (no_set_aspath_exclude,
- no_set_aspath_exclude_cmd,
- "no set as-path exclude (1-4294967295)...",
- NO_STR
- SET_STR
- "Transform BGP AS_PATH attribute\n"
- "Exclude from the as-path\n"
- "AS number\n")
+DEFUN_YANG (no_set_aspath_exclude,
+ no_set_aspath_exclude_cmd,
+ "no set as-path exclude (1-4294967295)...",
+ NO_STR
+ SET_STR
+ "Transform BGP AS_PATH attribute\n"
+ "Exclude from the as-path\n"
+ "AS number\n")
{
- int idx_asn = 4;
- int ret;
- char *str;
+ const char *xpath =
+ "./set-action[action='frr-bgp-route-map:as-path-exclude']";
- str = argv_concat(argv, argc, idx_asn);
- ret = generic_set_delete(vty, VTY_GET_CONTEXT(route_map_index),
- "as-path exclude", str);
- XFREE(MTYPE_TMP, str);
- return ret;
+ nb_cli_enqueue_change(vty, xpath, NB_OP_DESTROY, NULL);
+ return nb_cli_apply_changes(vty, NULL);
}
-ALIAS(no_set_aspath_exclude, no_set_aspath_exclude_all_cmd,
- "no set as-path exclude",
- NO_STR SET_STR
- "Transform BGP AS_PATH attribute\n"
- "Exclude from the as-path\n")
+ALIAS_YANG (no_set_aspath_exclude, no_set_aspath_exclude_all_cmd,
+ "no set as-path exclude",
+ NO_STR SET_STR
+ "Transform BGP AS_PATH attribute\n"
+ "Exclude from the as-path\n")
-DEFUN (set_community,
- set_community_cmd,
- "set community AA:NN...",
- SET_STR
- "BGP community attribute\n"
- COMMUNITY_VAL_STR)
+DEFUN_YANG (set_community,
+ set_community_cmd,
+ "set community AA:NN...",
+ SET_STR
+ "BGP community attribute\n"
+ COMMUNITY_VAL_STR)
{
int idx_aa_nn = 2;
int i;
@@ -4792,9 +5027,18 @@ DEFUN (set_community,
struct buffer *b;
struct community *com = NULL;
char *str;
- char *argstr;
+ char *argstr = NULL;
int ret;
+ const char *xpath =
+ "./set-action[action='frr-bgp-route-map:set-community']";
+ char xpath_value[XPATH_MAXLEN];
+
+ nb_cli_enqueue_change(vty, xpath, NB_OP_CREATE, NULL);
+ snprintf(xpath_value, sizeof(xpath_value),
+ "%s/rmap-set-action/frr-bgp-route-map:community-string",
+ xpath);
+
b = buffer_new(1024);
for (i = idx_aa_nn; i < argc; i++) {
@@ -4870,50 +5114,61 @@ DEFUN (set_community,
argstr = XCALLOC(MTYPE_TMP, argstr_sz);
strlcpy(argstr, str, argstr_sz);
strlcat(argstr, " additive", argstr_sz);
- ret = generic_set_add(vty, VTY_GET_CONTEXT(route_map_index),
- "community", argstr);
- XFREE(MTYPE_TMP, argstr);
+ nb_cli_enqueue_change(vty, xpath_value, NB_OP_MODIFY, argstr);
} else
- ret = generic_set_add(vty, VTY_GET_CONTEXT(route_map_index),
- "community", str);
+ nb_cli_enqueue_change(vty, xpath_value, NB_OP_MODIFY, str);
+
+ ret = nb_cli_apply_changes(vty, NULL);
+ if (argstr)
+ XFREE(MTYPE_TMP, argstr);
community_free(&com);
return ret;
}
-DEFUN (set_community_none,
- set_community_none_cmd,
- "set community none",
- SET_STR
- "BGP community attribute\n"
- "No community attribute\n")
+DEFUN_YANG (set_community_none,
+ set_community_none_cmd,
+ "set community none",
+ SET_STR
+ "BGP community attribute\n"
+ "No community attribute\n")
{
- return generic_set_add(vty, VTY_GET_CONTEXT(route_map_index),
- "community", "none");
+ const char *xpath =
+ "./set-action[action='frr-bgp-route-map:set-community']";
+ char xpath_value[XPATH_MAXLEN];
+
+ nb_cli_enqueue_change(vty, xpath, NB_OP_CREATE, NULL);
+
+ snprintf(xpath_value, sizeof(xpath_value),
+ "%s/rmap-set-action/frr-bgp-route-map:community-none", xpath);
+ nb_cli_enqueue_change(vty, xpath_value, NB_OP_MODIFY, "true");
+ return nb_cli_apply_changes(vty, NULL);
}
-DEFUN (no_set_community,
- no_set_community_cmd,
- "no set community AA:NN...",
- NO_STR
- SET_STR
- "BGP community attribute\n"
- COMMUNITY_VAL_STR)
+DEFUN_YANG (no_set_community,
+ no_set_community_cmd,
+ "no set community AA:NN...",
+ NO_STR
+ SET_STR
+ "BGP community attribute\n"
+ COMMUNITY_VAL_STR)
{
- return generic_set_delete(vty, VTY_GET_CONTEXT(route_map_index),
- "community", NULL);
-}
+ const char *xpath =
+ "./set-action[action='frr-bgp-route-map:set-community']";
-ALIAS (no_set_community,
- no_set_community_short_cmd,
- "no set community",
- NO_STR
- SET_STR
- "BGP community attribute\n")
+ nb_cli_enqueue_change(vty, xpath, NB_OP_DESTROY, NULL);
+ return nb_cli_apply_changes(vty, NULL);
+}
+ALIAS_YANG (no_set_community,
+ no_set_community_short_cmd,
+ "no set community",
+ NO_STR
+ SET_STR
+ "BGP community attribute\n")
-DEFUN (set_community_delete,
+DEFPY_YANG (set_community_delete,
set_community_delete_cmd,
"set comm-list <(1-99)|(100-500)|WORD> delete",
SET_STR
@@ -4923,93 +5178,124 @@ DEFUN (set_community_delete,
"Community-list name\n"
"Delete matching communities\n")
{
+ const char *xpath =
+ "./set-action[action='frr-bgp-route-map:comm-list-delete']";
+ char xpath_value[XPATH_MAXLEN];
int idx_comm_list = 2;
- char *args;
- args = argv_concat(argv, argc, idx_comm_list);
- generic_set_add(vty, VTY_GET_CONTEXT(route_map_index), "comm-list",
- args);
- XFREE(MTYPE_TMP, args);
+ nb_cli_enqueue_change(vty, xpath, NB_OP_CREATE, NULL);
+
+ snprintf(xpath_value, sizeof(xpath_value),
+ "%s/rmap-set-action/frr-bgp-route-map:comm-list-name",
+ xpath);
+ nb_cli_enqueue_change(vty, xpath_value, NB_OP_MODIFY,
+ argv[idx_comm_list]->arg);
+
+ return nb_cli_apply_changes(vty, NULL);
- return CMD_SUCCESS;
}
-DEFUN (no_set_community_delete,
- no_set_community_delete_cmd,
- "no set comm-list [<(1-99)|(100-500)|WORD> delete]",
- NO_STR
- SET_STR
- "set BGP community list (for deletion)\n"
- "Community-list number (standard)\n"
- "Community-list number (expanded)\n"
- "Community-list name\n"
- "Delete matching communities\n")
+DEFUN_YANG (no_set_community_delete,
+ no_set_community_delete_cmd,
+ "no set comm-list [<(1-99)|(100-500)|WORD> delete]",
+ NO_STR
+ SET_STR
+ "set BGP community list (for deletion)\n"
+ "Community-list number (standard)\n"
+ "Community-list number (expanded)\n"
+ "Community-list name\n"
+ "Delete matching communities\n")
{
- return generic_set_delete(vty, VTY_GET_CONTEXT(route_map_index),
- "comm-list", NULL);
+ const char *xpath =
+ "./set-action[action='frr-bgp-route-map:comm-list-delete']";
+
+ nb_cli_enqueue_change(vty, xpath, NB_OP_DESTROY, NULL);
+ return nb_cli_apply_changes(vty, NULL);
}
-DEFUN (set_lcommunity,
- set_lcommunity_cmd,
- "set large-community AA:BB:CC...",
- SET_STR
- "BGP large community attribute\n"
- "Large Community number in aa:bb:cc format or additive\n")
+DEFUN_YANG (set_lcommunity,
+ set_lcommunity_cmd,
+ "set large-community AA:BB:CC...",
+ SET_STR
+ "BGP large community attribute\n"
+ "Large Community number in aa:bb:cc format or additive\n")
{
- int ret;
char *str;
+ int ret;
+ const char *xpath =
+ "./set-action[action='frr-bgp-route-map:set-large-community']";
+ char xpath_value[XPATH_MAXLEN];
+
+ nb_cli_enqueue_change(vty, xpath, NB_OP_CREATE, NULL);
+ snprintf(xpath_value, sizeof(xpath_value),
+ "%s/rmap-set-action/frr-bgp-route-map:large-community-string",
+ xpath);
str = argv_concat(argv, argc, 2);
- ret = generic_set_add(vty, VTY_GET_CONTEXT(route_map_index),
- "large-community", str);
+ nb_cli_enqueue_change(vty, xpath_value, NB_OP_MODIFY, str);
+ ret = nb_cli_apply_changes(vty, NULL);
XFREE(MTYPE_TMP, str);
-
return ret;
}
-DEFUN (set_lcommunity_none,
- set_lcommunity_none_cmd,
- "set large-community none",
- SET_STR
- "BGP large community attribute\n"
- "No large community attribute\n")
+DEFUN_YANG (set_lcommunity_none,
+ set_lcommunity_none_cmd,
+ "set large-community none",
+ SET_STR
+ "BGP large community attribute\n"
+ "No large community attribute\n")
{
- return generic_set_add(vty, VTY_GET_CONTEXT(route_map_index),
- "large-community", "none");
+ const char *xpath =
+ "./set-action[action='frr-bgp-route-map:set-large-community']";
+ char xpath_value[XPATH_MAXLEN];
+
+ nb_cli_enqueue_change(vty, xpath, NB_OP_CREATE, NULL);
+
+ snprintf(xpath_value, sizeof(xpath_value),
+ "%s/rmap-set-action/frr-bgp-route-map:large-community-none",
+ xpath);
+ nb_cli_enqueue_change(vty, xpath_value, NB_OP_MODIFY, "true");
+ return nb_cli_apply_changes(vty, NULL);
}
-DEFUN (no_set_lcommunity,
- no_set_lcommunity_cmd,
- "no set large-community none",
- NO_STR
- SET_STR
- "BGP large community attribute\n"
- "No community attribute\n")
+DEFUN_YANG (no_set_lcommunity,
+ no_set_lcommunity_cmd,
+ "no set large-community none",
+ NO_STR
+ SET_STR
+ "BGP large community attribute\n"
+ "No community attribute\n")
{
- return generic_set_delete(vty, VTY_GET_CONTEXT(route_map_index),
- "large-community", NULL);
+ const char *xpath =
+ "./set-action[action='frr-bgp-route-map:set-large-community']";
+
+ nb_cli_enqueue_change(vty, xpath, NB_OP_DESTROY, NULL);
+ return nb_cli_apply_changes(vty, NULL);
}
-DEFUN (no_set_lcommunity1,
- no_set_lcommunity1_cmd,
- "no set large-community AA:BB:CC...",
- NO_STR
- SET_STR
- "BGP large community attribute\n"
- "Large community in AA:BB:CC... format or additive\n")
+DEFUN_YANG (no_set_lcommunity1,
+ no_set_lcommunity1_cmd,
+ "no set large-community AA:BB:CC...",
+ NO_STR
+ SET_STR
+ "BGP large community attribute\n"
+ "Large community in AA:BB:CC... format or additive\n")
{
- return generic_set_delete(vty, VTY_GET_CONTEXT(route_map_index),
- "large-community", NULL);
+ const char *xpath =
+ "./set-action[action='frr-bgp-route-map:set-large-community']";
+
+ nb_cli_enqueue_change(vty, xpath, NB_OP_DESTROY, NULL);
+ return nb_cli_apply_changes(vty, NULL);
}
-ALIAS (no_set_lcommunity1,
- no_set_lcommunity1_short_cmd,
- "no set large-community",
- NO_STR
- SET_STR
- "BGP large community attribute\n")
+ALIAS_YANG (no_set_lcommunity1,
+ no_set_lcommunity1_short_cmd,
+ "no set large-community",
+ NO_STR
+ SET_STR
+ "BGP large community attribute\n")
-DEFUN (set_lcommunity_delete,
+DEFPY_YANG (set_lcommunity_delete,
set_lcommunity_delete_cmd,
"set large-comm-list <(1-99)|(100-500)|WORD> delete",
SET_STR
@@ -5019,336 +5305,401 @@ DEFUN (set_lcommunity_delete,
"Large Community-list name\n"
"Delete matching large communities\n")
{
+ const char *xpath =
+ "./set-action[action='frr-bgp-route-map:large-comm-list-delete']";
+ char xpath_value[XPATH_MAXLEN];
int idx_lcomm_list = 2;
- char *args;
- args = argv_concat(argv, argc, idx_lcomm_list);
- generic_set_add(vty, VTY_GET_CONTEXT(route_map_index),
- "large-comm-list", args);
- XFREE(MTYPE_TMP, args);
+ nb_cli_enqueue_change(vty, xpath, NB_OP_CREATE, NULL);
- return CMD_SUCCESS;
+ snprintf(xpath_value, sizeof(xpath_value),
+ "%s/rmap-set-action/frr-bgp-route-map:comm-list-name",
+ xpath);
+ nb_cli_enqueue_change(vty, xpath_value, NB_OP_MODIFY,
+ argv[idx_lcomm_list]->arg);
+
+ return nb_cli_apply_changes(vty, NULL);
}
-DEFUN (no_set_lcommunity_delete,
- no_set_lcommunity_delete_cmd,
- "no set large-comm-list <(1-99)|(100-500)|WORD> [delete]",
- NO_STR
- SET_STR
- "set BGP large community list (for deletion)\n"
- "Large Community-list number (standard)\n"
- "Large Communitly-list number (expanded)\n"
- "Large Community-list name\n"
- "Delete matching large communities\n")
+DEFUN_YANG (no_set_lcommunity_delete,
+ no_set_lcommunity_delete_cmd,
+ "no set large-comm-list <(1-99)|(100-500)|WORD> [delete]",
+ NO_STR
+ SET_STR
+ "set BGP large community list (for deletion)\n"
+ "Large Community-list number (standard)\n"
+ "Large Communitly-list number (expanded)\n"
+ "Large Community-list name\n"
+ "Delete matching large communities\n")
{
- return generic_set_delete(vty, VTY_GET_CONTEXT(route_map_index),
- "large-comm-list", NULL);
+ const char *xpath =
+ "./set-action[action='frr-bgp-route-map:large-comm-list-delete']";
+
+ nb_cli_enqueue_change(vty, xpath, NB_OP_DESTROY, NULL);
+ return nb_cli_apply_changes(vty, NULL);
}
-ALIAS (no_set_lcommunity_delete,
- no_set_lcommunity_delete_short_cmd,
- "no set large-comm-list",
- NO_STR
- SET_STR
- "set BGP large community list (for deletion)\n")
+ALIAS_YANG (no_set_lcommunity_delete,
+ no_set_lcommunity_delete_short_cmd,
+ "no set large-comm-list",
+ NO_STR
+ SET_STR
+ "set BGP large community list (for deletion)\n")
-DEFUN (set_ecommunity_rt,
- set_ecommunity_rt_cmd,
- "set extcommunity rt ASN:NN_OR_IP-ADDRESS:NN...",
- SET_STR
- "BGP extended community attribute\n"
- "Route Target extended community\n"
- "VPN extended community\n")
+DEFUN_YANG (set_ecommunity_rt,
+ set_ecommunity_rt_cmd,
+ "set extcommunity rt ASN:NN_OR_IP-ADDRESS:NN...",
+ SET_STR
+ "BGP extended community attribute\n"
+ "Route Target extended community\n"
+ "VPN extended community\n")
{
int idx_asn_nn = 3;
- int ret;
char *str;
+ int ret;
+ const char *xpath =
+ "./set-action[action='frr-bgp-route-map:set-extcommunity-rt']";
+ char xpath_value[XPATH_MAXLEN];
+
+ nb_cli_enqueue_change(vty, xpath, NB_OP_CREATE, NULL);
+ snprintf(xpath_value, sizeof(xpath_value),
+ "%s/rmap-set-action/frr-bgp-route-map:extcommunity-rt", xpath);
str = argv_concat(argv, argc, idx_asn_nn);
- ret = generic_set_add(vty, VTY_GET_CONTEXT(route_map_index),
- "extcommunity rt", str);
+ nb_cli_enqueue_change(vty, xpath_value, NB_OP_MODIFY, str);
+ ret = nb_cli_apply_changes(vty, NULL);
XFREE(MTYPE_TMP, str);
-
return ret;
}
-DEFUN (no_set_ecommunity_rt,
- no_set_ecommunity_rt_cmd,
- "no set extcommunity rt ASN:NN_OR_IP-ADDRESS:NN...",
- NO_STR
- SET_STR
- "BGP extended community attribute\n"
- "Route Target extended community\n"
- "VPN extended community\n")
-{
- return generic_set_delete(vty, VTY_GET_CONTEXT(route_map_index),
- "extcommunity rt", NULL);
-}
-
-ALIAS (no_set_ecommunity_rt,
- no_set_ecommunity_rt_short_cmd,
- "no set extcommunity rt",
- NO_STR
- SET_STR
- "BGP extended community attribute\n"
- "Route Target extended community\n")
-
-DEFUN (set_ecommunity_soo,
- set_ecommunity_soo_cmd,
- "set extcommunity soo ASN:NN_OR_IP-ADDRESS:NN...",
- SET_STR
- "BGP extended community attribute\n"
- "Site-of-Origin extended community\n"
- "VPN extended community\n")
+DEFUN_YANG (no_set_ecommunity_rt,
+ no_set_ecommunity_rt_cmd,
+ "no set extcommunity rt ASN:NN_OR_IP-ADDRESS:NN...",
+ NO_STR
+ SET_STR
+ "BGP extended community attribute\n"
+ "Route Target extended community\n"
+ "VPN extended community\n")
+{
+ const char *xpath =
+ "./set-action[action='frr-bgp-route-map:set-extcommunity-rt']";
+ nb_cli_enqueue_change(vty, xpath, NB_OP_DESTROY, NULL);
+ return nb_cli_apply_changes(vty, NULL);
+}
+
+ALIAS_YANG (no_set_ecommunity_rt,
+ no_set_ecommunity_rt_short_cmd,
+ "no set extcommunity rt",
+ NO_STR
+ SET_STR
+ "BGP extended community attribute\n"
+ "Route Target extended community\n")
+
+DEFUN_YANG (set_ecommunity_soo,
+ set_ecommunity_soo_cmd,
+ "set extcommunity soo ASN:NN_OR_IP-ADDRESS:NN...",
+ SET_STR
+ "BGP extended community attribute\n"
+ "Site-of-Origin extended community\n"
+ "VPN extended community\n")
{
int idx_asn_nn = 3;
- int ret;
char *str;
+ int ret;
+ const char *xpath =
+ "./set-action[action='frr-bgp-route-map:set-extcommunity-soo']";
+ char xpath_value[XPATH_MAXLEN];
+ nb_cli_enqueue_change(vty, xpath, NB_OP_CREATE, NULL);
+
+ snprintf(xpath_value, sizeof(xpath_value),
+ "%s/rmap-set-action/frr-bgp-route-map:extcommunity-soo",
+ xpath);
str = argv_concat(argv, argc, idx_asn_nn);
- ret = generic_set_add(vty, VTY_GET_CONTEXT(route_map_index),
- "extcommunity soo", str);
+ nb_cli_enqueue_change(vty, xpath_value, NB_OP_MODIFY, str);
+ ret = nb_cli_apply_changes(vty, NULL);
XFREE(MTYPE_TMP, str);
return ret;
}
-
-DEFUN (no_set_ecommunity_soo,
- no_set_ecommunity_soo_cmd,
- "no set extcommunity soo ASN:NN_OR_IP-ADDRESS:NN...",
- NO_STR
- SET_STR
- "BGP extended community attribute\n"
- "Site-of-Origin extended community\n"
- "VPN extended community\n")
+DEFUN_YANG (no_set_ecommunity_soo,
+ no_set_ecommunity_soo_cmd,
+ "no set extcommunity soo ASN:NN_OR_IP-ADDRESS:NN...",
+ NO_STR
+ SET_STR
+ "BGP extended community attribute\n"
+ "Site-of-Origin extended community\n"
+ "VPN extended community\n")
+{
+ const char *xpath =
+ "./set-action[action='frr-bgp-route-map:set-extcommunity-soo']";
+ nb_cli_enqueue_change(vty, xpath, NB_OP_DESTROY, NULL);
+ return nb_cli_apply_changes(vty, NULL);
+}
+
+ALIAS_YANG (no_set_ecommunity_soo,
+ no_set_ecommunity_soo_short_cmd,
+ "no set extcommunity soo",
+ NO_STR
+ SET_STR
+ "GP extended community attribute\n"
+ "Site-of-Origin extended community\n")
+
+DEFUN_YANG (set_ecommunity_lb,
+ set_ecommunity_lb_cmd,
+ "set extcommunity bandwidth <(1-25600)|cumulative|num-multipaths> [non-transitive]",
+ SET_STR
+ "BGP extended community attribute\n"
+ "Link bandwidth extended community\n"
+ "Bandwidth value in Mbps\n"
+ "Cumulative bandwidth of all multipaths (outbound-only)\n"
+ "Internally computed bandwidth based on number of multipaths (outbound-only)\n"
+ "Attribute is set as non-transitive\n")
{
- return generic_set_delete(vty, VTY_GET_CONTEXT(route_map_index),
- "extcommunity soo", NULL);
-}
-
-ALIAS (no_set_ecommunity_soo,
- no_set_ecommunity_soo_short_cmd,
- "no set extcommunity soo",
- NO_STR
- SET_STR
- "GP extended community attribute\n"
- "Site-of-Origin extended community\n")
+ int idx_lb = 3;
+ int idx_non_transitive = 4;
+ const char *xpath =
+ "./set-action[action='frr-bgp-route-map:set-extcommunity-lb']";
+ char xpath_lb_type[XPATH_MAXLEN];
+ char xpath_bandwidth[XPATH_MAXLEN];
+ char xpath_non_transitive[XPATH_MAXLEN];
+
+ nb_cli_enqueue_change(vty, xpath, NB_OP_CREATE, NULL);
+
+ snprintf(xpath_lb_type, sizeof(xpath_lb_type),
+ "%s/rmap-set-action/frr-bgp-route-map:extcommunity-lb/lb-type",
+ xpath);
+ snprintf(xpath_bandwidth, sizeof(xpath_bandwidth),
+ "%s/rmap-set-action/frr-bgp-route-map:extcommunity-lb/bandwidth",
+ xpath);
+ snprintf(xpath_non_transitive, sizeof(xpath_non_transitive),
+ "%s/rmap-set-action/frr-bgp-route-map:extcommunity-lb/two-octet-as-specific",
+ xpath);
+
+ if ((strcmp(argv[idx_lb]->arg, "cumulative")) == 0)
+ nb_cli_enqueue_change(vty, xpath_lb_type, NB_OP_MODIFY,
+ "cumulative-bandwidth");
+ else if ((strcmp(argv[idx_lb]->arg, "num-multipaths")) == 0)
+ nb_cli_enqueue_change(vty, xpath_lb_type, NB_OP_MODIFY,
+ "computed-bandwidth");
+ else {
+ nb_cli_enqueue_change(vty, xpath_lb_type, NB_OP_MODIFY,
+ "explicit-bandwidth");
+ nb_cli_enqueue_change(vty, xpath_bandwidth, NB_OP_MODIFY,
+ argv[idx_lb]->arg);
+ }
-DEFUN (set_ecommunity_lb,
- set_ecommunity_lb_cmd,
- "set extcommunity bandwidth <(1-25600)|cumulative|num-multipaths> [non-transitive]",
- SET_STR
- "BGP extended community attribute\n"
- "Link bandwidth extended community\n"
- "Bandwidth value in Mbps\n"
- "Cumulative bandwidth of all multipaths (outbound-only)\n"
- "Internally computed bandwidth based on number of multipaths (outbound-only)\n"
- "Attribute is set as non-transitive\n")
+ if (argv[idx_non_transitive])
+ nb_cli_enqueue_change(vty, xpath_non_transitive, NB_OP_MODIFY,
+ "true");
+ else
+ nb_cli_enqueue_change(vty, xpath_non_transitive, NB_OP_MODIFY,
+ "false");
+
+ return nb_cli_apply_changes(vty, NULL);
+}
+
+DEFUN_YANG (no_set_ecommunity_lb,
+ no_set_ecommunity_lb_cmd,
+ "no set extcommunity bandwidth <(1-25600)|cumulative|num-multipaths> [non-transitive]",
+ NO_STR
+ SET_STR
+ "BGP extended community attribute\n"
+ "Link bandwidth extended community\n"
+ "Bandwidth value in Mbps\n"
+ "Cumulative bandwidth of all multipaths (outbound-only)\n"
+ "Internally computed bandwidth based on number of multipaths (outbound-only)\n"
+ "Attribute is set as non-transitive\n")
+{
+ const char *xpath =
+ "./set-action[action='frr-bgp-route-map:set-extcommunity-lb']";
+
+ nb_cli_enqueue_change(vty, xpath, NB_OP_DESTROY, NULL);
+ return nb_cli_apply_changes(vty, NULL);
+}
+
+ALIAS_YANG (no_set_ecommunity_lb,
+ no_set_ecommunity_lb_short_cmd,
+ "no set extcommunity bandwidth",
+ NO_STR
+ SET_STR
+ "BGP extended community attribute\n"
+ "Link bandwidth extended community\n")
+
+DEFUN_YANG (set_origin,
+ set_origin_cmd,
+ "set origin <egp|igp|incomplete>",
+ SET_STR
+ "BGP origin code\n"
+ "remote EGP\n"
+ "local IGP\n"
+ "unknown heritage\n")
{
- int idx_lb = 3;
- int ret;
- char *str;
+ int idx_origin = 2;
+ const char *origin_type;
+ const char *xpath =
+ "./set-action[action='frr-bgp-route-map:set-origin']";
+ char xpath_value[XPATH_MAXLEN];
- str = argv_concat(argv, argc, idx_lb);
- ret = generic_set_add(vty, VTY_GET_CONTEXT(route_map_index),
- "extcommunity bandwidth", str);
- XFREE(MTYPE_TMP, str);
- return ret;
-}
+ if (strncmp(argv[idx_origin]->arg, "igp", 2) == 0)
+ origin_type = "igp";
+ else if (strncmp(argv[idx_origin]->arg, "egp", 1) == 0)
+ origin_type = "egp";
+ else if (strncmp(argv[idx_origin]->arg, "incomplete", 2) == 0)
+ origin_type = "incomplete";
+ else {
+ vty_out(vty, "%% Invalid match origin type\n");
+ return CMD_WARNING_CONFIG_FAILED;
+ }
+ nb_cli_enqueue_change(vty, xpath, NB_OP_CREATE, NULL);
+ snprintf(xpath_value, sizeof(xpath_value),
+ "%s/rmap-set-action/frr-bgp-route-map:origin", xpath);
+ nb_cli_enqueue_change(vty, xpath_value, NB_OP_MODIFY, origin_type);
-DEFUN (no_set_ecommunity_lb,
- no_set_ecommunity_lb_cmd,
- "no set extcommunity bandwidth <(1-25600)|cumulative|num-multipaths> [non-transitive]",
- NO_STR
- SET_STR
- "BGP extended community attribute\n"
- "Link bandwidth extended community\n"
- "Bandwidth value in Mbps\n"
- "Cumulative bandwidth of all multipaths (outbound-only)\n"
- "Internally computed bandwidth based on number of multipaths (outbound-only)\n"
- "Attribute is set as non-transitive\n")
-{
- return generic_set_delete(vty, VTY_GET_CONTEXT(route_map_index),
- "extcommunity bandwidth", NULL);
+ return nb_cli_apply_changes(vty, NULL);
}
-ALIAS (no_set_ecommunity_lb,
- no_set_ecommunity_lb_short_cmd,
- "no set extcommunity bandwidth",
- NO_STR
- SET_STR
- "BGP extended community attribute\n"
- "Link bandwidth extended community\n")
-
-DEFUN (set_origin,
- set_origin_cmd,
- "set origin <egp|igp|incomplete>",
- SET_STR
- "BGP origin code\n"
- "remote EGP\n"
- "local IGP\n"
- "unknown heritage\n")
+DEFUN_YANG (no_set_origin,
+ no_set_origin_cmd,
+ "no set origin [<egp|igp|incomplete>]",
+ NO_STR
+ SET_STR
+ "BGP origin code\n"
+ "remote EGP\n"
+ "local IGP\n"
+ "unknown heritage\n")
{
- int idx_origin = 2;
- if (strncmp(argv[idx_origin]->arg, "igp", 2) == 0)
- return generic_set_add(vty, VTY_GET_CONTEXT(route_map_index),
- "origin", "igp");
- if (strncmp(argv[idx_origin]->arg, "egp", 1) == 0)
- return generic_set_add(vty, VTY_GET_CONTEXT(route_map_index),
- "origin", "egp");
- if (strncmp(argv[idx_origin]->arg, "incomplete", 2) == 0)
- return generic_set_add(vty, VTY_GET_CONTEXT(route_map_index),
- "origin", "incomplete");
+ const char *xpath =
+ "./set-action[action='frr-bgp-route-map:set-origin']";
- vty_out(vty, "%% Invalid set origin type\n");
- return CMD_WARNING_CONFIG_FAILED;
+ nb_cli_enqueue_change(vty, xpath, NB_OP_DESTROY, NULL);
+ return nb_cli_apply_changes(vty, NULL);
}
-
-DEFUN (no_set_origin,
- no_set_origin_cmd,
- "no set origin [<egp|igp|incomplete>]",
- NO_STR
- SET_STR
- "BGP origin code\n"
- "remote EGP\n"
- "local IGP\n"
- "unknown heritage\n")
+DEFUN_YANG (set_atomic_aggregate,
+ set_atomic_aggregate_cmd,
+ "set atomic-aggregate",
+ SET_STR
+ "BGP atomic aggregate attribute\n" )
{
- return generic_set_delete(vty, VTY_GET_CONTEXT(route_map_index),
- "origin", NULL);
-}
+ const char *xpath =
+ "./set-action[action='frr-bgp-route-map:atomic-aggregate']";
+ char xpath_value[XPATH_MAXLEN];
+ nb_cli_enqueue_change(vty, xpath, NB_OP_CREATE, NULL);
+ snprintf(xpath_value, sizeof(xpath_value),
+ "%s/rmap-set-action/frr-bgp-route-map:atomic-aggregate",
+ xpath);
+ nb_cli_enqueue_change(vty, xpath_value, NB_OP_MODIFY, NULL);
-DEFUN (set_atomic_aggregate,
- set_atomic_aggregate_cmd,
- "set atomic-aggregate",
- SET_STR
- "BGP atomic aggregate attribute\n" )
-{
- return generic_set_add(vty, VTY_GET_CONTEXT(route_map_index),
- "atomic-aggregate", NULL);
+ return nb_cli_apply_changes(vty, NULL);
}
-DEFUN (no_set_atomic_aggregate,
- no_set_atomic_aggregate_cmd,
- "no set atomic-aggregate",
- NO_STR
- SET_STR
- "BGP atomic aggregate attribute\n" )
+DEFUN_YANG (no_set_atomic_aggregate,
+ no_set_atomic_aggregate_cmd,
+ "no set atomic-aggregate",
+ NO_STR
+ SET_STR
+ "BGP atomic aggregate attribute\n" )
{
- return generic_set_delete(vty, VTY_GET_CONTEXT(route_map_index),
- "atomic-aggregate", NULL);
+ const char *xpath =
+ "./set-action[action='frr-bgp-route-map:atomic-aggregate']";
+
+ nb_cli_enqueue_change(vty, xpath, NB_OP_DESTROY, NULL);
+ return nb_cli_apply_changes(vty, NULL);
}
-DEFUN (set_aggregator_as,
- set_aggregator_as_cmd,
- "set aggregator as (1-4294967295) A.B.C.D",
- SET_STR
- "BGP aggregator attribute\n"
- "AS number of aggregator\n"
- "AS number\n"
- "IP address of aggregator\n")
+DEFUN_YANG (set_aggregator_as,
+ set_aggregator_as_cmd,
+ "set aggregator as (1-4294967295) A.B.C.D",
+ SET_STR
+ "BGP aggregator attribute\n"
+ "AS number of aggregator\n"
+ "AS number\n"
+ "IP address of aggregator\n")
{
int idx_number = 3;
int idx_ipv4 = 4;
- int ret;
- struct in_addr address;
- char *argstr;
- size_t argstr_len;
+ char xpath_asn[XPATH_MAXLEN];
+ char xpath_addr[XPATH_MAXLEN];
+ const char *xpath =
+ "./set-action[action='frr-bgp-route-map:aggregator']";
- ret = inet_aton(argv[idx_ipv4]->arg, &address);
- if (ret == 0) {
- vty_out(vty, "Aggregator IP address is invalid\n");
- return CMD_WARNING_CONFIG_FAILED;
- }
-
- argstr_len =
- strlen(argv[idx_number]->arg) + strlen(argv[idx_ipv4]->arg) + 2;
- argstr = XMALLOC(MTYPE_ROUTE_MAP_COMPILED, argstr_len);
-
- snprintf(argstr, argstr_len, "%s %s", argv[idx_number]->arg,
- argv[idx_ipv4]->arg);
+ nb_cli_enqueue_change(vty, xpath, NB_OP_CREATE, NULL);
- ret = generic_set_add(vty, VTY_GET_CONTEXT(route_map_index),
- "aggregator as", argstr);
+ snprintf(
+ xpath_asn, sizeof(xpath_asn),
+ "%s/rmap-set-action/frr-bgp-route-map:aggregator/aggregator-asn",
+ xpath);
+ nb_cli_enqueue_change(vty, xpath_asn, NB_OP_MODIFY,
+ argv[idx_number]->arg);
- XFREE(MTYPE_ROUTE_MAP_COMPILED, argstr);
+ snprintf(
+ xpath_addr, sizeof(xpath_addr),
+ "%s/rmap-set-action/frr-bgp-route-map:aggregator/aggregator-address",
+ xpath);
+ nb_cli_enqueue_change(vty, xpath_addr, NB_OP_MODIFY,
+ argv[idx_ipv4]->arg);
- return ret;
+ return nb_cli_apply_changes(vty, NULL);
}
-
-DEFUN (no_set_aggregator_as,
- no_set_aggregator_as_cmd,
- "no set aggregator as [(1-4294967295) A.B.C.D]",
- NO_STR
- SET_STR
- "BGP aggregator attribute\n"
- "AS number of aggregator\n"
- "AS number\n"
- "IP address of aggregator\n")
+DEFUN_YANG (no_set_aggregator_as,
+ no_set_aggregator_as_cmd,
+ "no set aggregator as [(1-4294967295) A.B.C.D]",
+ NO_STR
+ SET_STR
+ "BGP aggregator attribute\n"
+ "AS number of aggregator\n"
+ "AS number\n"
+ "IP address of aggregator\n")
{
- int idx_asn = 4;
- int idx_ip = 5;
- int ret;
- struct in_addr address;
- char *argstr;
- size_t argstr_len;
-
- if (argc <= idx_asn)
- return generic_set_delete(vty, VTY_GET_CONTEXT(route_map_index),
- "aggregator as", NULL);
-
- ret = inet_aton(argv[idx_ip]->arg, &address);
- if (ret == 0) {
- vty_out(vty, "Aggregator IP address is invalid\n");
- return CMD_WARNING_CONFIG_FAILED;
- }
-
- argstr_len = strlen(argv[idx_asn]->arg) + strlen(argv[idx_ip]->arg) + 2;
- argstr = XMALLOC(MTYPE_ROUTE_MAP_COMPILED, argstr_len);
+ const char *xpath =
+ "./set-action[action='frr-bgp-route-map:aggregator']";
- snprintf(argstr, argstr_len, "%s %s", argv[idx_asn]->arg,
- argv[idx_ip]->arg);
+ nb_cli_enqueue_change(vty, xpath, NB_OP_DESTROY, NULL);
+ return nb_cli_apply_changes(vty, NULL);
+}
- ret = generic_set_delete(vty, VTY_GET_CONTEXT(route_map_index),
- "aggregator as", argstr);
+DEFUN_YANG (match_ipv6_next_hop,
+ match_ipv6_next_hop_cmd,
+ "match ipv6 next-hop X:X::X:X",
+ MATCH_STR
+ IPV6_STR
+ "Match IPv6 next-hop address of route\n"
+ "IPv6 address of next hop\n")
+{
+ const char *xpath =
+ "./match-condition[condition='frr-bgp-route-map:ipv6-nexthop']";
+ char xpath_value[XPATH_MAXLEN];
- XFREE(MTYPE_ROUTE_MAP_COMPILED, argstr);
+ nb_cli_enqueue_change(vty, xpath, NB_OP_CREATE, NULL);
+ snprintf(xpath_value, sizeof(xpath_value),
+ "%s/rmap-match-condition/frr-bgp-route-map:ipv6-address",
+ xpath);
+ nb_cli_enqueue_change(vty, xpath_value, NB_OP_MODIFY, argv[3]->arg);
- return ret;
+ return nb_cli_apply_changes(vty, NULL);
}
-DEFUN (match_ipv6_next_hop,
- match_ipv6_next_hop_cmd,
- "match ipv6 next-hop X:X::X:X",
- MATCH_STR
- IPV6_STR
- "Match IPv6 next-hop address of route\n"
- "IPv6 address of next hop\n")
+DEFUN_YANG (no_match_ipv6_next_hop,
+ no_match_ipv6_next_hop_cmd,
+ "no match ipv6 next-hop X:X::X:X",
+ NO_STR
+ MATCH_STR
+ IPV6_STR
+ "Match IPv6 next-hop address of route\n"
+ "IPv6 address of next hop\n")
{
- int idx_ipv6 = 3;
- return bgp_route_match_add(vty, "ipv6 next-hop", argv[idx_ipv6]->arg,
- RMAP_EVENT_MATCH_ADDED);
-}
+ const char *xpath =
+ "./match-condition[condition='frr-bgp-route-map:ipv6-nexthop']";
-DEFUN (no_match_ipv6_next_hop,
- no_match_ipv6_next_hop_cmd,
- "no match ipv6 next-hop X:X::X:X",
- NO_STR
- MATCH_STR
- IPV6_STR
- "Match IPv6 next-hop address of route\n"
- "IPv6 address of next hop\n")
-{
- int idx_ipv6 = 4;
- return bgp_route_match_delete(vty, "ipv6 next-hop", argv[idx_ipv6]->arg,
- RMAP_EVENT_MATCH_DELETED);
+ nb_cli_enqueue_change(vty, xpath, NB_OP_DESTROY, NULL);
+ return nb_cli_apply_changes(vty, NULL);
}
-DEFPY (match_ipv4_next_hop,
+DEFPY_YANG (match_ipv4_next_hop,
match_ipv4_next_hop_cmd,
"match ip next-hop address A.B.C.D",
MATCH_STR
@@ -5357,13 +5708,20 @@ DEFPY (match_ipv4_next_hop,
"IP address\n"
"IP address of next-hop\n")
{
- int idx_ipv4 = 4;
+ const char *xpath =
+ "./match-condition[condition='frr-bgp-route-map:ipv4-nexthop']";
+ char xpath_value[XPATH_MAXLEN];
+
+ nb_cli_enqueue_change(vty, xpath, NB_OP_CREATE, NULL);
+ snprintf(xpath_value, sizeof(xpath_value),
+ "%s/rmap-match-condition/frr-bgp-route-map:ipv4-address",
+ xpath);
+ nb_cli_enqueue_change(vty, xpath_value, NB_OP_MODIFY, argv[4]->arg);
- return bgp_route_match_add(vty, "ip next-hop address",
- argv[idx_ipv4]->arg, RMAP_EVENT_MATCH_ADDED);
+ return nb_cli_apply_changes(vty, NULL);
}
-DEFPY (no_match_ipv4_next_hop,
+DEFPY_YANG (no_match_ipv4_next_hop,
no_match_ipv4_next_hop_cmd,
"no match ip next-hop address [A.B.C.D]",
NO_STR
@@ -5373,264 +5731,313 @@ DEFPY (no_match_ipv4_next_hop,
"IP address\n"
"IP address of next-hop\n")
{
- return bgp_route_match_delete(vty, "ip next-hop address", NULL,
- RMAP_EVENT_MATCH_DELETED);
+ const char *xpath =
+ "./match-condition[condition='frr-bgp-route-map:ipv4-nexthop']";
+
+ nb_cli_enqueue_change(vty, xpath, NB_OP_DESTROY, NULL);
+ return nb_cli_apply_changes(vty, NULL);
}
-DEFUN (set_ipv6_nexthop_peer,
- set_ipv6_nexthop_peer_cmd,
- "set ipv6 next-hop peer-address",
- SET_STR
- IPV6_STR
- "Next hop address\n"
- "Use peer address (for BGP only)\n")
+DEFUN_YANG (set_ipv6_nexthop_peer,
+ set_ipv6_nexthop_peer_cmd,
+ "set ipv6 next-hop peer-address",
+ SET_STR
+ IPV6_STR
+ "Next hop address\n"
+ "Use peer address (for BGP only)\n")
{
- return generic_set_add(vty, VTY_GET_CONTEXT(route_map_index),
- "ipv6 next-hop peer-address", NULL);
+ const char *xpath =
+ "./set-action[action='frr-bgp-route-map:ipv6-peer-address']";
+ char xpath_value[XPATH_MAXLEN];
+
+ nb_cli_enqueue_change(vty, xpath, NB_OP_CREATE, NULL);
+ snprintf(xpath_value, sizeof(xpath_value),
+ "%s/rmap-set-action/frr-bgp-route-map:preference", xpath);
+ nb_cli_enqueue_change(vty, xpath_value, NB_OP_MODIFY, "true");
+
+ return nb_cli_apply_changes(vty, NULL);
}
-DEFUN (no_set_ipv6_nexthop_peer,
- no_set_ipv6_nexthop_peer_cmd,
- "no set ipv6 next-hop peer-address",
- NO_STR
- SET_STR
- IPV6_STR
- "IPv6 next-hop address\n"
- "Use peer address (for BGP only)\n")
+DEFUN_YANG (no_set_ipv6_nexthop_peer,
+ no_set_ipv6_nexthop_peer_cmd,
+ "no set ipv6 next-hop peer-address",
+ NO_STR
+ SET_STR
+ IPV6_STR
+ "IPv6 next-hop address\n"
+ "Use peer address (for BGP only)\n")
{
- return generic_set_delete(vty, VTY_GET_CONTEXT(route_map_index),
- "ipv6 next-hop peer-address", NULL);
+ const char *xpath =
+ "./set-action[action='frr-bgp-route-map:ipv6-peer-address']";
+
+ nb_cli_enqueue_change(vty, xpath, NB_OP_DESTROY, NULL);
+ return nb_cli_apply_changes(vty, NULL);
}
-DEFUN (set_ipv6_nexthop_prefer_global,
- set_ipv6_nexthop_prefer_global_cmd,
- "set ipv6 next-hop prefer-global",
- SET_STR
- IPV6_STR
- "IPv6 next-hop address\n"
- "Prefer global over link-local if both exist\n")
+DEFUN_YANG (set_ipv6_nexthop_prefer_global,
+ set_ipv6_nexthop_prefer_global_cmd,
+ "set ipv6 next-hop prefer-global",
+ SET_STR
+ IPV6_STR
+ "IPv6 next-hop address\n"
+ "Prefer global over link-local if both exist\n")
{
- return generic_set_add(vty, VTY_GET_CONTEXT(route_map_index),
- "ipv6 next-hop prefer-global", NULL);
- ;
+ const char *xpath =
+ "./set-action[action='frr-bgp-route-map:ipv6-prefer-global']";
+ char xpath_value[XPATH_MAXLEN];
+
+ nb_cli_enqueue_change(vty, xpath, NB_OP_CREATE, NULL);
+ snprintf(xpath_value, sizeof(xpath_value),
+ "%s/rmap-set-action/frr-bgp-route-map:preference", xpath);
+ nb_cli_enqueue_change(vty, xpath_value, NB_OP_MODIFY, "true");
+
+ return nb_cli_apply_changes(vty, NULL);
}
-DEFUN (no_set_ipv6_nexthop_prefer_global,
- no_set_ipv6_nexthop_prefer_global_cmd,
- "no set ipv6 next-hop prefer-global",
- NO_STR
- SET_STR
- IPV6_STR
- "IPv6 next-hop address\n"
- "Prefer global over link-local if both exist\n")
+DEFUN_YANG (no_set_ipv6_nexthop_prefer_global,
+ no_set_ipv6_nexthop_prefer_global_cmd,
+ "no set ipv6 next-hop prefer-global",
+ NO_STR
+ SET_STR
+ IPV6_STR
+ "IPv6 next-hop address\n"
+ "Prefer global over link-local if both exist\n")
{
- return generic_set_delete(vty, VTY_GET_CONTEXT(route_map_index),
- "ipv6 next-hop prefer-global", NULL);
+ const char *xpath =
+ "./set-action[action='frr-bgp-route-map:ipv6-prefer-global']";
+
+ nb_cli_enqueue_change(vty, xpath, NB_OP_DESTROY, NULL);
+ return nb_cli_apply_changes(vty, NULL);
}
-DEFUN (set_ipv6_nexthop_global,
- set_ipv6_nexthop_global_cmd,
- "set ipv6 next-hop global X:X::X:X",
- SET_STR
- IPV6_STR
- "IPv6 next-hop address\n"
- "IPv6 global address\n"
- "IPv6 address of next hop\n")
+DEFUN_YANG (set_ipv6_nexthop_global,
+ set_ipv6_nexthop_global_cmd,
+ "set ipv6 next-hop global X:X::X:X",
+ SET_STR
+ IPV6_STR
+ "IPv6 next-hop address\n"
+ "IPv6 global address\n"
+ "IPv6 address of next hop\n")
{
int idx_ipv6 = 4;
- struct in6_addr addr;
- int ret;
+ const char *xpath =
+ "./set-action[action='frr-bgp-route-map:ipv6-nexthop-global']";
+ char xpath_value[XPATH_MAXLEN];
- ret = inet_pton(AF_INET6, argv[idx_ipv6]->arg, &addr);
- if (!ret) {
- vty_out(vty, "%% Malformed nexthop address\n");
- return CMD_WARNING_CONFIG_FAILED;
- }
- if (IN6_IS_ADDR_UNSPECIFIED(&addr) || IN6_IS_ADDR_LOOPBACK(&addr)
- || IN6_IS_ADDR_MULTICAST(&addr) || IN6_IS_ADDR_LINKLOCAL(&addr)) {
- vty_out(vty, "%% Invalid global nexthop address\n");
- return CMD_WARNING_CONFIG_FAILED;
- }
+ nb_cli_enqueue_change(vty, xpath, NB_OP_CREATE, NULL);
+ snprintf(xpath_value, sizeof(xpath_value),
+ "%s/rmap-set-action/frr-bgp-route-map:ipv6-address", xpath);
+ nb_cli_enqueue_change(vty, xpath_value, NB_OP_MODIFY,
+ argv[idx_ipv6]->arg);
- return generic_set_add(vty, VTY_GET_CONTEXT(route_map_index),
- "ipv6 next-hop global", argv[idx_ipv6]->arg);
+ return nb_cli_apply_changes(vty, NULL);
}
-
-DEFUN (no_set_ipv6_nexthop_global,
- no_set_ipv6_nexthop_global_cmd,
- "no set ipv6 next-hop global X:X::X:X",
- NO_STR
- SET_STR
- IPV6_STR
- "IPv6 next-hop address\n"
- "IPv6 global address\n"
- "IPv6 address of next hop\n")
+DEFUN_YANG (no_set_ipv6_nexthop_global,
+ no_set_ipv6_nexthop_global_cmd,
+ "no set ipv6 next-hop global X:X::X:X",
+ NO_STR
+ SET_STR
+ IPV6_STR
+ "IPv6 next-hop address\n"
+ "IPv6 global address\n"
+ "IPv6 address of next hop\n")
{
- int idx_ipv6 = 5;
- if (argc <= idx_ipv6)
- return generic_set_delete(vty, VTY_GET_CONTEXT(route_map_index),
- "ipv6 next-hop global", NULL);
- return generic_set_delete(vty, VTY_GET_CONTEXT(route_map_index),
- "ipv6 next-hop global", argv[idx_ipv6]->arg);
+ const char *xpath =
+ "./set-action[action='frr-bgp-route-map:ipv6-nexthop-global']";
+
+ nb_cli_enqueue_change(vty, xpath, NB_OP_DESTROY, NULL);
+ return nb_cli_apply_changes(vty, NULL);
}
#ifdef KEEP_OLD_VPN_COMMANDS
-DEFUN (set_vpn_nexthop,
- set_vpn_nexthop_cmd,
- "set <vpnv4 next-hop A.B.C.D|vpnv6 next-hop X:X::X:X>",
- SET_STR
- "VPNv4 information\n"
- "VPN next-hop address\n"
- "IP address of next hop\n"
- "VPNv6 information\n"
- "VPN next-hop address\n"
- "IPv6 address of next hop\n")
+DEFUN_YANG (set_vpn_nexthop,
+ set_vpn_nexthop_cmd,
+ "set <vpnv4 next-hop A.B.C.D|vpnv6 next-hop X:X::X:X>",
+ SET_STR
+ "VPNv4 information\n"
+ "VPN next-hop address\n"
+ "IP address of next hop\n"
+ "VPNv6 information\n"
+ "VPN next-hop address\n"
+ "IPv6 address of next hop\n")
{
int idx_ip = 3;
afi_t afi;
int idx = 0;
if (argv_find_and_parse_vpnvx(argv, argc, &idx, &afi)) {
- if (afi == AFI_IP)
- return generic_set_add(
- vty, VTY_GET_CONTEXT(route_map_index),
- "ipv4 vpn next-hop", argv[idx_ip]->arg);
- else
- return generic_set_add(
- vty, VTY_GET_CONTEXT(route_map_index),
- "ipv6 vpn next-hop", argv[idx_ip]->arg);
+ if (afi == AFI_IP) {
+ const char *xpath =
+ "./set-action[action='frr-bgp-route-map:ipv4-vpn-address']";
+
+ nb_cli_enqueue_change(vty, xpath, NB_OP_CREATE, NULL);
+ snprintf(
+ xpath_value, sizeof(xpath_value),
+ "%s/rmap-set-action/frr-bgp-route-map:ipv4-address",
+ xpath);
+ } else {
+ const char *xpath =
+ "./set-action[action='frr-bgp-route-map:ipv6-vpn-address']";
+
+ nb_cli_enqueue_change(vty, xpath, NB_OP_CREATE, NULL);
+ snprintf(
+ xpath_value, sizeof(xpath_value),
+ "%s/rmap-set-action/frr-bgp-route-map:ipv6-address",
+ xpath);
+ }
+
+ nb_cli_enqueue_change(vty, xpath_value, NB_OP_MODIFY,
+ argv[idx_ip]->arg);
+
+ return nb_cli_apply_changes(vty, NULL);
}
+
return CMD_SUCCESS;
}
-DEFUN (no_set_vpn_nexthop,
- no_set_vpn_nexthop_cmd,
- "no set <vpnv4 next-hop A.B.C.D|vpnv6 next-hop X:X::X:X>",
- NO_STR
- SET_STR
- "VPNv4 information\n"
- "VPN next-hop address\n"
- "IP address of next hop\n"
- "VPNv6 information\n"
- "VPN next-hop address\n"
- "IPv6 address of next hop\n")
+DEFUN_YANG (no_set_vpn_nexthop,
+ no_set_vpn_nexthop_cmd,
+ "no set <vpnv4 next-hop A.B.C.D|vpnv6 next-hop X:X::X:X>",
+ NO_STR
+ SET_STR
+ "VPNv4 information\n"
+ "VPN next-hop address\n"
+ "IP address of next hop\n"
+ "VPNv6 information\n"
+ "VPN next-hop address\n"
+ "IPv6 address of next hop\n")
{
int idx_ip = 4;
char *arg;
afi_t afi;
int idx = 0;
- if (argc <= idx_ip)
- arg = NULL;
- else
- arg = argv[idx_ip]->arg;
if (argv_find_and_parse_vpnvx(argv, argc, &idx, &afi)) {
- if (afi == AFI_IP)
- return generic_set_delete(
- vty, VTY_GET_CONTEXT(route_map_index),
- "ipv4 vpn next-hop", arg);
- else
- return generic_set_delete(
- vty, VTY_GET_CONTEXT(route_map_index),
- "ipv6 vpn next-hop", argv[idx_ip]->arg);
+ if (afi == AFI_IP) {
+ const char *xpath =
+ "./set-action[action='frr-bgp-route-map:ipv4-vpn-address']";
+ nb_cli_enqueue_change(vty, xpath, NB_OP_DESTROY, NULL);
+ } else {
+ const char *xpath =
+ "./set-action[action='frr-bgp-route-map:ipv6-vpn-address']";
+ nb_cli_enqueue_change(vty, xpath, NB_OP_DESTROY, NULL);
+ }
+ return nb_cli_apply_changes(vty, NULL);
}
return CMD_SUCCESS;
}
#endif /* KEEP_OLD_VPN_COMMANDS */
-DEFUN (set_ipx_vpn_nexthop,
- set_ipx_vpn_nexthop_cmd,
- "set <ipv4|ipv6> vpn next-hop <A.B.C.D|X:X::X:X>",
- SET_STR
- "IPv4 information\n"
- "IPv6 information\n"
- "VPN information\n"
- "VPN next-hop address\n"
- "IP address of next hop\n"
- "IPv6 address of next hop\n")
+DEFUN_YANG (set_ipx_vpn_nexthop,
+ set_ipx_vpn_nexthop_cmd,
+ "set <ipv4|ipv6> vpn next-hop <A.B.C.D|X:X::X:X>",
+ SET_STR
+ "IPv4 information\n"
+ "IPv6 information\n"
+ "VPN information\n"
+ "VPN next-hop address\n"
+ "IP address of next hop\n"
+ "IPv6 address of next hop\n")
{
int idx_ip = 4;
afi_t afi;
int idx = 0;
+ char xpath_value[XPATH_MAXLEN];
if (argv_find_and_parse_afi(argv, argc, &idx, &afi)) {
- if (afi == AFI_IP)
- return generic_set_add(
- vty, VTY_GET_CONTEXT(route_map_index),
- "ipv4 vpn next-hop", argv[idx_ip]->arg);
- else
- return generic_set_add(
- vty, VTY_GET_CONTEXT(route_map_index),
- "ipv6 vpn next-hop", argv[idx_ip]->arg);
+ if (afi == AFI_IP) {
+ const char *xpath =
+ "./set-action[action='frr-bgp-route-map:ipv4-vpn-address']";
+
+ nb_cli_enqueue_change(vty, xpath, NB_OP_CREATE, NULL);
+ snprintf(
+ xpath_value, sizeof(xpath_value),
+ "%s/rmap-set-action/frr-bgp-route-map:ipv4-address",
+ xpath);
+ } else {
+ const char *xpath =
+ "./set-action[action='frr-bgp-route-map:ipv6-vpn-address']";
+
+ nb_cli_enqueue_change(vty, xpath, NB_OP_CREATE, NULL);
+ snprintf(
+ xpath_value, sizeof(xpath_value),
+ "%s/rmap-set-action/frr-bgp-route-map:ipv6-address",
+ xpath);
+ }
+ nb_cli_enqueue_change(vty, xpath_value, NB_OP_MODIFY,
+ argv[idx_ip]->arg);
+ return nb_cli_apply_changes(vty, NULL);
}
return CMD_SUCCESS;
}
-DEFUN (no_set_ipx_vpn_nexthop,
- no_set_ipx_vpn_nexthop_cmd,
- "no set <ipv4|ipv6> vpn next-hop [<A.B.C.D|X:X::X:X>]",
- NO_STR
- SET_STR
- "IPv4 information\n"
- "IPv6 information\n"
- "VPN information\n"
- "VPN next-hop address\n"
- "IP address of next hop\n"
- "IPv6 address of next hop\n")
-{
- int idx_ip = 5;
- char *arg;
+DEFUN_YANG (no_set_ipx_vpn_nexthop,
+ no_set_ipx_vpn_nexthop_cmd,
+ "no set <ipv4|ipv6> vpn next-hop [<A.B.C.D|X:X::X:X>]",
+ NO_STR
+ SET_STR
+ "IPv4 information\n"
+ "IPv6 information\n"
+ "VPN information\n"
+ "VPN next-hop address\n"
+ "IP address of next hop\n"
+ "IPv6 address of next hop\n")
+{
afi_t afi;
int idx = 0;
- if (argc <= idx_ip)
- arg = NULL;
- else
- arg = argv[idx_ip]->arg;
if (argv_find_and_parse_afi(argv, argc, &idx, &afi)) {
- if (afi == AFI_IP)
- return generic_set_delete(
- vty, VTY_GET_CONTEXT(route_map_index),
- "ipv4 vpn next-hop", arg);
- else
- return generic_set_delete(
- vty, VTY_GET_CONTEXT(route_map_index),
- "ipv6 vpn next-hop", arg);
+ if (afi == AFI_IP) {
+ const char *xpath =
+ "./set-action[action='frr-bgp-route-map:ipv4-vpn-address']";
+ nb_cli_enqueue_change(vty, xpath, NB_OP_DESTROY, NULL);
+ } else {
+ const char *xpath =
+ "./set-action[action='frr-bgp-route-map:ipv6-vpn-address']";
+ nb_cli_enqueue_change(vty, xpath, NB_OP_DESTROY, NULL);
+ }
+ return nb_cli_apply_changes(vty, NULL);
}
return CMD_SUCCESS;
}
-DEFUN (set_originator_id,
- set_originator_id_cmd,
- "set originator-id A.B.C.D",
- SET_STR
- "BGP originator ID attribute\n"
- "IP address of originator\n")
+DEFUN_YANG (set_originator_id,
+ set_originator_id_cmd,
+ "set originator-id A.B.C.D",
+ SET_STR
+ "BGP originator ID attribute\n"
+ "IP address of originator\n")
{
int idx_ipv4 = 2;
- return generic_set_add(vty, VTY_GET_CONTEXT(route_map_index),
- "originator-id", argv[idx_ipv4]->arg);
-}
+ const char *xpath =
+ "./set-action[action='frr-bgp-route-map:originator-id']";
+ char xpath_value[XPATH_MAXLEN];
+ nb_cli_enqueue_change(vty, xpath, NB_OP_CREATE, NULL);
+ snprintf(xpath_value, sizeof(xpath_value),
+ "%s/rmap-set-action/frr-bgp-route-map:originator-id", xpath);
+ nb_cli_enqueue_change(vty, xpath_value, NB_OP_MODIFY,
+ argv[idx_ipv4]->arg);
-DEFUN (no_set_originator_id,
- no_set_originator_id_cmd,
- "no set originator-id [A.B.C.D]",
- NO_STR
- SET_STR
- "BGP originator ID attribute\n"
- "IP address of originator\n")
+ return nb_cli_apply_changes(vty, NULL);
+}
+
+DEFUN_YANG (no_set_originator_id,
+ no_set_originator_id_cmd,
+ "no set originator-id [A.B.C.D]",
+ NO_STR
+ SET_STR
+ "BGP originator ID attribute\n"
+ "IP address of originator\n")
{
- int idx = 0;
- char *arg =
- argv_find(argv, argc, "A.B.C.D", &idx) ? argv[idx]->arg : NULL;
+ const char *xpath =
+ "./set-action[action='frr-bgp-route-map:originator-id']";
- return generic_set_delete(vty, VTY_GET_CONTEXT(route_map_index),
- "originator-id", arg);
+ nb_cli_enqueue_change(vty, xpath, NB_OP_DESTROY, NULL);
+ return nb_cli_apply_changes(vty, NULL);
}
-
/* Initialization of route map. */
void bgp_route_map_init(void)
{
diff --git a/bgpd/bgp_routemap_nb.c b/bgpd/bgp_routemap_nb.c
new file mode 100644
index 000000000..fc5912218
--- /dev/null
+++ b/bgpd/bgp_routemap_nb.c
@@ -0,0 +1,376 @@
+/*
+ * Copyright (C) 2020 Vmware
+ * Sarita Patra
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the Free
+ * Software Foundation; either version 2 of the License, or (at your option)
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; see the file COPYING; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+
+#include "lib/command.h"
+#include "lib/log.h"
+#include "lib/northbound.h"
+#include "lib/routemap.h"
+#include "bgpd/bgpd.h"
+#include "bgpd/bgp_routemap_nb.h"
+
+/* clang-format off */
+const struct frr_yang_module_info frr_bgp_route_map_info = {
+ .name = "frr-bgp-route-map",
+ .nodes = {
+ {
+ .xpath = "/frr-route-map:lib/route-map/entry/match-condition/rmap-match-condition/frr-bgp-route-map:local-preference",
+ .cbs = {
+ .modify = lib_route_map_entry_match_condition_rmap_match_condition_local_preference_modify,
+ .destroy = lib_route_map_entry_match_condition_rmap_match_condition_local_preference_destroy,
+ }
+ },
+ {
+ .xpath = "/frr-route-map:lib/route-map/entry/match-condition/rmap-match-condition/frr-bgp-route-map:script",
+ .cbs = {
+ .modify = lib_route_map_entry_match_condition_rmap_match_condition_script_modify,
+ .destroy = lib_route_map_entry_match_condition_rmap_match_condition_script_destroy,
+ }
+ },
+ {
+ .xpath = "/frr-route-map:lib/route-map/entry/match-condition/rmap-match-condition/frr-bgp-route-map:origin",
+ .cbs = {
+ .modify = lib_route_map_entry_match_condition_rmap_match_condition_origin_modify,
+ .destroy = lib_route_map_entry_match_condition_rmap_match_condition_origin_destroy,
+ }
+ },
+ {
+ .xpath = "/frr-route-map:lib/route-map/entry/match-condition/rmap-match-condition/frr-bgp-route-map:rpki",
+ .cbs = {
+ .modify = lib_route_map_entry_match_condition_rmap_match_condition_rpki_modify,
+ .destroy = lib_route_map_entry_match_condition_rmap_match_condition_rpki_destroy,
+ }
+ },
+ {
+ .xpath = "/frr-route-map:lib/route-map/entry/match-condition/rmap-match-condition/frr-bgp-route-map:probability",
+ .cbs = {
+ .modify = lib_route_map_entry_match_condition_rmap_match_condition_probability_modify,
+ .destroy = lib_route_map_entry_match_condition_rmap_match_condition_probability_destroy,
+ }
+ },
+ {
+ .xpath = "/frr-route-map:lib/route-map/entry/match-condition/rmap-match-condition/frr-bgp-route-map:source-vrf",
+ .cbs = {
+ .modify = lib_route_map_entry_match_condition_rmap_match_condition_source_vrf_modify,
+ .destroy = lib_route_map_entry_match_condition_rmap_match_condition_source_vrf_destroy,
+ }
+ },
+ {
+ .xpath = "/frr-route-map:lib/route-map/entry/match-condition/rmap-match-condition/frr-bgp-route-map:peer-ipv4-address",
+ .cbs = {
+ .modify = lib_route_map_entry_match_condition_rmap_match_condition_peer_ipv4_address_modify,
+ .destroy = lib_route_map_entry_match_condition_rmap_match_condition_peer_ipv4_address_destroy,
+ }
+ },
+ {
+ .xpath = "/frr-route-map:lib/route-map/entry/match-condition/rmap-match-condition/frr-bgp-route-map:peer-interface",
+ .cbs = {
+ .modify = lib_route_map_entry_match_condition_rmap_match_condition_peer_interface_modify,
+ .destroy = lib_route_map_entry_match_condition_rmap_match_condition_peer_interface_destroy,
+ }
+ },
+ {
+ .xpath = "/frr-route-map:lib/route-map/entry/match-condition/rmap-match-condition/frr-bgp-route-map:peer-ipv6-address",
+ .cbs = {
+ .modify = lib_route_map_entry_match_condition_rmap_match_condition_peer_ipv6_address_modify,
+ .destroy = lib_route_map_entry_match_condition_rmap_match_condition_peer_ipv6_address_destroy,
+ }
+ },
+ {
+ .xpath = "/frr-route-map:lib/route-map/entry/match-condition/rmap-match-condition/frr-bgp-route-map:peer-local",
+ .cbs = {
+ .modify = lib_route_map_entry_match_condition_rmap_match_condition_peer_local_modify,
+ .destroy = lib_route_map_entry_match_condition_rmap_match_condition_peer_local_destroy,
+ }
+ },
+ {
+ .xpath = "/frr-route-map:lib/route-map/entry/match-condition/rmap-match-condition/frr-bgp-route-map:list-name",
+ .cbs = {
+ .modify = lib_route_map_entry_match_condition_rmap_match_condition_list_name_modify,
+ .destroy = lib_route_map_entry_match_condition_rmap_match_condition_list_name_destroy,
+ }
+ },
+ {
+ .xpath = "/frr-route-map:lib/route-map/entry/match-condition/rmap-match-condition/frr-bgp-route-map:evpn-default-route",
+ .cbs = {
+ .create = lib_route_map_entry_match_condition_rmap_match_condition_evpn_default_route_create,
+ .destroy = lib_route_map_entry_match_condition_rmap_match_condition_evpn_default_route_destroy,
+ }
+ },
+ {
+ .xpath = "/frr-route-map:lib/route-map/entry/match-condition/rmap-match-condition/frr-bgp-route-map:evpn-vni",
+ .cbs = {
+ .modify = lib_route_map_entry_match_condition_rmap_match_condition_evpn_vni_modify,
+ .destroy = lib_route_map_entry_match_condition_rmap_match_condition_evpn_vni_destroy,
+ }
+ },
+ {
+ .xpath = "/frr-route-map:lib/route-map/entry/match-condition/rmap-match-condition/frr-bgp-route-map:evpn-route-type",
+ .cbs = {
+ .modify = lib_route_map_entry_match_condition_rmap_match_condition_evpn_route_type_modify,
+ .destroy = lib_route_map_entry_match_condition_rmap_match_condition_evpn_route_type_destroy,
+ }
+ },
+ {
+ .xpath = "/frr-route-map:lib/route-map/entry/match-condition/rmap-match-condition/frr-bgp-route-map:route-distinguisher",
+ .cbs = {
+ .modify = lib_route_map_entry_match_condition_rmap_match_condition_route_distinguisher_modify,
+ .destroy = lib_route_map_entry_match_condition_rmap_match_condition_route_distinguisher_destroy,
+ }
+ },
+ {
+ .xpath = "/frr-route-map:lib/route-map/entry/match-condition/rmap-match-condition/frr-bgp-route-map:comm-list",
+ .cbs = {
+ .apply_finish = lib_route_map_entry_match_condition_rmap_match_condition_comm_list_finish,
+ }
+ },
+ {
+ .xpath = "/frr-route-map:lib/route-map/entry/match-condition/rmap-match-condition/frr-bgp-route-map:comm-list/comm-list-name",
+ .cbs = {
+ .modify = lib_route_map_entry_match_condition_rmap_match_condition_comm_list_comm_list_name_modify,
+ .destroy = lib_route_map_entry_match_condition_rmap_match_condition_comm_list_comm_list_name_destroy,
+ }
+ },
+ {
+ .xpath = "/frr-route-map:lib/route-map/entry/match-condition/rmap-match-condition/frr-bgp-route-map:comm-list/comm-list-name-exact-match",
+ .cbs = {
+ .modify = lib_route_map_entry_match_condition_rmap_match_condition_comm_list_comm_list_name_exact_match_modify,
+ .destroy = lib_route_map_entry_match_condition_rmap_match_condition_comm_list_comm_list_name_exact_match_destroy,
+ }
+ },
+ {
+ .xpath = "/frr-route-map:lib/route-map/entry/match-condition/rmap-match-condition/frr-bgp-route-map:ipv4-address",
+ .cbs = {
+ .modify = lib_route_map_entry_match_condition_rmap_match_condition_ipv4_address_modify,
+ .destroy = lib_route_map_entry_match_condition_rmap_match_condition_ipv4_address_destroy,
+ }
+ },
+ {
+ .xpath = "/frr-route-map:lib/route-map/entry/match-condition/rmap-match-condition/frr-bgp-route-map:ipv6-address",
+ .cbs = {
+ .modify = lib_route_map_entry_match_condition_rmap_match_condition_ipv6_address_modify,
+ .destroy = lib_route_map_entry_match_condition_rmap_match_condition_ipv6_address_destroy,
+ }
+ },
+ {
+ .xpath = "/frr-route-map:lib/route-map/entry/set-action/rmap-set-action/frr-bgp-route-map:distance",
+ .cbs = {
+ .modify = lib_route_map_entry_set_action_rmap_set_action_distance_modify,
+ .destroy = lib_route_map_entry_set_action_rmap_set_action_distance_destroy,
+ }
+ },
+ {
+ .xpath = "/frr-route-map:lib/route-map/entry/set-action/rmap-set-action/frr-bgp-route-map:extcommunity-rt",
+ .cbs = {
+ .modify = lib_route_map_entry_set_action_rmap_set_action_extcommunity_rt_modify,
+ .destroy = lib_route_map_entry_set_action_rmap_set_action_extcommunity_rt_destroy,
+ }
+ },
+ {
+ .xpath = "/frr-route-map:lib/route-map/entry/set-action/rmap-set-action/frr-bgp-route-map:extcommunity-soo",
+ .cbs = {
+ .modify = lib_route_map_entry_set_action_rmap_set_action_extcommunity_soo_modify,
+ .destroy = lib_route_map_entry_set_action_rmap_set_action_extcommunity_soo_destroy,
+ }
+ },
+ {
+ .xpath = "/frr-route-map:lib/route-map/entry/set-action/rmap-set-action/frr-bgp-route-map:ipv4-address",
+ .cbs = {
+ .modify = lib_route_map_entry_set_action_rmap_set_action_ipv4_address_modify,
+ .destroy = lib_route_map_entry_set_action_rmap_set_action_ipv4_address_destroy,
+ }
+ },
+ {
+ .xpath = "/frr-route-map:lib/route-map/entry/set-action/rmap-set-action/frr-bgp-route-map:ipv4-nexthop",
+ .cbs = {
+ .modify = lib_route_map_entry_set_action_rmap_set_action_ipv4_nexthop_modify,
+ .destroy = lib_route_map_entry_set_action_rmap_set_action_ipv4_nexthop_destroy,
+ }
+ },
+ {
+ .xpath = "/frr-route-map:lib/route-map/entry/set-action/rmap-set-action/frr-bgp-route-map:ipv6-address",
+ .cbs = {
+ .modify = lib_route_map_entry_set_action_rmap_set_action_ipv6_address_modify,
+ .destroy = lib_route_map_entry_set_action_rmap_set_action_ipv6_address_destroy,
+ }
+ },
+ {
+ .xpath = "/frr-route-map:lib/route-map/entry/set-action/rmap-set-action/frr-bgp-route-map:preference",
+ .cbs = {
+ .modify = lib_route_map_entry_set_action_rmap_set_action_preference_modify,
+ .destroy = lib_route_map_entry_set_action_rmap_set_action_preference_destroy,
+ }
+ },
+ {
+ .xpath = "/frr-route-map:lib/route-map/entry/set-action/rmap-set-action/frr-bgp-route-map:label-index",
+ .cbs = {
+ .modify = lib_route_map_entry_set_action_rmap_set_action_label_index_modify,
+ .destroy = lib_route_map_entry_set_action_rmap_set_action_label_index_destroy,
+ }
+ },
+ {
+ .xpath = "/frr-route-map:lib/route-map/entry/set-action/rmap-set-action/frr-bgp-route-map:local-pref",
+ .cbs = {
+ .modify = lib_route_map_entry_set_action_rmap_set_action_local_pref_modify,
+ .destroy = lib_route_map_entry_set_action_rmap_set_action_local_pref_destroy,
+ }
+ },
+ {
+ .xpath = "/frr-route-map:lib/route-map/entry/set-action/rmap-set-action/frr-bgp-route-map:weight",
+ .cbs = {
+ .modify = lib_route_map_entry_set_action_rmap_set_action_weight_modify,
+ .destroy = lib_route_map_entry_set_action_rmap_set_action_weight_destroy,
+ }
+ },
+ {
+ .xpath = "/frr-route-map:lib/route-map/entry/set-action/rmap-set-action/frr-bgp-route-map:origin",
+ .cbs = {
+ .modify = lib_route_map_entry_set_action_rmap_set_action_origin_modify,
+ .destroy = lib_route_map_entry_set_action_rmap_set_action_origin_destroy,
+ }
+ },
+ {
+ .xpath = "/frr-route-map:lib/route-map/entry/set-action/rmap-set-action/frr-bgp-route-map:originator-id",
+ .cbs = {
+ .modify = lib_route_map_entry_set_action_rmap_set_action_originator_id_modify,
+ .destroy = lib_route_map_entry_set_action_rmap_set_action_originator_id_destroy,
+ }
+ },
+ {
+ .xpath = "/frr-route-map:lib/route-map/entry/set-action/rmap-set-action/frr-bgp-route-map:table",
+ .cbs = {
+ .modify = lib_route_map_entry_set_action_rmap_set_action_table_modify,
+ .destroy = lib_route_map_entry_set_action_rmap_set_action_table_destroy,
+ }
+ },
+ {
+ .xpath = "/frr-route-map:lib/route-map/entry/set-action/rmap-set-action/frr-bgp-route-map:atomic-aggregate",
+ .cbs = {
+ .create = lib_route_map_entry_set_action_rmap_set_action_atomic_aggregate_create,
+ .destroy = lib_route_map_entry_set_action_rmap_set_action_atomic_aggregate_destroy,
+ }
+ },
+ {
+ .xpath = "/frr-route-map:lib/route-map/entry/set-action/rmap-set-action/frr-bgp-route-map:prepend-as-path",
+ .cbs = {
+ .modify = lib_route_map_entry_set_action_rmap_set_action_prepend_as_path_modify,
+ .destroy = lib_route_map_entry_set_action_rmap_set_action_prepend_as_path_destroy,
+ }
+ },
+ {
+ .xpath = "/frr-route-map:lib/route-map/entry/set-action/rmap-set-action/frr-bgp-route-map:last-as",
+ .cbs = {
+ .modify = lib_route_map_entry_set_action_rmap_set_action_last_as_modify,
+ .destroy = lib_route_map_entry_set_action_rmap_set_action_last_as_destroy,
+ }
+ },
+ {
+ .xpath = "/frr-route-map:lib/route-map/entry/set-action/rmap-set-action/frr-bgp-route-map:exclude-as-path",
+ .cbs = {
+ .modify = lib_route_map_entry_set_action_rmap_set_action_exclude_as_path_modify,
+ .destroy = lib_route_map_entry_set_action_rmap_set_action_exclude_as_path_destroy,
+ }
+ },
+ {
+ .xpath = "/frr-route-map:lib/route-map/entry/set-action/rmap-set-action/frr-bgp-route-map:community-none",
+ .cbs = {
+ .modify = lib_route_map_entry_set_action_rmap_set_action_community_none_modify,
+ .destroy = lib_route_map_entry_set_action_rmap_set_action_community_none_destroy,
+ }
+ },
+ {
+ .xpath = "/frr-route-map:lib/route-map/entry/set-action/rmap-set-action/frr-bgp-route-map:community-string",
+ .cbs = {
+ .modify = lib_route_map_entry_set_action_rmap_set_action_community_string_modify,
+ .destroy = lib_route_map_entry_set_action_rmap_set_action_community_string_destroy,
+ }
+ },
+ {
+ .xpath = "/frr-route-map:lib/route-map/entry/set-action/rmap-set-action/frr-bgp-route-map:large-community-none",
+ .cbs = {
+ .modify = lib_route_map_entry_set_action_rmap_set_action_large_community_none_modify,
+ .destroy = lib_route_map_entry_set_action_rmap_set_action_large_community_none_destroy,
+ }
+ },
+ {
+ .xpath = "/frr-route-map:lib/route-map/entry/set-action/rmap-set-action/frr-bgp-route-map:large-community-string",
+ .cbs = {
+ .modify = lib_route_map_entry_set_action_rmap_set_action_large_community_string_modify,
+ .destroy = lib_route_map_entry_set_action_rmap_set_action_large_community_string_destroy,
+ }
+ },
+ {
+ .xpath = "/frr-route-map:lib/route-map/entry/set-action/rmap-set-action/frr-bgp-route-map:aggregator",
+ .cbs = {
+ .apply_finish = lib_route_map_entry_set_action_rmap_set_action_aggregator_finish,
+ }
+ },
+ {
+ .xpath = "/frr-route-map:lib/route-map/entry/set-action/rmap-set-action/frr-bgp-route-map:aggregator/aggregator-asn",
+ .cbs = {
+ .modify = lib_route_map_entry_set_action_rmap_set_action_aggregator_aggregator_asn_modify,
+ .destroy = lib_route_map_entry_set_action_rmap_set_action_aggregator_aggregator_asn_destroy,
+ }
+ },
+ {
+ .xpath = "/frr-route-map:lib/route-map/entry/set-action/rmap-set-action/frr-bgp-route-map:aggregator/aggregator-address",
+ .cbs = {
+ .modify = lib_route_map_entry_set_action_rmap_set_action_aggregator_aggregator_address_modify,
+ .destroy = lib_route_map_entry_set_action_rmap_set_action_aggregator_aggregator_address_destroy,
+ }
+ },
+ {
+ .xpath = "/frr-route-map:lib/route-map/entry/set-action/rmap-set-action/frr-bgp-route-map:comm-list-name",
+ .cbs = {
+ .modify = lib_route_map_entry_set_action_rmap_set_action_comm_list_name_modify,
+ .destroy = lib_route_map_entry_set_action_rmap_set_action_comm_list_name_destroy,
+ }
+ },
+ {
+ .xpath = "/frr-route-map:lib/route-map/entry/set-action/rmap-set-action/frr-bgp-route-map:extcommunity-lb",
+ .cbs = {
+ .apply_finish = lib_route_map_entry_set_action_rmap_set_action_extcommunity_lb_finish,
+ }
+ },
+ {
+ .xpath = "/frr-route-map:lib/route-map/entry/set-action/rmap-set-action/frr-bgp-route-map:extcommunity-lb/lb-type",
+ .cbs = {
+ .modify = lib_route_map_entry_set_action_rmap_set_action_extcommunity_lb_lb_type_modify,
+ .destroy = lib_route_map_entry_set_action_rmap_set_action_extcommunity_lb_lb_type_destroy,
+ }
+ },
+ {
+ .xpath = "/frr-route-map:lib/route-map/entry/set-action/rmap-set-action/frr-bgp-route-map:extcommunity-lb/bandwidth",
+ .cbs = {
+ .modify = lib_route_map_entry_set_action_rmap_set_action_extcommunity_lb_bandwidth_modify,
+ .destroy = lib_route_map_entry_set_action_rmap_set_action_extcommunity_lb_bandwidth_destroy,
+ }
+ },
+ {
+ .xpath = "/frr-route-map:lib/route-map/entry/set-action/rmap-set-action/frr-bgp-route-map:extcommunity-lb/two-octet-as-specific",
+ .cbs = {
+ .modify = lib_route_map_entry_set_action_rmap_set_action_extcommunity_lb_two_octet_as_specific_modify,
+ .destroy = lib_route_map_entry_set_action_rmap_set_action_extcommunity_lb_two_octet_as_specific_destroy,
+ }
+ },
+ {
+ .xpath = NULL,
+ },
+ }
+};
diff --git a/bgpd/bgp_routemap_nb.h b/bgpd/bgp_routemap_nb.h
new file mode 100644
index 000000000..a15f52151
--- /dev/null
+++ b/bgpd/bgp_routemap_nb.h
@@ -0,0 +1,138 @@
+/*
+ * Copyright (C) 2020 Vmware
+ * Sarita Patra
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the Free
+ * Software Foundation; either version 2 of the License, or (at your option)
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; see the file COPYING; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef _FRR_BGP_ROUTEMAP_NB_H_
+#define _FRR_BGP_ROUTEMAP_NB_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+extern const struct frr_yang_module_info frr_bgp_route_map_info;
+
+/* prototypes */
+int lib_route_map_entry_match_condition_rmap_match_condition_local_preference_modify(struct nb_cb_modify_args *args);
+int lib_route_map_entry_match_condition_rmap_match_condition_local_preference_destroy(struct nb_cb_destroy_args *args);
+int lib_route_map_entry_match_condition_rmap_match_condition_script_modify(struct nb_cb_modify_args *args);
+int lib_route_map_entry_match_condition_rmap_match_condition_script_destroy(struct nb_cb_destroy_args *args);
+int lib_route_map_entry_match_condition_rmap_match_condition_origin_modify(struct nb_cb_modify_args *args);
+int lib_route_map_entry_match_condition_rmap_match_condition_origin_destroy(struct nb_cb_destroy_args *args);
+int lib_route_map_entry_match_condition_rmap_match_condition_rpki_modify(struct nb_cb_modify_args *args);
+int lib_route_map_entry_match_condition_rmap_match_condition_rpki_destroy(struct nb_cb_destroy_args *args);
+int lib_route_map_entry_match_condition_rmap_match_condition_probability_modify(struct nb_cb_modify_args *args);
+int lib_route_map_entry_match_condition_rmap_match_condition_probability_destroy(struct nb_cb_destroy_args *args);
+int lib_route_map_entry_match_condition_rmap_match_condition_source_vrf_modify(struct nb_cb_modify_args *args);
+int lib_route_map_entry_match_condition_rmap_match_condition_source_vrf_destroy(struct nb_cb_destroy_args *args);
+int lib_route_map_entry_match_condition_rmap_match_condition_peer_ipv4_address_modify(struct nb_cb_modify_args *args);
+int lib_route_map_entry_match_condition_rmap_match_condition_peer_ipv4_address_destroy(struct nb_cb_destroy_args *args);
+int lib_route_map_entry_match_condition_rmap_match_condition_peer_interface_modify(struct nb_cb_modify_args *args);
+int lib_route_map_entry_match_condition_rmap_match_condition_peer_interface_destroy(struct nb_cb_destroy_args *args);
+int lib_route_map_entry_match_condition_rmap_match_condition_peer_ipv6_address_modify(struct nb_cb_modify_args *args);
+int lib_route_map_entry_match_condition_rmap_match_condition_peer_ipv6_address_destroy(struct nb_cb_destroy_args *args);
+int lib_route_map_entry_match_condition_rmap_match_condition_peer_local_modify(struct nb_cb_modify_args *args);
+int lib_route_map_entry_match_condition_rmap_match_condition_peer_local_destroy(struct nb_cb_destroy_args *args);
+int lib_route_map_entry_match_condition_rmap_match_condition_access_list_num_modify(struct nb_cb_modify_args *args);
+int lib_route_map_entry_match_condition_rmap_match_condition_access_list_num_destroy(struct nb_cb_destroy_args *args);
+int lib_route_map_entry_match_condition_rmap_match_condition_access_list_num_extended_modify(struct nb_cb_modify_args *args);
+int lib_route_map_entry_match_condition_rmap_match_condition_access_list_num_extended_destroy(struct nb_cb_destroy_args *args);
+int lib_route_map_entry_match_condition_rmap_match_condition_list_name_modify(struct nb_cb_modify_args *args);
+int lib_route_map_entry_match_condition_rmap_match_condition_list_name_destroy(struct nb_cb_destroy_args *args);
+int lib_route_map_entry_match_condition_rmap_match_condition_evpn_default_route_create(struct nb_cb_create_args *args);
+int lib_route_map_entry_match_condition_rmap_match_condition_evpn_default_route_destroy(struct nb_cb_destroy_args *args);
+int lib_route_map_entry_match_condition_rmap_match_condition_evpn_vni_modify(struct nb_cb_modify_args *args);
+int lib_route_map_entry_match_condition_rmap_match_condition_evpn_vni_destroy(struct nb_cb_destroy_args *args);
+int lib_route_map_entry_match_condition_rmap_match_condition_evpn_route_type_modify(struct nb_cb_modify_args *args);
+int lib_route_map_entry_match_condition_rmap_match_condition_evpn_route_type_destroy(struct nb_cb_destroy_args *args);
+int lib_route_map_entry_match_condition_rmap_match_condition_route_distinguisher_modify(struct nb_cb_modify_args *args);
+int lib_route_map_entry_match_condition_rmap_match_condition_route_distinguisher_destroy(struct nb_cb_destroy_args *args);
+void lib_route_map_entry_match_condition_rmap_match_condition_comm_list_finish(struct nb_cb_apply_finish_args *args);
+int lib_route_map_entry_match_condition_rmap_match_condition_comm_list_comm_list_name_modify(struct nb_cb_modify_args *args);
+int lib_route_map_entry_match_condition_rmap_match_condition_comm_list_comm_list_name_destroy(struct nb_cb_destroy_args *args);
+int lib_route_map_entry_match_condition_rmap_match_condition_comm_list_comm_list_name_exact_match_modify(struct nb_cb_modify_args *args);
+int lib_route_map_entry_match_condition_rmap_match_condition_comm_list_comm_list_name_exact_match_destroy(struct nb_cb_destroy_args *args);
+int lib_route_map_entry_match_condition_rmap_match_condition_ipv4_address_modify(struct nb_cb_modify_args *args);
+int lib_route_map_entry_match_condition_rmap_match_condition_ipv4_address_destroy(struct nb_cb_destroy_args *args);
+int lib_route_map_entry_match_condition_rmap_match_condition_ipv6_address_modify(struct nb_cb_modify_args *args);
+int lib_route_map_entry_match_condition_rmap_match_condition_ipv6_address_destroy(struct nb_cb_destroy_args *args);
+int lib_route_map_entry_set_action_rmap_set_action_distance_modify(struct nb_cb_modify_args *args);
+int lib_route_map_entry_set_action_rmap_set_action_distance_destroy(struct nb_cb_destroy_args *args);
+int lib_route_map_entry_set_action_rmap_set_action_extcommunity_rt_modify(struct nb_cb_modify_args *args);
+int lib_route_map_entry_set_action_rmap_set_action_extcommunity_rt_destroy(struct nb_cb_destroy_args *args);
+int lib_route_map_entry_set_action_rmap_set_action_extcommunity_soo_modify(struct nb_cb_modify_args *args);
+int lib_route_map_entry_set_action_rmap_set_action_extcommunity_soo_destroy(struct nb_cb_destroy_args *args);
+int lib_route_map_entry_set_action_rmap_set_action_ipv4_address_modify(struct nb_cb_modify_args *args);
+int lib_route_map_entry_set_action_rmap_set_action_ipv4_address_destroy(struct nb_cb_destroy_args *args);
+int lib_route_map_entry_set_action_rmap_set_action_ipv4_nexthop_modify(struct nb_cb_modify_args *args);
+int lib_route_map_entry_set_action_rmap_set_action_ipv4_nexthop_destroy(struct nb_cb_destroy_args *args);
+int lib_route_map_entry_set_action_rmap_set_action_ipv6_address_modify(struct nb_cb_modify_args *args);
+int lib_route_map_entry_set_action_rmap_set_action_ipv6_address_destroy(struct nb_cb_destroy_args *args);
+int lib_route_map_entry_set_action_rmap_set_action_preference_modify(struct nb_cb_modify_args *args);
+int lib_route_map_entry_set_action_rmap_set_action_preference_destroy(struct nb_cb_destroy_args *args);
+int lib_route_map_entry_set_action_rmap_set_action_label_index_modify(struct nb_cb_modify_args *args);
+int lib_route_map_entry_set_action_rmap_set_action_label_index_destroy(struct nb_cb_destroy_args *args);
+int lib_route_map_entry_set_action_rmap_set_action_local_pref_modify(struct nb_cb_modify_args *args);
+int lib_route_map_entry_set_action_rmap_set_action_local_pref_destroy(struct nb_cb_destroy_args *args);
+int lib_route_map_entry_set_action_rmap_set_action_weight_modify(struct nb_cb_modify_args *args);
+int lib_route_map_entry_set_action_rmap_set_action_weight_destroy(struct nb_cb_destroy_args *args);
+int lib_route_map_entry_set_action_rmap_set_action_origin_modify(struct nb_cb_modify_args *args);
+int lib_route_map_entry_set_action_rmap_set_action_origin_destroy(struct nb_cb_destroy_args *args);
+int lib_route_map_entry_set_action_rmap_set_action_originator_id_modify(struct nb_cb_modify_args *args);
+int lib_route_map_entry_set_action_rmap_set_action_originator_id_destroy(struct nb_cb_destroy_args *args);
+int lib_route_map_entry_set_action_rmap_set_action_table_modify(struct nb_cb_modify_args *args);
+int lib_route_map_entry_set_action_rmap_set_action_table_destroy(struct nb_cb_destroy_args *args);
+int lib_route_map_entry_set_action_rmap_set_action_atomic_aggregate_create(struct nb_cb_create_args *args);
+int lib_route_map_entry_set_action_rmap_set_action_atomic_aggregate_destroy(struct nb_cb_destroy_args *args);
+int lib_route_map_entry_set_action_rmap_set_action_prepend_as_path_modify(struct nb_cb_modify_args *args);
+int lib_route_map_entry_set_action_rmap_set_action_prepend_as_path_destroy(struct nb_cb_destroy_args *args);
+int lib_route_map_entry_set_action_rmap_set_action_last_as_modify(struct nb_cb_modify_args *args);
+int lib_route_map_entry_set_action_rmap_set_action_last_as_destroy(struct nb_cb_destroy_args *args);
+int lib_route_map_entry_set_action_rmap_set_action_exclude_as_path_modify(struct nb_cb_modify_args *args);
+int lib_route_map_entry_set_action_rmap_set_action_exclude_as_path_destroy(struct nb_cb_destroy_args *args);
+int lib_route_map_entry_set_action_rmap_set_action_community_none_modify(struct nb_cb_modify_args *args);
+int lib_route_map_entry_set_action_rmap_set_action_community_none_destroy(struct nb_cb_destroy_args *args);
+int lib_route_map_entry_set_action_rmap_set_action_community_string_modify(struct nb_cb_modify_args *args);
+int lib_route_map_entry_set_action_rmap_set_action_community_string_destroy(struct nb_cb_destroy_args *args);
+int lib_route_map_entry_set_action_rmap_set_action_large_community_none_modify(struct nb_cb_modify_args *args);
+int lib_route_map_entry_set_action_rmap_set_action_large_community_none_destroy(struct nb_cb_destroy_args *args);
+int lib_route_map_entry_set_action_rmap_set_action_large_community_string_modify(struct nb_cb_modify_args *args);
+int lib_route_map_entry_set_action_rmap_set_action_large_community_string_destroy(struct nb_cb_destroy_args *args);
+void lib_route_map_entry_set_action_rmap_set_action_aggregator_finish(struct nb_cb_apply_finish_args *args);
+int lib_route_map_entry_set_action_rmap_set_action_aggregator_aggregator_asn_modify(struct nb_cb_modify_args *args);
+int lib_route_map_entry_set_action_rmap_set_action_aggregator_aggregator_asn_destroy(struct nb_cb_destroy_args *args);
+int lib_route_map_entry_set_action_rmap_set_action_aggregator_aggregator_address_modify(struct nb_cb_modify_args *args);
+int lib_route_map_entry_set_action_rmap_set_action_aggregator_aggregator_address_destroy(struct nb_cb_destroy_args *args);
+int lib_route_map_entry_set_action_rmap_set_action_comm_list_num_modify(struct nb_cb_modify_args *args);
+int lib_route_map_entry_set_action_rmap_set_action_comm_list_num_destroy(struct nb_cb_destroy_args *args);
+int lib_route_map_entry_set_action_rmap_set_action_comm_list_num_extended_modify(struct nb_cb_modify_args *args);
+int lib_route_map_entry_set_action_rmap_set_action_comm_list_num_extended_destroy(struct nb_cb_destroy_args *args);
+int lib_route_map_entry_set_action_rmap_set_action_comm_list_name_modify(struct nb_cb_modify_args *args);
+int lib_route_map_entry_set_action_rmap_set_action_comm_list_name_destroy(struct nb_cb_destroy_args *args);
+void lib_route_map_entry_set_action_rmap_set_action_extcommunity_lb_finish(struct nb_cb_apply_finish_args *args);
+int lib_route_map_entry_set_action_rmap_set_action_extcommunity_lb_lb_type_modify(struct nb_cb_modify_args *args);
+int lib_route_map_entry_set_action_rmap_set_action_extcommunity_lb_lb_type_destroy(struct nb_cb_destroy_args *args);
+int lib_route_map_entry_set_action_rmap_set_action_extcommunity_lb_bandwidth_modify(struct nb_cb_modify_args *args);
+int lib_route_map_entry_set_action_rmap_set_action_extcommunity_lb_bandwidth_destroy(struct nb_cb_destroy_args *args);
+int lib_route_map_entry_set_action_rmap_set_action_extcommunity_lb_two_octet_as_specific_modify(struct nb_cb_modify_args *args);
+int lib_route_map_entry_set_action_rmap_set_action_extcommunity_lb_two_octet_as_specific_destroy(struct nb_cb_destroy_args *args);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/bgpd/bgp_routemap_nb_config.c b/bgpd/bgp_routemap_nb_config.c
new file mode 100644
index 000000000..ec6284273
--- /dev/null
+++ b/bgpd/bgp_routemap_nb_config.c
@@ -0,0 +1,2637 @@
+/*
+ * Copyright (C) 2020 Vmware
+ * Sarita Patra
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the Free
+ * Software Foundation; either version 2 of the License, or (at your option)
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; see the file COPYING; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "lib/command.h"
+#include "lib/log.h"
+#include "lib/northbound.h"
+#include "lib/routemap.h"
+#include "bgpd/bgpd.h"
+#include "bgpd/bgp_routemap_nb.h"
+
+/* Add bgp route map rule. */
+static int bgp_route_match_add(struct route_map_index *index,
+ const char *command, const char *arg,
+ route_map_event_t type,
+ char *errmsg, size_t errmsg_len)
+{
+ int retval = CMD_SUCCESS;
+ enum rmap_compile_rets ret;
+
+ ret = route_map_add_match(index, command, arg, type);
+ switch (ret) {
+ case RMAP_RULE_MISSING:
+ snprintf(errmsg, errmsg_len, "%% BGP Can't find rule.");
+ retval = CMD_WARNING_CONFIG_FAILED;
+ break;
+ case RMAP_COMPILE_ERROR:
+ snprintf(errmsg, errmsg_len, "%% BGP Argument is malformed.");
+ retval = CMD_WARNING_CONFIG_FAILED;
+ break;
+ case RMAP_COMPILE_SUCCESS:
+ /*
+ * Intentionally doing nothing here.
+ */
+ break;
+ }
+
+ return retval;
+}
+
+/* Delete bgp route map rule. */
+static int bgp_route_match_delete(struct route_map_index *index,
+ const char *command, const char *arg,
+ route_map_event_t type,
+ char *errmsg, size_t errmsg_len)
+{
+ enum rmap_compile_rets ret;
+ int retval = CMD_SUCCESS;
+ char *dep_name = NULL;
+ const char *tmpstr;
+ char *rmap_name = NULL;
+
+ if (type != RMAP_EVENT_MATCH_DELETED) {
+ /* ignore the mundane, the types without any dependency */
+ if (arg == NULL) {
+ if ((tmpstr = route_map_get_match_arg(index, command))
+ != NULL)
+ dep_name =
+ XSTRDUP(MTYPE_ROUTE_MAP_RULE, tmpstr);
+ } else {
+ dep_name = XSTRDUP(MTYPE_ROUTE_MAP_RULE, arg);
+ }
+ rmap_name = XSTRDUP(MTYPE_ROUTE_MAP_NAME, index->map->name);
+ }
+
+ ret = route_map_delete_match(index, command, dep_name, type);
+ switch (ret) {
+ case RMAP_RULE_MISSING:
+ snprintf(errmsg, errmsg_len, "%% BGP Can't find rule.");
+ retval = CMD_WARNING_CONFIG_FAILED;
+ break;
+ case RMAP_COMPILE_ERROR:
+ snprintf(errmsg, errmsg_len,
+ "%% BGP Argument is malformed.");
+ retval = CMD_WARNING_CONFIG_FAILED;
+ break;
+ case RMAP_COMPILE_SUCCESS:
+ /*
+ * Nothing to do here
+ */
+ break;
+ }
+
+ XFREE(MTYPE_ROUTE_MAP_RULE, dep_name);
+ XFREE(MTYPE_ROUTE_MAP_NAME, rmap_name);
+
+ return retval;
+}
+
+/*
+ * XPath: /frr-route-map:lib/route-map/entry/match-condition/rmap-match-condition/frr-bgp-route-map:local-preference
+ */
+int
+lib_route_map_entry_match_condition_rmap_match_condition_local_preference_modify(
+ struct nb_cb_modify_args *args)
+{
+ struct routemap_hook_context *rhc;
+ const char *local_pref;
+ enum rmap_compile_rets ret;
+
+ switch (args->event) {
+ case NB_EV_VALIDATE:
+ case NB_EV_PREPARE:
+ case NB_EV_ABORT:
+ break;
+ case NB_EV_APPLY:
+ /* Add configuration. */
+ rhc = nb_running_get_entry(args->dnode, NULL, true);
+ local_pref = yang_dnode_get_string(args->dnode, NULL);
+
+ /* Set destroy information. */
+ rhc->rhc_mhook = bgp_route_match_delete;
+ rhc->rhc_rule = "local-preference";
+ rhc->rhc_event = RMAP_EVENT_MATCH_DELETED;
+
+ ret = bgp_route_match_add(rhc->rhc_rmi, "local-preference",
+ local_pref, RMAP_EVENT_MATCH_ADDED,
+ args->errmsg, args->errmsg_len);
+
+ if (ret != RMAP_COMPILE_SUCCESS) {
+ rhc->rhc_mhook = NULL;
+ return NB_ERR_INCONSISTENCY;
+ }
+ }
+
+ return NB_OK;
+}
+
+int
+lib_route_map_entry_match_condition_rmap_match_condition_local_preference_destroy(
+ struct nb_cb_destroy_args *args)
+{
+ switch (args->event) {
+ case NB_EV_VALIDATE:
+ case NB_EV_PREPARE:
+ case NB_EV_ABORT:
+ break;
+ case NB_EV_APPLY:
+ return lib_route_map_entry_match_destroy(args);
+ }
+
+ return NB_OK;
+}
+
+/*
+ * XPath: /frr-route-map:lib/route-map/entry/match-condition/rmap-match-condition/frr-bgp-route-map:script
+ */
+int
+lib_route_map_entry_match_condition_rmap_match_condition_script_modify(
+ struct nb_cb_modify_args *args)
+{
+ struct routemap_hook_context *rhc;
+ const char *script;
+ enum rmap_compile_rets ret;
+
+ switch (args->event) {
+ case NB_EV_VALIDATE:
+ case NB_EV_PREPARE:
+ case NB_EV_ABORT:
+ break;
+ case NB_EV_APPLY:
+ /* Add configuration. */
+ rhc = nb_running_get_entry(args->dnode, NULL, true);
+ script = yang_dnode_get_string(args->dnode, NULL);
+
+ /* Set destroy information. */
+ rhc->rhc_mhook = bgp_route_match_delete;
+ rhc->rhc_rule = "script";
+ rhc->rhc_event = RMAP_EVENT_MATCH_DELETED;
+
+ ret = bgp_route_match_add(rhc->rhc_rmi, "script",
+ script, RMAP_EVENT_MATCH_ADDED,
+ args->errmsg, args->errmsg_len);
+
+ if (ret != RMAP_COMPILE_SUCCESS) {
+ rhc->rhc_mhook = NULL;
+ return NB_ERR_INCONSISTENCY;
+ }
+ }
+
+ return NB_OK;
+}
+
+int
+lib_route_map_entry_match_condition_rmap_match_condition_script_destroy(
+ struct nb_cb_destroy_args *args)
+{
+ switch (args->event) {
+ case NB_EV_VALIDATE:
+ case NB_EV_PREPARE:
+ case NB_EV_ABORT:
+ break;
+ case NB_EV_APPLY:
+ return lib_route_map_entry_match_destroy(args);
+ }
+
+ return NB_OK;
+}
+
+/*
+ * XPath: /frr-route-map:lib/route-map/entry/match-condition/rmap-match-condition/frr-bgp-route-map:origin
+ */
+int
+lib_route_map_entry_match_condition_rmap_match_condition_origin_modify(
+ struct nb_cb_modify_args *args)
+{
+ struct routemap_hook_context *rhc;
+ const char *origin;
+ enum rmap_compile_rets ret;
+
+ switch (args->event) {
+ case NB_EV_VALIDATE:
+ case NB_EV_PREPARE:
+ case NB_EV_ABORT:
+ break;
+ case NB_EV_APPLY:
+ /* Add configuration. */
+ rhc = nb_running_get_entry(args->dnode, NULL, true);
+ origin = yang_dnode_get_string(args->dnode, NULL);
+
+ /* Set destroy information. */
+ rhc->rhc_mhook = bgp_route_match_delete;
+ rhc->rhc_rule = "origin";
+ rhc->rhc_event = RMAP_EVENT_MATCH_DELETED;
+
+ ret = bgp_route_match_add(rhc->rhc_rmi, "origin", origin,
+ RMAP_EVENT_MATCH_ADDED,
+ args->errmsg, args->errmsg_len);
+
+ if (ret != RMAP_COMPILE_SUCCESS) {
+ rhc->rhc_mhook = NULL;
+ return NB_ERR_INCONSISTENCY;
+ }
+ }
+
+ return NB_OK;
+}
+
+int
+lib_route_map_entry_match_condition_rmap_match_condition_origin_destroy(
+ struct nb_cb_destroy_args *args)
+{
+ switch (args->event) {
+ case NB_EV_VALIDATE:
+ case NB_EV_PREPARE:
+ case NB_EV_ABORT:
+ break;
+ case NB_EV_APPLY:
+ return lib_route_map_entry_match_destroy(args);
+ }
+
+ return NB_OK;
+}
+
+/*
+ * XPath: /frr-route-map:lib/route-map/entry/match-condition/rmap-match-condition/frr-bgp-route-map:rpki
+ */
+int
+lib_route_map_entry_match_condition_rmap_match_condition_rpki_modify(
+ struct nb_cb_modify_args *args)
+{
+ struct routemap_hook_context *rhc;
+ const char *rpki;
+ enum rmap_compile_rets ret;
+
+ switch (args->event) {
+ case NB_EV_VALIDATE:
+ case NB_EV_PREPARE:
+ case NB_EV_ABORT:
+ break;
+ case NB_EV_APPLY:
+ /* Add configuration. */
+ rhc = nb_running_get_entry(args->dnode, NULL, true);
+ rpki = yang_dnode_get_string(args->dnode, NULL);
+
+ /* Set destroy information. */
+ rhc->rhc_mhook = bgp_route_match_delete;
+ rhc->rhc_rule = "rpki";
+ rhc->rhc_event = RMAP_EVENT_MATCH_DELETED;
+
+ ret = bgp_route_match_add(rhc->rhc_rmi, "rpki", rpki,
+ RMAP_EVENT_MATCH_ADDED,
+ args->errmsg, args->errmsg_len);
+
+ if (ret != RMAP_COMPILE_SUCCESS) {
+ rhc->rhc_mhook = NULL;
+ return NB_ERR_INCONSISTENCY;
+ }
+ }
+
+ return NB_OK;
+}
+
+int
+lib_route_map_entry_match_condition_rmap_match_condition_rpki_destroy(
+ struct nb_cb_destroy_args *args)
+{
+ switch (args->event) {
+ case NB_EV_VALIDATE:
+ case NB_EV_PREPARE:
+ case NB_EV_ABORT:
+ break;
+ case NB_EV_APPLY:
+ return lib_route_map_entry_match_destroy(args);
+ }
+
+ return NB_OK;
+}
+
+/*
+ * XPath: /frr-route-map:lib/route-map/entry/match-condition/rmap-match-condition/frr-bgp-route-map:probability
+ */
+int
+lib_route_map_entry_match_condition_rmap_match_condition_probability_modify(
+ struct nb_cb_modify_args *args)
+{
+ struct routemap_hook_context *rhc;
+ const char *probability;
+ enum rmap_compile_rets ret;
+
+ switch (args->event) {
+ case NB_EV_VALIDATE:
+ case NB_EV_PREPARE:
+ case NB_EV_ABORT:
+ break;
+ case NB_EV_APPLY:
+ /* Add configuration. */
+ rhc = nb_running_get_entry(args->dnode, NULL, true);
+ probability = yang_dnode_get_string(args->dnode, NULL);
+
+ /* Set destroy information. */
+ rhc->rhc_mhook = bgp_route_match_delete;
+ rhc->rhc_rule = "probability";
+ rhc->rhc_event = RMAP_EVENT_MATCH_DELETED;
+
+ ret = bgp_route_match_add(rhc->rhc_rmi, "probability",
+ probability, RMAP_EVENT_MATCH_ADDED,
+ args->errmsg, args->errmsg_len);
+
+ if (ret != RMAP_COMPILE_SUCCESS) {
+ rhc->rhc_mhook = NULL;
+ return NB_ERR_INCONSISTENCY;
+ }
+ }
+
+ return NB_OK;
+}
+
+int
+lib_route_map_entry_match_condition_rmap_match_condition_probability_destroy(
+ struct nb_cb_destroy_args *args)
+{
+ switch (args->event) {
+ case NB_EV_VALIDATE:
+ case NB_EV_PREPARE:
+ case NB_EV_ABORT:
+ case NB_EV_APPLY:
+ return lib_route_map_entry_match_destroy(args);
+ }
+
+ return NB_OK;
+}
+
+/*
+ * XPath: /frr-route-map:lib/route-map/entry/match-condition/rmap-match-condition/frr-bgp-route-map:source-vrf
+ */
+int
+lib_route_map_entry_match_condition_rmap_match_condition_source_vrf_modify(
+ struct nb_cb_modify_args *args)
+{
+ struct routemap_hook_context *rhc;
+ const char *vrf;
+ enum rmap_compile_rets ret;
+
+ switch (args->event) {
+ case NB_EV_VALIDATE:
+ case NB_EV_PREPARE:
+ case NB_EV_ABORT:
+ break;
+ case NB_EV_APPLY:
+ /* Add configuration. */
+ rhc = nb_running_get_entry(args->dnode, NULL, true);
+ vrf = yang_dnode_get_string(args->dnode, NULL);
+
+ /* Set destroy information. */
+ rhc->rhc_mhook = bgp_route_match_delete;
+ rhc->rhc_rule = "source-vrf";
+ rhc->rhc_event = RMAP_EVENT_MATCH_DELETED;
+
+ ret = bgp_route_match_add(rhc->rhc_rmi, "source-vrf", vrf,
+ RMAP_EVENT_MATCH_ADDED,
+ args->errmsg, args->errmsg_len);
+
+ if (ret != RMAP_COMPILE_SUCCESS) {
+ rhc->rhc_mhook = NULL;
+ return NB_ERR_INCONSISTENCY;
+ }
+ }
+
+ return NB_OK;
+}
+
+int
+lib_route_map_entry_match_condition_rmap_match_condition_source_vrf_destroy(
+ struct nb_cb_destroy_args *args)
+{
+ switch (args->event) {
+ case NB_EV_VALIDATE:
+ case NB_EV_PREPARE:
+ case NB_EV_ABORT:
+ break;
+ case NB_EV_APPLY:
+ return lib_route_map_entry_match_destroy(args);
+ }
+
+ return NB_OK;
+}
+
+/*
+ * XPath: /frr-route-map:lib/route-map/entry/match-condition/rmap-match-condition/frr-bgp-route-map:peer-ipv4-address
+ */
+int
+lib_route_map_entry_match_condition_rmap_match_condition_peer_ipv4_address_modify(
+ struct nb_cb_modify_args *args)
+{
+ struct routemap_hook_context *rhc;
+ const char *peer;
+ enum rmap_compile_rets ret;
+
+ switch (args->event) {
+ case NB_EV_VALIDATE:
+ case NB_EV_PREPARE:
+ case NB_EV_ABORT:
+ break;
+ case NB_EV_APPLY:
+ /* Add configuration. */
+ rhc = nb_running_get_entry(args->dnode, NULL, true);
+ peer = yang_dnode_get_string(args->dnode, NULL);
+
+ /* Set destroy information. */
+ rhc->rhc_mhook = bgp_route_match_delete;
+ rhc->rhc_rule = "peer";
+ rhc->rhc_event = RMAP_EVENT_MATCH_DELETED;
+
+ ret = bgp_route_match_add(rhc->rhc_rmi, "peer", peer,
+ RMAP_EVENT_MATCH_ADDED,
+ args->errmsg, args->errmsg_len);
+
+ if (ret != RMAP_COMPILE_SUCCESS) {
+ rhc->rhc_mhook = NULL;
+ return NB_ERR_INCONSISTENCY;
+ }
+ }
+
+ return NB_OK;
+}
+
+int
+lib_route_map_entry_match_condition_rmap_match_condition_peer_ipv4_address_destroy(
+ struct nb_cb_destroy_args *args)
+{
+ switch (args->event) {
+ case NB_EV_VALIDATE:
+ case NB_EV_PREPARE:
+ case NB_EV_ABORT:
+ break;
+ case NB_EV_APPLY:
+ return lib_route_map_entry_match_destroy(args);
+ }
+
+ return NB_OK;
+}
+
+/*
+ * XPath: /frr-route-map:lib/route-map/entry/match-condition/rmap-match-condition/frr-bgp-route-map:peer-interface
+ */
+int
+lib_route_map_entry_match_condition_rmap_match_condition_peer_interface_modify(
+ struct nb_cb_modify_args *args)
+{
+ struct routemap_hook_context *rhc;
+ const char *peer;
+ enum rmap_compile_rets ret;
+
+ switch (args->event) {
+ case NB_EV_VALIDATE:
+ case NB_EV_PREPARE:
+ case NB_EV_ABORT:
+ break;
+ case NB_EV_APPLY:
+ /* Add configuration. */
+ rhc = nb_running_get_entry(args->dnode, NULL, true);
+ peer = yang_dnode_get_string(args->dnode, NULL);
+
+ /* Set destroy information. */
+ rhc->rhc_mhook = bgp_route_match_delete;
+ rhc->rhc_rule = "peer";
+ rhc->rhc_event = RMAP_EVENT_MATCH_DELETED;
+
+ ret = bgp_route_match_add(rhc->rhc_rmi, "peer", peer,
+ RMAP_EVENT_MATCH_ADDED,
+ args->errmsg, args->errmsg_len);
+
+ if (ret != RMAP_COMPILE_SUCCESS) {
+ rhc->rhc_mhook = NULL;
+ return NB_ERR_INCONSISTENCY;
+ }
+ }
+
+ return NB_OK;
+}
+
+int
+lib_route_map_entry_match_condition_rmap_match_condition_peer_interface_destroy(
+ struct nb_cb_destroy_args *args)
+{
+ switch (args->event) {
+ case NB_EV_VALIDATE:
+ case NB_EV_PREPARE:
+ case NB_EV_ABORT:
+ break;
+ case NB_EV_APPLY:
+ return lib_route_map_entry_match_destroy(args);
+ }
+
+ return NB_OK;
+}
+
+/*
+ * XPath: /frr-route-map:lib/route-map/entry/match-condition/rmap-match-condition/frr-bgp-route-map:peer-ipv6-address
+ */
+int
+lib_route_map_entry_match_condition_rmap_match_condition_peer_ipv6_address_modify(
+ struct nb_cb_modify_args *args)
+{
+ struct routemap_hook_context *rhc;
+ const char *peer;
+ enum rmap_compile_rets ret;
+
+ switch (args->event) {
+ case NB_EV_VALIDATE:
+ case NB_EV_PREPARE:
+ case NB_EV_ABORT:
+ break;
+ case NB_EV_APPLY:
+ /* Add configuration. */
+ rhc = nb_running_get_entry(args->dnode, NULL, true);
+ peer = yang_dnode_get_string(args->dnode, NULL);
+
+ /* Set destroy information. */
+ rhc->rhc_mhook = bgp_route_match_delete;
+ rhc->rhc_rule = "peer";
+ rhc->rhc_event = RMAP_EVENT_MATCH_DELETED;
+
+ ret = bgp_route_match_add(rhc->rhc_rmi, "peer", peer,
+ RMAP_EVENT_MATCH_ADDED,
+ args->errmsg, args->errmsg_len);
+
+ if (ret != RMAP_COMPILE_SUCCESS) {
+ rhc->rhc_mhook = NULL;
+ return NB_ERR_INCONSISTENCY;
+ }
+ }
+
+ return NB_OK;
+}
+
+int
+lib_route_map_entry_match_condition_rmap_match_condition_peer_ipv6_address_destroy(
+ struct nb_cb_destroy_args *args)
+{
+ switch (args->event) {
+ case NB_EV_VALIDATE:
+ case NB_EV_PREPARE:
+ case NB_EV_ABORT:
+ break;
+ case NB_EV_APPLY:
+ return lib_route_map_entry_match_destroy(args);
+ }
+
+ return NB_OK;
+}
+
+/*
+ * XPath: /frr-route-map:lib/route-map/entry/match-condition/rmap-match-condition/frr-bgp-route-map:peer-local
+ */
+int
+lib_route_map_entry_match_condition_rmap_match_condition_peer_local_modify(
+ struct nb_cb_modify_args *args)
+{
+ struct routemap_hook_context *rhc;
+ bool value;
+ enum rmap_compile_rets ret;
+
+ switch (args->event) {
+ case NB_EV_VALIDATE:
+ case NB_EV_PREPARE:
+ case NB_EV_ABORT:
+ break;
+ case NB_EV_APPLY:
+ /* Add configuration. */
+ rhc = nb_running_get_entry(args->dnode, NULL, true);
+ value = yang_dnode_get_bool(args->dnode, NULL);
+
+ /* Set destroy information. */
+ rhc->rhc_mhook = bgp_route_match_delete;
+ rhc->rhc_rule = "peer";
+ rhc->rhc_event = RMAP_EVENT_MATCH_DELETED;
+
+ if (value) {
+ ret = bgp_route_match_add(rhc->rhc_rmi, "peer",
+ "local",
+ RMAP_EVENT_MATCH_ADDED,
+ args->errmsg, args->errmsg_len);
+
+ if (ret != RMAP_COMPILE_SUCCESS) {
+ rhc->rhc_mhook = NULL;
+ return NB_ERR_INCONSISTENCY;
+ }
+ }
+ }
+
+ return NB_OK;
+}
+
+int
+lib_route_map_entry_match_condition_rmap_match_condition_peer_local_destroy(
+ struct nb_cb_destroy_args *args)
+{
+ switch (args->event) {
+ case NB_EV_VALIDATE:
+ case NB_EV_PREPARE:
+ case NB_EV_ABORT:
+ break;
+ case NB_EV_APPLY:
+ return lib_route_map_entry_match_destroy(args);
+ }
+
+ return NB_OK;
+}
+
+/*
+ * XPath: /frr-route-map:lib/route-map/entry/match-condition/rmap-match-condition/frr-bgp-route-map:list-name
+ */
+int
+lib_route_map_entry_match_condition_rmap_match_condition_list_name_modify(
+ struct nb_cb_modify_args *args)
+{
+ struct routemap_hook_context *rhc;
+ const char *list_name;
+ enum rmap_compile_rets ret = RMAP_COMPILE_SUCCESS;
+ const char *condition;
+
+ switch (args->event) {
+ case NB_EV_VALIDATE:
+ case NB_EV_PREPARE:
+ case NB_EV_ABORT:
+ break;
+ case NB_EV_APPLY:
+ /* Add configuration. */
+ rhc = nb_running_get_entry(args->dnode, NULL, true);
+ list_name = yang_dnode_get_string(args->dnode, NULL);
+ condition = yang_dnode_get_string(args->dnode,
+ "../../frr-route-map:condition");
+
+ if (IS_MATCH_AS_LIST(condition)) {
+ /* Set destroy information. */
+ rhc->rhc_mhook = bgp_route_match_delete;
+ rhc->rhc_rule = "as-path";
+ rhc->rhc_event = RMAP_EVENT_ASLIST_DELETED;
+
+ ret = bgp_route_match_add(rhc->rhc_rmi, "as-path",
+ list_name, RMAP_EVENT_ASLIST_ADDED,
+ args->errmsg, args->errmsg_len);
+ } else if (IS_MATCH_MAC_LIST(condition)) {
+ /* Set destroy information. */
+ rhc->rhc_mhook = bgp_route_match_delete;
+ rhc->rhc_rule = "mac address";
+ rhc->rhc_event = RMAP_EVENT_FILTER_DELETED;
+
+ ret = bgp_route_match_add(rhc->rhc_rmi,
+ "mac address",
+ list_name,
+ RMAP_EVENT_FILTER_ADDED,
+ args->errmsg, args->errmsg_len);
+ } else if (IS_MATCH_ROUTE_SRC(condition)) {
+ /* Set destroy information. */
+ rhc->rhc_mhook = bgp_route_match_delete;
+ rhc->rhc_rule = "ip route-source";
+ rhc->rhc_event = RMAP_EVENT_FILTER_DELETED;
+
+ ret = bgp_route_match_add(rhc->rhc_rmi,
+ "ip route-source",
+ list_name, RMAP_EVENT_FILTER_ADDED,
+ args->errmsg, args->errmsg_len);
+ } else if (IS_MATCH_ROUTE_SRC_PL(condition)) {
+ /* Set destroy information. */
+ rhc->rhc_mhook = bgp_route_match_delete;
+ rhc->rhc_rule = "ip route-source prefix-list";
+ rhc->rhc_event = RMAP_EVENT_PLIST_DELETED;
+
+ ret = bgp_route_match_add(rhc->rhc_rmi,
+ "ip route-source prefix-list",
+ list_name, RMAP_EVENT_PLIST_ADDED,
+ args->errmsg, args->errmsg_len);
+ }
+
+ if (ret != RMAP_COMPILE_SUCCESS) {
+ rhc->rhc_mhook = NULL;
+ return NB_ERR_INCONSISTENCY;
+ }
+ }
+
+ return NB_OK;
+}
+
+int
+lib_route_map_entry_match_condition_rmap_match_condition_list_name_destroy(
+ struct nb_cb_destroy_args *args)
+{
+ switch (args->event) {
+ case NB_EV_VALIDATE:
+ case NB_EV_PREPARE:
+ case NB_EV_ABORT:
+ break;
+ case NB_EV_APPLY:
+ return lib_route_map_entry_match_destroy(args);
+ }
+
+ return NB_OK;
+}
+
+/*
+ * XPath: /frr-route-map:lib/route-map/entry/match-condition/rmap-match-condition/frr-bgp-route-map:evpn-default-route
+ */
+int
+lib_route_map_entry_match_condition_rmap_match_condition_evpn_default_route_create(
+ struct nb_cb_create_args *args)
+{
+ struct routemap_hook_context *rhc;
+ enum rmap_compile_rets ret;
+
+ switch (args->event) {
+ case NB_EV_VALIDATE:
+ case NB_EV_PREPARE:
+ case NB_EV_ABORT:
+ break;
+ case NB_EV_APPLY:
+ /* Add configuration. */
+ rhc = nb_running_get_entry(args->dnode, NULL, true);
+
+ /* Set destroy information. */
+ rhc->rhc_mhook = bgp_route_match_delete;
+ rhc->rhc_rule = "evpn default-route";
+ rhc->rhc_event = RMAP_EVENT_MATCH_DELETED;
+
+ ret = bgp_route_match_add(rhc->rhc_rmi, "evpn default-route",
+ NULL, RMAP_EVENT_MATCH_ADDED,
+ args->errmsg, args->errmsg_len);
+
+ if (ret != RMAP_COMPILE_SUCCESS) {
+ rhc->rhc_mhook = NULL;
+ return NB_ERR_INCONSISTENCY;
+ }
+ }
+
+ return NB_OK;
+}
+
+int
+lib_route_map_entry_match_condition_rmap_match_condition_evpn_default_route_destroy(
+ struct nb_cb_destroy_args *args)
+{
+ switch (args->event) {
+ case NB_EV_VALIDATE:
+ case NB_EV_PREPARE:
+ case NB_EV_ABORT:
+ break;
+ case NB_EV_APPLY:
+ return lib_route_map_entry_match_destroy(args);
+ }
+
+ return NB_OK;
+}
+
+/*
+ * XPath: /frr-route-map:lib/route-map/entry/match-condition/rmap-match-condition/frr-bgp-route-map:evpn-vni
+ */
+int
+lib_route_map_entry_match_condition_rmap_match_condition_evpn_vni_modify(
+ struct nb_cb_modify_args *args)
+{
+ struct routemap_hook_context *rhc;
+ const char *vni;
+ enum rmap_compile_rets ret;
+
+ switch (args->event) {
+ case NB_EV_VALIDATE:
+ case NB_EV_PREPARE:
+ case NB_EV_ABORT:
+ break;
+ case NB_EV_APPLY:
+ /* Add configuration. */
+ rhc = nb_running_get_entry(args->dnode, NULL, true);
+ vni = yang_dnode_get_string(args->dnode, NULL);
+
+ /* Set destroy information. */
+ rhc->rhc_mhook = bgp_route_match_delete;
+ rhc->rhc_rule = "evpn vni";
+ rhc->rhc_event = RMAP_EVENT_MATCH_DELETED;
+
+ ret = bgp_route_match_add(rhc->rhc_rmi, "evpn vni", vni,
+ RMAP_EVENT_MATCH_ADDED,
+ args->errmsg, args->errmsg_len);
+
+ if (ret != RMAP_COMPILE_SUCCESS) {
+ rhc->rhc_mhook = NULL;
+ return NB_ERR_INCONSISTENCY;
+ }
+ }
+
+ return NB_OK;
+}
+
+int
+lib_route_map_entry_match_condition_rmap_match_condition_evpn_vni_destroy(
+ struct nb_cb_destroy_args *args)
+{
+ switch (args->event) {
+ case NB_EV_VALIDATE:
+ case NB_EV_PREPARE:
+ case NB_EV_ABORT:
+ break;
+ case NB_EV_APPLY:
+ return lib_route_map_entry_match_destroy(args);
+ }
+
+ return NB_OK;
+}
+
+/*
+ * XPath: /frr-route-map:lib/route-map/entry/match-condition/rmap-match-condition/frr-bgp-route-map:evpn-route-type
+ */
+int
+lib_route_map_entry_match_condition_rmap_match_condition_evpn_route_type_modify(
+ struct nb_cb_modify_args *args)
+{
+ struct routemap_hook_context *rhc;
+ const char *type;
+ enum rmap_compile_rets ret;
+
+ switch (args->event) {
+ case NB_EV_VALIDATE:
+ case NB_EV_PREPARE:
+ case NB_EV_ABORT:
+ break;
+ case NB_EV_APPLY:
+ /* Add configuration. */
+ rhc = nb_running_get_entry(args->dnode, NULL, true);
+ type = yang_dnode_get_string(args->dnode, NULL);
+
+ /* Set destroy information. */
+ rhc->rhc_mhook = bgp_route_match_delete;
+ rhc->rhc_rule = "evpn route-type";
+ rhc->rhc_event = RMAP_EVENT_MATCH_DELETED;
+
+ ret = bgp_route_match_add(rhc->rhc_rmi, "evpn route-type",
+ type,
+ RMAP_EVENT_MATCH_ADDED,
+ args->errmsg, args->errmsg_len);
+
+ if (ret != RMAP_COMPILE_SUCCESS) {
+ rhc->rhc_mhook = NULL;
+ return NB_ERR_INCONSISTENCY;
+ }
+ }
+
+ return NB_OK;
+}
+
+int
+lib_route_map_entry_match_condition_rmap_match_condition_evpn_route_type_destroy(
+ struct nb_cb_destroy_args *args)
+{
+ switch (args->event) {
+ case NB_EV_VALIDATE:
+ case NB_EV_PREPARE:
+ case NB_EV_ABORT:
+ break;
+ case NB_EV_APPLY:
+ return lib_route_map_entry_match_destroy(args);
+ }
+
+ return NB_OK;
+}
+
+/*
+ * XPath: /frr-route-map:lib/route-map/entry/match-condition/rmap-match-condition/frr-bgp-route-map:route-distinguisher
+ */
+int
+lib_route_map_entry_match_condition_rmap_match_condition_route_distinguisher_modify(
+ struct nb_cb_modify_args *args)
+{
+ struct routemap_hook_context *rhc;
+ const char *rd;
+ enum rmap_compile_rets ret;
+
+ switch (args->event) {
+ case NB_EV_VALIDATE:
+ case NB_EV_PREPARE:
+ case NB_EV_ABORT:
+ break;
+ case NB_EV_APPLY:
+ /* Add configuration. */
+ rhc = nb_running_get_entry(args->dnode, NULL, true);
+ rd = yang_dnode_get_string(args->dnode, NULL);
+
+ /* Set destroy information. */
+ rhc->rhc_mhook = bgp_route_match_delete;
+ rhc->rhc_rule = "evpn rd";
+ rhc->rhc_event = RMAP_EVENT_MATCH_DELETED;
+
+ ret = bgp_route_match_add(rhc->rhc_rmi, "evpn rd", rd,
+ RMAP_EVENT_MATCH_ADDED,
+ args->errmsg, args->errmsg_len);
+
+ if (ret != RMAP_COMPILE_SUCCESS) {
+ rhc->rhc_mhook = NULL;
+ return NB_ERR_INCONSISTENCY;
+ }
+ }
+
+ return NB_OK;
+}
+
+int
+lib_route_map_entry_match_condition_rmap_match_condition_route_distinguisher_destroy(
+ struct nb_cb_destroy_args *args)
+{
+ switch (args->event) {
+ case NB_EV_VALIDATE:
+ case NB_EV_PREPARE:
+ case NB_EV_ABORT:
+ break;
+ case NB_EV_APPLY:
+ return lib_route_map_entry_match_destroy(args);
+ }
+
+ return NB_OK;
+}
+
+/*
+ * XPath = /frr-route-map:lib/route-map/entry/match-condition/rmap-match-condition/frr-bgp-route-map:comm-list
+ */
+void
+lib_route_map_entry_match_condition_rmap_match_condition_comm_list_finish(
+ struct nb_cb_apply_finish_args *args)
+{
+ struct routemap_hook_context *rhc;
+ const char *value;
+ bool exact_match = false;
+ char *argstr;
+ const char *condition;
+ route_map_event_t event;
+
+ /* Add configuration. */
+ rhc = nb_running_get_entry(args->dnode, NULL, true);
+ value = yang_dnode_get_string(args->dnode, "./comm-list-name");
+
+ if (yang_dnode_exists(args->dnode, "./comm-list-name-exact-match"))
+ exact_match = yang_dnode_get_bool(
+ args->dnode, "./comm-list-name-exact-match");
+
+ if (exact_match) {
+ argstr = XMALLOC(MTYPE_ROUTE_MAP_COMPILED,
+ strlen(value) + strlen("exact-match") + 2);
+
+ snprintf(argstr, (strlen(value) + strlen("exact-match") + 2),
+ "%s exact-match", value);
+ } else
+ argstr = (char *)value;
+
+ /* Set destroy information. */
+ rhc->rhc_mhook = bgp_route_match_delete;
+
+ condition = yang_dnode_get_string(args->dnode,
+ "../../frr-route-map:condition");
+ if (IS_MATCH_COMMUNITY(condition)) {
+ rhc->rhc_rule = "community";
+ event = RMAP_EVENT_CLIST_ADDED;
+ rhc->rhc_event = RMAP_EVENT_CLIST_DELETED;
+ } else if (IS_MATCH_LCOMMUNITY(condition)) {
+ rhc->rhc_rule = "large-community";
+ event = RMAP_EVENT_LLIST_ADDED;
+ rhc->rhc_event = RMAP_EVENT_LLIST_DELETED;
+ } else {
+ rhc->rhc_rule = "extcommunity";
+ event = RMAP_EVENT_ECLIST_ADDED;
+ rhc->rhc_event = RMAP_EVENT_ECLIST_DELETED;
+ }
+
+ bgp_route_match_add(rhc->rhc_rmi, rhc->rhc_rule, argstr, event,
+ args->errmsg, args->errmsg_len);
+
+ if (argstr != value)
+ XFREE(MTYPE_ROUTE_MAP_COMPILED, argstr);
+}
+
+/*
+ * XPath:
+ * /frr-route-map:lib/route-map/entry/match-condition/rmap-match-condition/frr-bgp-route-map:comm-list/comm-list-name
+ */
+int
+lib_route_map_entry_match_condition_rmap_match_condition_comm_list_comm_list_name_modify(
+ struct nb_cb_modify_args *args)
+{
+ switch (args->event) {
+ case NB_EV_VALIDATE:
+ case NB_EV_PREPARE:
+ case NB_EV_ABORT:
+ case NB_EV_APPLY:
+ break;
+ }
+
+ return NB_OK;
+}
+
+int
+lib_route_map_entry_match_condition_rmap_match_condition_comm_list_comm_list_name_destroy(
+ struct nb_cb_destroy_args *args)
+{
+ switch (args->event) {
+ case NB_EV_VALIDATE:
+ case NB_EV_PREPARE:
+ case NB_EV_ABORT:
+ break;
+ case NB_EV_APPLY:
+ return lib_route_map_entry_match_destroy(args);
+ }
+
+ return NB_OK;
+
+}
+
+/*
+ * XPath: /frr-route-map:lib/route-map/entry/match-condition/rmap-match-condition/frr-bgp-route-map:comm-list/comm-list-name-exact-match
+ */
+int
+lib_route_map_entry_match_condition_rmap_match_condition_comm_list_comm_list_name_exact_match_modify(
+ struct nb_cb_modify_args *args)
+{
+ switch (args->event) {
+ case NB_EV_VALIDATE:
+ case NB_EV_PREPARE:
+ case NB_EV_ABORT:
+ case NB_EV_APPLY:
+ break;
+ }
+
+ return NB_OK;
+}
+
+int
+lib_route_map_entry_match_condition_rmap_match_condition_comm_list_comm_list_name_exact_match_destroy(
+ struct nb_cb_destroy_args *args)
+{
+ switch (args->event) {
+ case NB_EV_VALIDATE:
+ case NB_EV_PREPARE:
+ case NB_EV_ABORT:
+ break;
+ case NB_EV_APPLY:
+ return lib_route_map_entry_match_destroy(args);
+ }
+
+ return NB_OK;
+}
+
+/*
+ * XPath: /frr-route-map:lib/route-map/entry/match-condition/rmap-match-condition/frr-bgp-route-map:ipv4-address
+ */
+int
+lib_route_map_entry_match_condition_rmap_match_condition_ipv4_address_modify(
+ struct nb_cb_modify_args *args)
+{
+ struct routemap_hook_context *rhc;
+ const char *peer;
+ enum rmap_compile_rets ret;
+
+ switch (args->event) {
+ case NB_EV_VALIDATE:
+ case NB_EV_PREPARE:
+ case NB_EV_ABORT:
+ break;
+ case NB_EV_APPLY:
+ /* Add configuration. */
+ rhc = nb_running_get_entry(args->dnode, NULL, true);
+ peer = yang_dnode_get_string(args->dnode, NULL);
+
+ /* Set destroy information. */
+ rhc->rhc_mhook = bgp_route_match_delete;
+ rhc->rhc_rule = "ip next-hop address";
+ rhc->rhc_event = RMAP_EVENT_MATCH_DELETED;
+
+ ret = bgp_route_match_add(rhc->rhc_rmi, rhc->rhc_rule,
+ peer, RMAP_EVENT_MATCH_ADDED,
+ args->errmsg, args->errmsg_len);
+
+ if (ret != RMAP_COMPILE_SUCCESS) {
+ rhc->rhc_mhook = NULL;
+ return NB_ERR_INCONSISTENCY;
+ }
+ }
+
+ return NB_OK;
+}
+
+int
+lib_route_map_entry_match_condition_rmap_match_condition_ipv4_address_destroy(
+ struct nb_cb_destroy_args *args)
+{
+ switch (args->event) {
+ case NB_EV_VALIDATE:
+ case NB_EV_PREPARE:
+ case NB_EV_ABORT:
+ break;
+ case NB_EV_APPLY:
+ return lib_route_map_entry_match_destroy(args);
+ }
+
+ return NB_OK;
+}
+
+/*
+ * XPath: /frr-route-map:lib/route-map/entry/match-condition/rmap-match-condition/frr-bgp-route-map:ipv6-address
+ */
+int
+lib_route_map_entry_match_condition_rmap_match_condition_ipv6_address_modify(
+ struct nb_cb_modify_args *args)
+{
+ struct routemap_hook_context *rhc;
+ const char *peer;
+ enum rmap_compile_rets ret;
+
+ switch (args->event) {
+ case NB_EV_VALIDATE:
+ case NB_EV_PREPARE:
+ case NB_EV_ABORT:
+ break;
+ case NB_EV_APPLY:
+ /* Add configuration. */
+ rhc = nb_running_get_entry(args->dnode, NULL, true);
+ peer = yang_dnode_get_string(args->dnode, NULL);
+
+ /* Set destroy information. */
+ rhc->rhc_mhook = bgp_route_match_delete;
+ rhc->rhc_rule = "ipv6 next-hop";
+ rhc->rhc_event = RMAP_EVENT_MATCH_DELETED;
+
+ ret = bgp_route_match_add(rhc->rhc_rmi, rhc->rhc_rule,
+ peer, RMAP_EVENT_MATCH_ADDED,
+ args->errmsg, args->errmsg_len);
+
+ if (ret != RMAP_COMPILE_SUCCESS) {
+ rhc->rhc_mhook = NULL;
+ return NB_ERR_INCONSISTENCY;
+ }
+ }
+
+ return NB_OK;
+}
+
+int
+lib_route_map_entry_match_condition_rmap_match_condition_ipv6_address_destroy(
+ struct nb_cb_destroy_args *args)
+{
+ switch (args->event) {
+ case NB_EV_VALIDATE:
+ case NB_EV_PREPARE:
+ case NB_EV_ABORT:
+ break;
+ case NB_EV_APPLY:
+ return lib_route_map_entry_match_destroy(args);
+ }
+
+ return NB_OK;
+}
+
+/*
+ * XPath:
+ * /frr-route-map:lib/route-map/entry/set-action/rmap-set-action/frr-bgp-route-map:distance
+ */
+int lib_route_map_entry_set_action_rmap_set_action_distance_modify(
+ struct nb_cb_modify_args *args)
+{
+ struct routemap_hook_context *rhc;
+ const char *type;
+ int rv;
+
+ switch (args->event) {
+ case NB_EV_VALIDATE:
+ case NB_EV_PREPARE:
+ case NB_EV_ABORT:
+ break;
+ case NB_EV_APPLY:
+ /* Add configuration. */
+ rhc = nb_running_get_entry(args->dnode, NULL, true);
+ type = yang_dnode_get_string(args->dnode, NULL);
+
+ /* Set destroy information. */
+ rhc->rhc_shook = generic_set_delete;
+ rhc->rhc_rule = "distance";
+ rhc->rhc_event = RMAP_EVENT_SET_DELETED;
+
+ rv = generic_set_add(rhc->rhc_rmi, "distance", type,
+ args->errmsg, args->errmsg_len);
+ if (rv != CMD_SUCCESS) {
+ rhc->rhc_shook = NULL;
+ return NB_ERR_INCONSISTENCY;
+ }
+ }
+
+ return NB_OK;
+}
+
+int lib_route_map_entry_set_action_rmap_set_action_distance_destroy(
+ struct nb_cb_destroy_args *args)
+{
+ switch (args->event) {
+ case NB_EV_VALIDATE:
+ case NB_EV_PREPARE:
+ case NB_EV_ABORT:
+ break;
+ case NB_EV_APPLY:
+ return lib_route_map_entry_match_destroy(args);
+ }
+
+ return NB_OK;
+}
+
+/*
+ * XPath:
+ * /frr-route-map:lib/route-map/entry/set-action/rmap-set-action/frr-bgp-route-map:extcommunity-rt
+ */
+int
+lib_route_map_entry_set_action_rmap_set_action_extcommunity_rt_modify(
+ struct nb_cb_modify_args *args)
+{
+ struct routemap_hook_context *rhc;
+ const char *type;
+ int rv;
+
+ switch (args->event) {
+ case NB_EV_VALIDATE:
+ case NB_EV_PREPARE:
+ case NB_EV_ABORT:
+ break;
+ case NB_EV_APPLY:
+ /* Add configuration. */
+ rhc = nb_running_get_entry(args->dnode, NULL, true);
+ type = yang_dnode_get_string(args->dnode, NULL);
+
+ /* Set destroy information. */
+ rhc->rhc_shook = generic_set_delete;
+ rhc->rhc_rule = "extcommunity rt";
+ rhc->rhc_event = RMAP_EVENT_SET_DELETED;
+
+ rv = generic_set_add(rhc->rhc_rmi, "extcommunity rt", type,
+ args->errmsg, args->errmsg_len);
+ if (rv != CMD_SUCCESS) {
+ rhc->rhc_shook = NULL;
+ return NB_ERR_INCONSISTENCY;
+ }
+ }
+
+ return NB_OK;
+}
+
+int
+lib_route_map_entry_set_action_rmap_set_action_extcommunity_rt_destroy(
+ struct nb_cb_destroy_args *args)
+{
+ switch (args->event) {
+ case NB_EV_VALIDATE:
+ case NB_EV_PREPARE:
+ case NB_EV_ABORT:
+ break;
+ case NB_EV_APPLY:
+ return lib_route_map_entry_match_destroy(args);
+ }
+
+ return NB_OK;
+}
+
+/*
+ * XPath:
+ * /frr-route-map:lib/route-map/entry/set-action/rmap-set-action/frr-bgp-route-map:extcommunity-soo
+ */
+int
+lib_route_map_entry_set_action_rmap_set_action_extcommunity_soo_modify(
+ struct nb_cb_modify_args *args)
+{
+ struct routemap_hook_context *rhc;
+ const char *type;
+ int rv;
+
+ switch (args->event) {
+ case NB_EV_VALIDATE:
+ case NB_EV_PREPARE:
+ case NB_EV_ABORT:
+ break;
+ case NB_EV_APPLY:
+ /* Add configuration. */
+ rhc = nb_running_get_entry(args->dnode, NULL, true);
+ type = yang_dnode_get_string(args->dnode, NULL);
+
+ /* Set destroy information. */
+ rhc->rhc_shook = generic_set_delete;
+ rhc->rhc_rule = "extcommunity soo";
+ rhc->rhc_event = RMAP_EVENT_SET_DELETED;
+
+ rv = generic_set_add(rhc->rhc_rmi, "extcommunity soo",
+ type,
+ args->errmsg, args->errmsg_len);
+ if (rv != CMD_SUCCESS) {
+ rhc->rhc_shook = NULL;
+ return NB_ERR_INCONSISTENCY;
+ }
+ }
+
+ return NB_OK;
+}
+
+int
+lib_route_map_entry_set_action_rmap_set_action_extcommunity_soo_destroy(
+ struct nb_cb_destroy_args *args)
+{
+ switch (args->event) {
+ case NB_EV_VALIDATE:
+ case NB_EV_PREPARE:
+ case NB_EV_ABORT:
+ break;
+ case NB_EV_APPLY:
+ return lib_route_map_entry_match_destroy(args);
+ }
+
+ return NB_OK;
+}
+
+/*
+ * XPath:
+ * /frr-route-map:lib/route-map/entry/set-action/rmap-set-action/frr-bgp-route-map:ipv4-address
+ */
+int lib_route_map_entry_set_action_rmap_set_action_ipv4_address_modify(
+ struct nb_cb_modify_args *args)
+{
+ struct routemap_hook_context *rhc;
+ const char *addr;
+ int rv = CMD_SUCCESS;
+
+ switch (args->event) {
+ case NB_EV_VALIDATE:
+ case NB_EV_PREPARE:
+ case NB_EV_ABORT:
+ break;
+ case NB_EV_APPLY:
+ /* Add configuration. */
+ rhc = nb_running_get_entry(args->dnode, NULL, true);
+ addr = yang_dnode_get_string(args->dnode, NULL);
+
+ rhc->rhc_shook = generic_set_delete;
+ rhc->rhc_event = RMAP_EVENT_SET_DELETED;
+ rhc->rhc_rule = "ipv4 vpn next-hop";
+
+ rv = generic_set_add(rhc->rhc_rmi, rhc->rhc_rule, addr,
+ args->errmsg, args->errmsg_len);
+
+ if (rv != CMD_SUCCESS) {
+ rhc->rhc_shook = NULL;
+ return NB_ERR_INCONSISTENCY;
+ }
+ }
+
+ return NB_OK;
+}
+
+int lib_route_map_entry_set_action_rmap_set_action_ipv4_address_destroy(
+ struct nb_cb_destroy_args *args)
+{
+ switch (args->event) {
+ case NB_EV_VALIDATE:
+ case NB_EV_PREPARE:
+ case NB_EV_ABORT:
+ break;
+ case NB_EV_APPLY:
+ return lib_route_map_entry_set_destroy(args);
+ }
+
+ return NB_OK;
+}
+
+/*
+ * XPath:
+ * /frr-route-map:lib/route-map/entry/set-action/rmap-set-action/frr-bgp-route-map:ipv4-nexthop
+ */
+int lib_route_map_entry_set_action_rmap_set_action_ipv4_nexthop_modify(
+ struct nb_cb_modify_args *args)
+{
+ struct routemap_hook_context *rhc;
+ const char *type;
+ int rv;
+
+ switch (args->event) {
+ case NB_EV_VALIDATE:
+ case NB_EV_PREPARE:
+ case NB_EV_ABORT:
+ break;
+ case NB_EV_APPLY:
+ /* Add configuration. */
+ rhc = nb_running_get_entry(args->dnode, NULL, true);
+ type = yang_dnode_get_string(args->dnode, NULL);
+
+ /* Set destroy information. */
+ rhc->rhc_shook = generic_set_delete;
+ rhc->rhc_rule = "ip next-hop";
+ rhc->rhc_event = RMAP_EVENT_SET_DELETED;
+
+ rv = generic_set_add(rhc->rhc_rmi, rhc->rhc_rule, type,
+ args->errmsg, args->errmsg_len);
+
+ if (rv != CMD_SUCCESS) {
+ rhc->rhc_shook = NULL;
+ return NB_ERR_INCONSISTENCY;
+ }
+ }
+
+ return NB_OK;
+}
+
+int lib_route_map_entry_set_action_rmap_set_action_ipv4_nexthop_destroy(
+ struct nb_cb_destroy_args *args)
+{
+ switch (args->event) {
+ case NB_EV_VALIDATE:
+ case NB_EV_PREPARE:
+ case NB_EV_ABORT:
+ break;
+ case NB_EV_APPLY:
+ return lib_route_map_entry_set_destroy(args);
+ }
+
+ return NB_OK;
+}
+
+/*
+ * XPath:
+ * /frr-route-map:lib/route-map/entry/set-action/rmap-set-action/frr-bgp-route-map:ipv6-address
+ */
+int lib_route_map_entry_set_action_rmap_set_action_ipv6_address_modify(
+ struct nb_cb_modify_args *args)
+{
+ struct routemap_hook_context *rhc;
+ const char *addr;
+ int rv = CMD_SUCCESS;
+ const char *action = NULL;
+ struct in6_addr i6a;
+
+ action = yang_dnode_get_string(args->dnode,
+ "../../frr-route-map:action");
+ switch (args->event) {
+ case NB_EV_VALIDATE:
+ if (action && IS_SET_IPV6_NH_GLOBAL(action)) {
+ yang_dnode_get_ipv6(&i6a, args->dnode, NULL);
+ if (IN6_IS_ADDR_UNSPECIFIED(&i6a)
+ || IN6_IS_ADDR_LOOPBACK(&i6a)
+ || IN6_IS_ADDR_MULTICAST(&i6a)
+ || IN6_IS_ADDR_LINKLOCAL(&i6a))
+ return NB_ERR_VALIDATION;
+ }
+ /* FALLTHROUGH */
+ case NB_EV_PREPARE:
+ case NB_EV_ABORT:
+ return NB_OK;
+ case NB_EV_APPLY:
+ break;
+ }
+
+ /* Add configuration. */
+ rhc = nb_running_get_entry(args->dnode, NULL, true);
+ addr = yang_dnode_get_string(args->dnode, NULL);
+
+ rhc->rhc_shook = generic_set_delete;
+ rhc->rhc_event = RMAP_EVENT_SET_DELETED;
+
+ if (IS_SET_IPV6_NH_GLOBAL(action))
+ /* Set destroy information. */
+ rhc->rhc_rule = "ipv6 next-hop global";
+ else
+ rhc->rhc_rule = "ipv6 vpn next-hop";
+
+ rv = generic_set_add(rhc->rhc_rmi, rhc->rhc_rule, addr,
+ args->errmsg, args->errmsg_len);
+
+ if (rv != CMD_SUCCESS) {
+ rhc->rhc_shook = NULL;
+ return NB_ERR_INCONSISTENCY;
+ }
+
+ return NB_OK;
+}
+
+int lib_route_map_entry_set_action_rmap_set_action_ipv6_address_destroy(
+ struct nb_cb_destroy_args *args)
+{
+ switch (args->event) {
+ case NB_EV_VALIDATE:
+ case NB_EV_PREPARE:
+ case NB_EV_ABORT:
+ break;
+ case NB_EV_APPLY:
+ return lib_route_map_entry_set_destroy(args);
+ }
+
+ return NB_OK;
+}
+
+/*
+ * XPath:
+ * /frr-route-map:lib/route-map/entry/set-action/rmap-set-action/frr-bgp-route-map:preference
+ */
+int lib_route_map_entry_set_action_rmap_set_action_preference_modify(
+ struct nb_cb_modify_args *args)
+{
+ struct routemap_hook_context *rhc;
+ int rv = CMD_SUCCESS;
+ const char *action = NULL;
+ bool value;
+
+ switch (args->event) {
+ case NB_EV_VALIDATE:
+ case NB_EV_PREPARE:
+ case NB_EV_ABORT:
+ break;
+ case NB_EV_APPLY:
+ /* Add configuration. */
+ rhc = nb_running_get_entry(args->dnode, NULL, true);
+ value = yang_dnode_get_bool(args->dnode, NULL);
+
+ rhc->rhc_shook = generic_set_delete;
+ rhc->rhc_event = RMAP_EVENT_SET_DELETED;
+
+ action = yang_dnode_get_string(args->dnode,
+ "../../frr-route-map:action");
+
+ if (value) {
+ if (IS_SET_IPV6_PEER_ADDR(action))
+ /* Set destroy information. */
+ rhc->rhc_rule = "ipv6 next-hop peer-address";
+ else
+ rhc->rhc_rule = "ipv6 next-hop prefer-global";
+
+ rv = generic_set_add(rhc->rhc_rmi, rhc->rhc_rule,
+ NULL,
+ args->errmsg, args->errmsg_len);
+ }
+
+ if (rv != CMD_SUCCESS) {
+ rhc->rhc_shook = NULL;
+ return NB_ERR_INCONSISTENCY;
+ }
+ }
+
+ return NB_OK;
+}
+
+int lib_route_map_entry_set_action_rmap_set_action_preference_destroy(
+ struct nb_cb_destroy_args *args)
+{
+ switch (args->event) {
+ case NB_EV_VALIDATE:
+ case NB_EV_PREPARE:
+ case NB_EV_ABORT:
+ break;
+ case NB_EV_APPLY:
+ return lib_route_map_entry_set_destroy(args);
+ }
+
+ return NB_OK;
+}
+
+/*
+ * XPath:
+ * /frr-route-map:lib/route-map/entry/set-action/rmap-set-action/frr-bgp-route-map:label-index
+ */
+int lib_route_map_entry_set_action_rmap_set_action_label_index_modify(
+ struct nb_cb_modify_args *args)
+{
+ struct routemap_hook_context *rhc;
+ const char *type;
+ int rv;
+
+ switch (args->event) {
+ case NB_EV_VALIDATE:
+ case NB_EV_PREPARE:
+ case NB_EV_ABORT:
+ break;
+ case NB_EV_APPLY:
+ /* Add configuration. */
+ rhc = nb_running_get_entry(args->dnode, NULL, true);
+ type = yang_dnode_get_string(args->dnode, NULL);
+
+ /* Set destroy information. */
+ rhc->rhc_shook = generic_set_delete;
+ rhc->rhc_rule = "label-index";
+ rhc->rhc_event = RMAP_EVENT_SET_DELETED;
+
+ rv = generic_set_add(rhc->rhc_rmi, "label-index", type,
+ args->errmsg, args->errmsg_len);
+ if (rv != CMD_SUCCESS) {
+ rhc->rhc_shook = NULL;
+ return NB_ERR_INCONSISTENCY;
+ }
+ }
+
+ return NB_OK;
+}
+
+int lib_route_map_entry_set_action_rmap_set_action_label_index_destroy(
+ struct nb_cb_destroy_args *args)
+{
+ switch (args->event) {
+ case NB_EV_VALIDATE:
+ case NB_EV_PREPARE:
+ case NB_EV_ABORT:
+ break;
+ case NB_EV_APPLY:
+ return lib_route_map_entry_set_destroy(args);
+ }
+
+ return NB_OK;
+}
+
+/*
+ * XPath:
+ * /frr-route-map:lib/route-map/entry/set-action/rmap-set-action/frr-bgp-route-map:local-pref
+ */
+int lib_route_map_entry_set_action_rmap_set_action_local_pref_modify(
+ struct nb_cb_modify_args *args)
+{
+ struct routemap_hook_context *rhc;
+ const char *type;
+ int rv;
+
+ switch (args->event) {
+ case NB_EV_VALIDATE:
+ case NB_EV_PREPARE:
+ case NB_EV_ABORT:
+ break;
+ case NB_EV_APPLY:
+ /* Add configuration. */
+ rhc = nb_running_get_entry(args->dnode, NULL, true);
+ type = yang_dnode_get_string(args->dnode, NULL);
+
+ /* Set destroy information. */
+ rhc->rhc_shook = generic_set_delete;
+ rhc->rhc_rule = "local-preference";
+ rhc->rhc_event = RMAP_EVENT_SET_DELETED;
+
+ rv = generic_set_add(rhc->rhc_rmi, "local-preference",
+ type,
+ args->errmsg, args->errmsg_len);
+ if (rv != CMD_SUCCESS) {
+ rhc->rhc_shook = NULL;
+ return NB_ERR_INCONSISTENCY;
+ }
+ }
+
+ return NB_OK;
+}
+
+int lib_route_map_entry_set_action_rmap_set_action_local_pref_destroy(
+ struct nb_cb_destroy_args *args)
+{
+ switch (args->event) {
+ case NB_EV_VALIDATE:
+ case NB_EV_PREPARE:
+ case NB_EV_ABORT:
+ break;
+ case NB_EV_APPLY:
+ return lib_route_map_entry_set_destroy(args);
+ }
+
+ return NB_OK;
+}
+
+/*
+ * XPath:
+ * /frr-route-map:lib/route-map/entry/set-action/rmap-set-action/frr-bgp-route-map:weight
+ */
+int lib_route_map_entry_set_action_rmap_set_action_weight_modify(
+ struct nb_cb_modify_args *args)
+{
+ struct routemap_hook_context *rhc;
+ const char *type;
+ int rv;
+
+ switch (args->event) {
+ case NB_EV_VALIDATE:
+ case NB_EV_PREPARE:
+ case NB_EV_ABORT:
+ break;
+ case NB_EV_APPLY:
+ /* Add configuration. */
+ rhc = nb_running_get_entry(args->dnode, NULL, true);
+ type = yang_dnode_get_string(args->dnode, NULL);
+
+ /* Set destroy information. */
+ rhc->rhc_shook = generic_set_delete;
+ rhc->rhc_rule = "weight";
+ rhc->rhc_event = RMAP_EVENT_SET_DELETED;
+
+ rv = generic_set_add(rhc->rhc_rmi, "weight", type,
+ args->errmsg, args->errmsg_len);
+ if (rv != CMD_SUCCESS) {
+ rhc->rhc_shook = NULL;
+ return NB_ERR_INCONSISTENCY;
+ }
+ }
+
+ return NB_OK;
+}
+
+int lib_route_map_entry_set_action_rmap_set_action_weight_destroy(
+ struct nb_cb_destroy_args *args)
+{
+ switch (args->event) {
+ case NB_EV_VALIDATE:
+ case NB_EV_PREPARE:
+ case NB_EV_ABORT:
+ break;
+ case NB_EV_APPLY:
+ return lib_route_map_entry_set_destroy(args);
+ }
+
+ return NB_OK;
+}
+
+/*
+ * XPath:
+ * /frr-route-map:lib/route-map/entry/set-action/rmap-set-action/frr-bgp-route-map:origin
+ */
+int lib_route_map_entry_set_action_rmap_set_action_origin_modify(
+ struct nb_cb_modify_args *args)
+{
+ struct routemap_hook_context *rhc;
+ const char *type;
+ int rv;
+
+ switch (args->event) {
+ case NB_EV_VALIDATE:
+ case NB_EV_PREPARE:
+ case NB_EV_ABORT:
+ break;
+ case NB_EV_APPLY:
+ /* Add configuration. */
+ rhc = nb_running_get_entry(args->dnode, NULL, true);
+ type = yang_dnode_get_string(args->dnode, NULL);
+
+ /* Set destroy information. */
+ rhc->rhc_shook = generic_set_delete;
+ rhc->rhc_rule = "origin";
+ rhc->rhc_event = RMAP_EVENT_SET_DELETED;
+
+ rv = generic_set_add(rhc->rhc_rmi, "origin", type,
+ args->errmsg, args->errmsg_len);
+ if (rv != CMD_SUCCESS) {
+ rhc->rhc_shook = NULL;
+ return NB_ERR_INCONSISTENCY;
+ }
+ }
+
+ return NB_OK;
+}
+
+int lib_route_map_entry_set_action_rmap_set_action_origin_destroy(
+ struct nb_cb_destroy_args *args)
+{
+ switch (args->event) {
+ case NB_EV_VALIDATE:
+ case NB_EV_PREPARE:
+ case NB_EV_ABORT:
+ break;
+ case NB_EV_APPLY:
+ return lib_route_map_entry_set_destroy(args);
+
+ }
+
+ return NB_OK;
+}
+
+/*
+ * XPath:
+ * /frr-route-map:lib/route-map/entry/set-action/rmap-set-action/frr-bgp-route-map:originator-id
+ */
+int lib_route_map_entry_set_action_rmap_set_action_originator_id_modify(
+ struct nb_cb_modify_args *args)
+{
+ struct routemap_hook_context *rhc;
+ const char *type;
+ int rv;
+
+ switch (args->event) {
+ case NB_EV_VALIDATE:
+ case NB_EV_PREPARE:
+ case NB_EV_ABORT:
+ break;
+ case NB_EV_APPLY:
+ /* Add configuration. */
+ rhc = nb_running_get_entry(args->dnode, NULL, true);
+ type = yang_dnode_get_string(args->dnode, NULL);
+
+ /* Set destroy information. */
+ rhc->rhc_shook = generic_set_delete;
+ rhc->rhc_rule = "originator-id";
+ rhc->rhc_event = RMAP_EVENT_SET_DELETED;
+
+ rv = generic_set_add(rhc->rhc_rmi, "originator-id", type,
+ args->errmsg, args->errmsg_len);
+ if (rv != CMD_SUCCESS) {
+ rhc->rhc_shook = NULL;
+ return NB_ERR_INCONSISTENCY;
+ }
+ }
+
+ return NB_OK;
+}
+
+int lib_route_map_entry_set_action_rmap_set_action_originator_id_destroy(
+ struct nb_cb_destroy_args *args)
+{
+ switch (args->event) {
+ case NB_EV_VALIDATE:
+ case NB_EV_PREPARE:
+ case NB_EV_ABORT:
+ break;
+ case NB_EV_APPLY:
+ return lib_route_map_entry_set_destroy(args);
+ }
+
+ return NB_OK;
+}
+
+/*
+ * XPath:
+ * /frr-route-map:lib/route-map/entry/set-action/rmap-set-action/frr-bgp-route-map:table
+ */
+int lib_route_map_entry_set_action_rmap_set_action_table_modify(
+ struct nb_cb_modify_args *args)
+{
+ struct routemap_hook_context *rhc;
+ const char *type;
+ int rv;
+
+ switch (args->event) {
+ case NB_EV_VALIDATE:
+ case NB_EV_PREPARE:
+ case NB_EV_ABORT:
+ break;
+ case NB_EV_APPLY:
+ /* Add configuration. */
+ rhc = nb_running_get_entry(args->dnode, NULL, true);
+ type = yang_dnode_get_string(args->dnode, NULL);
+
+ /* Set destroy information. */
+ rhc->rhc_shook = generic_set_delete;
+ rhc->rhc_rule = "table";
+ rhc->rhc_event = RMAP_EVENT_SET_DELETED;
+
+ rv = generic_set_add(rhc->rhc_rmi, "table", type,
+ args->errmsg, args->errmsg_len);
+ if (rv != CMD_SUCCESS) {
+ rhc->rhc_shook = NULL;
+ return NB_ERR_INCONSISTENCY;
+ }
+ }
+
+ return NB_OK;
+}
+
+int lib_route_map_entry_set_action_rmap_set_action_table_destroy(
+ struct nb_cb_destroy_args *args)
+{
+ switch (args->event) {
+ case NB_EV_VALIDATE:
+ case NB_EV_PREPARE:
+ case NB_EV_ABORT:
+ break;
+ case NB_EV_APPLY:
+ return lib_route_map_entry_set_destroy(args);
+ }
+
+ return NB_OK;
+}
+
+/*
+ * XPath:
+ * /frr-route-map:lib/route-map/entry/set-action/rmap-set-action/frr-bgp-route-map:atomic-aggregate
+ */
+int
+lib_route_map_entry_set_action_rmap_set_action_atomic_aggregate_create(
+ struct nb_cb_create_args *args)
+{
+ struct routemap_hook_context *rhc;
+ int rv;
+
+ switch (args->event) {
+ case NB_EV_VALIDATE:
+ case NB_EV_PREPARE:
+ case NB_EV_ABORT:
+ break;
+ case NB_EV_APPLY:
+ /* Add configuration. */
+ rhc = nb_running_get_entry(args->dnode, NULL, true);
+
+ /* Set destroy information. */
+ rhc->rhc_shook = generic_set_delete;
+ rhc->rhc_rule = "atomic-aggregate";
+ rhc->rhc_event = RMAP_EVENT_SET_DELETED;
+
+ rv = generic_set_add(rhc->rhc_rmi, rhc->rhc_rule, NULL,
+ args->errmsg, args->errmsg_len);
+ if (rv != CMD_SUCCESS) {
+ rhc->rhc_shook = NULL;
+ return NB_ERR_INCONSISTENCY;
+ }
+ }
+
+ return NB_OK;
+}
+
+int
+lib_route_map_entry_set_action_rmap_set_action_atomic_aggregate_destroy(
+ struct nb_cb_destroy_args *args)
+{
+ switch (args->event) {
+ case NB_EV_VALIDATE:
+ case NB_EV_PREPARE:
+ case NB_EV_ABORT:
+ break;
+ case NB_EV_APPLY:
+ return lib_route_map_entry_set_destroy(args);
+ }
+
+ return NB_OK;
+}
+
+/*
+ * XPath:
+ * /frr-route-map:lib/route-map/entry/set-action/rmap-set-action/frr-bgp-route-map:prepend-as-path
+ */
+int
+lib_route_map_entry_set_action_rmap_set_action_prepend_as_path_modify(
+ struct nb_cb_modify_args *args)
+{
+ struct routemap_hook_context *rhc;
+ const char *type;
+ int rv;
+
+ switch (args->event) {
+ case NB_EV_VALIDATE:
+ case NB_EV_PREPARE:
+ case NB_EV_ABORT:
+ break;
+ case NB_EV_APPLY:
+ /* Add configuration. */
+ rhc = nb_running_get_entry(args->dnode, NULL, true);
+ type = yang_dnode_get_string(args->dnode, NULL);
+
+ /* Set destroy information. */
+ rhc->rhc_shook = generic_set_delete;
+ rhc->rhc_rule = "as-path prepend";
+ rhc->rhc_event = RMAP_EVENT_SET_DELETED;
+
+ rv = generic_set_add(rhc->rhc_rmi, "as-path prepend",
+ type,
+ args->errmsg, args->errmsg_len);
+ if (rv != CMD_SUCCESS) {
+ rhc->rhc_shook = NULL;
+ return NB_ERR_INCONSISTENCY;
+ }
+ }
+
+ return NB_OK;
+}
+
+int
+lib_route_map_entry_set_action_rmap_set_action_prepend_as_path_destroy(
+ struct nb_cb_destroy_args *args)
+{
+ switch (args->event) {
+ case NB_EV_VALIDATE:
+ case NB_EV_PREPARE:
+ case NB_EV_ABORT:
+ break;
+ case NB_EV_APPLY:
+ return lib_route_map_entry_set_destroy(args);
+ }
+
+ return NB_OK;
+}
+
+/*
+ * XPath:
+ * /frr-route-map:lib/route-map/entry/set-action/rmap-set-action/frr-bgp-route-map:last-as
+ */
+int lib_route_map_entry_set_action_rmap_set_action_last_as_modify(
+ struct nb_cb_modify_args *args)
+{
+ struct routemap_hook_context *rhc;
+ const char *value;
+ char *argstr;
+ int rv;
+
+ switch (args->event) {
+ case NB_EV_VALIDATE:
+ case NB_EV_PREPARE:
+ case NB_EV_ABORT:
+ break;
+ case NB_EV_APPLY:
+ /* Add configuration. */
+ rhc = nb_running_get_entry(args->dnode, NULL, true);
+ value = yang_dnode_get_string(args->dnode, NULL);
+
+ /* Set destroy information. */
+ rhc->rhc_shook = generic_set_delete;
+ rhc->rhc_rule = "as-path prepend";
+ rhc->rhc_event = RMAP_EVENT_SET_DELETED;
+
+ argstr = XMALLOC(MTYPE_ROUTE_MAP_COMPILED,
+ strlen(value) + strlen("last-as") + 2);
+
+ snprintf(argstr, (strlen(value) + strlen("last-as") + 2),
+ "last-as %s", value);
+
+ rv = generic_set_add(rhc->rhc_rmi, "as-path prepend",
+ argstr,
+ args->errmsg, args->errmsg_len);
+ if (rv != CMD_SUCCESS) {
+ rhc->rhc_shook = NULL;
+ XFREE(MTYPE_ROUTE_MAP_COMPILED, argstr);
+ return NB_ERR_INCONSISTENCY;
+ }
+
+ XFREE(MTYPE_ROUTE_MAP_COMPILED, argstr);
+ }
+
+ return NB_OK;
+}
+
+int lib_route_map_entry_set_action_rmap_set_action_last_as_destroy(
+ struct nb_cb_destroy_args *args)
+{
+ switch (args->event) {
+ case NB_EV_VALIDATE:
+ case NB_EV_PREPARE:
+ case NB_EV_ABORT:
+ break;
+ case NB_EV_APPLY:
+ return lib_route_map_entry_set_destroy(args);
+ }
+
+ return NB_OK;
+}
+
+/*
+ * XPath:
+ * /frr-route-map:lib/route-map/entry/set-action/rmap-set-action/frr-bgp-route-map:exclude-as-path
+ */
+int
+lib_route_map_entry_set_action_rmap_set_action_exclude_as_path_modify(
+ struct nb_cb_modify_args *args)
+{
+ struct routemap_hook_context *rhc;
+ const char *type;
+ int rv;
+
+ switch (args->event) {
+ case NB_EV_VALIDATE:
+ case NB_EV_PREPARE:
+ case NB_EV_ABORT:
+ break;
+ case NB_EV_APPLY:
+ /* Add configuration. */
+ rhc = nb_running_get_entry(args->dnode, NULL, true);
+ type = yang_dnode_get_string(args->dnode, NULL);
+
+ /* Set destroy information. */
+ rhc->rhc_shook = generic_set_delete;
+ rhc->rhc_rule = "as-path exclude";
+ rhc->rhc_event = RMAP_EVENT_SET_DELETED;
+
+ rv = generic_set_add(rhc->rhc_rmi, "as-path exclude",
+ type,
+ args->errmsg, args->errmsg_len);
+ if (rv != CMD_SUCCESS) {
+ rhc->rhc_shook = NULL;
+ return NB_ERR_INCONSISTENCY;
+ }
+ }
+
+ return NB_OK;
+}
+
+int
+lib_route_map_entry_set_action_rmap_set_action_exclude_as_path_destroy(
+ struct nb_cb_destroy_args *args)
+{
+ switch (args->event) {
+ case NB_EV_VALIDATE:
+ case NB_EV_PREPARE:
+ case NB_EV_ABORT:
+ break;
+ case NB_EV_APPLY:
+ return lib_route_map_entry_set_destroy(args);
+ }
+
+ return NB_OK;
+}
+
+/*
+ * XPath:
+ * /frr-route-map:lib/route-map/entry/set-action/rmap-set-action/frr-bgp-route-map:community-none
+ */
+int lib_route_map_entry_set_action_rmap_set_action_community_none_modify(
+ struct nb_cb_modify_args *args)
+{
+ struct routemap_hook_context *rhc;
+ bool none = false;
+ int rv;
+
+ switch (args->event) {
+ case NB_EV_VALIDATE:
+ case NB_EV_PREPARE:
+ case NB_EV_ABORT:
+ break;
+ case NB_EV_APPLY:
+ /* Add configuration. */
+ rhc = nb_running_get_entry(args->dnode, NULL, true);
+ none = yang_dnode_get_bool(args->dnode, NULL);
+
+ /* Set destroy information. */
+ rhc->rhc_shook = generic_set_delete;
+ rhc->rhc_rule = "community";
+ rhc->rhc_event = RMAP_EVENT_SET_DELETED;
+
+ if (none) {
+ rv = generic_set_add(rhc->rhc_rmi, "community",
+ "none",
+ args->errmsg, args->errmsg_len);
+ if (rv != CMD_SUCCESS) {
+ rhc->rhc_shook = NULL;
+ return NB_ERR_INCONSISTENCY;
+ }
+ return NB_OK;
+ }
+
+ return NB_ERR_INCONSISTENCY;
+ }
+
+ return NB_OK;
+}
+
+int
+lib_route_map_entry_set_action_rmap_set_action_community_none_destroy(
+ struct nb_cb_destroy_args *args)
+{
+ switch (args->event) {
+ case NB_EV_VALIDATE:
+ case NB_EV_PREPARE:
+ case NB_EV_ABORT:
+ break;
+ case NB_EV_APPLY:
+ return lib_route_map_entry_set_destroy(args);
+ }
+
+ return NB_OK;
+}
+
+/*
+ * XPath:
+ * /frr-route-map:lib/route-map/entry/set-action/rmap-set-action/frr-bgp-route-map:community-string
+ */
+int
+lib_route_map_entry_set_action_rmap_set_action_community_string_modify(
+ struct nb_cb_modify_args *args)
+{
+ struct routemap_hook_context *rhc;
+ const char *type;
+ int rv;
+
+ switch (args->event) {
+ case NB_EV_VALIDATE:
+ case NB_EV_PREPARE:
+ case NB_EV_ABORT:
+ break;
+ case NB_EV_APPLY:
+ /* Add configuration. */
+ rhc = nb_running_get_entry(args->dnode, NULL, true);
+ type = yang_dnode_get_string(args->dnode, NULL);
+
+ /* Set destroy information. */
+ rhc->rhc_shook = generic_set_delete;
+ rhc->rhc_rule = "community";
+ rhc->rhc_event = RMAP_EVENT_SET_DELETED;
+
+ rv = generic_set_add(rhc->rhc_rmi, "community", type,
+ args->errmsg, args->errmsg_len);
+ if (rv != CMD_SUCCESS) {
+ rhc->rhc_shook = NULL;
+ return NB_ERR_INCONSISTENCY;
+ }
+ }
+
+ return NB_OK;
+}
+
+int
+lib_route_map_entry_set_action_rmap_set_action_community_string_destroy(
+ struct nb_cb_destroy_args *args)
+{
+ switch (args->event) {
+ case NB_EV_VALIDATE:
+ case NB_EV_PREPARE:
+ case NB_EV_ABORT:
+ break;
+ case NB_EV_APPLY:
+ return lib_route_map_entry_set_destroy(args);
+ }
+
+ return NB_OK;
+}
+
+/*
+ * XPath:
+ * /frr-route-map:lib/route-map/entry/set-action/rmap-set-action/frr-bgp-route-map:large-community-none
+ */
+int
+lib_route_map_entry_set_action_rmap_set_action_large_community_none_modify(
+ struct nb_cb_modify_args *args)
+{
+ struct routemap_hook_context *rhc;
+ bool none = false;
+ int rv;
+
+ switch (args->event) {
+ case NB_EV_VALIDATE:
+ case NB_EV_PREPARE:
+ case NB_EV_ABORT:
+ break;
+ case NB_EV_APPLY:
+ /* Add configuration. */
+ rhc = nb_running_get_entry(args->dnode, NULL, true);
+ none = yang_dnode_get_bool(args->dnode, NULL);
+
+ /* Set destroy information. */
+ rhc->rhc_shook = generic_set_delete;
+ rhc->rhc_rule = "large-community";
+ rhc->rhc_event = RMAP_EVENT_SET_DELETED;
+
+ if (none) {
+ rv = generic_set_add(rhc->rhc_rmi,
+ "large-community",
+ "none",
+ args->errmsg, args->errmsg_len);
+ if (rv != CMD_SUCCESS) {
+ rhc->rhc_shook = NULL;
+ return NB_ERR_INCONSISTENCY;
+ }
+ return NB_OK;
+ }
+
+ return NB_ERR_INCONSISTENCY;
+ }
+
+ return NB_OK;
+}
+
+int
+lib_route_map_entry_set_action_rmap_set_action_large_community_none_destroy(
+ struct nb_cb_destroy_args *args)
+{
+ switch (args->event) {
+ case NB_EV_VALIDATE:
+ case NB_EV_PREPARE:
+ case NB_EV_ABORT:
+ break;
+ case NB_EV_APPLY:
+ return lib_route_map_entry_set_destroy(args);
+ }
+
+ return NB_OK;
+}
+
+/*
+ * XPath:
+ * /frr-route-map:lib/route-map/entry/set-action/rmap-set-action/frr-bgp-route-map:large-community-string
+ */
+int
+lib_route_map_entry_set_action_rmap_set_action_large_community_string_modify(
+ struct nb_cb_modify_args *args)
+{
+ struct routemap_hook_context *rhc;
+ const char *type;
+ int rv;
+
+ switch (args->event) {
+ case NB_EV_VALIDATE:
+ case NB_EV_PREPARE:
+ case NB_EV_ABORT:
+ break;
+ case NB_EV_APPLY:
+ /* Add configuration. */
+ rhc = nb_running_get_entry(args->dnode, NULL, true);
+ type = yang_dnode_get_string(args->dnode, NULL);
+
+ /* Set destroy information. */
+ rhc->rhc_shook = generic_set_delete;
+ rhc->rhc_rule = "large-community";
+ rhc->rhc_event = RMAP_EVENT_SET_DELETED;
+
+ rv = generic_set_add(rhc->rhc_rmi, "large-community",
+ type,
+ args->errmsg, args->errmsg_len);
+ if (rv != CMD_SUCCESS) {
+ rhc->rhc_shook = NULL;
+ return NB_ERR_INCONSISTENCY;
+ }
+ }
+
+ return NB_OK;
+}
+
+int
+lib_route_map_entry_set_action_rmap_set_action_large_community_string_destroy(
+ struct nb_cb_destroy_args *args)
+{
+ switch (args->event) {
+ case NB_EV_VALIDATE:
+ case NB_EV_PREPARE:
+ case NB_EV_ABORT:
+ break;
+ case NB_EV_APPLY:
+ return lib_route_map_entry_set_destroy(args);
+ }
+
+ return NB_OK;
+}
+
+/*
+ * xpath =
+ * /frr-route-map:lib/route-map/entry/set-action/rmap-set-action/frr-bgp-route-map:aggregator
+ */
+void lib_route_map_entry_set_action_rmap_set_action_aggregator_finish(
+ struct nb_cb_apply_finish_args *args)
+{
+ struct routemap_hook_context *rhc;
+ const char *asn;
+ const char *addr;
+ char *argstr;
+
+ /* Add configuration. */
+ rhc = nb_running_get_entry(args->dnode, NULL, true);
+ asn = yang_dnode_get_string(args->dnode, "./aggregator-asn");
+ addr = yang_dnode_get_string(args->dnode, "./aggregator-address");
+
+ argstr = XMALLOC(MTYPE_ROUTE_MAP_COMPILED,
+ strlen(asn) + strlen(addr) + 2);
+
+ snprintf(argstr, (strlen(asn) + strlen(addr) + 2), "%s %s", asn, addr);
+
+ /* Set destroy information. */
+ rhc->rhc_shook = generic_set_delete;
+ rhc->rhc_rule = "aggregator as";
+ rhc->rhc_event = RMAP_EVENT_SET_DELETED;
+
+ generic_set_add(rhc->rhc_rmi, rhc->rhc_rule, argstr,
+ args->errmsg, args->errmsg_len);
+ XFREE(MTYPE_ROUTE_MAP_COMPILED, argstr);
+}
+/*
+ * XPath:
+ * /frr-route-map:lib/route-map/entry/set-action/rmap-set-action/frr-bgp-route-map:aggregator/aggregator-asn
+ */
+int
+lib_route_map_entry_set_action_rmap_set_action_aggregator_aggregator_asn_modify(
+ struct nb_cb_modify_args *args)
+{
+ switch (args->event) {
+ case NB_EV_VALIDATE:
+ case NB_EV_PREPARE:
+ case NB_EV_ABORT:
+ case NB_EV_APPLY:
+ break;
+ }
+
+ return NB_OK;
+}
+
+int
+lib_route_map_entry_set_action_rmap_set_action_aggregator_aggregator_asn_destroy(
+ struct nb_cb_destroy_args *args)
+{
+ switch (args->event) {
+ case NB_EV_VALIDATE:
+ case NB_EV_PREPARE:
+ case NB_EV_ABORT:
+ break;
+ case NB_EV_APPLY:
+ return lib_route_map_entry_set_destroy(args);
+ }
+
+ return NB_OK;
+}
+
+/*
+ * XPath:
+ * /frr-route-map:lib/route-map/entry/set-action/rmap-set-action/frr-bgp-route-map:aggregator/aggregator-address
+ */
+int
+lib_route_map_entry_set_action_rmap_set_action_aggregator_aggregator_address_modify(
+ struct nb_cb_modify_args *args)
+{
+ switch (args->event) {
+ case NB_EV_VALIDATE:
+ case NB_EV_PREPARE:
+ case NB_EV_ABORT:
+ case NB_EV_APPLY:
+ break;
+ }
+
+ return NB_OK;
+}
+
+int
+lib_route_map_entry_set_action_rmap_set_action_aggregator_aggregator_address_destroy(
+ struct nb_cb_destroy_args *args)
+{
+ switch (args->event) {
+ case NB_EV_VALIDATE:
+ case NB_EV_PREPARE:
+ case NB_EV_ABORT:
+ break;
+ case NB_EV_APPLY:
+ return lib_route_map_entry_set_destroy(args);
+ }
+
+ return NB_OK;
+}
+
+/*
+ * XPath:
+ * /frr-route-map:lib/route-map/entry/set-action/rmap-set-action/frr-bgp-route-map:comm-list-name
+ */
+int lib_route_map_entry_set_action_rmap_set_action_comm_list_name_modify(
+ struct nb_cb_modify_args *args)
+{
+ struct routemap_hook_context *rhc;
+ const char *value;
+ const char *action;
+ int rv = CMD_SUCCESS;
+
+ switch (args->event) {
+ case NB_EV_VALIDATE:
+ case NB_EV_PREPARE:
+ case NB_EV_ABORT:
+ break;
+ case NB_EV_APPLY:
+ /* Add configuration. */
+ rhc = nb_running_get_entry(args->dnode, NULL, true);
+ value = yang_dnode_get_string(args->dnode, NULL);
+
+ /* Set destroy information. */
+ rhc->rhc_shook = generic_set_delete;
+
+ action = yang_dnode_get_string(args->dnode,
+ "../../frr-route-map:action");
+ if (IS_SET_COMM_LIST_DEL(action))
+ rhc->rhc_rule = "comm-list";
+ else
+ rhc->rhc_rule = "large-comm-list";
+
+ rhc->rhc_event = RMAP_EVENT_SET_DELETED;
+
+ rv = generic_set_add(rhc->rhc_rmi, rhc->rhc_rule, value,
+ args->errmsg, args->errmsg_len);
+
+ if (rv != CMD_SUCCESS) {
+ rhc->rhc_shook = NULL;
+ return NB_ERR_INCONSISTENCY;
+ }
+ }
+
+ return NB_OK;
+}
+
+int
+lib_route_map_entry_set_action_rmap_set_action_comm_list_name_destroy(
+ struct nb_cb_destroy_args *args)
+{
+ switch (args->event) {
+ case NB_EV_VALIDATE:
+ case NB_EV_PREPARE:
+ case NB_EV_ABORT:
+ break;
+ case NB_EV_APPLY:
+ return lib_route_map_entry_set_destroy(args);
+ }
+
+ return NB_OK;
+}
+
+enum e_community_lb_type {
+ EXPLICIT_BANDWIDTH,
+ CUMULATIVE_BANDWIDTH,
+ COMPUTED_BANDWIDTH
+};
+
+/*
+ * XPath:
+ * /frr-route-map:lib/route-map/entry/set-action/rmap-set-action/frr-bgp-route-map:extcommunity-lb
+ */
+void
+lib_route_map_entry_set_action_rmap_set_action_extcommunity_lb_finish(
+ struct nb_cb_apply_finish_args *args)
+{
+ struct routemap_hook_context *rhc;
+ int lb_type;
+ char str[VTY_BUFSIZ];
+ uint16_t bandwidth;
+
+ /* Add configuration. */
+ rhc = nb_running_get_entry(args->dnode, NULL, true);
+ lb_type = yang_dnode_get_enum(args->dnode, "./lb-type");
+
+ /* Set destroy information. */
+ rhc->rhc_shook = generic_set_delete;
+ rhc->rhc_rule = "extcommunity bandwidth";
+ rhc->rhc_event = RMAP_EVENT_SET_DELETED;
+
+ switch (lb_type) {
+ case EXPLICIT_BANDWIDTH:
+ bandwidth = yang_dnode_get_uint16(args->dnode, "./bandwidth");
+ snprintf(str, sizeof(str), "%d", bandwidth);
+ break;
+ case CUMULATIVE_BANDWIDTH:
+ snprintf(str, sizeof(str), "%s", "cumulative");
+ break;
+ case COMPUTED_BANDWIDTH:
+ snprintf(str, sizeof(str), "%s", "num-multipaths");
+ }
+
+ if (yang_dnode_get_bool(args->dnode, "./two-octet-as-specific"))
+ strlcat(str, " non-transitive", sizeof(str));
+
+ generic_set_add(rhc->rhc_rmi,
+ "extcommunity bandwidth", str,
+ args->errmsg, args->errmsg_len);
+}
+
+/*
+ * XPath:
+ * /frr-route-map:lib/route-map/entry/set-action/rmap-set-action/frr-bgp-route-map:extcommunity-lb/lb-type
+ */
+int
+lib_route_map_entry_set_action_rmap_set_action_extcommunity_lb_lb_type_modify(
+ struct nb_cb_modify_args *args)
+{
+ return NB_OK;
+}
+
+int
+lib_route_map_entry_set_action_rmap_set_action_extcommunity_lb_lb_type_destroy(
+ struct nb_cb_destroy_args *args)
+{
+ return lib_route_map_entry_set_destroy(args);
+}
+
+/*
+ * XPath:
+ * /frr-route-map:lib/route-map/entry/set-action/rmap-set-action/frr-bgp-route-map:extcommunity-lb/bandwidth
+ */
+int
+lib_route_map_entry_set_action_rmap_set_action_extcommunity_lb_bandwidth_modify(
+ struct nb_cb_modify_args *args)
+{
+ return NB_OK;
+}
+
+int
+lib_route_map_entry_set_action_rmap_set_action_extcommunity_lb_bandwidth_destroy(
+ struct nb_cb_destroy_args *args)
+{
+ return lib_route_map_entry_set_destroy(args);
+}
+
+/*
+ * XPath:
+ * /frr-route-map:lib/route-map/entry/set-action/rmap-set-action/frr-bgp-route-map:extcommunity-lb/two-octet-as-specific
+ */
+int
+lib_route_map_entry_set_action_rmap_set_action_extcommunity_lb_two_octet_as_specific_modify(
+ struct nb_cb_modify_args *args)
+{
+ return NB_OK;
+}
+
+int
+lib_route_map_entry_set_action_rmap_set_action_extcommunity_lb_two_octet_as_specific_destroy(
+ struct nb_cb_destroy_args *args)
+{
+ return lib_route_map_entry_set_destroy(args);
+}
diff --git a/bgpd/bgp_rpki.c b/bgpd/bgp_rpki.c
index 3ef0137ba..3d4902aa4 100644
--- a/bgpd/bgp_rpki.c
+++ b/bgpd/bgp_rpki.c
@@ -1164,7 +1164,7 @@ DEFUN (show_rpki_prefix_table,
return CMD_SUCCESS;
}
-DEFPY(show_rpki_as_number, show_rpki_as_number_cmd,
+DEFPY (show_rpki_as_number, show_rpki_as_number_cmd,
"show rpki as-number (1-4294967295)$by_asn",
SHOW_STR RPKI_OUTPUT_STRING
"Lookup by ASN in prefix table\n"
@@ -1357,7 +1357,7 @@ DEFUN (no_debug_rpki,
return CMD_SUCCESS;
}
-DEFUN (match_rpki,
+DEFUN_YANG (match_rpki,
match_rpki_cmd,
"match rpki <valid|invalid|notfound>",
MATCH_STR
@@ -1366,27 +1366,19 @@ DEFUN (match_rpki,
"Invalid prefix\n"
"Prefix not found\n")
{
- VTY_DECLVAR_CONTEXT(route_map_index, index);
- enum rmap_compile_rets ret;
-
- ret = route_map_add_match(index, "rpki", argv[2]->arg,
- RMAP_EVENT_MATCH_ADDED);
- switch (ret) {
- case RMAP_RULE_MISSING:
- vty_out(vty, "%% BGP Can't find rule.\n");
- return CMD_WARNING_CONFIG_FAILED;
- case RMAP_COMPILE_ERROR:
- vty_out(vty, "%% BGP Argument is malformed.\n");
- return CMD_WARNING_CONFIG_FAILED;
- case RMAP_COMPILE_SUCCESS:
- return CMD_SUCCESS;
- break;
- }
+ const char *xpath =
+ "./match-condition[condition='frr-bgp-route-map:rpki']";
+ char xpath_value[XPATH_MAXLEN];
- return CMD_SUCCESS;
+ nb_cli_enqueue_change(vty, xpath, NB_OP_CREATE, NULL);
+ snprintf(xpath_value, sizeof(xpath_value),
+ "%s/rmap-match-condition/frr-bgp-route-map:rpki", xpath);
+ nb_cli_enqueue_change(vty, xpath_value, NB_OP_MODIFY, argv[2]->arg);
+
+ return nb_cli_apply_changes(vty, NULL);
}
-DEFUN (no_match_rpki,
+DEFUN_YANG (no_match_rpki,
no_match_rpki_cmd,
"no match rpki <valid|invalid|notfound>",
NO_STR
@@ -1396,26 +1388,12 @@ DEFUN (no_match_rpki,
"Invalid prefix\n"
"Prefix not found\n")
{
- VTY_DECLVAR_CONTEXT(route_map_index, index);
- enum rmap_compile_rets ret;
-
- ret = route_map_delete_match(index, "rpki", argv[3]->arg,
- RMAP_EVENT_MATCH_DELETED);
- switch (ret) {
- case RMAP_RULE_MISSING:
- vty_out(vty, "%% BGP Can't find rule.\n");
- return CMD_WARNING_CONFIG_FAILED;
- break;
- case RMAP_COMPILE_ERROR:
- vty_out(vty, "%% BGP Argument is malformed.\n");
- return CMD_WARNING_CONFIG_FAILED;
- break;
- case RMAP_COMPILE_SUCCESS:
- return CMD_SUCCESS;
- break;
- }
+ const char *xpath =
+ "./match-condition[condition='frr-bgp-route-map:rpki']";
+ char xpath_value[XPATH_MAXLEN];
- return CMD_SUCCESS;
+ nb_cli_enqueue_change(vty, xpath, NB_OP_CREATE, NULL);
+ return nb_cli_apply_changes(vty, NULL);
}
static void install_cli_commands(void)
diff --git a/bgpd/subdir.am b/bgpd/subdir.am
index 0ca43fd30..583d1cd20 100644
--- a/bgpd/subdir.am
+++ b/bgpd/subdir.am
@@ -96,6 +96,8 @@ bgpd_libbgp_a_SOURCES = \
bgpd/bgp_regex.c \
bgpd/bgp_route.c \
bgpd/bgp_routemap.c \
+ bgpd/bgp_routemap_nb.c \
+ bgpd/bgp_routemap_nb_config.c \
bgpd/bgp_script.c \
bgpd/bgp_table.c \
bgpd/bgp_updgrp.c \
@@ -178,6 +180,7 @@ noinst_HEADERS += \
bgpd/bgp_regex.h \
bgpd/bgp_rpki.h \
bgpd/bgp_route.h \
+ bgpd/bgp_routemap_nb.h \
bgpd/bgp_script.h \
bgpd/bgp_table.h \
bgpd/bgp_updgrp.h \
@@ -255,4 +258,6 @@ nodist_bgpd_bgpd_SOURCES = \
yang/frr-bgp-bmp.yang.c \
yang/frr-bgp-rpki.yang.c \
yang/frr-deviations-bgp-datacenter.yang.c \
+ yang/frr-bgp-filter.yang.c \
+ yang/frr-bgp-route-map.yang.c \
# end
diff --git a/lib/routemap.c b/lib/routemap.c
index b836b55aa..33c65ac33 100644
--- a/lib/routemap.c
+++ b/lib/routemap.c
@@ -87,112 +87,126 @@ struct route_map_match_set_hooks rmap_match_set_hook;
/* match interface */
void route_map_match_interface_hook(int (*func)(
- struct vty *vty, struct route_map_index *index, const char *command,
- const char *arg, route_map_event_t type))
+ struct route_map_index *index, const char *command,
+ const char *arg, route_map_event_t type,
+ char *errmsg, size_t errmsg_len))
{
rmap_match_set_hook.match_interface = func;
}
/* no match interface */
void route_map_no_match_interface_hook(int (*func)(
- struct vty *vty, struct route_map_index *index, const char *command,
- const char *arg, route_map_event_t type))
+ struct route_map_index *index, const char *command,
+ const char *arg, route_map_event_t type,
+ char *errmsg, size_t errmsg_len))
{
rmap_match_set_hook.no_match_interface = func;
}
/* match ip address */
void route_map_match_ip_address_hook(int (*func)(
- struct vty *vty, struct route_map_index *index, const char *command,
- const char *arg, route_map_event_t type))
+ struct route_map_index *index, const char *command,
+ const char *arg, route_map_event_t type,
+ char *errmsg, size_t errmsg_len))
{
rmap_match_set_hook.match_ip_address = func;
}
/* no match ip address */
void route_map_no_match_ip_address_hook(int (*func)(
- struct vty *vty, struct route_map_index *index, const char *command,
- const char *arg, route_map_event_t type))
+ struct route_map_index *index, const char *command,
+ const char *arg, route_map_event_t type,
+ char *errmsg, size_t errmsg_len))
{
rmap_match_set_hook.no_match_ip_address = func;
}
/* match ip address prefix list */
void route_map_match_ip_address_prefix_list_hook(int (*func)(
- struct vty *vty, struct route_map_index *index, const char *command,
- const char *arg, route_map_event_t type))
+ struct route_map_index *index, const char *command,
+ const char *arg, route_map_event_t type,
+ char *errmsg, size_t errmsg_len))
{
rmap_match_set_hook.match_ip_address_prefix_list = func;
}
/* no match ip address prefix list */
void route_map_no_match_ip_address_prefix_list_hook(int (*func)(
- struct vty *vty, struct route_map_index *index, const char *command,
- const char *arg, route_map_event_t type))
+ struct route_map_index *index, const char *command,
+ const char *arg, route_map_event_t type,
+ char *errmsg, size_t errmsg_len))
{
rmap_match_set_hook.no_match_ip_address_prefix_list = func;
}
/* match ip next hop */
void route_map_match_ip_next_hop_hook(int (*func)(
- struct vty *vty, struct route_map_index *index, const char *command,
- const char *arg, route_map_event_t type))
+ struct route_map_index *index, const char *command,
+ const char *arg, route_map_event_t type,
+ char *errmsg, size_t errmsg_len))
{
rmap_match_set_hook.match_ip_next_hop = func;
}
/* no match ip next hop */
void route_map_no_match_ip_next_hop_hook(int (*func)(
- struct vty *vty, struct route_map_index *index, const char *command,
- const char *arg, route_map_event_t type))
+ struct route_map_index *index, const char *command,
+ const char *arg, route_map_event_t type,
+ char *errmsg, size_t errmsg_len))
{
rmap_match_set_hook.no_match_ip_next_hop = func;
}
/* match ip next hop prefix list */
void route_map_match_ip_next_hop_prefix_list_hook(int (*func)(
- struct vty *vty, struct route_map_index *index, const char *command,
- const char *arg, route_map_event_t type))
+ struct route_map_index *index, const char *command,
+ const char *arg, route_map_event_t type,
+ char *errmsg, size_t errmsg_len))
{
rmap_match_set_hook.match_ip_next_hop_prefix_list = func;
}
/* no match ip next hop prefix list */
void route_map_no_match_ip_next_hop_prefix_list_hook(int (*func)(
- struct vty *vty, struct route_map_index *index, const char *command,
- const char *arg, route_map_event_t type))
+ struct route_map_index *index, const char *command,
+ const char *arg, route_map_event_t type,
+ char *errmsg, size_t errmsg_len))
{
rmap_match_set_hook.no_match_ip_next_hop_prefix_list = func;
}
/* match ip next-hop type */
void route_map_match_ip_next_hop_type_hook(int (*func)(
- struct vty *vty, struct route_map_index *index, const char *command,
- const char *arg, route_map_event_t type))
+ struct route_map_index *index, const char *command,
+ const char *arg, route_map_event_t type,
+ char *errmsg, size_t errmsg_len))
{
rmap_match_set_hook.match_ip_next_hop_type = func;
}
/* no match ip next-hop type */
void route_map_no_match_ip_next_hop_type_hook(int (*func)(
- struct vty *vty, struct route_map_index *index, const char *command,
- const char *arg, route_map_event_t type))
+ struct route_map_index *index, const char *command,
+ const char *arg, route_map_event_t type,
+ char *errmsg, size_t errmsg_len))
{
rmap_match_set_hook.no_match_ip_next_hop_type = func;
}
/* match ipv6 address */
void route_map_match_ipv6_address_hook(int (*func)(
- struct vty *vty, struct route_map_index *index, const char *command,
- const char *arg, route_map_event_t type))
+ struct route_map_index *index, const char *command,
+ const char *arg, route_map_event_t type,
+ char *errmsg, size_t errmsg_len))
{
rmap_match_set_hook.match_ipv6_address = func;
}
/* no match ipv6 address */
void route_map_no_match_ipv6_address_hook(int (*func)(
- struct vty *vty, struct route_map_index *index, const char *command,
- const char *arg, route_map_event_t type))
+ struct route_map_index *index, const char *command,
+ const char *arg, route_map_event_t type,
+ char *errmsg, size_t errmsg_len))
{
rmap_match_set_hook.no_match_ipv6_address = func;
}
@@ -200,178 +214,183 @@ void route_map_no_match_ipv6_address_hook(int (*func)(
/* match ipv6 address prefix list */
void route_map_match_ipv6_address_prefix_list_hook(int (*func)(
- struct vty *vty, struct route_map_index *index, const char *command,
- const char *arg, route_map_event_t type))
+ struct route_map_index *index, const char *command,
+ const char *arg, route_map_event_t type,
+ char *errmsg, size_t errmsg_len))
{
rmap_match_set_hook.match_ipv6_address_prefix_list = func;
}
/* no match ipv6 address prefix list */
void route_map_no_match_ipv6_address_prefix_list_hook(int (*func)(
- struct vty *vty, struct route_map_index *index, const char *command,
- const char *arg, route_map_event_t type))
+ struct route_map_index *index, const char *command,
+ const char *arg, route_map_event_t type,
+ char *errmsg, size_t errmsg_len))
{
rmap_match_set_hook.no_match_ipv6_address_prefix_list = func;
}
/* match ipv6 next-hop type */
void route_map_match_ipv6_next_hop_type_hook(int (*func)(
- struct vty *vty, struct route_map_index *index, const char *command,
- const char *arg, route_map_event_t type))
+ struct route_map_index *index, const char *command,
+ const char *arg, route_map_event_t type,
+ char *errmsg, size_t errmsg_len))
{
rmap_match_set_hook.match_ipv6_next_hop_type = func;
}
/* no match ipv6 next-hop type */
void route_map_no_match_ipv6_next_hop_type_hook(int (*func)(
- struct vty *vty, struct route_map_index *index, const char *command,
- const char *arg, route_map_event_t type))
+ struct route_map_index *index, const char *command,
+ const char *arg, route_map_event_t type,
+ char *errmsg, size_t errmsg_len))
{
rmap_match_set_hook.no_match_ipv6_next_hop_type = func;
}
/* match metric */
void route_map_match_metric_hook(int (*func)(
- struct vty *vty, struct route_map_index *index, const char *command,
- const char *arg, route_map_event_t type))
+ struct route_map_index *index, const char *command,
+ const char *arg, route_map_event_t type,
+ char *errmsg, size_t errmsg_len))
{
rmap_match_set_hook.match_metric = func;
}
/* no match metric */
void route_map_no_match_metric_hook(int (*func)(
- struct vty *vty, struct route_map_index *index, const char *command,
- const char *arg, route_map_event_t type))
+ struct route_map_index *index, const char *command,
+ const char *arg, route_map_event_t type,
+ char *errmsg, size_t errmsg_len))
{
rmap_match_set_hook.no_match_metric = func;
}
/* match tag */
-void route_map_match_tag_hook(int (*func)(struct vty *vty,
- struct route_map_index *index,
+void route_map_match_tag_hook(int (*func)(struct route_map_index *index,
const char *command, const char *arg,
- route_map_event_t type))
+ route_map_event_t type,
+ char *errmsg, size_t errmsg_len))
{
rmap_match_set_hook.match_tag = func;
}
/* no match tag */
void route_map_no_match_tag_hook(int (*func)(
- struct vty *vty, struct route_map_index *index, const char *command,
- const char *arg, route_map_event_t type))
+ struct route_map_index *index, const char *command,
+ const char *arg, route_map_event_t type,
+ char *errmsg, size_t errmsg_len))
{
rmap_match_set_hook.no_match_tag = func;
}
/* set sr-te color */
-void route_map_set_srte_color_hook(int (*func)(struct vty *vty,
- struct route_map_index *index,
+void route_map_set_srte_color_hook(int (*func)(struct route_map_index *index,
const char *command,
- const char *arg))
+ const char *arg,
+ char *errmsg, size_t errmsg_len))
{
rmap_match_set_hook.set_srte_color = func;
}
/* no set sr-te color */
-void route_map_no_set_srte_color_hook(int (*func)(struct vty *vty,
- struct route_map_index *index,
+void route_map_no_set_srte_color_hook(int (*func)(struct route_map_index *index,
const char *command,
- const char *arg))
+ const char *arg,
+ char *errmsg, size_t errmsg_len))
{
rmap_match_set_hook.no_set_srte_color = func;
}
/* set ip nexthop */
-void route_map_set_ip_nexthop_hook(int (*func)(struct vty *vty,
- struct route_map_index *index,
+void route_map_set_ip_nexthop_hook(int (*func)(struct route_map_index *index,
const char *command,
- const char *arg))
+ const char *arg,
+ char *errmsg, size_t errmsg_len))
{
rmap_match_set_hook.set_ip_nexthop = func;
}
/* no set ip nexthop */
-void route_map_no_set_ip_nexthop_hook(int (*func)(struct vty *vty,
- struct route_map_index *index,
+void route_map_no_set_ip_nexthop_hook(int (*func)(struct route_map_index *index,
const char *command,
- const char *arg))
+ const char *arg,
+ char *errmsg,
+ size_t errmsg_len))
{
rmap_match_set_hook.no_set_ip_nexthop = func;
}
/* set ipv6 nexthop local */
void route_map_set_ipv6_nexthop_local_hook(
- int (*func)(struct vty *vty, struct route_map_index *index,
- const char *command, const char *arg))
+ int (*func)(struct route_map_index *index,
+ const char *command, const char *arg,
+ char *errmsg, size_t errmsg_len))
{
rmap_match_set_hook.set_ipv6_nexthop_local = func;
}
/* no set ipv6 nexthop local */
void route_map_no_set_ipv6_nexthop_local_hook(
- int (*func)(struct vty *vty, struct route_map_index *index,
- const char *command, const char *arg))
+ int (*func)(struct route_map_index *index,
+ const char *command, const char *arg,
+ char *errmsg, size_t errmsg_len))
{
rmap_match_set_hook.no_set_ipv6_nexthop_local = func;
}
/* set metric */
-void route_map_set_metric_hook(int (*func)(struct vty *vty,
- struct route_map_index *index,
+void route_map_set_metric_hook(int (*func)(struct route_map_index *index,
const char *command,
- const char *arg))
+ const char *arg,
+ char *errmsg, size_t errmsg_len))
{
rmap_match_set_hook.set_metric = func;
}
/* no set metric */
-void route_map_no_set_metric_hook(int (*func)(struct vty *vty,
- struct route_map_index *index,
+void route_map_no_set_metric_hook(int (*func)(struct route_map_index *index,
const char *command,
- const char *arg))
+ const char *arg,
+ char *errmsg, size_t errmsg_len))
{
rmap_match_set_hook.no_set_metric = func;
}
/* set tag */
-void route_map_set_tag_hook(int (*func)(struct vty *vty,
- struct route_map_index *index,
- const char *command, const char *arg))
+void route_map_set_tag_hook(int (*func)(struct route_map_index *index,
+ const char *command, const char *arg,
+ char *errmsg, size_t errmsg_len))
{
rmap_match_set_hook.set_tag = func;
}
/* no set tag */
-void route_map_no_set_tag_hook(int (*func)(struct vty *vty,
- struct route_map_index *index,
+void route_map_no_set_tag_hook(int (*func)(struct route_map_index *index,
const char *command,
- const char *arg))
+ const char *arg,
+ char *errmsg, size_t errmsg_len))
{
rmap_match_set_hook.no_set_tag = func;
}
-int generic_match_add(struct vty *vty, struct route_map_index *index,
+int generic_match_add(struct route_map_index *index,
const char *command, const char *arg,
- route_map_event_t type)
+ route_map_event_t type,
+ char *errmsg, size_t errmsg_len)
{
enum rmap_compile_rets ret;
ret = route_map_add_match(index, command, arg, type);
switch (ret) {
case RMAP_RULE_MISSING:
- if (vty)
- vty_out(vty, "%% [%s] Can't find rule.\n",
- frr_protonameinst);
- else
- zlog_warn("Can't find rule: %s", command);
+ snprintf(errmsg, errmsg_len, "%% [%s] Can't find rule.",
+ frr_protonameinst);
return CMD_WARNING_CONFIG_FAILED;
case RMAP_COMPILE_ERROR:
- if (vty)
- vty_out(vty,
- "%% [%s] Argument form is unsupported or malformed.\n",
- frr_protonameinst);
- else
- zlog_warn("Argument form is unsupported or malformed: %s %s", command, arg);
+ snprintf(errmsg, errmsg_len,
+ "%% [%s] Argument form is unsupported or malformed.",
+ frr_protonameinst);
return CMD_WARNING_CONFIG_FAILED;
case RMAP_COMPILE_SUCCESS:
/*
@@ -383,9 +402,10 @@ int generic_match_add(struct vty *vty, struct route_map_index *index,
return CMD_SUCCESS;
}
-int generic_match_delete(struct vty *vty, struct route_map_index *index,
+int generic_match_delete(struct route_map_index *index,
const char *command, const char *arg,
- route_map_event_t type)
+ route_map_event_t type,
+ char *errmsg, size_t errmsg_len)
{
enum rmap_compile_rets ret;
int retval = CMD_SUCCESS;
@@ -409,20 +429,14 @@ int generic_match_delete(struct vty *vty, struct route_map_index *index,
ret = route_map_delete_match(index, command, dep_name, type);
switch (ret) {
case RMAP_RULE_MISSING:
- if (vty)
- vty_out(vty, "%% [%s] Can't find rule.\n",
- frr_protonameinst);
- else
- zlog_warn("Can't find rule: %s", command);
+ snprintf(errmsg, errmsg_len, "%% [%s] Can't find rule.",
+ frr_protonameinst);
retval = CMD_WARNING_CONFIG_FAILED;
break;
case RMAP_COMPILE_ERROR:
- if (vty)
- vty_out(vty,
- "%% [%s] Argument form is unsupported or malformed.\n",
- frr_protonameinst);
- else
- zlog_warn("Argument form is unsupported or malformed: %s %s", command, arg);
+ snprintf(errmsg, errmsg_len,
+ "%% [%s] Argument form is unsupported or malformed.",
+ frr_protonameinst);
retval = CMD_WARNING_CONFIG_FAILED;
break;
case RMAP_COMPILE_SUCCESS:
@@ -438,26 +452,22 @@ int generic_match_delete(struct vty *vty, struct route_map_index *index,
return retval;
}
-int generic_set_add(struct vty *vty, struct route_map_index *index,
- const char *command, const char *arg)
+int generic_set_add(struct route_map_index *index,
+ const char *command, const char *arg,
+ char *errmsg, size_t errmsg_len)
{
enum rmap_compile_rets ret;
ret = route_map_add_set(index, command, arg);
switch (ret) {
case RMAP_RULE_MISSING:
- if (vty)
- vty_out(vty, "%% [%s] Can't find rule.\n", frr_protonameinst);
- else
- zlog_warn("Can't find rule: %s", command);
+ snprintf(errmsg, errmsg_len,
+ "%% [%s] Can't find rule.", frr_protonameinst);
return CMD_WARNING_CONFIG_FAILED;
case RMAP_COMPILE_ERROR:
- if (vty)
- vty_out(vty,
- "%% [%s] Argument form is unsupported or malformed.\n",
- frr_protonameinst);
- else
- zlog_warn("Argument form is unsupported or malformed: %s %s", command, arg);
+ snprintf(errmsg, errmsg_len,
+ "%% [%s] Argument form is unsupported or malformed.",
+ frr_protonameinst);
return CMD_WARNING_CONFIG_FAILED;
case RMAP_COMPILE_SUCCESS:
break;
@@ -466,26 +476,22 @@ int generic_set_add(struct vty *vty, struct route_map_index *index,
return CMD_SUCCESS;
}
-int generic_set_delete(struct vty *vty, struct route_map_index *index,
- const char *command, const char *arg)
+int generic_set_delete(struct route_map_index *index,
+ const char *command, const char *arg,
+ char *errmsg, size_t errmsg_len)
{
enum rmap_compile_rets ret;
ret = route_map_delete_set(index, command, arg);
switch (ret) {
case RMAP_RULE_MISSING:
- if (vty)
- vty_out(vty, "%% [%s] Can't find rule.\n", frr_protonameinst);
- else
- zlog_warn("Can't find rule: %s", command);
+ snprintf(errmsg, errmsg_len, "%% [%s] Can't find rule.",
+ frr_protonameinst);
return CMD_WARNING_CONFIG_FAILED;
case RMAP_COMPILE_ERROR:
- if (vty)
- vty_out(vty,
- "%% [%s] Argument form is unsupported or malformed.\n",
- frr_protonameinst);
- else
- zlog_warn("Argument form is unsupported or malformed: %s %s", command, arg);
+ snprintf(errmsg, errmsg_len,
+ "%% [%s] Argument form is unsupported or malformed.",
+ frr_protonameinst);
return CMD_WARNING_CONFIG_FAILED;
case RMAP_COMPILE_SUCCESS:
break;
@@ -2627,47 +2633,6 @@ static unsigned int route_map_dep_data_hash_make_key(const void *p)
return string_hash_make(dep_data->rname);
}
-DEFUN (set_srte_color,
- set_srte_color_cmd,
- "set sr-te color [(1-4294967295)]",
- SET_STR
- SRTE_STR
- SRTE_COLOR_STR
- "Color of the SR-TE Policies to match with\n")
-{
- VTY_DECLVAR_CONTEXT(route_map_index, index);
- int idx = 0;
- char *arg = argv_find(argv, argc, "(1-4294967295)", &idx)
- ? argv[idx]->arg
- : NULL;
-
- if (rmap_match_set_hook.set_srte_color)
- return rmap_match_set_hook.set_srte_color(vty, index,
- "sr-te color", arg);
- return CMD_SUCCESS;
-}
-
-DEFUN (no_set_srte_color,
- no_set_srte_color_cmd,
- "no set sr-te color [(1-4294967295)]",
- NO_STR
- SET_STR
- SRTE_STR
- SRTE_COLOR_STR
- "Color of the SR-TE Policies to match with\n")
-{
- VTY_DECLVAR_CONTEXT(route_map_index, index);
- int idx = 0;
- char *arg = argv_find(argv, argc, "(1-4294967295)", &idx)
- ? argv[idx]->arg
- : NULL;
-
- if (rmap_match_set_hook.no_set_srte_color)
- return rmap_match_set_hook.no_set_srte_color(
- vty, index, "sr-te color", arg);
- return CMD_SUCCESS;
-}
-
static void *route_map_dep_hash_alloc(void *p)
{
char *dep_name = (char *)p;
@@ -3279,8 +3244,5 @@ void route_map_init(void)
install_element(RMAP_NODE, &routemap_optimization_cmd);
install_element(RMAP_NODE, &no_routemap_optimization_cmd);
- install_element(RMAP_NODE, &set_srte_color_cmd);
- install_element(RMAP_NODE, &no_set_srte_color_cmd);
-
install_element(ENABLE_NODE, &show_route_map_pfx_tbl_cmd);
}
diff --git a/lib/routemap.h b/lib/routemap.h
index f1791405d..6385193bb 100644
--- a/lib/routemap.h
+++ b/lib/routemap.h
@@ -229,6 +229,144 @@ struct route_map {
};
DECLARE_QOBJ_TYPE(route_map);
+/* Route-map match conditions */
+#define IS_MATCH_INTERFACE(C) \
+ (strmatch(C, "frr-route-map:interface"))
+#define IS_MATCH_IPv4_ADDRESS_LIST(C) \
+ (strmatch(C, "frr-route-map:ipv4-address-list"))
+#define IS_MATCH_IPv6_ADDRESS_LIST(C) \
+ (strmatch(C, "frr-route-map:ipv6-address-list"))
+#define IS_MATCH_IPv4_NEXTHOP_LIST(C) \
+ (strmatch(C, "frr-route-map:ipv4-next-hop-list"))
+#define IS_MATCH_IPv4_PREFIX_LIST(C) \
+ (strmatch(C, "frr-route-map:ipv4-prefix-list"))
+#define IS_MATCH_IPv6_PREFIX_LIST(C) \
+ (strmatch(C, "frr-route-map:ipv6-prefix-list"))
+#define IS_MATCH_IPv4_NEXTHOP_PREFIX_LIST(C) \
+ (strmatch(C, "frr-route-map:ipv4-next-hop-prefix-list"))
+#define IS_MATCH_IPv4_NEXTHOP_TYPE(C) \
+ (strmatch(C, "frr-route-map:ipv4-next-hop-type"))
+#define IS_MATCH_IPv6_NEXTHOP_TYPE(C) \
+ (strmatch(C, "frr-route-map:ipv6-next-hop-type"))
+#define IS_MATCH_METRIC(C) \
+ (strmatch(C, "frr-route-map:match-metric"))
+#define IS_MATCH_TAG(C) (strmatch(C, "frr-route-map:match-tag"))
+/* Zebra route-map match conditions */
+#define IS_MATCH_IPv4_PREFIX_LEN(C) \
+ (strmatch(C, "frr-zebra-route-map:ipv4-prefix-length"))
+#define IS_MATCH_IPv6_PREFIX_LEN(C) \
+ (strmatch(C, "frr-zebra-route-map:ipv6-prefix-length"))
+#define IS_MATCH_IPv4_NH_PREFIX_LEN(C) \
+ (strmatch(C, "frr-zebra-route-map:ipv4-next-hop-prefix-length"))
+#define IS_MATCH_SRC_PROTO(C) \
+ (strmatch(C, "frr-zebra-route-map:source-protocol"))
+#define IS_MATCH_SRC_INSTANCE(C) \
+ (strmatch(C, "frr-zebra-route-map:source-instance"))
+/* BGP route-map match conditions */
+#define IS_MATCH_LOCAL_PREF(C) \
+ (strmatch(C, "frr-bgp-route-map:match-local-preference"))
+#define IS_MATCH_ORIGIN(C) \
+ (strmatch(C, "frr-bgp-route-map:match-origin"))
+#define IS_MATCH_RPKI(C) (strmatch(C, "frr-bgp-route-map:rpki"))
+#define IS_MATCH_PROBABILITY(C) \
+ (strmatch(C, "frr-bgp-route-map:probability"))
+#define IS_MATCH_SRC_VRF(C) \
+ (strmatch(C, "frr-bgp-route-map:source-vrf"))
+#define IS_MATCH_PEER(C) (strmatch(C, "frr-bgp-route-map:peer"))
+#define IS_MATCH_AS_LIST(C) \
+ (strmatch(C, "frr-bgp-route-map:as-path-list"))
+#define IS_MATCH_MAC_LIST(C) \
+ (strmatch(C, "frr-bgp-route-map:mac-address-list"))
+#define IS_MATCH_EVPN_ROUTE_TYPE(C) \
+ (strmatch(C, "frr-bgp-route-map:evpn-route-type"))
+#define IS_MATCH_EVPN_DEFAULT_ROUTE(C) \
+ (strmatch(C, "frr-bgp-route-map:evpn-default-route"))
+#define IS_MATCH_EVPN_VNI(C) \
+ (strmatch(C, "frr-bgp-route-map:evpn-vni"))
+#define IS_MATCH_EVPN_DEFAULT_ROUTE(C) \
+ (strmatch(C, "frr-bgp-route-map:evpn-default-route"))
+#define IS_MATCH_EVPN_RD(C) \
+ (strmatch(C, "frr-bgp-route-map:evpn-rd"))
+#define IS_MATCH_ROUTE_SRC(C) \
+ (strmatch(C, "frr-bgp-route-map:ip-route-source"))
+#define IS_MATCH_ROUTE_SRC_PL(C) \
+ (strmatch(C, "frr-bgp-route-map:ip-route-source-prefix-list"))
+#define IS_MATCH_COMMUNITY(C) \
+ (strmatch(C, "frr-bgp-route-map:match-community"))
+#define IS_MATCH_LCOMMUNITY(C) \
+ (strmatch(C, "frr-bgp-route-map:match-large-community"))
+#define IS_MATCH_EXTCOMMUNITY(C) \
+ (strmatch(C, "frr-bgp-route-map:match-extcommunity"))
+#define IS_MATCH_IPV4_NH(C) \
+ (strmatch(C, "frr-bgp-route-map:ipv4-nexthop"))
+#define IS_MATCH_IPV6_NH(C) \
+ (strmatch(C, "frr-bgp-route-map:ipv6-nexthop"))
+
+/* Route-map set actions */
+#define IS_SET_IPv4_NH(A) \
+ (strmatch(A, "frr-route-map:ipv4-next-hop"))
+#define IS_SET_IPv6_NH(A) \
+ (strmatch(A, "frr-route-map:ipv6-next-hop"))
+#define IS_SET_METRIC(A) \
+ (strmatch(A, "frr-route-map:set-metric"))
+#define IS_SET_TAG(A) (strmatch(A, "frr-route-map:set-tag"))
+#define IS_SET_SR_TE_COLOR(A) \
+ (strmatch(A, "frr-route-map:set-sr-te-color"))
+/* Zebra route-map set actions */
+#define IS_SET_SRC(A) \
+ (strmatch(A, "frr-zebra-route-map:src-address"))
+/* OSPF route-map set actions */
+#define IS_SET_METRIC_TYPE(A) \
+ (strmatch(A, "frr-ospf-route-map:metric-type"))
+#define IS_SET_FORWARDING_ADDR(A) \
+ (strmatch(A, "frr-ospf6-route-map:forwarding-address"))
+/* BGP route-map_set actions */
+#define IS_SET_WEIGHT(A) \
+ (strmatch(A, "frr-bgp-route-map:weight"))
+#define IS_SET_TABLE(A) (strmatch(A, "frr-bgp-route-map:table"))
+#define IS_SET_LOCAL_PREF(A) \
+ (strmatch(A, "frr-bgp-route-map:set-local-preference"))
+#define IS_SET_LABEL_INDEX(A) \
+ (strmatch(A, "frr-bgp-route-map:label-index"))
+#define IS_SET_DISTANCE(A) \
+ (strmatch(A, "frr-bgp-route-map:distance"))
+#define IS_SET_ORIGIN(A) \
+ (strmatch(A, "frr-bgp-route-map:set-origin"))
+#define IS_SET_ATOMIC_AGGREGATE(A) \
+ (strmatch(A, "frr-bgp-route-map:atomic-aggregate"))
+#define IS_SET_ORIGINATOR_ID(A) \
+ (strmatch(A, "frr-bgp-route-map:originator-id"))
+#define IS_SET_COMM_LIST_DEL(A) \
+ (strmatch(A, "frr-bgp-route-map:comm-list-delete"))
+#define IS_SET_LCOMM_LIST_DEL(A) \
+ (strmatch(A, "frr-bgp-route-map:large-comm-list-delete"))
+#define IS_SET_LCOMMUNITY(A) \
+ (strmatch(A, "frr-bgp-route-map:set-large-community"))
+#define IS_SET_COMMUNITY(A) \
+ (strmatch(A, "frr-bgp-route-map:set-community"))
+#define IS_SET_EXTCOMMUNITY_RT(A) \
+ (strmatch(A, "frr-bgp-route-map:set-extcommunity-rt"))
+#define IS_SET_EXTCOMMUNITY_SOO(A) \
+ (strmatch(A, "frr-bgp-route-map:set-extcommunity-soo"))
+#define IS_SET_AGGREGATOR(A) \
+ (strmatch(A, "frr-bgp-route-map:aggregator"))
+#define IS_SET_AS_PREPEND(A) \
+ (strmatch(A, "frr-bgp-route-map:as-path-prepend"))
+#define IS_SET_AS_EXCLUDE(A) \
+ (strmatch(A, "frr-bgp-route-map:as-path-exclude"))
+#define IS_SET_IPV6_NH_GLOBAL(A) \
+ (strmatch(A, "frr-bgp-route-map:ipv6-nexthop-global"))
+#define IS_SET_IPV6_VPN_NH(A) \
+ (strmatch(A, "frr-bgp-route-map:ipv6-vpn-address"))
+#define IS_SET_IPV6_PEER_ADDR(A) \
+ (strmatch(A, "frr-bgp-route-map:ipv6-peer-address"))
+#define IS_SET_IPV6_PREFER_GLOBAL(A) \
+ (strmatch(A, "frr-bgp-route-map:ipv6-prefer-global"))
+#define IS_SET_IPV4_VPN_NH(A) \
+ (strmatch(A, "frr-bgp-route-map:ipv4-vpn-address"))
+#define IS_SET_BGP_IPV4_NH(A) \
+ (strmatch(A, "frr-bgp-route-map:set-ipv4-nexthop"))
+
/* Prototypes. */
extern void route_map_init(void);
@@ -310,150 +448,186 @@ extern void
route_map_notify_pentry_dependencies(const char *affected_name,
struct prefix_list_entry *pentry,
route_map_event_t event);
-extern int generic_match_add(struct vty *vty, struct route_map_index *index,
+extern int generic_match_add(struct route_map_index *index,
const char *command, const char *arg,
- route_map_event_t type);
-
-extern int generic_match_delete(struct vty *vty, struct route_map_index *index,
+ route_map_event_t type,
+ char *errmsg, size_t errmsg_len);
+extern int generic_match_delete(struct route_map_index *index,
const char *command, const char *arg,
- route_map_event_t type);
-extern int generic_set_add(struct vty *vty, struct route_map_index *index,
- const char *command, const char *arg);
-extern int generic_set_delete(struct vty *vty, struct route_map_index *index,
- const char *command, const char *arg);
+ route_map_event_t type,
+ char *errmsg, size_t errmsg_len);
+
+extern int generic_set_add(struct route_map_index *index,
+ const char *command, const char *arg,
+ char *errmsg, size_t errmsg_len);
+extern int generic_set_delete(struct route_map_index *index,
+ const char *command, const char *arg,
+ char *errmsg, size_t errmsg_len);
/* match interface */
extern void route_map_match_interface_hook(int (*func)(
- struct vty *vty, struct route_map_index *index, const char *command,
- const char *arg, route_map_event_t type));
+ struct route_map_index *index, const char *command,
+ const char *arg, route_map_event_t type,
+ char *errmsg, size_t errmsg_len));
/* no match interface */
extern void route_map_no_match_interface_hook(int (*func)(
- struct vty *vty, struct route_map_index *index, const char *command,
- const char *arg, route_map_event_t type));
+ struct route_map_index *index, const char *command,
+ const char *arg, route_map_event_t type,
+ char *errmsg, size_t errmsg_len));
/* match ip address */
extern void route_map_match_ip_address_hook(int (*func)(
- struct vty *vty, struct route_map_index *index, const char *command,
- const char *arg, route_map_event_t type));
+ struct route_map_index *index, const char *command,
+ const char *arg, route_map_event_t type,
+ char *errmsg, size_t errmsg_len));
/* no match ip address */
extern void route_map_no_match_ip_address_hook(int (*func)(
- struct vty *vty, struct route_map_index *index, const char *command,
- const char *arg, route_map_event_t type));
+ struct route_map_index *index, const char *command,
+ const char *arg, route_map_event_t type,
+ char *errmsg, size_t errmsg_len));
/* match ip address prefix list */
extern void route_map_match_ip_address_prefix_list_hook(int (*func)(
- struct vty *vty, struct route_map_index *index, const char *command,
- const char *arg, route_map_event_t type));
+ struct route_map_index *index, const char *command,
+ const char *arg, route_map_event_t type,
+ char *errmsg, size_t errmsg_len));
/* no match ip address prefix list */
extern void route_map_no_match_ip_address_prefix_list_hook(int (*func)(
- struct vty *vty, struct route_map_index *index, const char *command,
- const char *arg, route_map_event_t type));
+ struct route_map_index *index, const char *command,
+ const char *arg, route_map_event_t type,
+ char *errmsg, size_t errmsg_len));
/* match ip next hop */
extern void route_map_match_ip_next_hop_hook(int (*func)(
- struct vty *vty, struct route_map_index *index, const char *command,
- const char *arg, route_map_event_t type));
+ struct route_map_index *index, const char *command,
+ const char *arg, route_map_event_t type,
+ char *errmsg, size_t errmsg_len));
/* no match ip next hop */
extern void route_map_no_match_ip_next_hop_hook(int (*func)(
- struct vty *vty, struct route_map_index *index, const char *command,
- const char *arg, route_map_event_t type));
+ struct route_map_index *index, const char *command,
+ const char *arg, route_map_event_t type,
+ char *errmsg, size_t errmsg_len));
/* match ip next hop prefix list */
extern void route_map_match_ip_next_hop_prefix_list_hook(int (*func)(
- struct vty *vty, struct route_map_index *index, const char *command,
- const char *arg, route_map_event_t type));
+ struct route_map_index *index, const char *command,
+ const char *arg, route_map_event_t type,
+ char *errmsg, size_t errmsg_len));
/* no match ip next hop prefix list */
extern void route_map_no_match_ip_next_hop_prefix_list_hook(int (*func)(
- struct vty *vty, struct route_map_index *index, const char *command,
- const char *arg, route_map_event_t type));
+ struct route_map_index *index, const char *command,
+ const char *arg, route_map_event_t type,
+ char *errmsg, size_t errmsg_len));
/* match ip next hop type */
extern void route_map_match_ip_next_hop_type_hook(int (*func)(
- struct vty *vty, struct route_map_index *index, const char *command,
- const char *arg, route_map_event_t type));
+ struct route_map_index *index, const char *command,
+ const char *arg, route_map_event_t type,
+ char *errmsg, size_t errmsg_len));
/* no match ip next hop type */
extern void route_map_no_match_ip_next_hop_type_hook(int (*func)(
- struct vty *vty, struct route_map_index *index, const char *command,
- const char *arg, route_map_event_t type));
+ struct route_map_index *index, const char *command,
+ const char *arg, route_map_event_t type,
+ char *errmsg, size_t errmsg_len));
/* match ipv6 address */
extern void route_map_match_ipv6_address_hook(int (*func)(
- struct vty *vty, struct route_map_index *index, const char *command,
- const char *arg, route_map_event_t type));
+ struct route_map_index *index, const char *command,
+ const char *arg, route_map_event_t type,
+ char *errmsg, size_t errmsg_len));
/* no match ipv6 address */
extern void route_map_no_match_ipv6_address_hook(int (*func)(
- struct vty *vty, struct route_map_index *index, const char *command,
- const char *arg, route_map_event_t type));
+ struct route_map_index *index, const char *command,
+ const char *arg, route_map_event_t type,
+ char *errmsg, size_t errmsg_len));
/* match ipv6 address prefix list */
extern void route_map_match_ipv6_address_prefix_list_hook(int (*func)(
- struct vty *vty, struct route_map_index *index, const char *command,
- const char *arg, route_map_event_t type));
+ struct route_map_index *index, const char *command,
+ const char *arg, route_map_event_t type,
+ char *errmsg, size_t errmsg_len));
/* no match ipv6 address prefix list */
extern void route_map_no_match_ipv6_address_prefix_list_hook(int (*func)(
- struct vty *vty, struct route_map_index *index, const char *command,
- const char *arg, route_map_event_t type));
+ struct route_map_index *index, const char *command,
+ const char *arg, route_map_event_t type,
+ char *errmsg, size_t errmsg_len));
/* match ipv6 next-hop type */
extern void route_map_match_ipv6_next_hop_type_hook(int (*func)(
- struct vty *vty, struct route_map_index *index, const char *command,
- const char *arg, route_map_event_t type));
+ struct route_map_index *index, const char *command,
+ const char *arg, route_map_event_t type,
+ char *errmsg, size_t errmsg_len));
/* no match ipv6 next-hop type */
extern void route_map_no_match_ipv6_next_hop_type_hook(int (*func)(
- struct vty *vty, struct route_map_index *index, const char *command,
- const char *arg, route_map_event_t type));
+ struct route_map_index *index, const char *command,
+ const char *arg, route_map_event_t type,
+ char *errmsg, size_t errmsg_len));
/* match metric */
extern void route_map_match_metric_hook(int (*func)(
- struct vty *vty, struct route_map_index *index, const char *command,
- const char *arg, route_map_event_t type));
+ struct route_map_index *index, const char *command,
+ const char *arg, route_map_event_t type,
+ char *errmsg, size_t errmsg_len));
/* no match metric */
extern void route_map_no_match_metric_hook(int (*func)(
- struct vty *vty, struct route_map_index *index, const char *command,
- const char *arg, route_map_event_t type));
+ struct route_map_index *index, const char *command,
+ const char *arg, route_map_event_t type,
+ char *errmsg, size_t errmsg_len));
/* match tag */
extern void route_map_match_tag_hook(int (*func)(
- struct vty *vty, struct route_map_index *index, const char *command,
- const char *arg, route_map_event_t type));
+ struct route_map_index *index, const char *command,
+ const char *arg, route_map_event_t type,
+ char *errmsg, size_t errmsg_len));
/* no match tag */
extern void route_map_no_match_tag_hook(int (*func)(
- struct vty *vty, struct route_map_index *index, const char *command,
- const char *arg, route_map_event_t type));
+ struct route_map_index *index, const char *command,
+ const char *arg, route_map_event_t type,
+ char *errmsg, size_t errmsg_len));
/* set sr-te color */
extern void route_map_set_srte_color_hook(
- int (*func)(struct vty *vty, struct route_map_index *index,
- const char *command, const char *arg));
+ int (*func)(struct route_map_index *index,
+ const char *command, const char *arg,
+ char *errmsg, size_t errmsg_len));
/* no set sr-te color */
extern void route_map_no_set_srte_color_hook(
- int (*func)(struct vty *vty, struct route_map_index *index,
- const char *command, const char *arg));
+ int (*func)(struct route_map_index *index,
+ const char *command, const char *arg,
+ char *errmsg, size_t errmsg_len));
/* set ip nexthop */
extern void route_map_set_ip_nexthop_hook(
- int (*func)(struct vty *vty, struct route_map_index *index,
- const char *command, const char *arg));
+ int (*func)(struct route_map_index *index,
+ const char *command, const char *arg,
+ char *errmsg, size_t errmsg_len));
/* no set ip nexthop */
extern void route_map_no_set_ip_nexthop_hook(
- int (*func)(struct vty *vty, struct route_map_index *index,
- const char *command, const char *arg));
+ int (*func)(struct route_map_index *index,
+ const char *command, const char *arg,
+ char *errmsg, size_t errmsg_len));
/* set ipv6 nexthop local */
extern void route_map_set_ipv6_nexthop_local_hook(
- int (*func)(struct vty *vty, struct route_map_index *index,
- const char *command, const char *arg));
+ int (*func)(struct route_map_index *index,
+ const char *command, const char *arg,
+ char *errmsg, size_t errmsg_len));
/* no set ipv6 nexthop local */
extern void route_map_no_set_ipv6_nexthop_local_hook(
- int (*func)(struct vty *vty, struct route_map_index *index,
- const char *command, const char *arg));
+ int (*func)(struct route_map_index *index,
+ const char *command, const char *arg,
+ char *errmsg, size_t errmsg_len));
/* set metric */
-extern void route_map_set_metric_hook(int (*func)(struct vty *vty,
- struct route_map_index *index,
+extern void route_map_set_metric_hook(int (*func)(struct route_map_index *index,
const char *command,
- const char *arg));
+ const char *arg,
+ char *errmsg,
+ size_t errmsg_len));
/* no set metric */
extern void route_map_no_set_metric_hook(
- int (*func)(struct vty *vty, struct route_map_index *index,
- const char *command, const char *arg));
+ int (*func)(struct route_map_index *index,
+ const char *command, const char *arg,
+ char *errmsg, size_t errmsg_len));
/* set tag */
-extern void route_map_set_tag_hook(int (*func)(struct vty *vty,
- struct route_map_index *index,
+extern void route_map_set_tag_hook(int (*func)(struct route_map_index *index,
const char *command,
- const char *arg));
+ const char *arg,
+ char *errmsg,
+ size_t errmsg_len));
/* no set tag */
-extern void route_map_no_set_tag_hook(int (*func)(struct vty *vty,
- struct route_map_index *index,
+extern void route_map_no_set_tag_hook(int (*func)(struct route_map_index *index,
const char *command,
- const char *arg));
+ const char *arg,
+ char *errmsg,
+ size_t errmsg_len));
extern void *route_map_rule_tag_compile(const char *arg);
extern void route_map_rule_tag_free(void *rule);
@@ -467,181 +641,200 @@ extern void route_map_counter_decrement(struct route_map *map);
/* Route map hooks data structure. */
struct route_map_match_set_hooks {
/* match interface */
- int (*match_interface)(struct vty *vty, struct route_map_index *index,
+ int (*match_interface)(struct route_map_index *index,
const char *command, const char *arg,
- route_map_event_t type);
+ route_map_event_t type,
+ char *errmsg, size_t errmsg_len);
/* no match interface */
- int (*no_match_interface)(struct vty *vty,
- struct route_map_index *index,
+ int (*no_match_interface)(struct route_map_index *index,
const char *command, const char *arg,
- route_map_event_t type);
+ route_map_event_t type,
+ char *errmsg, size_t errmsg_len);
/* match ip address */
- int (*match_ip_address)(struct vty *vty, struct route_map_index *index,
+ int (*match_ip_address)(struct route_map_index *index,
const char *command, const char *arg,
- route_map_event_t type);
+ route_map_event_t type,
+ char *errmsg, size_t errmsg_len);
/* no match ip address */
- int (*no_match_ip_address)(struct vty *vty,
- struct route_map_index *index,
+ int (*no_match_ip_address)(struct route_map_index *index,
const char *command, const char *arg,
- route_map_event_t type);
+ route_map_event_t type,
+ char *errmsg, size_t errmsg_len);
/* match ip address prefix list */
- int (*match_ip_address_prefix_list)(struct vty *vty,
- struct route_map_index *index,
+ int (*match_ip_address_prefix_list)(struct route_map_index *index,
const char *command,
const char *arg,
- route_map_event_t type);
+ route_map_event_t type,
+ char *errmsg, size_t errmsg_len);
/* no match ip address prefix list */
- int (*no_match_ip_address_prefix_list)(struct vty *vty,
- struct route_map_index *index,
+ int (*no_match_ip_address_prefix_list)(struct route_map_index *index,
const char *command,
const char *arg,
- route_map_event_t type);
+ route_map_event_t type,
+ char *errmsg, size_t errmsg_len);
/* match ip next hop */
- int (*match_ip_next_hop)(struct vty *vty, struct route_map_index *index,
+ int (*match_ip_next_hop)(struct route_map_index *index,
const char *command, const char *arg,
- route_map_event_t type);
+ route_map_event_t type,
+ char *errmsg, size_t errmsg_len);
/* no match ip next hop */
- int (*no_match_ip_next_hop)(struct vty *vty,
- struct route_map_index *index,
+ int (*no_match_ip_next_hop)(struct route_map_index *index,
const char *command, const char *arg,
- route_map_event_t type);
+ route_map_event_t type,
+ char *errmsg, size_t errmsg_len);
/* match ip next hop prefix list */
- int (*match_ip_next_hop_prefix_list)(struct vty *vty,
- struct route_map_index *index,
+ int (*match_ip_next_hop_prefix_list)(struct route_map_index *index,
const char *command,
const char *arg,
- route_map_event_t type);
+ route_map_event_t type,
+ char *errmsg, size_t errmsg_len);
/* no match ip next hop prefix list */
- int (*no_match_ip_next_hop_prefix_list)(struct vty *vty,
- struct route_map_index *index,
+ int (*no_match_ip_next_hop_prefix_list)(struct route_map_index *index,
const char *command,
const char *arg,
- route_map_event_t type);
+ route_map_event_t type,
+ char *errmsg,
+ size_t errmsg_len);
/* match ip next-hop type */
- int (*match_ip_next_hop_type)(struct vty *vty,
- struct route_map_index *index,
- const char *command,
- const char *arg,
- route_map_event_t type);
+ int (*match_ip_next_hop_type)(struct route_map_index *index,
+ const char *command,
+ const char *arg,
+ route_map_event_t type,
+ char *errmsg,
+ size_t errmsg_len);
/* no match ip next-hop type */
- int (*no_match_ip_next_hop_type)(struct vty *vty,
- struct route_map_index *index,
- const char *command,
- const char *arg,
- route_map_event_t type);
+ int (*no_match_ip_next_hop_type)(struct route_map_index *index,
+ const char *command,
+ const char *arg,
+ route_map_event_t type,
+ char *errmsg,
+ size_t errmsg_len);
/* match ipv6 address */
- int (*match_ipv6_address)(struct vty *vty,
- struct route_map_index *index,
+ int (*match_ipv6_address)(struct route_map_index *index,
const char *command, const char *arg,
- route_map_event_t type);
+ route_map_event_t type,
+ char *errmsg, size_t errmsg_len);
/* no match ipv6 address */
- int (*no_match_ipv6_address)(struct vty *vty,
- struct route_map_index *index,
+ int (*no_match_ipv6_address)(struct route_map_index *index,
const char *command, const char *arg,
- route_map_event_t type);
+ route_map_event_t type,
+ char *errmsg, size_t errmsg_len);
/* match ipv6 address prefix list */
- int (*match_ipv6_address_prefix_list)(struct vty *vty,
- struct route_map_index *index,
+ int (*match_ipv6_address_prefix_list)(struct route_map_index *index,
const char *command,
const char *arg,
- route_map_event_t type);
+ route_map_event_t type,
+ char *errmsg, size_t errmsg_len);
/* no match ipv6 address prefix list */
- int (*no_match_ipv6_address_prefix_list)(struct vty *vty,
- struct route_map_index *index,
+ int (*no_match_ipv6_address_prefix_list)(struct route_map_index *index,
const char *command,
const char *arg,
- route_map_event_t type);
+ route_map_event_t type,
+ char *errmsg,
+ size_t errmsg_len);
/* match ipv6 next-hop type */
- int (*match_ipv6_next_hop_type)(struct vty *vty,
- struct route_map_index *index,
+ int (*match_ipv6_next_hop_type)(struct route_map_index *index,
const char *command,
const char *arg,
- route_map_event_t type);
+ route_map_event_t type,
+ char *errmsg, size_t errmsg_len);
/* no match ipv6 next-hop type */
- int (*no_match_ipv6_next_hop_type)(struct vty *vty,
- struct route_map_index *index,
+ int (*no_match_ipv6_next_hop_type)(struct route_map_index *index,
const char *command, const char *arg,
- route_map_event_t type);
+ route_map_event_t type,
+ char *errmsg, size_t errmsg_len);
/* match metric */
- int (*match_metric)(struct vty *vty, struct route_map_index *index,
+ int (*match_metric)(struct route_map_index *index,
const char *command, const char *arg,
- route_map_event_t type);
+ route_map_event_t type,
+ char *errmsg, size_t errmsg_len);
/* no match metric */
- int (*no_match_metric)(struct vty *vty, struct route_map_index *index,
+ int (*no_match_metric)(struct route_map_index *index,
const char *command, const char *arg,
- route_map_event_t type);
+ route_map_event_t type,
+ char *errmsg, size_t errmsg_len);
/* match tag */
- int (*match_tag)(struct vty *vty, struct route_map_index *index,
+ int (*match_tag)(struct route_map_index *index,
const char *command, const char *arg,
- route_map_event_t type);
+ route_map_event_t type,
+ char *errmsg, size_t errmsg_len);
/* no match tag */
- int (*no_match_tag)(struct vty *vty, struct route_map_index *index,
+ int (*no_match_tag)(struct route_map_index *index,
const char *command, const char *arg,
- route_map_event_t type);
+ route_map_event_t type,
+ char *errmsg, size_t errmsg_len);
/* set sr-te color */
- int (*set_srte_color)(struct vty *vty, struct route_map_index *index,
- const char *command, const char *arg);
+ int (*set_srte_color)(struct route_map_index *index,
+ const char *command, const char *arg,
+ char *errmsg, size_t errmsg_len);
/* no set sr-te color */
- int (*no_set_srte_color)(struct vty *vty, struct route_map_index *index,
- const char *command, const char *arg);
+ int (*no_set_srte_color)(struct route_map_index *index,
+ const char *command, const char *arg,
+ char *errmsg, size_t errmsg_len);
/* set ip nexthop */
- int (*set_ip_nexthop)(struct vty *vty, struct route_map_index *index,
- const char *command, const char *arg);
+ int (*set_ip_nexthop)(struct route_map_index *index,
+ const char *command, const char *arg,
+ char *errmsg, size_t errmsg_len);
/* no set ip nexthop */
- int (*no_set_ip_nexthop)(struct vty *vty, struct route_map_index *index,
- const char *command, const char *arg);
+ int (*no_set_ip_nexthop)(struct route_map_index *index,
+ const char *command, const char *arg,
+ char *errmsg, size_t errmsg_len);
/* set ipv6 nexthop local */
- int (*set_ipv6_nexthop_local)(struct vty *vty,
- struct route_map_index *index,
- const char *command, const char *arg);
+ int (*set_ipv6_nexthop_local)(struct route_map_index *index,
+ const char *command, const char *arg,
+ char *errmsg, size_t errmsg_len);
/* no set ipv6 nexthop local */
- int (*no_set_ipv6_nexthop_local)(struct vty *vty,
- struct route_map_index *index,
- const char *command, const char *arg);
+ int (*no_set_ipv6_nexthop_local)(struct route_map_index *index,
+ const char *command, const char *arg,
+ char *errmsg, size_t errmsg_len);
/* set metric */
- int (*set_metric)(struct vty *vty, struct route_map_index *index,
- const char *command, const char *arg);
+ int (*set_metric)(struct route_map_index *index,
+ const char *command, const char *arg,
+ char *errmsg, size_t errmsg_len);
/* no set metric */
- int (*no_set_metric)(struct vty *vty, struct route_map_index *index,
- const char *command, const char *arg);
+ int (*no_set_metric)(struct route_map_index *index,
+ const char *command, const char *arg,
+ char *errmsg, size_t errmsg_len);
/* set tag */
- int (*set_tag)(struct vty *vty, struct route_map_index *index,
- const char *command, const char *arg);
+ int (*set_tag)(struct route_map_index *index,
+ const char *command, const char *arg,
+ char *errmsg, size_t errmsg_len);
/* no set tag */
- int (*no_set_tag)(struct vty *vty, struct route_map_index *index,
- const char *command, const char *arg);
+ int (*no_set_tag)(struct route_map_index *index,
+ const char *command, const char *arg,
+ char *errmsg, size_t errmsg_len);
};
extern struct route_map_match_set_hooks rmap_match_set_hook;
@@ -666,15 +859,13 @@ extern struct route_map_index *route_map_index_get(struct route_map *map,
extern void route_map_index_delete(struct route_map_index *index, int notify);
/* routemap_northbound.c */
-typedef int (*routemap_match_hook_fun)(struct vty *vty,
- struct route_map_index *rmi,
+typedef int (*routemap_match_hook_fun)(struct route_map_index *rmi,
const char *command, const char *arg,
- route_map_event_t event);
-
-typedef int (*routemap_set_hook_fun)(struct vty *vty,
- struct route_map_index *rmi,
- const char *command, const char *arg);
-
+ route_map_event_t event,
+ char *errmsg, size_t errmsg_len);
+typedef int (*routemap_set_hook_fun)(struct route_map_index *rmi,
+ const char *command, const char *arg,
+ char *errmsg, size_t errmsg_len);
struct routemap_hook_context {
struct route_map_index *rhc_rmi;
const char *rhc_rule;
diff --git a/lib/routemap_cli.c b/lib/routemap_cli.c
index bf61e10fe..9a53c11a4 100644
--- a/lib/routemap_cli.c
+++ b/lib/routemap_cli.c
@@ -46,9 +46,6 @@ DEFPY_YANG_NOSH(
ROUTE_MAP_OP_CMD_STR
ROUTE_MAP_SEQUENCE_CMD_STR)
{
- struct route_map_index *rmi;
- struct route_map *rm;
- int action_type;
char xpath_action[XPATH_MAXLEN + 64];
char xpath_index[XPATH_MAXLEN + 32];
char xpath[XPATH_MAXLEN];
@@ -66,17 +63,9 @@ DEFPY_YANG_NOSH(
nb_cli_enqueue_change(vty, xpath_action, NB_OP_MODIFY, action);
rv = nb_cli_apply_changes(vty, NULL);
- if (rv == CMD_SUCCESS) {
+ if (rv == CMD_SUCCESS)
VTY_PUSH_XPATH(RMAP_NODE, xpath_index);
- /* Add support for non-migrated route map users. */
- nb_cli_pending_commit_check(vty);
- rm = route_map_get(name);
- action_type = (action[0] == 'p') ? RMAP_PERMIT : RMAP_DENY;
- rmi = route_map_index_get(rm, action_type, sequence);
- VTY_PUSH_CONTEXT(RMAP_NODE, rmi);
- }
-
return rv;
}
@@ -108,6 +97,7 @@ DEFPY_YANG(
snprintf(xpath, sizeof(xpath),
"/frr-route-map:lib/route-map[name='%s']/entry[sequence='%lu']",
name, sequence);
+
nb_cli_enqueue_change(vty, xpath, NB_OP_DESTROY, NULL);
return nb_cli_apply_changes(vty, NULL);
@@ -124,63 +114,12 @@ int route_map_instance_cmp(struct lyd_node *dnode1, struct lyd_node *dnode2)
void route_map_instance_show(struct vty *vty, struct lyd_node *dnode,
bool show_defaults)
{
- const struct route_map_rule *rmr;
- const struct route_map_index *rmi;
const char *name = yang_dnode_get_string(dnode, "../name");
const char *action = yang_dnode_get_string(dnode, "./action");
const char *sequence = yang_dnode_get_string(dnode, "./sequence");
vty_out(vty, "route-map %s %s %s\n", name, action, sequence);
- rmi = nb_running_get_entry(dnode, NULL, false);
- if (rmi == NULL) {
- /*
- * We can't have outdated rules if route map hasn't
- * been created yet.
- */
- return;
- }
-
-#define SKIP_RULE(name) if (strcmp((name), rmr->cmd->str) == 0) continue
-
- /* Print route map `match` for old CLI users. */
- for (rmr = rmi->match_list.head; rmr; rmr = rmr->next) {
- /* Skip all matches implemented by northbound. */
- SKIP_RULE("interface");
- SKIP_RULE("ip address");
- SKIP_RULE("ip address prefix-list");
- SKIP_RULE("ip next-hop");
- SKIP_RULE("ip next-hop prefix-list");
- SKIP_RULE("ip next-hop type");
- SKIP_RULE("ipv6 address");
- SKIP_RULE("ipv6 address prefix-list");
- SKIP_RULE("ipv6 next-hop type");
- SKIP_RULE("metric");
- SKIP_RULE("tag");
- /* Zebra specific match conditions. */
- SKIP_RULE("ip address prefix-len");
- SKIP_RULE("ipv6 address prefix-len");
- SKIP_RULE("ip next-hop prefix-len");
- SKIP_RULE("source-protocol");
- SKIP_RULE("source-instance");
-
- vty_out(vty, " match %s %s\n", rmr->cmd->str,
- rmr->rule_str ? rmr->rule_str : "");
- }
-
- /* Print route map `set` for old CLI users. */
- for (rmr = rmi->set_list.head; rmr; rmr = rmr->next) {
- /* Skip all sets implemented by northbound. */
- SKIP_RULE("metric");
- SKIP_RULE("tag");
- /* Zebra specific set actions. */
- SKIP_RULE("src");
-
- vty_out(vty, " set %s %s\n", rmr->cmd->str,
- rmr->rule_str ? rmr->rule_str : "");
- }
-
-#undef SKIP_RULE
}
void route_map_instance_show_end(struct vty *vty, struct lyd_node *dnode)
@@ -195,11 +134,13 @@ DEFPY_YANG(
"Match first hop interface of route\n"
INTERFACE_STR)
{
- const char *xpath = "./match-condition[condition='interface']";
+ const char *xpath =
+ "./match-condition[condition='frr-route-map:interface']";
char xpath_value[XPATH_MAXLEN];
nb_cli_enqueue_change(vty, xpath, NB_OP_CREATE, NULL);
- snprintf(xpath_value, sizeof(xpath_value), "%s/interface", xpath);
+ snprintf(xpath_value, sizeof(xpath_value),
+ "%s/rmap-match-condition/interface", xpath);
nb_cli_enqueue_change(vty, xpath_value, NB_OP_MODIFY, ifname);
return nb_cli_apply_changes(vty, NULL);
@@ -213,7 +154,8 @@ DEFPY_YANG(
"Match first hop interface of route\n"
INTERFACE_STR)
{
- const char *xpath = "./match-condition[condition='interface']";
+ const char *xpath =
+ "./match-condition[condition='frr-route-map:interface']";
nb_cli_enqueue_change(vty, xpath, NB_OP_DESTROY, NULL);
@@ -230,11 +172,13 @@ DEFPY_YANG(
"IP access-list number (expanded range)\n"
"IP Access-list name\n")
{
- const char *xpath = "./match-condition[condition='ipv4-address-list']";
+ const char *xpath =
+ "./match-condition[condition='frr-route-map:ipv4-address-list']";
char xpath_value[XPATH_MAXLEN + 32];
nb_cli_enqueue_change(vty, xpath, NB_OP_CREATE, NULL);
- snprintf(xpath_value, sizeof(xpath_value), "%s/list-name", xpath);
+ snprintf(xpath_value, sizeof(xpath_value),
+ "%s/rmap-match-condition/list-name", xpath);
nb_cli_enqueue_change(vty, xpath_value, NB_OP_MODIFY, name);
return nb_cli_apply_changes(vty, NULL);
@@ -251,7 +195,8 @@ DEFPY_YANG(
"IP access-list number (expanded range)\n"
"IP Access-list name\n")
{
- const char *xpath = "./match-condition[condition='ipv4-address-list']";
+ const char *xpath =
+ "./match-condition[condition='frr-route-map:ipv4-address-list']";
nb_cli_enqueue_change(vty, xpath, NB_OP_DESTROY, NULL);
@@ -268,11 +213,13 @@ DEFPY_YANG(
"Match entries of prefix-lists\n"
"IP prefix-list name\n")
{
- const char *xpath = "./match-condition[condition='ipv4-prefix-list']";
+ const char *xpath =
+ "./match-condition[condition='frr-route-map:ipv4-prefix-list']";
char xpath_value[XPATH_MAXLEN];
nb_cli_enqueue_change(vty, xpath, NB_OP_CREATE, NULL);
- snprintf(xpath_value, sizeof(xpath_value), "%s/list-name", xpath);
+ snprintf(xpath_value, sizeof(xpath_value),
+ "%s/rmap-match-condition/list-name", xpath);
nb_cli_enqueue_change(vty, xpath_value, NB_OP_MODIFY, name);
return nb_cli_apply_changes(vty, NULL);
@@ -288,7 +235,8 @@ DEFPY_YANG(
"Match entries of prefix-lists\n"
"IP prefix-list name\n")
{
- const char *xpath = "./match-condition[condition='ipv4-prefix-list']";
+ const char *xpath =
+ "./match-condition[condition='frr-route-map:ipv4-prefix-list']";
nb_cli_enqueue_change(vty, xpath, NB_OP_DESTROY, NULL);
@@ -305,11 +253,13 @@ DEFPY_YANG(
"IP access-list number (expanded range)\n"
"IP Access-list name\n")
{
- const char *xpath = "./match-condition[condition='ipv4-next-hop-list']";
+ const char *xpath =
+ "./match-condition[condition='frr-route-map:ipv4-next-hop-list']";
char xpath_value[XPATH_MAXLEN + 32];
nb_cli_enqueue_change(vty, xpath, NB_OP_CREATE, NULL);
- snprintf(xpath_value, sizeof(xpath_value), "%s/list-name", xpath);
+ snprintf(xpath_value, sizeof(xpath_value),
+ "%s/rmap-match-condition/list-name", xpath);
nb_cli_enqueue_change(vty, xpath_value, NB_OP_MODIFY, name);
return nb_cli_apply_changes(vty, NULL);
@@ -326,7 +276,8 @@ DEFPY_YANG(
"IP access-list number (expanded range)\n"
"IP Access-list name\n")
{
- const char *xpath = "./match-condition[condition='ipv4-next-hop-list']";
+ const char *xpath =
+ "./match-condition[condition='frr-route-map:ipv4-next-hop-list']";
nb_cli_enqueue_change(vty, xpath, NB_OP_DESTROY, NULL);
@@ -344,11 +295,12 @@ DEFPY_YANG(
"IP prefix-list name\n")
{
const char *xpath =
- "./match-condition[condition='ipv4-next-hop-prefix-list']";
+ "./match-condition[condition='frr-route-map:ipv4-next-hop-prefix-list']";
char xpath_value[XPATH_MAXLEN];
nb_cli_enqueue_change(vty, xpath, NB_OP_CREATE, NULL);
- snprintf(xpath_value, sizeof(xpath_value), "%s/list-name", xpath);
+ snprintf(xpath_value, sizeof(xpath_value),
+ "%s/rmap-match-condition/list-name", xpath);
nb_cli_enqueue_change(vty, xpath_value, NB_OP_MODIFY, name);
return nb_cli_apply_changes(vty, NULL);
@@ -366,7 +318,7 @@ DEFPY_YANG(
"IP prefix-list name\n")
{
const char *xpath =
- "./match-condition[condition='ipv4-next-hop-prefix-list']";
+ "./match-condition[condition='frr-route-map:ipv4-next-hop-prefix-list']";
nb_cli_enqueue_change(vty, xpath, NB_OP_DESTROY, NULL);
@@ -382,12 +334,13 @@ DEFPY_YANG(
"Match entries by type\n"
"Blackhole\n")
{
- const char *xpath = "./match-condition[condition='ipv4-next-hop-type']";
+ const char *xpath =
+ "./match-condition[condition='frr-route-map:ipv4-next-hop-type']";
char xpath_value[XPATH_MAXLEN];
nb_cli_enqueue_change(vty, xpath, NB_OP_CREATE, NULL);
- snprintf(xpath_value, sizeof(xpath_value), "%s/ipv4-next-hop-type",
- xpath);
+ snprintf(xpath_value, sizeof(xpath_value),
+ "%s/rmap-match-condition/ipv4-next-hop-type", xpath);
nb_cli_enqueue_change(vty, xpath_value, NB_OP_MODIFY, type);
return nb_cli_apply_changes(vty, NULL);
@@ -401,7 +354,8 @@ DEFPY_YANG(
"Match entries by type\n"
"Blackhole\n")
{
- const char *xpath = "./match-condition[condition='ipv4-next-hop-type']";
+ const char *xpath =
+ "./match-condition[condition='frr-route-map:ipv4-next-hop-type']";
nb_cli_enqueue_change(vty, xpath, NB_OP_DESTROY, NULL);
@@ -416,11 +370,13 @@ DEFPY_YANG(
"Match IPv6 address of route\n"
"IPv6 access-list name\n")
{
- const char *xpath = "./match-condition[condition='ipv6-address-list']";
+ const char *xpath =
+ "./match-condition[condition='frr-route-map:ipv6-address-list']";
char xpath_value[XPATH_MAXLEN];
nb_cli_enqueue_change(vty, xpath, NB_OP_CREATE, NULL);
- snprintf(xpath_value, sizeof(xpath_value), "%s/list-name", xpath);
+ snprintf(xpath_value, sizeof(xpath_value),
+ "%s/rmap-match-condition/list-name", xpath);
nb_cli_enqueue_change(vty, xpath_value, NB_OP_MODIFY, name);
return nb_cli_apply_changes(vty, NULL);
@@ -435,7 +391,8 @@ DEFPY_YANG(
"Match IPv6 address of route\n"
"IPv6 access-list name\n")
{
- const char *xpath = "./match-condition[condition='ipv6-address-list']";
+ const char *xpath =
+ "./match-condition[condition='frr-route-map:ipv6-address-list']";
nb_cli_enqueue_change(vty, xpath, NB_OP_DESTROY, NULL);
@@ -451,11 +408,13 @@ DEFPY_YANG(
"Match entries of prefix-lists\n"
"IP prefix-list name\n")
{
- const char *xpath = "./match-condition[condition='ipv6-prefix-list']";
+ const char *xpath =
+ "./match-condition[condition='frr-route-map:ipv6-prefix-list']";
char xpath_value[XPATH_MAXLEN];
nb_cli_enqueue_change(vty, xpath, NB_OP_CREATE, NULL);
- snprintf(xpath_value, sizeof(xpath_value), "%s/list-name", xpath);
+ snprintf(xpath_value, sizeof(xpath_value),
+ "%s/rmap-match-condition/list-name", xpath);
nb_cli_enqueue_change(vty, xpath_value, NB_OP_MODIFY, name);
return nb_cli_apply_changes(vty, NULL);
@@ -472,7 +431,8 @@ DEFPY_YANG(
"Match entries of prefix-lists\n"
"IP prefix-list name\n")
{
- const char *xpath = "./match-condition[condition='ipv6-prefix-list']";
+ const char *xpath =
+ "./match-condition[condition='frr-route-map:ipv6-prefix-list']";
nb_cli_enqueue_change(vty, xpath, NB_OP_DESTROY, NULL);
@@ -487,12 +447,13 @@ DEFPY_YANG(
"Match entries by type\n"
"Blackhole\n")
{
- const char *xpath = "./match-condition[condition='ipv6-next-hop-type']";
+ const char *xpath =
+ "./match-condition[condition='frr-route-map:ipv6-next-hop-type']";
char xpath_value[XPATH_MAXLEN];
nb_cli_enqueue_change(vty, xpath, NB_OP_CREATE, NULL);
- snprintf(xpath_value, sizeof(xpath_value), "%s/ipv6-next-hop-type",
- xpath);
+ snprintf(xpath_value, sizeof(xpath_value),
+ "%s/rmap-match-condition/ipv6-next-hop-type", xpath);
nb_cli_enqueue_change(vty, xpath_value, NB_OP_MODIFY, type);
return nb_cli_apply_changes(vty, NULL);
@@ -506,7 +467,8 @@ DEFPY_YANG(
"Match entries by type\n"
"Blackhole\n")
{
- const char *xpath = "./match-condition[condition='ipv6-next-hop-type']";
+ const char *xpath =
+ "./match-condition[condition='frr-route-map:ipv6-next-hop-type']";
nb_cli_enqueue_change(vty, xpath, NB_OP_DESTROY, NULL);
@@ -520,11 +482,13 @@ DEFPY_YANG(
"Match metric of route\n"
"Metric value\n")
{
- const char *xpath = "./match-condition[condition='metric']";
+ const char *xpath =
+ "./match-condition[condition='frr-route-map:match-metric']";
char xpath_value[XPATH_MAXLEN];
nb_cli_enqueue_change(vty, xpath, NB_OP_CREATE, NULL);
- snprintf(xpath_value, sizeof(xpath_value), "%s/metric", xpath);
+ snprintf(xpath_value, sizeof(xpath_value),
+ "%s/rmap-match-condition/metric", xpath);
nb_cli_enqueue_change(vty, xpath_value, NB_OP_MODIFY, metric_str);
return nb_cli_apply_changes(vty, NULL);
@@ -538,7 +502,8 @@ DEFPY_YANG(
"Match metric of route\n"
"Metric value\n")
{
- const char *xpath = "./match-condition[condition='metric']";
+ const char *xpath =
+ "./match-condition[condition='frr-route-map:match-metric']";
nb_cli_enqueue_change(vty, xpath, NB_OP_DESTROY, NULL);
@@ -552,11 +517,13 @@ DEFPY_YANG(
"Match tag of route\n"
"Tag value\n")
{
- const char *xpath = "./match-condition[condition='tag']";
+ const char *xpath =
+ "./match-condition[condition='frr-route-map:match-tag']";
char xpath_value[XPATH_MAXLEN];
nb_cli_enqueue_change(vty, xpath, NB_OP_CREATE, NULL);
- snprintf(xpath_value, sizeof(xpath_value), "%s/tag", xpath);
+ snprintf(xpath_value, sizeof(xpath_value),
+ "%s/rmap-match-condition/tag", xpath);
nb_cli_enqueue_change(vty, xpath_value, NB_OP_MODIFY, tag_str);
return nb_cli_apply_changes(vty, NULL);
@@ -570,7 +537,8 @@ DEFPY_YANG(
"Match tag of route\n"
"Tag value\n")
{
- const char *xpath = "./match-condition[condition='tag']";
+ const char *xpath =
+ "./match-condition[condition='frr-route-map:match-tag']";
nb_cli_enqueue_change(vty, xpath, NB_OP_DESTROY, NULL);
@@ -580,78 +548,259 @@ DEFPY_YANG(
void route_map_condition_show(struct vty *vty, struct lyd_node *dnode,
bool show_defaults)
{
- int condition = yang_dnode_get_enum(dnode, "./condition");
+ const char *condition = yang_dnode_get_string(dnode, "./condition");
+ struct lyd_node *ln;
+ const char *acl;
- switch (condition) {
- case 0: /* interface */
+ if (IS_MATCH_INTERFACE(condition)) {
vty_out(vty, " match interface %s\n",
- yang_dnode_get_string(dnode, "./interface"));
- break;
- case 1: /* ipv4-address-list */
- case 3: /* ipv4-next-hop-list */
- switch (condition) {
- case 1:
- vty_out(vty, " match ip address %s\n",
- yang_dnode_get_string(dnode, "./list-name"));
- break;
- case 3:
- vty_out(vty, " match ip next-hop %s\n",
- yang_dnode_get_string(dnode, "./list-name"));
- break;
- }
- break;
- case 2: /* ipv4-prefix-list */
+ yang_dnode_get_string(
+ dnode, "./rmap-match-condition/interface"));
+ } else if (IS_MATCH_IPv4_ADDRESS_LIST(condition)
+ || IS_MATCH_IPv4_NEXTHOP_LIST(condition)) {
+ acl = NULL;
+ if ((ln = yang_dnode_get(dnode,
+ "./rmap-match-condition/list-name"))
+ != NULL)
+ acl = yang_dnode_get_string(ln, NULL);
+
+ assert(acl);
+
+ if (IS_MATCH_IPv4_ADDRESS_LIST(condition))
+ vty_out(vty, " match ip address %s\n", acl);
+ else
+ vty_out(vty, " match ip next-hop %s\n", acl);
+ } else if (IS_MATCH_IPv4_PREFIX_LIST(condition)) {
vty_out(vty, " match ip address prefix-list %s\n",
- yang_dnode_get_string(dnode, "./list-name"));
- break;
- case 4: /* ipv4-next-hop-prefix-list */
+ yang_dnode_get_string(
+ dnode, "./rmap-match-condition/list-name"));
+ } else if (IS_MATCH_IPv4_NEXTHOP_PREFIX_LIST(condition)) {
vty_out(vty, " match ip next-hop prefix-list %s\n",
- yang_dnode_get_string(dnode, "./list-name"));
- break;
- case 5: /* ipv4-next-hop-type */
- vty_out(vty, " match ip next-hop type %s\n",
- yang_dnode_get_string(dnode, "./ipv4-next-hop-type"));
- break;
- case 6: /* ipv6-address-list */
+ yang_dnode_get_string(
+ dnode, "./rmap-match-condition/list-name"));
+ } else if (IS_MATCH_IPv6_ADDRESS_LIST(condition)) {
vty_out(vty, " match ipv6 address %s\n",
- yang_dnode_get_string(dnode, "./list-name"));
- break;
- case 7: /* ipv6-prefix-list */
+ yang_dnode_get_string(
+ dnode, "./rmap-match-condition/list-name"));
+ } else if (IS_MATCH_IPv6_PREFIX_LIST(condition)) {
vty_out(vty, " match ipv6 address prefix-list %s\n",
- yang_dnode_get_string(dnode, "./list-name"));
- break;
- case 8: /* ipv6-next-hop-type */
+ yang_dnode_get_string(
+ dnode, "./rmap-match-condition/list-name"));
+ } else if (IS_MATCH_IPv4_NEXTHOP_TYPE(condition)) {
+ vty_out(vty, " match ip next-hop type %s\n",
+ yang_dnode_get_string(
+ dnode,
+ "./rmap-match-condition/ipv4-next-hop-type"));
+ } else if (IS_MATCH_IPv6_NEXTHOP_TYPE(condition)) {
vty_out(vty, " match ipv6 next-hop type %s\n",
- yang_dnode_get_string(dnode, "./ipv6-next-hop-type"));
- break;
- case 9: /* metric */
+ yang_dnode_get_string(
+ dnode,
+ "./rmap-match-condition/ipv6-next-hop-type"));
+ } else if (IS_MATCH_METRIC(condition)) {
vty_out(vty, " match metric %s\n",
- yang_dnode_get_string(dnode, "./metric"));
- break;
- case 10: /* tag */
+ yang_dnode_get_string(dnode,
+ "./rmap-match-condition/metric"));
+ } else if (IS_MATCH_TAG(condition)) {
vty_out(vty, " match tag %s\n",
- yang_dnode_get_string(dnode, "./tag"));
- break;
- case 100: /* ipv4-prefix-length */
+ yang_dnode_get_string(dnode,
+ "./rmap-match-condition/tag"));
+ } else if (IS_MATCH_IPv4_PREFIX_LEN(condition)) {
vty_out(vty, " match ip address prefix-len %s\n",
- yang_dnode_get_string(dnode,"./frr-zebra:ipv4-prefix-length"));
- break;
- case 101: /* ipv6-prefix-length */
+ yang_dnode_get_string(
+ dnode,
+ "./rmap-match-condition/frr-zebra-route-map:ipv4-prefix-length"));
+ } else if (IS_MATCH_IPv6_PREFIX_LEN(condition)) {
vty_out(vty, " match ipv6 address prefix-len %s\n",
- yang_dnode_get_string(dnode, "./frr-zebra:ipv6-prefix-length"));
- break;
- case 102: /* ipv4-next-hop-prefix-length */
+ yang_dnode_get_string(
+ dnode,
+ "./rmap-match-condition/frr-zebra-route-map:ipv6-prefix-length"));
+ } else if (IS_MATCH_IPv4_NH_PREFIX_LEN(condition)) {
vty_out(vty, " match ip next-hop prefix-len %s\n",
- yang_dnode_get_string(dnode, "./frr-zebra:ipv4-prefix-length"));
- break;
- case 103: /* source-protocol */
+ yang_dnode_get_string(
+ dnode,
+ "./rmap-match-condition/frr-zebra-route-map:ipv4-prefix-length"));
+ } else if (IS_MATCH_SRC_PROTO(condition)) {
vty_out(vty, " match source-protocol %s\n",
- yang_dnode_get_string(dnode, "./frr-zebra:source-protocol"));
- break;
- case 104: /* source-instance */
+ yang_dnode_get_string(
+ dnode,
+ "./rmap-match-condition/frr-zebra-route-map:source-protocol"));
+ } else if (IS_MATCH_SRC_INSTANCE(condition)) {
vty_out(vty, " match source-instance %s\n",
- yang_dnode_get_string(dnode, "./frr-zebra:source-instance"));
- break;
+ yang_dnode_get_string(
+ dnode,
+ "./rmap-match-condition/frr-zebra-route-map:source-instance"));
+ } else if (IS_MATCH_LOCAL_PREF(condition)) {
+ vty_out(vty, " match local-preference %s\n",
+ yang_dnode_get_string(
+ dnode,
+ "./rmap-match-condition/frr-bgp-route-map:local-preference"));
+ } else if (IS_MATCH_ORIGIN(condition)) {
+ vty_out(vty, " match origin %s\n",
+ yang_dnode_get_string(
+ dnode,
+ "./rmap-match-condition/frr-bgp-route-map:origin"));
+ } else if (IS_MATCH_RPKI(condition)) {
+ vty_out(vty, " match rpki %s\n",
+ yang_dnode_get_string(
+ dnode,
+ "./rmap-match-condition/frr-bgp-route-map:rpki"));
+ } else if (IS_MATCH_PROBABILITY(condition)) {
+ vty_out(vty, " match probability %s\n",
+ yang_dnode_get_string(
+ dnode,
+ "./rmap-match-condition/frr-bgp-route-map:probability"));
+ } else if (IS_MATCH_SRC_VRF(condition)) {
+ vty_out(vty, " match source-vrf %s\n",
+ yang_dnode_get_string(
+ dnode,
+ "./rmap-match-condition/frr-bgp-route-map:source-vrf"));
+ } else if (IS_MATCH_PEER(condition)) {
+ acl = NULL;
+ if ((ln = yang_dnode_get(
+ dnode,
+ "./rmap-match-condition/frr-bgp-route-map:peer-ipv4-address"))
+ != NULL)
+ acl = yang_dnode_get_string(ln, NULL);
+ else if (
+ (ln = yang_dnode_get(
+ dnode,
+ "./rmap-match-condition/frr-bgp-route-map:peer-ipv6-address"))
+ != NULL)
+ acl = yang_dnode_get_string(ln, NULL);
+ else if (
+ (ln = yang_dnode_get(
+ dnode,
+ "./rmap-match-condition/frr-bgp-route-map:peer-interface"))
+ != NULL)
+ acl = yang_dnode_get_string(ln, NULL);
+ else if (yang_dnode_get(
+ dnode,
+ "./rmap-match-condition/frr-bgp-route-map:peer-local")
+ != NULL)
+ acl = "local";
+
+ vty_out(vty, " match peer %s\n", acl);
+ } else if (IS_MATCH_AS_LIST(condition)) {
+ vty_out(vty, " match as-path %s\n",
+ yang_dnode_get_string(
+ dnode,
+ "./rmap-match-condition/frr-bgp-route-map:list-name"));
+ } else if (IS_MATCH_EVPN_ROUTE_TYPE(condition)) {
+ vty_out(vty, " match evpn route-type %s\n",
+ yang_dnode_get_string(
+ dnode,
+ "./rmap-match-condition/frr-bgp-route-map:evpn-route-type"));
+ } else if (IS_MATCH_EVPN_DEFAULT_ROUTE(condition)) {
+ vty_out(vty, " match evpn default-route\n");
+ } else if (IS_MATCH_EVPN_VNI(condition)) {
+ vty_out(vty, " match evpn vni %s\n",
+ yang_dnode_get_string(
+ dnode,
+ "./rmap-match-condition/frr-bgp-route-map:evpn-vni"));
+ } else if (IS_MATCH_EVPN_DEFAULT_ROUTE(condition)) {
+ vty_out(vty, " match evpn default-route %s\n",
+ yang_dnode_get_string(
+ dnode,
+ "./rmap-match-condition/frr-bgp-route-map:evpn-default-route"));
+ } else if (IS_MATCH_EVPN_RD(condition)) {
+ vty_out(vty, " match evpn rd %s\n",
+ yang_dnode_get_string(
+ dnode,
+ "./rmap-match-condition/frr-bgp-route-map:route-distinguisher"));
+ } else if (IS_MATCH_MAC_LIST(condition)) {
+ vty_out(vty, " match mac address %s\n",
+ yang_dnode_get_string(
+ dnode,
+ "./rmap-match-condition/frr-bgp-route-map:list-name"));
+ } else if (IS_MATCH_ROUTE_SRC(condition)) {
+ acl = NULL;
+ if ((ln = yang_dnode_get(
+ dnode,
+ "./rmap-match-condition/frr-bgp-route-map:list-name"))
+ != NULL)
+ acl = yang_dnode_get_string(ln, NULL);
+
+ assert(acl);
+
+ vty_out(vty, " match ip route-source %s\n", acl);
+ } else if (IS_MATCH_ROUTE_SRC_PL(condition)) {
+ vty_out(vty, " match ip route-source prefix-list %s\n",
+ yang_dnode_get_string(
+ dnode,
+ "./rmap-match-condition/frr-bgp-route-map:list-name"));
+ } else if (IS_MATCH_ROUTE_SRC(condition)) {
+ acl = NULL;
+ if ((ln = yang_dnode_get(
+ dnode,
+ "./rmap-match-condition/frr-bgp-route-map:list-name"))
+ != NULL)
+ acl = yang_dnode_get_string(ln, NULL);
+
+ assert(acl);
+
+ vty_out(vty, " match ip route-source %s\n", acl);
+ } else if (IS_MATCH_COMMUNITY(condition)) {
+ acl = NULL;
+ if ((ln = yang_dnode_get(
+ dnode,
+ "./rmap-match-condition/frr-bgp-route-map:comm-list/comm-list-name"))
+ != NULL) {
+ acl = yang_dnode_get_string(ln, NULL);
+
+ if (true
+ == yang_dnode_get_bool(
+ dnode,
+ "./rmap-match-condition/frr-bgp-route-map:comm-list/comm-list-name-exact-match"))
+ vty_out(vty,
+ " match community %s exact-match\n",
+ acl);
+ else
+ vty_out(vty, " match community %s\n", acl);
+ }
+
+ assert(acl);
+ } else if (IS_MATCH_LCOMMUNITY(condition)) {
+ acl = NULL;
+ if ((ln = yang_dnode_get(
+ dnode,
+ "./rmap-match-condition/frr-bgp-route-map:comm-list/comm-list-name"))
+ != NULL) {
+ acl = yang_dnode_get_string(ln, NULL);
+
+ if (true
+ == yang_dnode_get_bool(
+ dnode,
+ "./rmap-match-condition/frr-bgp-route-map:comm-list/comm-list-name-exact-match"))
+ vty_out(vty,
+ " match large-community %s exact-match\n",
+ acl);
+ else
+ vty_out(vty, " match large-community %s\n",
+ acl);
+ }
+
+ assert(acl);
+ } else if (IS_MATCH_EXTCOMMUNITY(condition)) {
+ acl = NULL;
+ if ((ln = yang_dnode_get(
+ dnode,
+ "./rmap-match-condition/frr-bgp-route-map:comm-list/comm-list-name"))
+ != NULL)
+ acl = yang_dnode_get_string(ln, NULL);
+
+ assert(acl);
+
+ vty_out(vty, " match extcommunity %s\n", acl);
+ } else if (IS_MATCH_IPV4_NH(condition)) {
+ vty_out(vty, " match ip next-hop %s\n",
+ yang_dnode_get_string(
+ dnode,
+ "./rmap-match-condition/frr-bgp-route-map:ipv4-address"));
+ } else if (IS_MATCH_IPV6_NH(condition)) {
+ vty_out(vty, " match ipv6 next-hop %s\n",
+ yang_dnode_get_string(
+ dnode,
+ "./rmap-match-condition/frr-bgp-route-map:ipv6-address"));
}
}
@@ -663,11 +812,13 @@ DEFPY_YANG(
"Next hop address\n"
"IP address of next hop\n")
{
- const char *xpath = "./set-action[action='ipv4-next-hop']";
+ const char *xpath =
+ "./set-action[action='frr-route-map:ipv4-next-hop']";
char xpath_value[XPATH_MAXLEN];
nb_cli_enqueue_change(vty, xpath, NB_OP_CREATE, NULL);
- snprintf(xpath_value, sizeof(xpath_value), "%s/ipv4-address", xpath);
+ snprintf(xpath_value, sizeof(xpath_value),
+ "%s/rmap-set-action/ipv4-address", xpath);
nb_cli_enqueue_change(vty, xpath_value, NB_OP_MODIFY, addr_str);
return nb_cli_apply_changes(vty, NULL);
@@ -682,7 +833,8 @@ DEFPY_YANG(
"Next hop address\n"
"IP address of next hop\n")
{
- const char *xpath = "./set-action[action='ipv4-next-hop']";
+ const char *xpath =
+ "./set-action[action='frr-route-map:ipv4-next-hop']";
nb_cli_enqueue_change(vty, xpath, NB_OP_DESTROY, NULL);
@@ -698,11 +850,13 @@ DEFPY_YANG(
"IPv6 local address\n"
"IPv6 address of next hop\n")
{
- const char *xpath = "./set-action[action='ipv6-next-hop']";
+ const char *xpath =
+ "./set-action[action='frr-route-map:ipv6-next-hop']";
char xpath_value[XPATH_MAXLEN];
nb_cli_enqueue_change(vty, xpath, NB_OP_CREATE, NULL);
- snprintf(xpath_value, sizeof(xpath_value), "%s/ipv6-address", xpath);
+ snprintf(xpath_value, sizeof(xpath_value),
+ "%s/rmap-set-action/ipv6-address", xpath);
nb_cli_enqueue_change(vty, xpath_value, NB_OP_MODIFY, addr_str);
return nb_cli_apply_changes(vty, NULL);
@@ -718,7 +872,8 @@ DEFPY_YANG(
"IPv6 local address\n"
"IPv6 address of next hop\n")
{
- const char *xpath = "./set-action[action='ipv6-next-hop']";
+ const char *xpath =
+ "./set-action[action='frr-route-map:ipv6-next-hop']";
nb_cli_enqueue_change(vty, xpath, NB_OP_DESTROY, NULL);
@@ -735,33 +890,34 @@ DEFPY_YANG(
"Add round trip time\n"
"Subtract round trip time\n")
{
- const char *xpath = "./set-action[action='metric']";
+ const char *xpath = "./set-action[action='frr-route-map:set-metric']";
char xpath_value[XPATH_MAXLEN];
char value[64];
nb_cli_enqueue_change(vty, xpath, NB_OP_CREATE, NULL);
if (rtt) {
snprintf(xpath_value, sizeof(xpath_value),
- "%s/use-round-trip-time", xpath);
+ "%s/rmap-set-action/use-round-trip-time", xpath);
snprintf(value, sizeof(value), "true");
} else if (artt) {
snprintf(xpath_value, sizeof(xpath_value),
- "%s/add-round-trip-time", xpath);
+ "%s/rmap-set-action/add-round-trip-time", xpath);
snprintf(value, sizeof(value), "true");
} else if (srtt) {
snprintf(xpath_value, sizeof(xpath_value),
- "%s/subtract-round-trip-time", xpath);
+ "%s/rmap-set-action/subtract-round-trip-time", xpath);
snprintf(value, sizeof(value), "true");
} else if (metric_str && metric_str[0] == '+') {
- snprintf(xpath_value, sizeof(xpath_value), "%s/add-metric",
- xpath);
+ snprintf(xpath_value, sizeof(xpath_value),
+ "%s/rmap-set-action/add-metric", xpath);
snprintf(value, sizeof(value), "%s", ++metric_str);
} else if (metric_str && metric_str[0] == '-') {
- snprintf(xpath_value, sizeof(xpath_value), "%s/subtract-metric",
- xpath);
+ snprintf(xpath_value, sizeof(xpath_value),
+ "%s/rmap-set-action/subtract-metric", xpath);
snprintf(value, sizeof(value), "%s", ++metric_str);
} else {
- snprintf(xpath_value, sizeof(xpath_value), "%s/value", xpath);
+ snprintf(xpath_value, sizeof(xpath_value),
+ "%s/rmap-set-action/value", xpath);
snprintf(value, sizeof(value), "%s", metric_str);
}
nb_cli_enqueue_change(vty, xpath_value, NB_OP_MODIFY, value);
@@ -777,7 +933,7 @@ DEFPY_YANG(
"Metric value for destination routing protocol\n"
"Metric value\n")
{
- const char *xpath = "./set-action[action='metric']";
+ const char *xpath = "./set-action[action='frr-route-map:set-metric']";
nb_cli_enqueue_change(vty, xpath, NB_OP_DESTROY, NULL);
return nb_cli_apply_changes(vty, NULL);
@@ -790,11 +946,12 @@ DEFPY_YANG(
"Tag value for routing protocol\n"
"Tag value\n")
{
- const char *xpath = "./set-action[action='tag']";
+ const char *xpath = "./set-action[action='frr-route-map:set-tag']";
char xpath_value[XPATH_MAXLEN];
nb_cli_enqueue_change(vty, xpath, NB_OP_CREATE, NULL);
- snprintf(xpath_value, sizeof(xpath_value), "%s/tag", xpath);
+ snprintf(xpath_value, sizeof(xpath_value), "%s/rmap-set-action/tag",
+ xpath);
nb_cli_enqueue_change(vty, xpath_value, NB_OP_MODIFY, tag_str);
return nb_cli_apply_changes(vty, NULL);
@@ -808,58 +965,289 @@ DEFPY_YANG(
"Tag value for routing protocol\n"
"Tag value\n")
{
- const char *xpath = "./set-action[action='tag']";
+ const char *xpath = "./set-action[action='frr-route-map:set-tag']";
+
+ nb_cli_enqueue_change(vty, xpath, NB_OP_DESTROY, NULL);
+
+ return nb_cli_apply_changes(vty, NULL);
+}
+
+DEFUN_YANG (set_srte_color,
+ set_srte_color_cmd,
+ "set sr-te color (1-4294967295)",
+ SET_STR
+ SRTE_STR
+ SRTE_COLOR_STR
+ "Color of the SR-TE Policies to match with\n")
+{
+ const char *xpath =
+ "./set-action[action='frr-route-map:set-sr-te-color']";
+ char xpath_value[XPATH_MAXLEN];
+ int idx = 0;
+
+ char *arg = argv_find(argv, argc, "(1-4294967295)", &idx)
+ ? argv[idx]->arg
+ : NULL;
+
+ nb_cli_enqueue_change(vty, xpath, NB_OP_CREATE, NULL);
+ snprintf(xpath_value, sizeof(xpath_value),
+ "%s/rmap-set-action/policy", xpath);
+ nb_cli_enqueue_change(vty, xpath_value, NB_OP_MODIFY, arg);
+
+ return nb_cli_apply_changes(vty, NULL);
+}
+
+DEFUN_YANG (no_set_srte_color,
+ no_set_srte_color_cmd,
+ "no set sr-te color [(1-4294967295)]",
+ NO_STR
+ SET_STR
+ SRTE_STR
+ SRTE_COLOR_STR
+ "Color of the SR-TE Policies to match with\n")
+{
+ const char *xpath =
+ "./set-action[action='frr-route-map:set-sr-te-color']";
nb_cli_enqueue_change(vty, xpath, NB_OP_DESTROY, NULL);
return nb_cli_apply_changes(vty, NULL);
}
+
void route_map_action_show(struct vty *vty, struct lyd_node *dnode,
bool show_defaults)
{
- int action = yang_dnode_get_enum(dnode, "./action");
+ const char *action = yang_dnode_get_string(dnode, "./action");
+ struct lyd_node *ln;
+ const char *acl;
- switch (action) {
- case 0: /* ipv4-next-hop */
+ if (IS_SET_IPv4_NH(action)) {
vty_out(vty, " set ip next-hop %s\n",
- yang_dnode_get_string(dnode, "./ipv4-address"));
- break;
- case 1: /* ipv6-next-hop */
+ yang_dnode_get_string(
+ dnode, "./rmap-set-action/ipv4-address"));
+ } else if (IS_SET_IPv6_NH(action)) {
vty_out(vty, " set ipv6 next-hop local %s\n",
- yang_dnode_get_string(dnode, "./ipv6-address"));
- break;
- case 2: /* metric */
- if (yang_dnode_get(dnode, "./use-round-trip-time")) {
+ yang_dnode_get_string(
+ dnode, "./rmap-set-action/ipv6-address"));
+ } else if (IS_SET_METRIC(action)) {
+ if (yang_dnode_get(dnode,
+ "./rmap-set-action/use-round-trip-time")) {
vty_out(vty, " set metric rtt\n");
- } else if (yang_dnode_get(dnode, "./add-round-trip-time")) {
+ } else if (yang_dnode_get(
+ dnode,
+ "./rmap-set-action/add-round-trip-time")) {
vty_out(vty, " set metric +rtt\n");
- } else if (yang_dnode_get(dnode, "./subtract-round-trip-time")) {
+ } else if (
+ yang_dnode_get(
+ dnode,
+ "./rmap-set-action/subtract-round-trip-time")) {
vty_out(vty, " set metric -rtt\n");
- } else if (yang_dnode_get(dnode, "./add-metric")) {
+ } else if (yang_dnode_get(dnode,
+ "./rmap-set-action/add-metric")) {
vty_out(vty, " set metric +%s\n",
- yang_dnode_get_string(dnode, "./add-metric"));
- } else if (yang_dnode_get(dnode, "./subtract-metric")) {
+ yang_dnode_get_string(
+ dnode, "./rmap-set-action/add-metric"));
+ } else if (yang_dnode_get(
+ dnode,
+ "./rmap-set-action/subtract-metric")) {
vty_out(vty, " set metric -%s\n",
- yang_dnode_get_string(dnode,
- "./subtract-metric"));
+ yang_dnode_get_string(
+ dnode,
+ "./rmap-set-action/subtract-metric"));
} else {
vty_out(vty, " set metric %s\n",
- yang_dnode_get_string(dnode, "./value"));
+ yang_dnode_get_string(
+ dnode, "./rmap-set-action/value"));
}
- break;
- case 3: /* tag */
+ } else if (IS_SET_TAG(action)) {
vty_out(vty, " set tag %s\n",
- yang_dnode_get_string(dnode, "./tag"));
- break;
- case 100: /* source */
- if (yang_dnode_exists(dnode, "./frr-zebra:source-v4"))
+ yang_dnode_get_string(dnode, "./rmap-set-action/tag"));
+ } else if (IS_SET_SR_TE_COLOR(action)) {
+ vty_out(vty, " set sr-te color %s\n",
+ yang_dnode_get_string(dnode,
+ "./rmap-set-action/policy"));
+ } else if (IS_SET_SRC(action)) {
+ if (yang_dnode_exists(
+ dnode,
+ "./rmap-set-action/frr-zebra-route-map:ipv4-src-address"))
vty_out(vty, " set src %s\n",
- yang_dnode_get_string(dnode, "./frr-zebra:source-v4"));
+ yang_dnode_get_string(
+ dnode,
+ "./rmap-set-action/frr-zebra-route-map:ipv4-src-address"));
else
vty_out(vty, " set src %s\n",
- yang_dnode_get_string(dnode, "./frr-zebra:source-v6"));
- break;
+ yang_dnode_get_string(
+ dnode,
+ "./rmap-set-action/frr-zebra-route-map:ipv6-src-address"));
+ } else if (IS_SET_METRIC_TYPE(action)) {
+ vty_out(vty, " set metric-type %s\n",
+ yang_dnode_get_string(
+ dnode,
+ "./rmap-set-action/frr-ospf-route-map:metric-type"));
+ } else if (IS_SET_FORWARDING_ADDR(action)) {
+ vty_out(vty, " set forwarding-address %s\n",
+ yang_dnode_get_string(
+ dnode,
+ "./rmap-set-action/frr-ospf6-route-map:ipv6-address"));
+ } else if (IS_SET_WEIGHT(action)) {
+ vty_out(vty, " set weight %s\n",
+ yang_dnode_get_string(
+ dnode,
+ "./rmap-set-action/frr-bgp-route-map:weight"));
+ } else if (IS_SET_TABLE(action)) {
+ vty_out(vty, " set table %s\n",
+ yang_dnode_get_string(
+ dnode,
+ "./rmap-set-action/frr-bgp-route-map:table"));
+ } else if (IS_SET_LOCAL_PREF(action)) {
+ vty_out(vty, " set local-preference %s\n",
+ yang_dnode_get_string(
+ dnode,
+ "./rmap-set-action/frr-bgp-route-map:local-pref"));
+ } else if (IS_SET_LABEL_INDEX(action)) {
+ vty_out(vty, " set label-index %s\n",
+ yang_dnode_get_string(
+ dnode,
+ "./rmap-set-action/frr-bgp-route-map:label-index"));
+ } else if (IS_SET_DISTANCE(action)) {
+ vty_out(vty, " set distance %s\n",
+ yang_dnode_get_string(
+ dnode,
+ "./rmap-set-action/frr-bgp-route-map:distance"));
+ } else if (IS_SET_ORIGIN(action)) {
+ vty_out(vty, " set origin %s\n",
+ yang_dnode_get_string(
+ dnode,
+ "./rmap-set-action/frr-bgp-route-map:origin"));
+ } else if (IS_SET_ATOMIC_AGGREGATE(action)) {
+ vty_out(vty, " set atomic-aggregate\n");
+ } else if (IS_SET_ORIGINATOR_ID(action)) {
+ vty_out(vty, " set originator-id %s\n",
+ yang_dnode_get_string(
+ dnode,
+ "./rmap-set-action/frr-bgp-route-map:originator-id"));
+ } else if (IS_SET_COMM_LIST_DEL(action)) {
+ acl = NULL;
+ if ((ln = yang_dnode_get(
+ dnode,
+ "./rmap-set-action/frr-bgp-route-map:comm-list-name"))
+ != NULL)
+ acl = yang_dnode_get_string(ln, NULL);
+
+ assert(acl);
+
+ vty_out(vty, " set comm-list %s delete\n", acl);
+ } else if (IS_SET_LCOMM_LIST_DEL(action)) {
+ acl = NULL;
+ if ((ln = yang_dnode_get(
+ dnode,
+ "./rmap-set-action/frr-bgp-route-map:comm-list-name"))
+ != NULL)
+ acl = yang_dnode_get_string(ln, NULL);
+
+ assert(acl);
+
+ vty_out(vty, " set large-comm-list %s delete\n", acl);
+ } else if (IS_SET_LCOMMUNITY(action)) {
+ if (yang_dnode_exists(
+ dnode,
+ "./rmap-set-action/frr-bgp-route-map:large-community-string"))
+ vty_out(vty, " set large-community %s\n",
+ yang_dnode_get_string(
+ dnode,
+ "./rmap-set-action/frr-bgp-route-map:large-community-string"));
+ else {
+ if (true
+ == yang_dnode_get_bool(
+ dnode,
+ "./rmap-set-action/frr-bgp-route-map:large-community-none"))
+ vty_out(vty, " set large-community none\n");
+ }
+ } else if (IS_SET_COMMUNITY(action)) {
+ if (yang_dnode_exists(
+ dnode,
+ "./rmap-set-action/frr-bgp-route-map:community-string"))
+ vty_out(vty, " set community %s\n",
+ yang_dnode_get_string(
+ dnode,
+ "./rmap-set-action/frr-bgp-route-map:community-string"));
+ else {
+ if (true
+ == yang_dnode_get_bool(
+ dnode,
+ "./rmap-set-action/frr-bgp-route-map:community-none"))
+ vty_out(vty, " set community none\n");
+ }
+ } else if (IS_SET_EXTCOMMUNITY_RT(action)) {
+ vty_out(vty, " set extcommunity rt %s\n",
+ yang_dnode_get_string(
+ dnode,
+ "./rmap-set-action/frr-bgp-route-map:extcommunity-rt"));
+ } else if (IS_SET_EXTCOMMUNITY_SOO(action)) {
+ vty_out(vty, " set extcommunity soo %s\n",
+ yang_dnode_get_string(
+ dnode,
+ "./rmap-set-action/frr-bgp-route-map:extcommunity-soo"));
+ } else if (IS_SET_AGGREGATOR(action)) {
+ vty_out(vty, " set aggregator as %s %s\n",
+ yang_dnode_get_string(
+ dnode,
+ "./rmap-set-action/frr-bgp-route-map:aggregator/aggregator-asn"),
+ yang_dnode_get_string(
+ dnode,
+ "./rmap-set-action/frr-bgp-route-map:aggregator/aggregator-address"));
+ } else if (IS_SET_AS_EXCLUDE(action)) {
+ vty_out(vty, " set as-path exclude %s\n",
+ yang_dnode_get_string(
+ dnode,
+ "./rmap-set-action/frr-bgp-route-map:exclude-as-path"));
+ } else if (IS_SET_AS_PREPEND(action)) {
+ if (yang_dnode_exists(
+ dnode,
+ "./rmap-set-action/frr-bgp-route-map:prepend-as-path"))
+ vty_out(vty, " set as-path prepend %s\n",
+ yang_dnode_get_string(
+ dnode,
+ "./rmap-set-action/frr-bgp-route-map:prepend-as-path"));
+ else {
+ vty_out(vty, " set as-path prepend last-as %u\n",
+ yang_dnode_get_uint8(
+ dnode,
+ "./rmap-set-action/frr-bgp-route-map:last-as"));
+ }
+ } else if (IS_SET_IPV6_NH_GLOBAL(action)) {
+ vty_out(vty, " set ipv6 next-hop global %s\n",
+ yang_dnode_get_string(
+ dnode,
+ "./rmap-set-action/frr-bgp-route-map:ipv6-address"));
+ } else if (IS_SET_IPV6_VPN_NH(action)) {
+ vty_out(vty, " set ipv6 vpn next-hop %s\n",
+ yang_dnode_get_string(
+ dnode,
+ "./rmap-set-action/frr-bgp-route-map:ipv6-address"));
+ } else if (IS_SET_IPV6_PEER_ADDR(action)) {
+ if (true
+ == yang_dnode_get_bool(
+ dnode,
+ "./rmap-set-action/frr-bgp-route-map:preference"))
+ vty_out(vty, " set ipv6 next-hop peer-address\n");
+ } else if (IS_SET_IPV6_PREFER_GLOBAL(action)) {
+ if (true
+ == yang_dnode_get_bool(
+ dnode,
+ "./rmap-set-action/frr-bgp-route-map:preference"))
+ vty_out(vty, " set ipv6 next-hop prefer-global\n");
+ } else if (IS_SET_IPV4_VPN_NH(action)) {
+ vty_out(vty, " set ipv4 vpn next-hop %s\n",
+ yang_dnode_get_string(
+ dnode,
+ "./rmap-set-action/frr-bgp-route-map:ipv4-address"));
+ } else if (IS_SET_BGP_IPV4_NH(action)) {
+ vty_out(vty, " set ip next-hop %s\n",
+ yang_dnode_get_string(
+ dnode,
+ "./rmap-set-action/frr-bgp-route-map:ipv4-nexthop"));
}
}
@@ -1122,4 +1510,7 @@ void route_map_cli_init(void)
install_element(RMAP_NODE, &set_tag_cmd);
install_element(RMAP_NODE, &no_set_tag_cmd);
+
+ install_element(RMAP_NODE, &set_srte_color_cmd);
+ install_element(RMAP_NODE, &no_set_srte_color_cmd);
}
diff --git a/lib/routemap_northbound.c b/lib/routemap_northbound.c
index 8546284c3..410eb51f5 100644
--- a/lib/routemap_northbound.c
+++ b/lib/routemap_northbound.c
@@ -45,8 +45,9 @@ int lib_route_map_entry_match_destroy(struct nb_cb_destroy_args *args)
if (rhc->rhc_mhook == NULL)
return NB_OK;
- rv = rhc->rhc_mhook(NULL, rhc->rhc_rmi, rhc->rhc_rule, NULL,
- rhc->rhc_event);
+ rv = rhc->rhc_mhook(rhc->rhc_rmi, rhc->rhc_rule, NULL,
+ rhc->rhc_event,
+ args->errmsg, args->errmsg_len);
if (rv != CMD_SUCCESS)
return NB_ERR_INCONSISTENCY;
@@ -65,7 +66,8 @@ int lib_route_map_entry_set_destroy(struct nb_cb_destroy_args *args)
if (rhc->rhc_shook == NULL)
return NB_OK;
- rv = rhc->rhc_shook(NULL, rhc->rhc_rmi, rhc->rhc_rule, NULL);
+ rv = rhc->rhc_shook(rhc->rhc_rmi, rhc->rhc_rule, NULL,
+ args->errmsg, args->errmsg_len);
if (rv != CMD_SUCCESS)
return NB_ERR_INCONSISTENCY;
@@ -498,9 +500,10 @@ static int lib_route_map_entry_match_condition_interface_modify(
rhc->rhc_rule = "interface";
rhc->rhc_event = RMAP_EVENT_MATCH_DELETED;
- rv = rmap_match_set_hook.match_interface(NULL, rhc->rhc_rmi,
+ rv = rmap_match_set_hook.match_interface(rhc->rhc_rmi,
"interface", ifname,
- RMAP_EVENT_MATCH_ADDED);
+ RMAP_EVENT_MATCH_ADDED,
+ args->errmsg, args->errmsg_len);
if (rv != CMD_SUCCESS) {
rhc->rhc_mhook = NULL;
return NB_ERR_INCONSISTENCY;
@@ -523,7 +526,7 @@ static int lib_route_map_entry_match_condition_list_name_modify(
{
struct routemap_hook_context *rhc;
const char *acl;
- int condition;
+ const char *condition;
int rv;
if (args->event != NB_EV_APPLY)
@@ -532,19 +535,19 @@ static int lib_route_map_entry_match_condition_list_name_modify(
/* Check for hook installation, otherwise we can just stop. */
acl = yang_dnode_get_string(args->dnode, NULL);
rhc = nb_running_get_entry(args->dnode, NULL, true);
- condition = yang_dnode_get_enum(args->dnode, "../condition");
- switch (condition) {
- case 1: /* ipv4-address-list */
+ condition = yang_dnode_get_string(args->dnode, "../../condition");
+
+ if (IS_MATCH_IPv4_ADDRESS_LIST(condition)) {
if (rmap_match_set_hook.match_ip_address == NULL)
return NB_OK;
rhc->rhc_mhook = rmap_match_set_hook.no_match_ip_address;
rhc->rhc_rule = "ip address";
rhc->rhc_event = RMAP_EVENT_FILTER_DELETED;
rv = rmap_match_set_hook.match_ip_address(
- NULL, rhc->rhc_rmi, "ip address", acl,
- RMAP_EVENT_FILTER_ADDED);
- break;
- case 2: /* ipv4-prefix-list */
+ rhc->rhc_rmi, "ip address", acl,
+ RMAP_EVENT_FILTER_ADDED,
+ args->errmsg, args->errmsg_len);
+ } else if (IS_MATCH_IPv4_PREFIX_LIST(condition)) {
if (rmap_match_set_hook.match_ip_address_prefix_list == NULL)
return NB_OK;
rhc->rhc_mhook =
@@ -552,20 +555,20 @@ static int lib_route_map_entry_match_condition_list_name_modify(
rhc->rhc_rule = "ip address prefix-list";
rhc->rhc_event = RMAP_EVENT_PLIST_DELETED;
rv = rmap_match_set_hook.match_ip_address_prefix_list(
- NULL, rhc->rhc_rmi, "ip address prefix-list", acl,
- RMAP_EVENT_PLIST_ADDED);
- break;
- case 3: /* ipv4-next-hop-list */
+ rhc->rhc_rmi, "ip address prefix-list", acl,
+ RMAP_EVENT_PLIST_ADDED,
+ args->errmsg, args->errmsg_len);
+ } else if (IS_MATCH_IPv4_NEXTHOP_LIST(condition)) {
if (rmap_match_set_hook.match_ip_next_hop == NULL)
return NB_OK;
rhc->rhc_mhook = rmap_match_set_hook.no_match_ip_next_hop;
rhc->rhc_rule = "ip next-hop";
rhc->rhc_event = RMAP_EVENT_FILTER_DELETED;
rv = rmap_match_set_hook.match_ip_next_hop(
- NULL, rhc->rhc_rmi, "ip next-hop", acl,
- RMAP_EVENT_FILTER_ADDED);
- break;
- case 4: /* ipv4-next-hop-prefix-list */
+ rhc->rhc_rmi, "ip next-hop", acl,
+ RMAP_EVENT_FILTER_ADDED,
+ args->errmsg, args->errmsg_len);
+ } else if (IS_MATCH_IPv4_NEXTHOP_PREFIX_LIST(condition)) {
if (rmap_match_set_hook.match_ip_next_hop_prefix_list == NULL)
return NB_OK;
rhc->rhc_mhook =
@@ -573,20 +576,20 @@ static int lib_route_map_entry_match_condition_list_name_modify(
rhc->rhc_rule = "ip next-hop prefix-list";
rhc->rhc_event = RMAP_EVENT_PLIST_DELETED;
rv = rmap_match_set_hook.match_ip_next_hop_prefix_list(
- NULL, rhc->rhc_rmi, "ip next-hop prefix-list", acl,
- RMAP_EVENT_PLIST_ADDED);
- break;
- case 6: /* ipv6-address-list */
+ rhc->rhc_rmi, "ip next-hop prefix-list", acl,
+ RMAP_EVENT_PLIST_ADDED,
+ args->errmsg, args->errmsg_len);
+ } else if (IS_MATCH_IPv6_ADDRESS_LIST(condition)) {
if (rmap_match_set_hook.match_ipv6_address == NULL)
return NB_OK;
rhc->rhc_mhook = rmap_match_set_hook.no_match_ipv6_address;
rhc->rhc_rule = "ipv6 address";
rhc->rhc_event = RMAP_EVENT_FILTER_DELETED;
rv = rmap_match_set_hook.match_ipv6_address(
- NULL, rhc->rhc_rmi, "ipv6 address", acl,
- RMAP_EVENT_FILTER_ADDED);
- break;
- case 7: /* ipv6-prefix-list */
+ rhc->rhc_rmi, "ipv6 address", acl,
+ RMAP_EVENT_FILTER_ADDED,
+ args->errmsg, args->errmsg_len);
+ } else if (IS_MATCH_IPv6_PREFIX_LIST(condition)) {
if (rmap_match_set_hook.match_ipv6_address_prefix_list == NULL)
return NB_OK;
rhc->rhc_mhook =
@@ -594,13 +597,12 @@ static int lib_route_map_entry_match_condition_list_name_modify(
rhc->rhc_rule = "ipv6 address prefix-list";
rhc->rhc_event = RMAP_EVENT_PLIST_DELETED;
rv = rmap_match_set_hook.match_ipv6_address_prefix_list(
- NULL, rhc->rhc_rmi, "ipv6 address prefix-list", acl,
- RMAP_EVENT_PLIST_ADDED);
- break;
- default:
+ rhc->rhc_rmi, "ipv6 address prefix-list", acl,
+ RMAP_EVENT_PLIST_ADDED,
+ args->errmsg, args->errmsg_len);
+ } else
rv = CMD_ERR_NO_MATCH;
- break;
- }
+
if (rv != CMD_SUCCESS) {
rhc->rhc_mhook = NULL;
return NB_ERR_INCONSISTENCY;
@@ -642,8 +644,9 @@ static int lib_route_map_entry_match_condition_ipv4_next_hop_type_modify(
rhc->rhc_event = RMAP_EVENT_MATCH_DELETED;
rv = rmap_match_set_hook.match_ip_next_hop_type(
- NULL, rhc->rhc_rmi, "ip next-hop type", type,
- RMAP_EVENT_MATCH_ADDED);
+ rhc->rhc_rmi, "ip next-hop type", type,
+ RMAP_EVENT_MATCH_ADDED,
+ args->errmsg, args->errmsg_len);
if (rv != CMD_SUCCESS) {
rhc->rhc_mhook = NULL;
return NB_ERR_INCONSISTENCY;
@@ -685,8 +688,9 @@ static int lib_route_map_entry_match_condition_ipv6_next_hop_type_modify(
rhc->rhc_event = RMAP_EVENT_MATCH_DELETED;
rv = rmap_match_set_hook.match_ipv6_next_hop_type(
- NULL, rhc->rhc_rmi, "ipv6 next-hop type", type,
- RMAP_EVENT_MATCH_ADDED);
+ rhc->rhc_rmi, "ipv6 next-hop type", type,
+ RMAP_EVENT_MATCH_ADDED,
+ args->errmsg, args->errmsg_len);
if (rv != CMD_SUCCESS) {
rhc->rhc_mhook = NULL;
return NB_ERR_INCONSISTENCY;
@@ -727,8 +731,9 @@ static int lib_route_map_entry_match_condition_metric_modify(
rhc->rhc_rule = "metric";
rhc->rhc_event = RMAP_EVENT_MATCH_DELETED;
- rv = rmap_match_set_hook.match_metric(NULL, rhc->rhc_rmi, "metric",
- type, RMAP_EVENT_MATCH_ADDED);
+ rv = rmap_match_set_hook.match_metric(rhc->rhc_rmi, "metric",
+ type, RMAP_EVENT_MATCH_ADDED,
+ args->errmsg, args->errmsg_len);
if (rv != CMD_SUCCESS) {
rhc->rhc_mhook = NULL;
return NB_ERR_INCONSISTENCY;
@@ -769,8 +774,9 @@ lib_route_map_entry_match_condition_tag_modify(struct nb_cb_modify_args *args)
rhc->rhc_rule = "tag";
rhc->rhc_event = RMAP_EVENT_MATCH_DELETED;
- rv = rmap_match_set_hook.match_tag(NULL, rhc->rhc_rmi, "tag", tag,
- RMAP_EVENT_MATCH_ADDED);
+ rv = rmap_match_set_hook.match_tag(rhc->rhc_rmi, "tag", tag,
+ RMAP_EVENT_MATCH_ADDED,
+ args->errmsg, args->errmsg_len);
if (rv != CMD_SUCCESS) {
rhc->rhc_mhook = NULL;
return NB_ERR_INCONSISTENCY;
@@ -850,8 +856,9 @@ static int lib_route_map_entry_set_action_ipv4_address_modify(
rhc->rhc_shook = rmap_match_set_hook.no_set_ip_nexthop;
rhc->rhc_rule = "ip next-hop";
- rv = rmap_match_set_hook.set_ip_nexthop(NULL, rhc->rhc_rmi,
- "ip next-hop", address);
+ rv = rmap_match_set_hook.set_ip_nexthop(rhc->rhc_rmi, "ip next-hop",
+ address,
+ args->errmsg, args->errmsg_len);
if (rv != CMD_SUCCESS) {
rhc->rhc_shook = NULL;
return NB_ERR_INCONSISTENCY;
@@ -909,7 +916,8 @@ static int lib_route_map_entry_set_action_ipv6_address_modify(
rhc->rhc_rule = "ipv6 next-hop local";
rv = rmap_match_set_hook.set_ipv6_nexthop_local(
- NULL, rhc->rhc_rmi, "ipv6 next-hop local", address);
+ rhc->rhc_rmi, "ipv6 next-hop local", address,
+ args->errmsg, args->errmsg_len);
if (rv != CMD_SUCCESS) {
rhc->rhc_shook = NULL;
return NB_ERR_INCONSISTENCY;
@@ -928,7 +936,8 @@ static int lib_route_map_entry_set_action_ipv6_address_destroy(
* XPath: /frr-route-map:lib/route-map/entry/set-action/value
*/
static int set_action_modify(enum nb_event event, const struct lyd_node *dnode,
- union nb_resource *resource, const char *value)
+ union nb_resource *resource, const char *value,
+ char *errmsg, size_t errmsg_len)
{
struct routemap_hook_context *rhc;
int rv;
@@ -952,8 +961,10 @@ static int set_action_modify(enum nb_event event, const struct lyd_node *dnode,
rhc->rhc_shook = rmap_match_set_hook.no_set_metric;
rhc->rhc_rule = "metric";
- rv = rmap_match_set_hook.set_metric(NULL, rhc->rhc_rmi, "metric",
- value);
+ rv = rmap_match_set_hook.set_metric(rhc->rhc_rmi, "metric",
+ value,
+ errmsg, errmsg_len
+ );
if (rv != CMD_SUCCESS) {
rhc->rhc_shook = NULL;
return NB_ERR_INCONSISTENCY;
@@ -968,7 +979,7 @@ lib_route_map_entry_set_action_value_modify(struct nb_cb_modify_args *args)
const char *metric = yang_dnode_get_string(args->dnode, NULL);
return set_action_modify(args->event, args->dnode, args->resource,
- metric);
+ metric, args->errmsg, args->errmsg_len);
}
static int
@@ -995,7 +1006,8 @@ lib_route_map_entry_set_action_add_metric_modify(struct nb_cb_modify_args *args)
snprintf(metric_str, sizeof(metric_str), "+%s",
yang_dnode_get_string(args->dnode, NULL));
return set_action_modify(args->event, args->dnode, args->resource,
- metric_str);
+ metric_str,
+ args->errmsg, args->errmsg_len);
}
static int lib_route_map_entry_set_action_add_metric_destroy(
@@ -1022,7 +1034,8 @@ static int lib_route_map_entry_set_action_subtract_metric_modify(
snprintf(metric_str, sizeof(metric_str), "-%s",
yang_dnode_get_string(args->dnode, NULL));
return set_action_modify(args->event, args->dnode, args->resource,
- metric_str);
+ metric_str,
+ args->errmsg, args->errmsg_len);
}
static int lib_route_map_entry_set_action_subtract_metric_destroy(
@@ -1038,7 +1051,8 @@ static int lib_route_map_entry_set_action_use_round_trip_time_modify(
struct nb_cb_modify_args *args)
{
return set_action_modify(args->event, args->dnode, args->resource,
- "rtt");
+ "rtt",
+ args->errmsg, args->errmsg_len);
}
static int lib_route_map_entry_set_action_use_round_trip_time_destroy(
@@ -1054,7 +1068,8 @@ static int lib_route_map_entry_set_action_add_round_trip_time_modify(
struct nb_cb_modify_args *args)
{
return set_action_modify(args->event, args->dnode, args->resource,
- "+rtt");
+ "+rtt",
+ args->errmsg, args->errmsg_len);
}
static int lib_route_map_entry_set_action_add_round_trip_time_destroy(
@@ -1070,7 +1085,7 @@ static int lib_route_map_entry_set_action_subtract_round_trip_time_modify(
struct nb_cb_modify_args *args)
{
return set_action_modify(args->event, args->dnode, args->resource,
- "-rtt");
+ "-rtt", args->errmsg, args->errmsg_len);
}
static int lib_route_map_entry_set_action_subtract_round_trip_time_destroy(
@@ -1109,7 +1124,8 @@ lib_route_map_entry_set_action_tag_modify(struct nb_cb_modify_args *args)
rhc->rhc_shook = rmap_match_set_hook.no_set_tag;
rhc->rhc_rule = "tag";
- rv = rmap_match_set_hook.set_tag(NULL, rhc->rhc_rmi, "tag", tag);
+ rv = rmap_match_set_hook.set_tag(rhc->rhc_rmi, "tag", tag,
+ args->errmsg, args->errmsg_len);
if (rv != CMD_SUCCESS) {
rhc->rhc_shook = NULL;
return NB_ERR_INCONSISTENCY;
@@ -1124,6 +1140,52 @@ lib_route_map_entry_set_action_tag_destroy(struct nb_cb_destroy_args *args)
return lib_route_map_entry_set_destroy(args);
}
+/*
+ * XPath: /frr-route-map:lib/route-map/entry/set-action/policy
+ */
+static int
+lib_route_map_entry_set_action_policy_modify(struct nb_cb_modify_args *args)
+{
+ struct routemap_hook_context *rhc;
+ const char *policy;
+ int rv;
+
+ /*
+ * NOTE: validate if 'action' is 'tag', currently it is not
+ * necessary because this is the only implemented action. Other
+ * actions might have different validations.
+ */
+ if (args->event != NB_EV_APPLY)
+ return NB_OK;
+
+ /* Check for hook function. */
+ if (rmap_match_set_hook.set_srte_color == NULL)
+ return NB_OK;
+
+ /* Add configuration. */
+ rhc = nb_running_get_entry(args->dnode, NULL, true);
+ policy = yang_dnode_get_string(args->dnode, NULL);
+
+ /* Set destroy information. */
+ rhc->rhc_shook = rmap_match_set_hook.no_set_tag;
+ rhc->rhc_rule = "sr-te color";
+
+ rv = rmap_match_set_hook.set_tag(rhc->rhc_rmi, "sr-te color", policy,
+ args->errmsg, args->errmsg_len);
+ if (rv != CMD_SUCCESS) {
+ rhc->rhc_shook = NULL;
+ return NB_ERR_INCONSISTENCY;
+ }
+
+ return NB_OK;
+}
+
+static int
+lib_route_map_entry_set_action_policy_destroy(struct nb_cb_destroy_args *args)
+{
+ return lib_route_map_entry_set_destroy(args);
+}
+
/* clang-format off */
const struct frr_yang_module_info frr_route_map_info = {
.name = "frr-route-map",
@@ -1190,42 +1252,42 @@ const struct frr_yang_module_info frr_route_map_info = {
}
},
{
- .xpath = "/frr-route-map:lib/route-map/entry/match-condition/interface",
+ .xpath = "/frr-route-map:lib/route-map/entry/match-condition/rmap-match-condition/interface",
.cbs = {
.modify = lib_route_map_entry_match_condition_interface_modify,
.destroy = lib_route_map_entry_match_condition_interface_destroy,
}
},
{
- .xpath = "/frr-route-map:lib/route-map/entry/match-condition/list-name",
+ .xpath = "/frr-route-map:lib/route-map/entry/match-condition/rmap-match-condition/list-name",
.cbs = {
.modify = lib_route_map_entry_match_condition_list_name_modify,
.destroy = lib_route_map_entry_match_condition_list_name_destroy,
}
},
{
- .xpath = "/frr-route-map:lib/route-map/entry/match-condition/ipv4-next-hop-type",
+ .xpath = "/frr-route-map:lib/route-map/entry/match-condition/rmap-match-condition/ipv4-next-hop-type",
.cbs = {
.modify = lib_route_map_entry_match_condition_ipv4_next_hop_type_modify,
.destroy = lib_route_map_entry_match_condition_ipv4_next_hop_type_destroy,
}
},
{
- .xpath = "/frr-route-map:lib/route-map/entry/match-condition/ipv6-next-hop-type",
+ .xpath = "/frr-route-map:lib/route-map/entry/match-condition/rmap-match-condition/ipv6-next-hop-type",
.cbs = {
.modify = lib_route_map_entry_match_condition_ipv6_next_hop_type_modify,
.destroy = lib_route_map_entry_match_condition_ipv6_next_hop_type_destroy,
}
},
{
- .xpath = "/frr-route-map:lib/route-map/entry/match-condition/metric",
+ .xpath = "/frr-route-map:lib/route-map/entry/match-condition/rmap-match-condition/metric",
.cbs = {
.modify = lib_route_map_entry_match_condition_metric_modify,
.destroy = lib_route_map_entry_match_condition_metric_destroy,
}
},
{
- .xpath = "/frr-route-map:lib/route-map/entry/match-condition/tag",
+ .xpath = "/frr-route-map:lib/route-map/entry/match-condition/rmap-match-condition/tag",
.cbs = {
.modify = lib_route_map_entry_match_condition_tag_modify,
.destroy = lib_route_map_entry_match_condition_tag_destroy,
@@ -1240,69 +1302,77 @@ const struct frr_yang_module_info frr_route_map_info = {
}
},
{
- .xpath = "/frr-route-map:lib/route-map/entry/set-action/ipv4-address",
+ .xpath = "/frr-route-map:lib/route-map/entry/set-action/rmap-set-action/ipv4-address",
.cbs = {
.modify = lib_route_map_entry_set_action_ipv4_address_modify,
.destroy = lib_route_map_entry_set_action_ipv4_address_destroy,
}
},
{
- .xpath = "/frr-route-map:lib/route-map/entry/set-action/ipv6-address",
+ .xpath = "/frr-route-map:lib/route-map/entry/set-action/rmap-set-action/ipv6-address",
.cbs = {
.modify = lib_route_map_entry_set_action_ipv6_address_modify,
.destroy = lib_route_map_entry_set_action_ipv6_address_destroy,
}
},
{
- .xpath = "/frr-route-map:lib/route-map/entry/set-action/value",
+ .xpath = "/frr-route-map:lib/route-map/entry/set-action/rmap-set-action/value",
.cbs = {
.modify = lib_route_map_entry_set_action_value_modify,
.destroy = lib_route_map_entry_set_action_value_destroy,
}
},
{
- .xpath = "/frr-route-map:lib/route-map/entry/set-action/add-metric",
+ .xpath = "/frr-route-map:lib/route-map/entry/set-action/rmap-set-action/add-metric",
.cbs = {
.modify = lib_route_map_entry_set_action_add_metric_modify,
.destroy = lib_route_map_entry_set_action_add_metric_destroy,
}
},
{
- .xpath = "/frr-route-map:lib/route-map/entry/set-action/subtract-metric",
+ .xpath = "/frr-route-map:lib/route-map/entry/set-action/rmap-set-action/subtract-metric",
.cbs = {
.modify = lib_route_map_entry_set_action_subtract_metric_modify,
.destroy = lib_route_map_entry_set_action_subtract_metric_destroy,
}
},
{
- .xpath = "/frr-route-map:lib/route-map/entry/set-action/use-round-trip-time",
+ .xpath = "/frr-route-map:lib/route-map/entry/set-action/rmap-set-action/use-round-trip-time",
.cbs = {
.modify = lib_route_map_entry_set_action_use_round_trip_time_modify,
.destroy = lib_route_map_entry_set_action_use_round_trip_time_destroy,
}
},
{
- .xpath = "/frr-route-map:lib/route-map/entry/set-action/add-round-trip-time",
+ .xpath = "/frr-route-map:lib/route-map/entry/set-action/rmap-set-action/add-round-trip-time",
.cbs = {
.modify = lib_route_map_entry_set_action_add_round_trip_time_modify,
.destroy = lib_route_map_entry_set_action_add_round_trip_time_destroy,
}
},
{
- .xpath = "/frr-route-map:lib/route-map/entry/set-action/subtract-round-trip-time",
+ .xpath = "/frr-route-map:lib/route-map/entry/set-action/rmap-set-action/subtract-round-trip-time",
.cbs = {
.modify = lib_route_map_entry_set_action_subtract_round_trip_time_modify,
.destroy = lib_route_map_entry_set_action_subtract_round_trip_time_destroy,
}
},
{
- .xpath = "/frr-route-map:lib/route-map/entry/set-action/tag",
+ .xpath = "/frr-route-map:lib/route-map/entry/set-action/rmap-set-action/tag",
.cbs = {
.modify = lib_route_map_entry_set_action_tag_modify,
.destroy = lib_route_map_entry_set_action_tag_destroy,
}
},
{
+ .xpath = "/frr-route-map:lib/route-map/entry/set-action/rmap-set-action/policy",
+ .cbs = {
+ .modify = lib_route_map_entry_set_action_policy_modify,
+ .destroy = lib_route_map_entry_set_action_policy_destroy,
+ }
+ },
+
+ {
.xpath = NULL,
},
}
diff --git a/ospf6d/ospf6_asbr.c b/ospf6d/ospf6_asbr.c
index 9fb21d554..ffd6dc22c 100644
--- a/ospf6d/ospf6_asbr.c
+++ b/ospf6d/ospf6_asbr.c
@@ -30,6 +30,7 @@
#include "plist.h"
#include "thread.h"
#include "linklist.h"
+#include "lib/northbound_cli.h"
#include "ospf6_proto.h"
#include "ospf6_lsa.h"
@@ -1924,99 +1925,83 @@ ospf6_routemap_rule_set_tag(void *rule, const struct prefix *p, void *object)
return RMAP_OKAY;
}
-static const struct route_map_rule_cmd
- ospf6_routemap_rule_set_tag_cmd = {
+static const struct route_map_rule_cmd ospf6_routemap_rule_set_tag_cmd = {
"tag",
ospf6_routemap_rule_set_tag,
route_map_rule_tag_compile,
route_map_rule_tag_free,
};
-static int route_map_command_status(struct vty *vty, enum rmap_compile_rets ret)
-{
- switch (ret) {
- case RMAP_RULE_MISSING:
- vty_out(vty, "OSPF6 Can't find rule.\n");
- return CMD_WARNING_CONFIG_FAILED;
- case RMAP_COMPILE_ERROR:
- vty_out(vty, "OSPF6 Argument is malformed.\n");
- return CMD_WARNING_CONFIG_FAILED;
- case RMAP_COMPILE_SUCCESS:
- break;
- }
-
- return CMD_SUCCESS;
-}
-
/* add "set metric-type" */
-DEFUN (ospf6_routemap_set_metric_type,
- ospf6_routemap_set_metric_type_cmd,
- "set metric-type <type-1|type-2>",
- "Set value\n"
- "Type of metric\n"
- "OSPF6 external type 1 metric\n"
- "OSPF6 external type 2 metric\n")
+DEFUN_YANG (ospf6_routemap_set_metric_type, ospf6_routemap_set_metric_type_cmd,
+ "set metric-type <type-1|type-2>",
+ "Set value\n"
+ "Type of metric\n"
+ "OSPF6 external type 1 metric\n"
+ "OSPF6 external type 2 metric\n")
{
- VTY_DECLVAR_CONTEXT(route_map_index, route_map_index);
- int idx_external = 2;
- enum rmap_compile_rets ret = route_map_add_set(route_map_index,
- "metric-type",
- argv[idx_external]->arg);
+ char *ext = argv[2]->text;
- return route_map_command_status(vty, ret);
+ const char *xpath =
+ "./set-action[action='frr-ospf-route-map:metric-type']";
+ char xpath_value[XPATH_MAXLEN];
+
+ nb_cli_enqueue_change(vty, xpath, NB_OP_CREATE, NULL);
+ snprintf(xpath_value, sizeof(xpath_value),
+ "%s/rmap-set-action/frr-ospf-route-map:metric-type", xpath);
+ nb_cli_enqueue_change(vty, xpath_value, NB_OP_MODIFY, ext);
+ return nb_cli_apply_changes(vty, NULL);
}
/* delete "set metric-type" */
-DEFUN (ospf6_routemap_no_set_metric_type,
- ospf6_routemap_no_set_metric_type_cmd,
- "no set metric-type [<type-1|type-2>]",
- NO_STR
- "Set value\n"
- "Type of metric\n"
- "OSPF6 external type 1 metric\n"
- "OSPF6 external type 2 metric\n")
+DEFUN_YANG (ospf6_routemap_no_set_metric_type, ospf6_routemap_no_set_metric_type_cmd,
+ "no set metric-type [<type-1|type-2>]",
+ NO_STR
+ "Set value\n"
+ "Type of metric\n"
+ "OSPF6 external type 1 metric\n"
+ "OSPF6 external type 2 metric\n")
{
- VTY_DECLVAR_CONTEXT(route_map_index, route_map_index);
- char *ext = (argc == 4) ? argv[3]->text : NULL;
- enum rmap_compile_rets ret = route_map_delete_set(route_map_index,
- "metric-type", ext);
+ const char *xpath =
+ "./set-action[action='frr-ospf-route-map:metric-type']";
- return route_map_command_status(vty, ret);
+ nb_cli_enqueue_change(vty, xpath, NB_OP_DESTROY, NULL);
+ return nb_cli_apply_changes(vty, NULL);
}
/* add "set forwarding-address" */
-DEFUN (ospf6_routemap_set_forwarding,
- ospf6_routemap_set_forwarding_cmd,
- "set forwarding-address X:X::X:X",
- "Set value\n"
- "Forwarding Address\n"
- "IPv6 Address\n")
-{
- VTY_DECLVAR_CONTEXT(route_map_index, route_map_index);
+DEFUN_YANG (ospf6_routemap_set_forwarding, ospf6_routemap_set_forwarding_cmd,
+ "set forwarding-address X:X::X:X",
+ "Set value\n"
+ "Forwarding Address\n"
+ "IPv6 Address\n")
+{
int idx_ipv6 = 2;
- enum rmap_compile_rets ret = route_map_add_set(route_map_index,
- "forwarding-address",
- argv[idx_ipv6]->arg);
+ const char *xpath =
+ "./set-action[action='frr-ospf6-route-map:forwarding-address']";
+ char xpath_value[XPATH_MAXLEN];
- return route_map_command_status(vty, ret);
+ nb_cli_enqueue_change(vty, xpath, NB_OP_CREATE, NULL);
+ snprintf(xpath_value, sizeof(xpath_value),
+ "%s/rmap-set-action/frr-ospf6-route-map:ipv6-address", xpath);
+ nb_cli_enqueue_change(vty, xpath_value, NB_OP_MODIFY,
+ argv[idx_ipv6]->arg);
+ return nb_cli_apply_changes(vty, NULL);
}
/* delete "set forwarding-address" */
-DEFUN (ospf6_routemap_no_set_forwarding,
- ospf6_routemap_no_set_forwarding_cmd,
- "no set forwarding-address X:X::X:X",
- NO_STR
- "Set value\n"
- "Forwarding Address\n"
- "IPv6 Address\n")
-{
- VTY_DECLVAR_CONTEXT(route_map_index, route_map_index);
- int idx_ipv6 = 3;
- enum rmap_compile_rets ret = route_map_delete_set(route_map_index,
- "forwarding-address",
- argv[idx_ipv6]->arg);
-
- return route_map_command_status(vty, ret);
+DEFUN_YANG (ospf6_routemap_no_set_forwarding, ospf6_routemap_no_set_forwarding_cmd,
+ "no set forwarding-address [X:X::X:X]",
+ NO_STR
+ "Set value\n"
+ "Forwarding Address\n"
+ "IPv6 Address\n")
+{
+ const char *xpath =
+ "./set-action[action='frr-ospf6-route-map:forwarding-address']";
+
+ nb_cli_enqueue_change(vty, xpath, NB_OP_DESTROY, NULL);
+ return nb_cli_apply_changes(vty, NULL);
}
static void ospf6_routemap_init(void)
diff --git a/ospf6d/ospf6_main.c b/ospf6d/ospf6_main.c
index c601693a7..cf61ca7a6 100644
--- a/ospf6d/ospf6_main.c
+++ b/ospf6d/ospf6_main.c
@@ -47,6 +47,7 @@
#include "ospf6_lsa.h"
#include "ospf6_interface.h"
#include "ospf6_zebra.h"
+#include "ospf6_routemap_nb.h"
/* Default configuration file name for ospf6d. */
#define OSPF6_DEFAULT_CONFIG "ospf6d.conf"
@@ -172,6 +173,8 @@ static const struct frr_yang_module_info *const ospf6d_yang_modules[] = {
&frr_interface_info,
&frr_route_map_info,
&frr_vrf_info,
+ &frr_ospf_route_map_info,
+ &frr_ospf6_route_map_info,
};
FRR_DAEMON_INFO(ospf6d, OSPF6, .vty_port = OSPF6_VTY_PORT,
diff --git a/ospf6d/ospf6_routemap_nb.c b/ospf6d/ospf6_routemap_nb.c
new file mode 100644
index 000000000..b710fefbd
--- /dev/null
+++ b/ospf6d/ospf6_routemap_nb.c
@@ -0,0 +1,55 @@
+/*
+ * Copyright (C) 2020 Vmware
+ * Sarita Patra
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the Free
+ * Software Foundation; either version 2 of the License, or (at your option)
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; see the file COPYING; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "lib/northbound.h"
+#include "lib/routemap.h"
+#include "ospf6_routemap_nb.h"
+
+/* clang-format off */
+const struct frr_yang_module_info frr_ospf_route_map_info = {
+ .name = "frr-ospf-route-map",
+ .nodes = {
+ {
+ .xpath = "/frr-route-map:lib/route-map/entry/set-action/rmap-set-action/frr-ospf-route-map:metric-type",
+ .cbs = {
+ .modify = lib_route_map_entry_set_action_rmap_set_action_metric_type_modify,
+ .destroy = lib_route_map_entry_set_action_rmap_set_action_metric_type_destroy,
+ }
+ },
+ {
+ .xpath = NULL,
+ },
+ }
+};
+
+const struct frr_yang_module_info frr_ospf6_route_map_info = {
+ .name = "frr-ospf6-route-map",
+ .nodes = {
+ {
+ .xpath = "/frr-route-map:lib/route-map/entry/set-action/rmap-set-action/frr-ospf6-route-map:ipv6-address",
+ .cbs = {
+ .modify = lib_route_map_entry_set_action_rmap_set_action_ipv6_address_modify,
+ .destroy = lib_route_map_entry_set_action_rmap_set_action_ipv6_address_destroy,
+ }
+ },
+ {
+ .xpath = NULL,
+ },
+ }
+};
diff --git a/ospf6d/ospf6_routemap_nb.h b/ospf6d/ospf6_routemap_nb.h
new file mode 100644
index 000000000..181e71a8c
--- /dev/null
+++ b/ospf6d/ospf6_routemap_nb.h
@@ -0,0 +1,40 @@
+/*
+ * Copyright (C) 2020 Vmware
+ * Sarita Patra
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the Free
+ * Software Foundation; either version 2 of the License, or (at your option)
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; see the file COPYING; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef _FRR_OSPF6_ROUTEMAP_NB_H_
+#define _FRR_OSPF6_ROUTEMAP_NB_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+extern const struct frr_yang_module_info frr_ospf_route_map_info;
+extern const struct frr_yang_module_info frr_ospf6_route_map_info;
+
+/* prototypes */
+int lib_route_map_entry_set_action_rmap_set_action_ipv6_address_modify(struct nb_cb_modify_args *args);
+int lib_route_map_entry_set_action_rmap_set_action_ipv6_address_destroy(struct nb_cb_destroy_args *args);
+int lib_route_map_entry_set_action_rmap_set_action_metric_type_modify(struct nb_cb_modify_args *args);
+int lib_route_map_entry_set_action_rmap_set_action_metric_type_destroy(struct nb_cb_destroy_args *args);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/ospf6d/ospf6_routemap_nb_config.c b/ospf6d/ospf6_routemap_nb_config.c
new file mode 100644
index 000000000..3c7741e47
--- /dev/null
+++ b/ospf6d/ospf6_routemap_nb_config.c
@@ -0,0 +1,129 @@
+/*
+ * Copyright (C) 2020 Vmware
+ * Sarita Patra
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the Free
+ * Software Foundation; either version 2 of the License, or (at your option)
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; see the file COPYING; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "lib/command.h"
+#include "lib/log.h"
+#include "lib/northbound.h"
+#include "lib/routemap.h"
+#include "ospf6_routemap_nb.h"
+
+/*
+ * XPath:
+ * /frr-route-map:lib/route-map/entry/set-action/rmap-set-action/frr-ospf-route-map:metric-type
+ */
+int lib_route_map_entry_set_action_rmap_set_action_metric_type_modify(
+ struct nb_cb_modify_args *args)
+{
+ struct routemap_hook_context *rhc;
+ const char *type;
+ int rv;
+
+ switch (args->event) {
+ case NB_EV_VALIDATE:
+ case NB_EV_PREPARE:
+ case NB_EV_ABORT:
+ break;
+ case NB_EV_APPLY:
+ /* Add configuration. */
+ rhc = nb_running_get_entry(args->dnode, NULL, true);
+ type = yang_dnode_get_string(args->dnode, NULL);
+
+ /* Set destroy information. */
+ rhc->rhc_shook = generic_set_delete;
+ rhc->rhc_rule = "metric-type";
+ rhc->rhc_event = RMAP_EVENT_SET_DELETED;
+
+ rv = generic_set_add(rhc->rhc_rmi, "metric-type", type,
+ args->errmsg, args->errmsg_len);
+ if (rv != CMD_SUCCESS) {
+ rhc->rhc_mhook = NULL;
+ return NB_ERR_INCONSISTENCY;
+ }
+ }
+
+ return NB_OK;
+}
+
+int lib_route_map_entry_set_action_rmap_set_action_metric_type_destroy(
+ struct nb_cb_destroy_args *args)
+{
+ switch (args->event) {
+ case NB_EV_VALIDATE:
+ case NB_EV_PREPARE:
+ case NB_EV_ABORT:
+ break;
+ case NB_EV_APPLY:
+ return lib_route_map_entry_set_destroy(args);
+ }
+
+ return NB_OK;
+}
+
+/*
+ * XPath:
+ * /frr-route-map:lib/route-map/entry/set-action/rmap-set-action/frr-ospf6-route-map:ipv6-address
+ */
+int lib_route_map_entry_set_action_rmap_set_action_ipv6_address_modify(
+ struct nb_cb_modify_args *args)
+{
+ struct routemap_hook_context *rhc;
+ const char *ipv6_addr;
+ int rv;
+
+ switch (args->event) {
+ case NB_EV_VALIDATE:
+ case NB_EV_PREPARE:
+ case NB_EV_ABORT:
+ break;
+ case NB_EV_APPLY:
+ /* Add configuration. */
+ rhc = nb_running_get_entry(args->dnode, NULL, true);
+ ipv6_addr = yang_dnode_get_string(args->dnode, NULL);
+
+ /* Set destroy information. */
+ rhc->rhc_shook = generic_set_delete;
+ rhc->rhc_rule = "forwarding-address";
+ rhc->rhc_event = RMAP_EVENT_SET_DELETED;
+
+ rv = generic_set_add(rhc->rhc_rmi, "forwarding-address",
+ ipv6_addr,
+ args->errmsg, args->errmsg_len);
+ if (rv != CMD_SUCCESS) {
+ rhc->rhc_mhook = NULL;
+ return NB_ERR_INCONSISTENCY;
+ }
+ }
+
+ return NB_OK;
+}
+
+int lib_route_map_entry_set_action_rmap_set_action_ipv6_address_destroy(
+ struct nb_cb_destroy_args *args)
+{
+ switch (args->event) {
+ case NB_EV_VALIDATE:
+ case NB_EV_PREPARE:
+ case NB_EV_ABORT:
+ break;
+ case NB_EV_APPLY:
+ return lib_route_map_entry_set_destroy(args);
+ }
+
+ return NB_OK;
+}
diff --git a/ospf6d/subdir.am b/ospf6d/subdir.am
index dc173da9d..788b532a9 100644
--- a/ospf6d/subdir.am
+++ b/ospf6d/subdir.am
@@ -34,6 +34,8 @@ ospf6d_libospf6_a_SOURCES = \
ospf6d/ospf6_abr.c \
ospf6d/ospf6_area.c \
ospf6d/ospf6_asbr.c \
+ ospf6d/ospf6_routemap_nb.c \
+ ospf6d/ospf6_routemap_nb_config.c \
ospf6d/ospf6_bfd.c \
ospf6d/ospf6_flood.c \
ospf6d/ospf6_interface.c \
@@ -66,6 +68,7 @@ noinst_HEADERS += \
ospf6d/ospf6_network.h \
ospf6d/ospf6_proto.h \
ospf6d/ospf6_route.h \
+ ospf6d/ospf6_routemap_nb.h \
ospf6d/ospf6_spf.h \
ospf6d/ospf6_top.h \
ospf6d/ospf6_zebra.h \
@@ -85,3 +88,8 @@ ospf6d_ospf6d_snmp_la_LIBADD = lib/libfrrsnmp.la
clippy_scan += \
ospf6d/ospf6_asbr.c \
# end
+
+nodist_ospf6d_ospf6d_SOURCES = \
+ yang/frr-ospf-route-map.yang.c \
+ yang/frr-ospf6-route-map.yang.c \
+ # end
diff --git a/ospfd/ospf_main.c b/ospfd/ospf_main.c
index d23dea0ca..91ba3044f 100644
--- a/ospfd/ospf_main.c
+++ b/ospfd/ospf_main.c
@@ -56,6 +56,7 @@
#include "ospfd/ospf_bfd.h"
#include "ospfd/ospf_errors.h"
#include "ospfd/ospf_ldp_sync.h"
+#include "ospfd/ospf_routemap_nb.h"
/* ospfd privileges */
zebra_capabilities_t _caps_p[] = {ZCAP_NET_RAW, ZCAP_BIND, ZCAP_NET_ADMIN,
@@ -134,6 +135,7 @@ static const struct frr_yang_module_info *const ospfd_yang_modules[] = {
&frr_interface_info,
&frr_route_map_info,
&frr_vrf_info,
+ &frr_ospf_route_map_info,
};
FRR_DAEMON_INFO(ospfd, OSPF, .vty_port = OSPF_VTY_PORT,
diff --git a/ospfd/ospf_routemap.c b/ospfd/ospf_routemap.c
index bdc65d23b..d3b114840 100644
--- a/ospfd/ospf_routemap.c
+++ b/ospfd/ospf_routemap.c
@@ -33,6 +33,7 @@
#include "plist.h"
#include "vrf.h"
#include "frrstr.h"
+#include "northbound_cli.h"
#include "ospfd/ospfd.h"
#include "ospfd/ospf_asbr.h"
@@ -534,7 +535,7 @@ static const struct route_map_rule_cmd route_set_tag_cmd = {
route_map_rule_tag_free,
};
-DEFUN (set_metric_type,
+DEFUN_YANG (set_metric_type,
set_metric_type_cmd,
"set metric-type <type-1|type-2>",
SET_STR
@@ -543,11 +544,19 @@ DEFUN (set_metric_type,
"OSPF[6] external type 2 metric\n")
{
char *ext = argv[2]->text;
- return generic_set_add(vty, VTY_GET_CONTEXT(route_map_index),
- "metric-type", ext);
+
+ const char *xpath =
+ "./set-action[action='frr-ospf-route-map:metric-type']";
+ char xpath_value[XPATH_MAXLEN];
+
+ nb_cli_enqueue_change(vty, xpath, NB_OP_CREATE, NULL);
+ snprintf(xpath_value, sizeof(xpath_value),
+ "%s/rmap-set-action/frr-ospf-route-map:metric-type", xpath);
+ nb_cli_enqueue_change(vty, xpath_value, NB_OP_MODIFY, ext);
+ return nb_cli_apply_changes(vty, NULL);
}
-DEFUN (no_set_metric_type,
+DEFUN_YANG (no_set_metric_type,
no_set_metric_type_cmd,
"no set metric-type [<type-1|type-2>]",
NO_STR
@@ -556,9 +565,11 @@ DEFUN (no_set_metric_type,
"OSPF[6] external type 1 metric\n"
"OSPF[6] external type 2 metric\n")
{
- char *ext = (argc == 4) ? argv[3]->text : NULL;
- return generic_set_delete(vty, VTY_GET_CONTEXT(route_map_index),
- "metric-type", ext);
+ const char *xpath =
+ "./set-action[action='frr-ospf-route-map:metric-type']";
+
+ nb_cli_enqueue_change(vty, xpath, NB_OP_DESTROY, NULL);
+ return nb_cli_apply_changes(vty, NULL);
}
/* Route-map init */
diff --git a/ospfd/ospf_routemap_nb.c b/ospfd/ospf_routemap_nb.c
new file mode 100644
index 000000000..1f6b0ef78
--- /dev/null
+++ b/ospfd/ospf_routemap_nb.c
@@ -0,0 +1,39 @@
+/*
+ * Copyright (C) 2020 Vmware
+ * Sarita Patra
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the Free
+ * Software Foundation; either version 2 of the License, or (at your option)
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; see the file COPYING; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "lib/northbound.h"
+#include "lib/routemap.h"
+#include "ospf_routemap_nb.h"
+
+/* clang-format off */
+const struct frr_yang_module_info frr_ospf_route_map_info = {
+ .name = "frr-ospf-route-map",
+ .nodes = {
+ {
+ .xpath = "/frr-route-map:lib/route-map/entry/set-action/rmap-set-action/frr-ospf-route-map:metric-type",
+ .cbs = {
+ .modify = lib_route_map_entry_set_action_rmap_set_action_metric_type_modify,
+ .destroy = lib_route_map_entry_set_action_rmap_set_action_metric_type_destroy,
+ }
+ },
+ {
+ .xpath = NULL,
+ },
+ }
+};
diff --git a/ospfd/ospf_routemap_nb.h b/ospfd/ospf_routemap_nb.h
new file mode 100644
index 000000000..17bcb4f5c
--- /dev/null
+++ b/ospfd/ospf_routemap_nb.h
@@ -0,0 +1,37 @@
+/*
+ * Copyright (C) 2020 Vmware
+ * Sarita Patra
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the Free
+ * Software Foundation; either version 2 of the License, or (at your option)
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; see the file COPYING; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef _FRR_OSPF_ROUTEMAP_NB_H_
+#define _FRR_OSPF_ROUTEMAP_NB_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+extern const struct frr_yang_module_info frr_ospf_route_map_info;
+
+/* prototypes */
+int lib_route_map_entry_set_action_rmap_set_action_metric_type_modify(struct nb_cb_modify_args *args);
+int lib_route_map_entry_set_action_rmap_set_action_metric_type_destroy(struct nb_cb_destroy_args *args);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/ospfd/ospf_routemap_nb_config.c b/ospfd/ospf_routemap_nb_config.c
new file mode 100644
index 000000000..bfb18c5e0
--- /dev/null
+++ b/ospfd/ospf_routemap_nb_config.c
@@ -0,0 +1,63 @@
+/*
+ * Copyright (C) 2020 Vmware
+ * Sarita Patra
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the Free
+ * Software Foundation; either version 2 of the License, or (at your option)
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; see the file COPYING; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "lib/command.h"
+#include "lib/log.h"
+#include "lib/northbound.h"
+#include "lib/routemap.h"
+#include "ospf_routemap_nb.h"
+
+/*
+ * XPath:
+ * /frr-route-map:lib/route-map/entry/set-action/rmap-set-action/frr-ospf-route-map:metric-type
+ */
+int lib_route_map_entry_set_action_rmap_set_action_metric_type_modify(
+ struct nb_cb_modify_args *args)
+{
+ struct routemap_hook_context *rhc;
+ const char *type;
+ int rv;
+
+ if (args->event != NB_EV_APPLY)
+ return NB_OK;
+
+ /* Add configuration. */
+ rhc = nb_running_get_entry(args->dnode, NULL, true);
+ type = yang_dnode_get_string(args->dnode, NULL);
+
+ /* Set destroy information. */
+ rhc->rhc_shook = generic_set_delete;
+ rhc->rhc_rule = "metric-type";
+ rhc->rhc_event = RMAP_EVENT_SET_DELETED;
+
+ rv = generic_set_add(rhc->rhc_rmi, "metric-type", type,
+ args->errmsg, args->errmsg_len);
+ if (rv != CMD_SUCCESS) {
+ rhc->rhc_mhook = NULL;
+ return NB_ERR_INCONSISTENCY;
+ }
+
+ return NB_OK;
+}
+
+int lib_route_map_entry_set_action_rmap_set_action_metric_type_destroy(
+ struct nb_cb_destroy_args *args)
+{
+ return lib_route_map_entry_set_destroy(args);
+}
diff --git a/ospfd/ospfd.h b/ospfd/ospfd.h
index 7463e069a..2093eb2e4 100644
--- a/ospfd/ospfd.h
+++ b/ospfd/ospfd.h
@@ -732,4 +732,5 @@ extern int p_spaces_compare_func(const struct p_space *a,
const struct p_space *b);
extern int q_spaces_compare_func(const struct q_space *a,
const struct q_space *b);
+
#endif /* _ZEBRA_OSPFD_H */
diff --git a/ospfd/subdir.am b/ospfd/subdir.am
index 25ddef358..63610e38d 100644
--- a/ospfd/subdir.am
+++ b/ospfd/subdir.am
@@ -51,6 +51,8 @@ ospfd_libfrrospf_a_SOURCES = \
ospfd/ospf_ri.c \
ospfd/ospf_route.c \
ospfd/ospf_routemap.c \
+ ospfd/ospf_routemap_nb.c \
+ ospfd/ospf_routemap_nb_config.c \
ospfd/ospf_spf.c \
ospfd/ospf_ti_lfa.c \
ospfd/ospf_sr.c \
@@ -100,6 +102,7 @@ noinst_HEADERS += \
ospfd/ospf_packet.h \
ospfd/ospf_ri.h \
ospfd/ospf_route.h \
+ ospfd/ospf_routemap_nb.h \
ospfd/ospf_spf.h \
ospfd/ospf_ti_lfa.h \
ospfd/ospf_sr.h \
@@ -120,3 +123,7 @@ ospfd_ospfd_snmp_la_LIBADD = lib/libfrrsnmp.la
EXTRA_DIST += \
ospfd/ChangeLog.opaque.txt \
# end
+
+nodist_ospfd_ospfd_SOURCES = \
+ yang/frr-ospf-route-map.yang.c \
+ # end
diff --git a/yang/frr-bgp-filter.yang b/yang/frr-bgp-filter.yang
new file mode 100644
index 000000000..199e70997
--- /dev/null
+++ b/yang/frr-bgp-filter.yang
@@ -0,0 +1,329 @@
+module frr-bgp-filter {
+ yang-version 1.1;
+ namespace "http://frrouting.org/yang/bgp-filter";
+ prefix frr-bgp-filter;
+
+ import frr-filter {
+ prefix frr-filter;
+ }
+
+ import ietf-routing-types {
+ prefix rt-types;
+ }
+
+ organization
+ "Free Range Routing";
+ contact
+ "FRR Users List: <mailto:frog@lists.frrouting.org>
+ FRR Development List: <mailto:dev@lists.frrouting.org>";
+ description
+ "This module defines filter settings";
+
+ revision 2020-01-15 {
+ description
+ "Initial revision";
+ }
+
+ typedef list-sequence {
+ type uint32 {
+ range "1..4294967295";
+ }
+ description
+ "List instance priority (low number means higher priority)";
+ }
+
+ typedef list-action {
+ type enumeration {
+ enum "deny" {
+ value 0;
+ description
+ "Deny an entry";
+ }
+ enum "permit" {
+ value 1;
+ description
+ "Accept an entry";
+ }
+ }
+ description
+ "Return action on match";
+ }
+
+ typedef bgp-list-name {
+ type string;
+ description
+ "List name";
+ }
+
+ typedef community-string {
+ type string {
+ pattern "(6553[0-5]|655[0-2][0-9]|65[0-4][0-9]{2}|6[0-4][0-9]{3}|[1-5][0-9]{4}|[1-9][0-9]{0,3}|0)|((6553[0-5]|655[0-2][0-9]|65[0-4][0-9]{2}|6[0-4][0-9]{3}|[1-5][0-9]{4}|[1-9][0-9]{0,3}|0):(6553[0-5]|655[0-2][0-9]|65[0-4][0-9]{2}|6[0-4][0-9]{3}|[1-5][0-9]{4}|[1-9][0-9]{0,3}|0))|(local-AS)|(no-advertise)|(no-export)|(internet)";
+ }
+ description
+ "The BGP community string";
+ }
+
+ typedef large-community-string {
+ type string {
+ pattern "(429496729[0-5]|42949672[0-8][0-9]|4294967[01][0-9]{2}|429496[0-6][0-9]{3}|42949[0-5][0-9]{4}|4294[0-8][0-9]{5}|429[0-3][0-9]{6}|42[0-8][0-9]{7}|4[01][0-9]{8}|[1-3][0-9]{9}|[1-9][0-9]{0,8}|0)|(429496729[0-5]|42949672[0-8][0-9]|4294967[01][0-9]{2}|429496[0-6][0-9]{3}|42949[0-5][0-9]{4}|4294[0-8][0-9]{5}|429[0-3][0-9]{6}|42[0-8][0-9]{7}|4[01][0-9]{8}|[1-3][0-9]{9}|[1-9][0-9]{0,8}|0):(429496729[0-5]|42949672[0-8][0-9]|4294967[01][0-9]{2}|429496[0-6][0-9]{3}|42949[0-5][0-9]{4}|4294[0-8][0-9]{5}|429[0-3][0-9]{6}|42[0-8][0-9]{7}|4[01][0-9]{8}|[1-3][0-9]{9}|[1-9][0-9]{0,8}|0)|(429496729[0-5]|42949672[0-8][0-9]|4294967[01][0-9]{2}|429496[0-6][0-9]{3}|42949[0-5][0-9]{4}|4294[0-8][0-9]{5}|429[0-3][0-9]{6}|42[0-8][0-9]{7}|4[01][0-9]{8}|[1-3][0-9]{9}|[1-9][0-9]{0,8}|0):(429496729[0-5]|42949672[0-8][0-9]|4294967[01][0-9]{2}|429496[0-6][0-9]{3}|42949[0-5][0-9]{4}|4294[0-8][0-9]{5}|429[0-3][0-9]{6}|42[0-8][0-9]{7}|4[01][0-9]{8}|[1-3][0-9]{9}|[1-9][0-9]{0,8}|0):(429496729[0-5]|42949672[0-8][0-9]|4294967[01][0-9]{2}|429496[0-6][0-9]{3}|42949[0-5][0-9]{4}|4294[0-8][0-9]{5}|429[0-3][0-9]{6}|42[0-8][0-9]{7}|4[01][0-9]{8}|[1-3][0-9]{9}|[1-9][0-9]{0,8}|0)";
+ }
+ description
+ "The BGP large-community string";
+ }
+
+ augment "/frr-filter:lib" {
+ list community-list {
+ key "name";
+ description
+ "Community-list instance";
+ leaf name {
+ type string;
+ }
+
+ list entry {
+ key "sequence";
+ description
+ "Community-list entry";
+ leaf sequence {
+ type list-sequence;
+ }
+
+ leaf action {
+ type list-action;
+ }
+
+ leaf type {
+ type enumeration {
+ enum "community-list-standard" {
+ value 0;
+ description
+ "Standard community-list name/identifier";
+ }
+ enum "community-list-extended" {
+ value 1;
+ description
+ "Expanded community-list name/identifier";
+ }
+ }
+ mandatory true;
+ description
+ "Community-list instance name/identifier";
+ }
+
+ choice community-string {
+ description
+ "Community string";
+ case standard {
+ when "./type = 'community-list-standard'";
+ leaf-list standard-community-string {
+ type community-string;
+ description
+ "Community string";
+ }
+ }
+
+ case expanded {
+ when "./type = 'community-list-extended'";
+ leaf expanded-community-string {
+ type string;
+ description
+ "Community string reg-ex";
+ }
+ }
+ }
+ }
+ }
+
+ list large-community-list {
+ key "name";
+ description
+ "Large community-list instance";
+ leaf name {
+ type string;
+ }
+
+ list entry {
+ key "sequence";
+ description
+ "Large community-list entry";
+ leaf sequence {
+ type list-sequence;
+ }
+
+ leaf action {
+ type list-action;
+ }
+
+ leaf type {
+ type enumeration {
+ enum "large-community-list-standard-id" {
+ value 0;
+ description
+ "Standard large-community-list identifier";
+ }
+ enum "large-community-list-extended-id" {
+ value 1;
+ description
+ "Expanded large-community-list identifier";
+ }
+ enum "large-community-list-standard-name" {
+ value 2;
+ description
+ "Standard large-community-list name";
+ }
+ enum "large-community-list-extended-name" {
+ value 3;
+ description
+ "Expanded large-community-list name";
+ }
+ }
+ mandatory true;
+ description
+ "Large community-list instance name/identifier";
+ }
+
+ choice large-community-string {
+ description
+ "Large community string";
+ case standard {
+ when "./type = 'large-community-list-standard-id' or "
+ + "./type = 'large-community-list-standard-name'";
+ leaf-list standard-large-community-string {
+ type large-community-string;
+ description
+ "Large community string";
+ }
+ }
+
+ case expanded {
+ when "./type = 'large-community-list-extended-id' or "
+ + "./type = 'large-community-list-extended-name'";
+ leaf expanded-large-community-string {
+ type string;
+ description
+ "Large community string reg-ex";
+ }
+ }
+ }
+ }
+ }
+
+ list extcommunity-list {
+ key "name";
+ description
+ "Extcommunity-list instance";
+ leaf name {
+ type string;
+ }
+
+ list entry {
+ key "sequence";
+ description
+ "Extcommunity-list entry";
+ leaf sequence {
+ type list-sequence;
+ }
+
+ leaf action {
+ type list-action;
+ }
+
+ leaf type {
+ type enumeration {
+ enum "extcommunity-list-standard-id" {
+ value 0;
+ description
+ "Standard extcommunity-list identifier";
+ }
+ enum "extcommunity-list-extended-id" {
+ value 1;
+ description
+ "Expanded extcommunity-list identifier";
+ }
+ enum "extcommunity-list-standard-name" {
+ value 2;
+ description
+ "Standard extcommunity-list name";
+ }
+ enum "extcommunity-list-extended-name" {
+ value 3;
+ description
+ "Expanded extcommunity-list name";
+ }
+ }
+ mandatory true;
+ description
+ "Extcommunity-list instance name/identifier";
+ }
+
+ choice extcommunity-string {
+ description
+ "Extcommunity string";
+ case standard {
+ when "./type = 'extcommunity-list-standard-id' or "
+ + "./type = 'extcommunity-list-standard-name'";
+ choice standard-extcommunity-string {
+ description
+ "Value of the ext-community";
+ case extcommunity-rt {
+ description
+ "Set BGP ext-community route-target attribute";
+ leaf-list extcommunity-rt {
+ type rt-types:route-target;
+ }
+ }
+
+ case extcommunity-soo {
+ description
+ "Set BGP ext-community site-of-origin attribute";
+ leaf-list extcommunity-soo {
+ type rt-types:route-target;
+ }
+ }
+ }
+ }
+
+ case expanded {
+ when "./type = 'extcommunity-list-extended-id' or "
+ + "./type = 'extcommunity-list-extended-name'";
+ leaf expanded-extcommunity-string {
+ type string;
+ description
+ "Extcommunity string reg-ex";
+ }
+ }
+ }
+ }
+ }
+
+ list as-path-list {
+ key "name";
+ description
+ "AS-path access-list instance";
+ leaf name {
+ type string;
+ description
+ "AS-path access-list instance name/identifier";
+ }
+
+ list entry {
+ key "sequence";
+ description
+ "AS-path access-list entry";
+ leaf sequence {
+ type list-sequence;
+ }
+
+ leaf action {
+ type list-action;
+ }
+
+ leaf as-path {
+ type string;
+ description
+ "AS-path access-list string reg-ex";
+ }
+ }
+ }
+ }
+}
diff --git a/yang/frr-bgp-route-map.yang b/yang/frr-bgp-route-map.yang
new file mode 100644
index 000000000..96505b08a
--- /dev/null
+++ b/yang/frr-bgp-route-map.yang
@@ -0,0 +1,820 @@
+module frr-bgp-route-map {
+ yang-version 1.1;
+ namespace "http://frrouting.org/yang/bgp-route-map";
+ prefix frr-bgp-route-map;
+
+ import ietf-inet-types {
+ prefix inet;
+ }
+
+ import frr-route-map {
+ prefix frr-route-map;
+ }
+
+ import frr-filter {
+ prefix filter;
+ }
+
+ import frr-bgp-filter {
+ prefix bgp-filter;
+ }
+
+ import ietf-routing-types {
+ prefix rt-types;
+ }
+
+ organization
+ "Free Range Routing";
+ contact
+ "FRR Users List: <mailto:frog@lists.frrouting.org>
+ FRR Development List: <mailto:dev@lists.frrouting.org>";
+ description
+ "This module defines bgp route map settings";
+
+ revision 2020-01-02 {
+ description
+ "Initial revision";
+ }
+
+ identity match-local-preference {
+ base frr-route-map:rmap-match-type;
+ description
+ "Match local-preference of routes";
+ }
+
+ identity match-script {
+ base frr-route-map:rmap-match-type;
+ description
+ "Match script of routes";
+ }
+
+ identity match-origin {
+ base frr-route-map:rmap-match-type;
+ description
+ "Match BGP route origin code";
+ }
+
+ identity rpki {
+ base frr-route-map:rmap-match-type;
+ description
+ "Control rpki specific settings";
+ }
+
+ identity probability {
+ base frr-route-map:rmap-match-type;
+ description
+ "Match portion of routes defined by percentage value";
+ }
+
+ identity source-vrf {
+ base frr-route-map:rmap-match-type;
+ description
+ "Match source vrf of routes";
+ }
+
+ identity peer {
+ base frr-route-map:rmap-match-type;
+ description
+ "Match peer address";
+ }
+
+ identity mac-address-list {
+ base frr-route-map:rmap-match-type;
+ description
+ "Match MAC address access-list";
+ }
+
+ identity ip-route-source {
+ base frr-route-map:rmap-match-type;
+ description
+ "Match advertising source address of route";
+ }
+
+ identity ip-route-source-prefix-list {
+ base frr-route-map:rmap-match-type;
+ description
+ "Match advertising source address of route";
+ }
+
+ identity evpn-route-type {
+ base frr-route-map:rmap-match-type;
+ description
+ "Match EVPN route type";
+ }
+
+ identity evpn-default-route {
+ base frr-route-map:rmap-match-type;
+ description
+ "Match EVPN default Type-5 route";
+ }
+
+ identity evpn-vni {
+ base frr-route-map:rmap-match-type;
+ description
+ "Match EVPN VNI";
+ }
+
+ identity evpn-rd {
+ base frr-route-map:rmap-match-type;
+ description
+ "Match EVPN route distinguisher";
+ }
+
+ identity match-community {
+ base frr-route-map:rmap-match-type;
+ description
+ "Match BGP community list";
+ }
+
+ identity match-large-community {
+ base frr-route-map:rmap-match-type;
+ description
+ "Match BGP large-community list";
+ }
+
+ identity match-extcommunity {
+ base frr-route-map:rmap-match-type;
+ description
+ "Match BGP extcommunity list";
+ }
+
+ identity as-path-list {
+ base frr-route-map:rmap-match-type;
+ description
+ "Match BGP AS path list";
+ }
+
+ identity ipv4-nexthop {
+ base frr-route-map:rmap-match-type;
+ description
+ "Match IPv4 next hop address";
+ }
+
+ identity ipv6-nexthop {
+ base frr-route-map:rmap-match-type;
+ description
+ "Match IPv6 next hop address";
+ }
+
+ identity distance {
+ base frr-route-map:rmap-set-type;
+ description
+ "Set BGP administrative distance to use";
+ }
+
+ identity set-extcommunity-rt {
+ base frr-route-map:rmap-set-type;
+ description
+ "Set BGP extended community attribute";
+ }
+
+ identity set-extcommunity-soo {
+ base frr-route-map:rmap-set-type;
+ description
+ "Set BGP extended community attribute";
+ }
+
+ identity set-extcommunity-lb {
+ base frr-route-map:rmap-set-type;
+ description
+ "Set BGP extended community attribute";
+ }
+
+ identity set-ipv4-nexthop {
+ base frr-route-map:rmap-set-type;
+ description
+ "Set the IPv4 next-hop to peer-address/unchanged";
+ }
+
+ identity ipv4-vpn-address {
+ base frr-route-map:rmap-set-type;
+ description
+ "Set IPv4 VPN next-hop address";
+ }
+
+ identity ipv6-nexthop-global {
+ base frr-route-map:rmap-set-type;
+ description
+ "Set IPv6 next-hop global address";
+ }
+
+ identity ipv6-prefer-global {
+ base frr-route-map:rmap-set-type;
+ description
+ "Set IPv6 next-hop to prefer global address";
+ }
+
+ identity ipv6-peer-address {
+ base frr-route-map:rmap-set-type;
+ description
+ "Set IPv6 next-hop peer address";
+ }
+
+ identity ipv6-vpn-address {
+ base frr-route-map:rmap-set-type;
+ description
+ "Set IPv6 VPN next-hop address";
+ }
+
+ identity label-index {
+ base frr-route-map:rmap-set-type;
+ description
+ "Set the label index to associate with the prefixs";
+ }
+
+ identity set-local-preference {
+ base frr-route-map:rmap-set-type;
+ description
+ "Set the BGP local preference path attribute";
+ }
+
+ identity set-origin {
+ base frr-route-map:rmap-set-type;
+ description
+ "Set BGP route origin code";
+ }
+
+ identity weight {
+ base frr-route-map:rmap-set-type;
+ description
+ "Set the BGP weight attribute";
+ }
+
+ identity originator-id {
+ base frr-route-map:rmap-set-type;
+ description
+ "Set the BGP originator ID attribute";
+ }
+
+ identity table {
+ base frr-route-map:rmap-set-type;
+ description
+ "Export route to non-main kernel table";
+ }
+
+ identity atomic-aggregate {
+ base frr-route-map:rmap-set-type;
+ description
+ "Set BGP atomic-aggregate attribute";
+ }
+
+ identity as-path-prepend {
+ base frr-route-map:rmap-set-type;
+ description
+ "Set the BGP AS-path attribute";
+ }
+
+ identity as-path-exclude {
+ base frr-route-map:rmap-set-type;
+ description
+ "Set the BGP AS-path attribute";
+ }
+
+ identity set-community {
+ base frr-route-map:rmap-set-type;
+ description
+ "Set the BGP community attribute";
+ }
+
+ identity set-large-community {
+ base frr-route-map:rmap-set-type;
+ description
+ "Set the BGP large-community attribute";
+ }
+
+ identity aggregator {
+ base frr-route-map:rmap-set-type;
+ description
+ "Set the BGP aggregator attribute";
+ }
+
+ identity comm-list-delete {
+ base frr-route-map:rmap-set-type;
+ description
+ "Set BGP community list (for deletion)";
+ }
+
+ identity large-comm-list-delete {
+ base frr-route-map:rmap-set-type;
+ description
+ "Set BGP large community list (for deletion)";
+ }
+
+ grouping extcommunity-non-transitive-types {
+ leaf two-octet-as-specific {
+ type boolean;
+ description
+ "Non-Transitive Two-Octet AS-Specific Extended Community";
+ }
+ }
+
+ typedef extcommunity-lb-type {
+ type enumeration {
+ enum "explicit-bandwidth" {
+ value 0;
+ description
+ "Bandwidth value in Mbps";
+ }
+ enum "cumulative-bandwidth" {
+ value 1;
+ description
+ "Cumulative bandwidth of all multipaths (outbound-only)";
+ }
+ enum "computed-bandwidth" {
+ value 2;
+ description
+ "Internally computed bandwidth based on number of multipaths (outbound-only)";
+ }
+ }
+ description
+ "ext-community link bandwidth types.";
+ }
+
+ augment "/frr-route-map:lib/frr-route-map:route-map/frr-route-map:entry/frr-route-map:match-condition/frr-route-map:rmap-match-condition/frr-route-map:match-condition" {
+ case local-preference {
+ when "derived-from-or-self(/frr-route-map:lib/frr-route-map:route-map/frr-route-map:entry/frr-route-map:match-condition/frr-route-map:condition, 'match-local-preference')";
+ leaf local-preference {
+ type uint32 {
+ range "0..4294967295";
+ }
+ }
+ }
+
+ case script {
+ when "derived-from-or-self(/frr-route-map:lib/frr-route-map:route-map/frr-route-map:entry/frr-route-map:match-condition/frr-route-map:condition, 'match-script')";
+ leaf script {
+ type string;
+ }
+ }
+
+ case origin {
+ when "derived-from-or-self(/frr-route-map:lib/frr-route-map:route-map/frr-route-map:entry/frr-route-map:match-condition/frr-route-map:condition, 'match-origin')";
+ leaf origin {
+ type enumeration {
+ enum "egp" {
+ value 0;
+ description
+ "Remote EGP";
+ }
+ enum "igp" {
+ value 1;
+ description
+ "Local IGP";
+ }
+ enum "incomplete" {
+ value 2;
+ description
+ "Unknown heritage";
+ }
+ }
+ }
+ }
+
+ case rpki {
+ when "derived-from-or-self(/frr-route-map:lib/frr-route-map:route-map/frr-route-map:entry/frr-route-map:match-condition/frr-route-map:condition, 'rpki')";
+ leaf rpki {
+ type enumeration {
+ enum "invalid" {
+ value 0;
+ description
+ "Invalid prefix";
+ }
+ enum "notfound" {
+ value 1;
+ description
+ "Prefix not found";
+ }
+ enum "valid" {
+ value 2;
+ description
+ "Valid prefix";
+ }
+ }
+ }
+ }
+
+ case probability {
+ when "derived-from-or-self(/frr-route-map:lib/frr-route-map:route-map/frr-route-map:entry/frr-route-map:match-condition/frr-route-map:condition, 'probability')";
+ leaf probability {
+ type uint8 {
+ range "0..100";
+ }
+ }
+ }
+
+ case source-vrf {
+ when "derived-from-or-self(/frr-route-map:lib/frr-route-map:route-map/frr-route-map:entry/frr-route-map:match-condition/frr-route-map:condition, 'source-vrf')";
+ leaf source-vrf {
+ type string;
+ }
+ }
+
+ case peer {
+ when "derived-from-or-self(/frr-route-map:lib/frr-route-map:route-map/frr-route-map:entry/frr-route-map:match-condition/frr-route-map:condition, 'peer')";
+ choice peer {
+ description
+ "Value of the peer";
+ case peer-ipv4-address {
+ description
+ "IP address of peer";
+ leaf peer-ipv4-address {
+ type inet:ipv4-address;
+ }
+ }
+
+ case peer-interface {
+ description
+ "Interface name of peer";
+ leaf peer-interface {
+ type string;
+ }
+ }
+
+ case peer-ipv6-address {
+ description
+ "IPv6 address of peer";
+ leaf peer-ipv6-address {
+ type inet:ipv6-address;
+ }
+ }
+
+ case peer-local {
+ description
+ "Static or Redistributed routes";
+ leaf peer-local {
+ type boolean;
+ }
+ }
+ }
+ }
+
+ case access-list-name {
+ when "derived-from-or-self(/frr-route-map:lib/frr-route-map:route-map/frr-route-map:entry/frr-route-map:match-condition/frr-route-map:condition, 'mac-address-list') or "
+ + "derived-from-or-self(/frr-route-map:lib/frr-route-map:route-map/frr-route-map:entry/frr-route-map:match-condition/frr-route-map:condition, 'as-path-list') or "
+ + "derived-from-or-self(/frr-route-map:lib/frr-route-map:route-map/frr-route-map:entry/frr-route-map:match-condition/frr-route-map:condition, 'ip-route-source') or "
+ + "derived-from-or-self(/frr-route-map:lib/frr-route-map:route-map/frr-route-map:entry/frr-route-map:match-condition/frr-route-map:condition, 'ip-route-source-prefix-list')";
+ description
+ "Access-list name";
+ leaf list-name {
+ type filter:access-list-name;
+ }
+ }
+
+ case evpn-default-route {
+ when "derived-from-or-self(/frr-route-map:lib/frr-route-map:route-map/frr-route-map:entry/frr-route-map:match-condition/frr-route-map:condition, 'evpn-default-route')";
+ description
+ "Match default EVPN type-5 route";
+ leaf evpn-default-route {
+ type empty;
+ }
+ }
+
+ case evpn-vni {
+ when "derived-from-or-self(/frr-route-map:lib/frr-route-map:route-map/frr-route-map:entry/frr-route-map:match-condition/frr-route-map:condition, 'evpn-vni')";
+ description
+ "Match eVPN VNI";
+ leaf evpn-vni {
+ type uint32 {
+ range "1..16777215";
+ }
+ }
+ }
+
+ case evpn-route-type {
+ when "derived-from-or-self(/frr-route-map:lib/frr-route-map:route-map/frr-route-map:entry/frr-route-map:match-condition/frr-route-map:condition, 'evpn-route-type')";
+ description
+ "Match eVPN route-type";
+ leaf evpn-route-type {
+ type enumeration {
+ enum "macip" {
+ value 0;
+ description
+ "Mac-IP route";
+ }
+ enum "multicast" {
+ value 1;
+ description
+ "IMET route";
+ }
+ enum "prefix" {
+ value 2;
+ description
+ "Prefix route";
+ }
+ }
+ }
+ }
+
+ case evpn-rd {
+ when "derived-from-or-self(/frr-route-map:lib/frr-route-map:route-map/frr-route-map:entry/frr-route-map:match-condition/frr-route-map:condition, 'evpn-rd')";
+ description
+ "Match eVPN route-distinguisher";
+ leaf route-distinguisher {
+ type rt-types:route-distinguisher;
+ }
+ }
+
+ case comm-list-name {
+ when "derived-from-or-self(/frr-route-map:lib/frr-route-map:route-map/frr-route-map:entry/frr-route-map:match-condition/frr-route-map:condition, 'match-community') or "
+ + "derived-from-or-self(/frr-route-map:lib/frr-route-map:route-map/frr-route-map:entry/frr-route-map:match-condition/frr-route-map:condition, 'match-large-community') or "
+ + "derived-from-or-self(/frr-route-map:lib/frr-route-map:route-map/frr-route-map:entry/frr-route-map:match-condition/frr-route-map:condition, 'match-extcommunity')";
+ container comm-list {
+ leaf comm-list-name {
+ type bgp-filter:bgp-list-name;
+ }
+
+ leaf comm-list-name-exact-match {
+ type boolean;
+ description
+ "Do exact matching of communities";
+ }
+ }
+ }
+
+ case ipv4-address {
+ when "derived-from-or-self(/frr-route-map:lib/frr-route-map:route-map/frr-route-map:entry/frr-route-map:match-condition/frr-route-map:condition, 'ipv4-nexthop')";
+ leaf ipv4-address {
+ type inet:ipv4-address;
+ description
+ "IPv4 address";
+ }
+ }
+
+ case ipv6-address {
+ when "derived-from-or-self(/frr-route-map:lib/frr-route-map:route-map/frr-route-map:entry/frr-route-map:match-condition/frr-route-map:condition, 'ipv6-nexthop')";
+ leaf ipv6-address {
+ type inet:ipv6-address;
+ description
+ "IPv6 address";
+ }
+ }
+ }
+
+ augment "/frr-route-map:lib/frr-route-map:route-map/frr-route-map:entry/frr-route-map:set-action/frr-route-map:rmap-set-action/frr-route-map:set-action" {
+ case distance {
+ when "derived-from-or-self(/frr-route-map:lib/frr-route-map:route-map/frr-route-map:entry/frr-route-map:set-action/frr-route-map:action, 'distance')";
+ leaf distance {
+ type uint8 {
+ range "0..255";
+ }
+ }
+ }
+
+ case extcommunity-rt {
+ when "derived-from-or-self(/frr-route-map:lib/frr-route-map:route-map/frr-route-map:entry/frr-route-map:set-action/frr-route-map:action, 'set-extcommunity-rt')";
+ description
+ "Value of the ext-community";
+ leaf extcommunity-rt {
+ type string;
+ description
+ "Set BGP ext-community route-target attribute";
+ }
+ }
+
+ case extcommunity-soo {
+ when "derived-from-or-self(/frr-route-map:lib/frr-route-map:route-map/frr-route-map:entry/frr-route-map:set-action/frr-route-map:action, 'set-extcommunity-soo')";
+ description
+ "Value of the ext-community";
+ leaf extcommunity-soo {
+ type string;
+ description
+ "Set BGP ext-community site-of-origin attribute";
+ }
+ }
+
+ case extcommunity-lb {
+ when "derived-from-or-self(/frr-route-map:lib/frr-route-map:route-map/frr-route-map:entry/frr-route-map:set-action/frr-route-map:action, 'set-extcommunity-lb')";
+ container extcommunity-lb {
+ description
+ "Value of the ext-community.";
+ leaf lb-type {
+ type frr-bgp-route-map:extcommunity-lb-type;
+ }
+
+ leaf bandwidth {
+ when "../lb-type = 'explicit-bandwidth'";
+ type uint16 {
+ range "1..25600";
+ }
+ description
+ "Bandwidth value in Mbps";
+ }
+ uses extcommunity-non-transitive-types;
+ }
+ }
+
+ case ipv4-address {
+ when "derived-from-or-self(/frr-route-map:lib/frr-route-map:route-map/frr-route-map:entry/frr-route-map:set-action/frr-route-map:action, 'ipv4-vpn-address')";
+ description
+ "Set the IPv4 address";
+ leaf ipv4-address {
+ type inet:ipv4-address;
+ }
+ }
+
+ case ipv4-nexthop {
+ when "derived-from-or-self(/frr-route-map:lib/frr-route-map:route-map/frr-route-map:entry/frr-route-map:set-action/frr-route-map:action, 'set-ipv4-nexthop')";
+ leaf ipv4-nexthop {
+ type string;
+ }
+ }
+
+ case ipv6-address {
+ when "derived-from-or-self(/frr-route-map:lib/frr-route-map:route-map/frr-route-map:entry/frr-route-map:set-action/frr-route-map:action, 'ipv6-nexthop-global') or "
+ + "derived-from-or-self(/frr-route-map:lib/frr-route-map:route-map/frr-route-map:entry/frr-route-map:set-action/frr-route-map:action, 'ipv6-vpn-address')";
+ description
+ "Set the IPv6 address";
+ leaf ipv6-address {
+ type inet:ipv6-address;
+ }
+ }
+
+ case preference {
+ when "derived-from-or-self(/frr-route-map:lib/frr-route-map:route-map/frr-route-map:entry/frr-route-map:set-action/frr-route-map:action, 'ipv6-prefer-global') or "
+ + "derived-from-or-self(/frr-route-map:lib/frr-route-map:route-map/frr-route-map:entry/frr-route-map:set-action/frr-route-map:action, 'ipv6-peer-address')";
+ leaf preference {
+ type boolean;
+ }
+ }
+
+ case label-index {
+ when "derived-from-or-self(/frr-route-map:lib/frr-route-map:route-map/frr-route-map:entry/frr-route-map:set-action/frr-route-map:action, 'label-index')";
+ leaf label-index {
+ type uint32 {
+ range "0..1048560";
+ }
+ }
+ }
+
+ case local-pref {
+ when "derived-from-or-self(/frr-route-map:lib/frr-route-map:route-map/frr-route-map:entry/frr-route-map:set-action/frr-route-map:action, 'set-local-preference')";
+ leaf local-pref {
+ type string;
+ }
+ }
+
+ case weight {
+ when "derived-from-or-self(/frr-route-map:lib/frr-route-map:route-map/frr-route-map:entry/frr-route-map:set-action/frr-route-map:action, 'weight')";
+ leaf weight {
+ type uint32 {
+ range "0..4294967295";
+ }
+ }
+ }
+
+ case origin {
+ when "derived-from-or-self(/frr-route-map:lib/frr-route-map:route-map/frr-route-map:entry/frr-route-map:set-action/frr-route-map:action, 'set-origin')";
+ leaf origin {
+ type enumeration {
+ enum "egp" {
+ value 0;
+ description
+ "Remote EGP";
+ }
+ enum "igp" {
+ value 1;
+ description
+ "Local IGP";
+ }
+ enum "incomplete" {
+ value 2;
+ description
+ "Unknown heritage";
+ }
+ }
+ }
+ }
+
+ case originator-id {
+ when "derived-from-or-self(/frr-route-map:lib/frr-route-map:route-map/frr-route-map:entry/frr-route-map:set-action/frr-route-map:action, 'originator-id')";
+ leaf originator-id {
+ type inet:ipv4-address;
+ }
+ }
+
+ case table {
+ when "derived-from-or-self(/frr-route-map:lib/frr-route-map:route-map/frr-route-map:entry/frr-route-map:set-action/frr-route-map:action, 'table')";
+ leaf table {
+ type uint32 {
+ range "1..4294967295";
+ }
+ }
+ }
+
+ case atomic-aggregate {
+ when "derived-from-or-self(/frr-route-map:lib/frr-route-map:route-map/frr-route-map:entry/frr-route-map:set-action/frr-route-map:action, 'atomic-aggregate')";
+ leaf atomic-aggregate {
+ type empty;
+ }
+ }
+
+ case as-path-prepend {
+ when "derived-from-or-self(/frr-route-map:lib/frr-route-map:route-map/frr-route-map:entry/frr-route-map:set-action/frr-route-map:action, 'as-path-prepend')";
+ choice as-path-prepend {
+ description
+ "Value of the BGP AS-path attribute";
+ case prepend-as {
+ description
+ "Prepend the mentioned AS-path";
+ leaf prepend-as-path {
+ type string;
+ }
+ }
+
+ case last-as {
+ description
+ "Prepend the last ASN in the AS-path";
+ leaf last-as {
+ type uint8 {
+ range "1..10";
+ }
+ }
+ }
+ }
+ }
+
+ case as-path-exclude {
+ when "derived-from-or-self(/frr-route-map:lib/frr-route-map:route-map/frr-route-map:entry/frr-route-map:set-action/frr-route-map:action, 'as-path-exclude')";
+ leaf exclude-as-path {
+ type string;
+ description
+ "Exclude the mentioned AS-path";
+ }
+ }
+
+ case community {
+ when "derived-from-or-self(/frr-route-map:lib/frr-route-map:route-map/frr-route-map:entry/frr-route-map:set-action/frr-route-map:action, 'set-community')";
+ choice community {
+ description
+ "Value of the BGP community attribute";
+ case none {
+ description
+ "No community attribute";
+ leaf community-none {
+ type boolean;
+ }
+ }
+
+ case community-string {
+ description
+ "Community string";
+ leaf community-string {
+ type string;
+ }
+ }
+ }
+ }
+
+ case large-community {
+ when "derived-from-or-self(/frr-route-map:lib/frr-route-map:route-map/frr-route-map:entry/frr-route-map:set-action/frr-route-map:action, 'set-large-community')";
+ choice large-community {
+ description
+ "Value of the BGP large-community attribute";
+ case none {
+ description
+ "No large-community attribute";
+ leaf large-community-none {
+ type boolean;
+ }
+ }
+
+ case large-community-string {
+ description
+ "Large-Community string";
+ leaf large-community-string {
+ type string;
+ }
+ }
+ }
+ }
+
+ case aggregator {
+ when "derived-from-or-self(/frr-route-map:lib/frr-route-map:route-map/frr-route-map:entry/frr-route-map:set-action/frr-route-map:action, 'aggregator')";
+ container aggregator {
+ leaf aggregator-asn {
+ type uint32 {
+ range "1..4294967295";
+ }
+ description
+ "ASN of the aggregator";
+ }
+
+ leaf aggregator-address {
+ when "../aggregator-asn > 0 or "
+ + "../aggregator-asn <= 4294967295";
+ type inet:ipv4-address;
+ description
+ "IPv4 address of the aggregator";
+ }
+ }
+ }
+
+ case comm-list-name {
+ when "derived-from-or-self(/frr-route-map:lib/frr-route-map:route-map/frr-route-map:entry/frr-route-map:set-action/frr-route-map:action, 'comm-list-delete') or "
+ + "derived-from-or-self(/frr-route-map:lib/frr-route-map:route-map/frr-route-map:entry/frr-route-map:set-action/frr-route-map:action, 'large-comm-list-delete')";
+ leaf comm-list-name {
+ type bgp-filter:bgp-list-name;
+ }
+ }
+ }
+}
diff --git a/yang/frr-ospf-route-map.yang b/yang/frr-ospf-route-map.yang
new file mode 100644
index 000000000..ad7ba5c1b
--- /dev/null
+++ b/yang/frr-ospf-route-map.yang
@@ -0,0 +1,52 @@
+module frr-ospf-route-map {
+ yang-version 1.1;
+ namespace "http://frrouting.org/yang/ospf-route-map";
+ prefix frr-ospf-route-map;
+
+ import ietf-inet-types {
+ prefix inet;
+ }
+
+ import frr-route-map {
+ prefix frr-route-map;
+ }
+
+ organization
+ "Free Range Routing";
+ contact
+ "FRR Users List: <mailto:frog@lists.frrouting.org>
+ FRR Development List: <mailto:dev@lists.frrouting.org>";
+ description
+ "This module defines ospf route map settings";
+
+ revision 2020-01-02 {
+ description
+ "Initial revision";
+ }
+
+ identity metric-type {
+ base frr-route-map:rmap-set-type;
+ description
+ "Set the type of metric";
+ }
+
+ augment "/frr-route-map:lib/frr-route-map:route-map/frr-route-map:entry/frr-route-map:set-action/frr-route-map:rmap-set-action/frr-route-map:set-action" {
+ case metric-type {
+ when "derived-from-or-self(/frr-route-map:lib/frr-route-map:route-map/frr-route-map:entry/frr-route-map:set-action/frr-route-map:action, 'metric-type')";
+ leaf metric-type {
+ type enumeration {
+ enum "type-1" {
+ value 0;
+ description
+ "OSPF6 external type 1 metric";
+ }
+ enum "type-2" {
+ value 1;
+ description
+ "OSPF6 external type 2 metric";
+ }
+ }
+ }
+ }
+ }
+}
diff --git a/yang/frr-ospf6-route-map.yang b/yang/frr-ospf6-route-map.yang
new file mode 100644
index 000000000..e5d4969d4
--- /dev/null
+++ b/yang/frr-ospf6-route-map.yang
@@ -0,0 +1,47 @@
+module frr-ospf6-route-map {
+ yang-version 1.1;
+ namespace "http://frrouting.org/yang/ospf6-route-map";
+ prefix frr-ospf6-route-map;
+
+ import ietf-inet-types {
+ prefix inet;
+ }
+
+ import frr-route-map {
+ prefix frr-route-map;
+ }
+
+ organization
+ "Free Range Routing";
+ contact
+ "FRR Users List: <mailto:frog@lists.frrouting.org>
+ FRR Development List: <mailto:dev@lists.frrouting.org>";
+ description
+ "This module defines ospf6 route map settings";
+
+ revision 2020-01-02 {
+ description
+ "Initial revision";
+ }
+
+ identity forwarding-address {
+ base frr-route-map:rmap-set-type;
+ description
+ "Set the forwarding address";
+ }
+
+ identity metric-type {
+ base frr-route-map:rmap-set-type;
+ description
+ "Set the type of metric";
+ }
+
+ augment "/frr-route-map:lib/frr-route-map:route-map/frr-route-map:entry/frr-route-map:set-action/frr-route-map:rmap-set-action/frr-route-map:set-action" {
+ case ipv6-address {
+ when "derived-from-or-self(/frr-route-map:lib/frr-route-map:route-map/frr-route-map:entry/frr-route-map:set-action/frr-route-map:action, 'forwarding-address')";
+ leaf ipv6-address {
+ type inet:ipv6-address;
+ }
+ }
+ }
+}
diff --git a/yang/frr-route-map.yang b/yang/frr-route-map.yang
index b22a96a74..6ed3dadaa 100644
--- a/yang/frr-route-map.yang
+++ b/yang/frr-route-map.yang
@@ -53,21 +53,124 @@ module frr-route-map {
"Initial revision";
}
- /*
- * Types.
- */
+ identity rmap-match-type {
+ description
+ "Base route-map match-condition";
+ }
+
+ identity interface {
+ base rmap-match-type;
+ description
+ "Match interface";
+ }
+
+ identity ipv4-address-list {
+ base rmap-match-type;
+ description
+ "Match an IPv4 access-list";
+ }
+
+ identity ipv4-prefix-list {
+ base rmap-match-type;
+ description
+ "Match an IPv4 prefix-list";
+ }
+
+ identity ipv4-next-hop-list {
+ base rmap-match-type;
+ description
+ "Match an IPv4 next-hop";
+ }
+
+ identity ipv4-next-hop-prefix-list {
+ base rmap-match-type;
+ description
+ "Match an IPv4 next-hop prefix list";
+ }
+
+ identity ipv4-next-hop-type {
+ base rmap-match-type;
+ description
+ "Match an IPv4 next-hop type";
+ }
+
+ identity ipv6-address-list {
+ base rmap-match-type;
+ description
+ "Match an IPv6 access-list";
+ }
+
+ identity ipv6-prefix-list {
+ base rmap-match-type;
+ description
+ "Match an IPv6 prefix-list";
+ }
+
+ identity ipv6-next-hop-type {
+ base rmap-match-type;
+ description
+ "Match an IPv6 next-hop type";
+ }
+
+ identity match-metric {
+ base rmap-match-type;
+ description
+ "Match a route metric";
+ }
+
+ identity match-tag {
+ base rmap-match-type;
+ description
+ "Match a route tag";
+ }
+
+ identity rmap-set-type {
+ description
+ "Base route-map set-action";
+ }
+
+ identity ipv4-next-hop {
+ base rmap-set-type;
+ description
+ "Set IPv4 address of the next hop";
+ }
+
+ identity ipv6-next-hop {
+ base rmap-set-type;
+ description
+ "Set IPv6 address of the next hop";
+ }
+
+ identity set-metric {
+ base rmap-set-type;
+ description
+ "Set prefix/route metric";
+ }
+
+ identity set-tag {
+ base rmap-set-type;
+ description
+ "Set tag";
+ }
+
+ identity set-sr-te-color {
+ base rmap-set-type;
+ description
+ "Set Color of the SR-TE";
+ }
+
typedef route-map-sequence {
type uint16 {
range "1..65535";
}
description
- "Route map valid sequence numbers.";
+ "Route map valid sequence numbers";
}
typedef route-map-name {
type string;
description
- "Route map name format.";
+ "Route map name format";
}
typedef route-map-ref {
@@ -79,349 +182,294 @@ module frr-route-map {
"Reference to a route-map.";
}
- /*
- * Operational data.
- */
+ grouping rmap-match-condition {
+ container rmap-match-condition {
+ choice match-condition {
+ description
+ "Value to match (interpretation depends on condition type)";
+ case interface {
+ when "derived-from-or-self(../condition, 'interface')";
+ leaf interface {
+ type frr-interface:interface-ref;
+ }
+ }
+
+ case list-name {
+ when "derived-from-or-self(../condition, 'ipv4-address-list') or "
+ + "derived-from-or-self(../condition, 'ipv4-prefix-list') or "
+ + "derived-from-or-self(../condition, 'ipv4-next-hop-list') or "
+ + "derived-from-or-self(../condition, 'ipv4-next-hop-prefix-list') or "
+ + "derived-from-or-self(../condition, 'ipv6-address-list') or "
+ + "derived-from-or-self(../condition, 'ipv6-prefix-list')";
+ leaf list-name {
+ type filter:access-list-name;
+ }
+ }
+
+ case ipv4-next-hop-type {
+ when "derived-from-or-self(../condition, 'ipv4-next-hop-type')";
+ leaf ipv4-next-hop-type {
+ type enumeration {
+ enum "blackhole" {
+ value 0;
+ }
+ }
+ }
+ }
+
+ case ipv6-next-hop-type {
+ when "derived-from-or-self(../condition, 'ipv6-next-hop-type')";
+ leaf ipv6-next-hop-type {
+ type enumeration {
+ enum "blackhole" {
+ value 0;
+ }
+ }
+ }
+ }
+
+ case match-metric {
+ when "derived-from-or-self(../condition, 'match-metric')";
+ leaf metric {
+ type uint32 {
+ range "1..4294967295";
+ }
+ }
+ }
+
+ case match-tag {
+ when "derived-from-or-self(../condition, 'match-tag')";
+ leaf tag {
+ type uint32 {
+ range "1..4294967295";
+ }
+ }
+ }
+ }
+ }
+ }
+
+ grouping rmap-set-action {
+ container rmap-set-action {
+ choice set-action {
+ description
+ "Value to set (interpretation depends on action-type)";
+ case ipv4-address {
+ when "derived-from-or-self(../action, 'ipv4-next-hop')";
+ leaf ipv4-address {
+ type inet:ipv4-address;
+ description
+ "IPv4 address";
+ }
+ }
+
+ case ipv6-address {
+ when "derived-from-or-self(../action, 'ipv6-next-hop')";
+ leaf ipv6-address {
+ type inet:ipv6-address;
+ description
+ "IPv6 address";
+ }
+ }
+
+ case set-metric {
+ when "derived-from-or-self(../action, 'set-metric')";
+ choice metric-value {
+ description
+ "Metric to set or use";
+ case value {
+ leaf value {
+ type uint32 {
+ range "0..4294967295";
+ }
+ description
+ "Use the following metric value";
+ }
+ }
+
+ case add-metric {
+ leaf add-metric {
+ description "Add value to metric.";
+ type uint32 {
+ range "0..4294967295";
+ }
+ }
+ }
+
+ case subtract-metric {
+ leaf subtract-metric {
+ description "Subtract value from metric.";
+ type uint32 {
+ range "0..4294967295";
+ }
+ }
+ }
+
+ case use-round-trip-time {
+ leaf use-round-trip-time {
+ type boolean;
+ description
+ "Use the round trip time as metric";
+ }
+ }
+
+ case add-round-trip-time {
+ leaf add-round-trip-time {
+ type boolean;
+ description
+ "Add round trip time to metric";
+ }
+ }
+
+ case subtract-round-trip-time {
+ leaf subtract-round-trip-time {
+ type boolean;
+ description
+ "Subtract round trip time to metric";
+ }
+ }
+ }
+ }
+
+ case set-tag {
+ when "derived-from-or-self(../action, 'set-tag')";
+ leaf tag {
+ type uint32 {
+ range "0..4294967295";
+ }
+ description
+ "Tag value";
+ }
+ }
+
+ case set-sr-te-color {
+ when "derived-from-or-self(../action, 'set-sr-te-color')";
+ leaf policy {
+ type string;
+ description
+ "Color of the SR-TE Policies to match with";
+ }
+ }
+ }
+ }
+ }
+
container lib {
list route-map {
key "name";
description
- "Route map instance.";
+ "Route map instance";
leaf name {
type route-map-name;
description
- "Route map instance name.";
+ "Route map instance name";
}
list entry {
key "sequence";
description
- "Route map entry.";
+ "Route map entry";
leaf sequence {
- description
- "Route map instance priority (low number means higher priority).";
type route-map-sequence;
+ description
+ "Route map instance priority (low number means higher priority)";
}
leaf description {
- description "Route map description.";
type string;
+ description
+ "Route map description";
}
leaf action {
- description
- "Route map actions: permit (executes action), deny (quits evaluation).";
- mandatory true;
type enumeration {
- enum permit {
+ enum "permit" {
+ value 0;
description
"Executes configured action and permits the prefix/route
if the conditions matched. An alternative exit action can
be configured to continue processing the route map list
or jump to process another route map.";
- value 0;
}
- enum deny {
+ enum "deny" {
+ value 1;
description
"If all conditions are met the prefix/route is denied and
route map processing stops.";
- value 1;
}
}
+ mandatory true;
+ description
+ "Route map actions: permit (executes action), deny (quits evaluation)";
}
leaf call {
+ type route-map-name;
description
"Call another route map before calling `exit-policy`. If the
called route map returns deny then this route map will also
- return deny.";
- type route-map-name;
+ return deny";
}
leaf exit-policy {
- description "What do to after route map successful match, set and call.";
type enumeration {
- enum permit-or-deny {
- description "End route map evaluation and return.";
+ enum "permit-or-deny" {
value 0;
- }
- enum next {
description
- "Proceed evaluating next route map entry per sequence.";
- value 1;
+ "End route map evaluation and return";
}
- enum goto {
+ enum "next" {
+ value 1;
description
- "Go to route map entry with the provided sequence number.";
+ "Proceed evaluating next route map entry per sequence";
+ }
+ enum "goto" {
value 2;
+ description
+ "Go to route map entry with the provided sequence number";
}
}
default "permit-or-deny";
+ description
+ "What do to after route map successful match, set and call";
}
leaf goto-value {
when "../exit-policy = 'goto'";
- description
- "Sequence number to jump (when using `goto` exit policy).";
- mandatory true;
type route-map-sequence;
+ mandatory true;
+ description
+ "Sequence number to jump (when using `goto` exit policy)";
}
list match-condition {
key "condition";
description
- "Route map match conditions.";
+ "Route map match conditions";
leaf condition {
- description "Match condition.";
- type enumeration {
- enum interface {
- description "Match interface.";
- value 0;
- }
- enum ipv4-address-list {
- description "Match an IPv4 access-list.";
- value 1;
- }
- enum ipv4-prefix-list {
- description "Match an IPv4 prefix-list.";
- value 2;
- }
- enum ipv4-next-hop-list {
- description "Match an IPv4 next-hop.";
- value 3;
- }
- enum ipv4-next-hop-prefix-list {
- description "Match an IPv4 next-hop prefix list.";
- value 4;
- }
- enum ipv4-next-hop-type {
- description "Match an IPv4 next-hop type.";
- value 5;
- }
- enum ipv6-address-list {
- description "Match an IPv6 access-list.";
- value 6;
- }
- enum ipv6-prefix-list {
- description "Match an IPv6 prefix-list.";
- value 7;
- }
- enum ipv6-next-hop-type {
- description "Match an IPv6 next-hop type.";
- value 8;
- }
- enum metric {
- description "Match a route metric.";
- value 9;
- }
- enum tag {
- description "Match a route tag.";
- value 10;
- }
- /* zebra specific conditions. */
- enum ipv4-prefix-length {
- description "Match IPv4 prefix length.";
- value 100;
- }
- enum ipv6-prefix-length {
- description "Match IPv6 prefix length.";
- value 101;
- }
- enum ipv4-next-hop-prefix-length {
- description "Match next-hop prefix length.";
- value 102;
- }
- enum source-protocol {
- description "Match source protocol.";
- value 103;
- }
- enum source-instance {
- description "Match source protocol instance.";
- value 104;
- }
+ type identityref {
+ base rmap-match-type;
}
- }
-
- choice condition-value {
description
- "Value to match (interpretation depends on condition type).";
- mandatory true;
- case interface {
- when "./condition = 'interface'";
- leaf interface {
- type frr-interface:interface-ref;
- }
- }
-
- case list-name {
- when "./condition = 'ipv4-address-list' or
- ./condition = 'ipv4-prefix-list' or
- ./condition = 'ipv4-next-hop-list' or
- ./condition = 'ipv4-next-hop-prefix-list' or
- ./condition = 'ipv6-address-list' or
- ./condition = 'ipv6-prefix-list'";
- leaf list-name {
- type filter:access-list-name;
- }
- }
-
- case ipv4-next-hop-type {
- when "./condition = 'ipv4-next-hop-type'";
- leaf ipv4-next-hop-type {
- type enumeration {
- enum blackhole {
- value 0;
- }
- }
- }
- }
-
- case ipv6-next-hop-type {
- when "./condition = 'ipv6-next-hop-type'";
- leaf ipv6-next-hop-type {
- type enumeration {
- enum blackhole {
- value 0;
- }
- }
- }
- }
-
- case metric {
- when "./condition = 'metric'";
- leaf metric {
- type uint32 {
- range "1..4294967295";
- }
- }
- }
-
- case tag {
- when "./condition = 'tag'";
- leaf tag {
- type uint32 {
- range "1..4294967295";
- }
- }
- }
+ "Match condition";
}
+
+ uses rmap-match-condition;
}
list set-action {
- description "Route map set actions.";
-
key "action";
-
+ description
+ "Route map set actions";
leaf action {
- description "Action to do when the route map matches.";
- type enumeration {
- enum ipv4-next-hop {
- description "Set IPv4 address of the next hop.";
- value 0;
- }
- enum ipv6-next-hop {
- description "Set IPv6 address of the next hop.";
- value 1;
- }
- enum metric {
- description "Set prefix/route metric.";
- value 2;
- }
- enum tag {
- description "Set tag.";
- value 3;
- }
- /* zebra specific conditions. */
- enum source {
- description "Set source address for route.";
- value 100;
- }
+ type identityref {
+ base rmap-set-type;
}
- }
-
- choice action-value {
description
- "Value to set (interpretation depends on action-type).";
- case ipv4-address {
- when "./action = 'ipv4-next-hop'";
- leaf ipv4-address {
- description "IPv4 address.";
- type inet:ipv4-address;
- }
- }
-
- case ipv6-address {
- when "./action = 'ipv6-next-hop'";
- leaf ipv6-address {
- description "IPv6 address.";
- type inet:ipv6-address;
- }
- }
-
- case metric {
- when "./action = 'metric'";
- choice metric-value {
- description "Metric to set or use.";
- case value {
- leaf value {
- description "Use the following metric value.";
- type uint32 {
- range "0..4294967295";
- }
- }
- }
-
- case add-metric {
- leaf add-metric {
- description "Add value to metric.";
- type uint32 {
- range "0..4294967295";
- }
- }
- }
-
- case subtract-metric {
- leaf subtract-metric {
- description "Subtract value from metric.";
- type uint32 {
- range "0..4294967295";
- }
- }
- }
-
- case use-round-trip-time {
- leaf use-round-trip-time {
- description "Use the round trip time as metric.";
- type boolean;
- }
- }
-
- case add-round-trip-time {
- leaf add-round-trip-time {
- description "Add round trip time to metric.";
- type boolean;
- }
- }
-
- case subtract-round-trip-time {
- leaf subtract-round-trip-time {
- description "Subtract round trip time to metric.";
- type boolean;
- }
- }
- }
- }
-
- case tag {
- when "./action = 'tag'";
- leaf tag {
- description "Tag value.";
- type uint32 {
- range "0..4294967295";
- }
- }
- }
+ "Action to do when the route map matches";
}
+
+ uses rmap-set-action;
}
}
}
diff --git a/yang/frr-zebra-route-map.yang b/yang/frr-zebra-route-map.yang
new file mode 100644
index 000000000..91f4c87e3
--- /dev/null
+++ b/yang/frr-zebra-route-map.yang
@@ -0,0 +1,126 @@
+module frr-zebra-route-map {
+ yang-version 1.1;
+ namespace "http://frrouting.org/yang/zebra-route-map";
+ prefix frr-zebra-route-map;
+
+ import ietf-inet-types {
+ prefix inet;
+ }
+
+ import frr-route-map {
+ prefix frr-route-map;
+ }
+
+ import frr-route-types {
+ prefix frr-route-types;
+ }
+
+ organization
+ "Free Range Routing";
+ contact
+ "FRR Users List: <mailto:frog@lists.frrouting.org>
+ FRR Development List: <mailto:dev@lists.frrouting.org>";
+ description
+ "This module defines zebra route map settings";
+
+ revision 2020-01-02 {
+ description
+ "Initial revision";
+ }
+
+ identity ipv4-prefix-length {
+ base frr-route-map:rmap-match-type;
+ description
+ "Match IPv4 address prefix length";
+ }
+
+ identity ipv4-next-hop-prefix-length {
+ base frr-route-map:rmap-match-type;
+ description
+ "Match IPv4 next-hop address prefix length";
+ }
+
+ identity ipv6-prefix-length {
+ base frr-route-map:rmap-match-type;
+ description
+ "Match IPv6 address prefix length";
+ }
+
+ identity source-instance {
+ base frr-route-map:rmap-match-type;
+ description
+ "Match the protocol's instance number";
+ }
+
+ identity source-protocol {
+ base frr-route-map:rmap-match-type;
+ description
+ "Match protocol via which the route was learnt";
+ }
+
+ identity src-address {
+ base frr-route-map:rmap-set-type;
+ description
+ "Set IPv4/IPv6 source address for route";
+ }
+
+ augment "/frr-route-map:lib/frr-route-map:route-map/frr-route-map:entry/frr-route-map:match-condition/frr-route-map:rmap-match-condition/frr-route-map:match-condition" {
+ case ipv4-prefix-length {
+ when "derived-from-or-self(../condition, 'ipv4-prefix-length') or "
+ + "derived-from-or-self(../condition, 'ipv4-next-hop-prefix-length')";
+ leaf ipv4-prefix-length {
+ type uint8 {
+ range "0..32";
+ }
+ }
+ }
+
+ case ipv6-prefix-length {
+ when "derived-from-or-self(../condition, 'ipv6-prefix-length')";
+ leaf ipv6-prefix-length {
+ type uint8 {
+ range "0..128";
+ }
+ }
+ }
+
+ case source-instance {
+ when "derived-from-or-self(../condition, 'source-instance')";
+ leaf source-instance {
+ type uint8 {
+ range "0..255";
+ }
+ }
+ }
+
+ case source-protocol {
+ when "derived-from-or-self(../condition, 'source-protocol')";
+ leaf source-protocol {
+ type frr-route-types:frr-route-types;
+ }
+ }
+ }
+
+ augment "/frr-route-map:lib/frr-route-map:route-map/frr-route-map:entry/frr-route-map:set-action/frr-route-map:rmap-set-action/frr-route-map:set-action" {
+ case src-address {
+ when "derived-from-or-self(../action, 'src-address')";
+ choice src-address {
+ description
+ "Value of the source address";
+ case ipv4-src-address {
+ leaf ipv4-src-address {
+ type inet:ipv4-address;
+ mandatory true;
+ }
+ }
+
+ case ipv6-src-address {
+ leaf ipv6-src-address {
+ type inet:ipv6-address;
+ mandatory true;
+ }
+ }
+ }
+ }
+ }
+}
diff --git a/yang/frr-zebra.yang b/yang/frr-zebra.yang
index be2f7b5a6..5c2560837 100644
--- a/yang/frr-zebra.yang
+++ b/yang/frr-zebra.yang
@@ -2175,65 +2175,4 @@ module frr-zebra {
}
// End of operational / state container
}
-
- // End interface model augmentation
-
- augment "/frr-route-map:lib"
- + "/frr-route-map:route-map"
- + "/frr-route-map:entry"
- + "/frr-route-map:match-condition"
- + "/frr-route-map:condition-value" {
- case ipv4-prefix-length {
- when "./condition = 'ipv4-prefix-length' or
- ./condition = 'ipv4-next-hop-prefix-length'";
- leaf ipv4-prefix-length {
- type uint8 {
- range "0..32";
- }
- }
- }
- case ipv6-prefix-length {
- when "./condition = 'ipv6-prefix-length'";
- leaf ipv6-prefix-length {
- type uint8 {
- range "0..128";
- }
- }
- }
- case source-protocol {
- when "./condition = 'source-protocol'";
- leaf source-protocol {
- type frr-route-types:frr-route-types;
- }
- }
- case source-instance {
- when "./condition = 'source-instance'";
- leaf source-instance {
- type uint8 {
- range "0..255";
- }
- }
- }
- }
-
- augment "/frr-route-map:lib"
- + "/frr-route-map:route-map"
- + "/frr-route-map:entry"
- + "/frr-route-map:set-action"
- + "/frr-route-map:action-value" {
- case source-v4 {
- when "./action = 'source'";
- leaf source-v4 {
- description "IPv4 address";
- type inet:ipv4-address;
- }
- }
- case source-v6 {
- when "./action = 'source'";
- leaf source-v6 {
- description "IPv6 address";
- type inet:ipv6-address;
- }
- }
- }
}
diff --git a/yang/subdir.am b/yang/subdir.am
index da4432b62..a2243fb8e 100644
--- a/yang/subdir.am
+++ b/yang/subdir.am
@@ -25,6 +25,11 @@ dist_yangmodels_DATA += yang/frr-nexthop.yang
dist_yangmodels_DATA += yang/frr-test-module.yang
dist_yangmodels_DATA += yang/frr-interface.yang
dist_yangmodels_DATA += yang/frr-route-map.yang
+dist_yangmodels_DATA += yang/frr-zebra-route-map.yang
+dist_yangmodels_DATA += yang/frr-ospf-route-map.yang
+dist_yangmodels_DATA += yang/frr-ospf6-route-map.yang
+dist_yangmodels_DATA += yang/frr-bgp-filter.yang
+dist_yangmodels_DATA += yang/frr-bgp-route-map.yang
dist_yangmodels_DATA += yang/frr-vrf.yang
dist_yangmodels_DATA += yang/frr-route-types.yang
dist_yangmodels_DATA += yang/frr-routing.yang
diff --git a/zebra/main.c b/zebra/main.c
index 09350f72c..3f75b222b 100644
--- a/zebra/main.c
+++ b/zebra/main.c
@@ -260,6 +260,7 @@ static const struct frr_yang_module_info *const zebra_yang_modules[] = {
&frr_zebra_info,
&frr_vrf_info,
&frr_routing_info,
+ &frr_zebra_route_map_info,
};
FRR_DAEMON_INFO(
diff --git a/zebra/subdir.am b/zebra/subdir.am
index b5c26d720..6a582f690 100644
--- a/zebra/subdir.am
+++ b/zebra/subdir.am
@@ -111,6 +111,8 @@ zebra_zebra_SOURCES = \
zebra/zebra_router.c \
zebra/zebra_rnh.c \
zebra/zebra_routemap.c \
+ zebra/zebra_routemap_nb.c \
+ zebra/zebra_routemap_nb_config.c \
zebra/zebra_srte.c \
zebra/zebra_vrf.c \
zebra/zebra_vty.c \
@@ -174,6 +176,7 @@ noinst_HEADERS += \
zebra/zebra_pw.h \
zebra/zebra_rnh.h \
zebra/zebra_routemap.h \
+ zebra/zebra_routemap_nb.h \
zebra/zebra_router.h \
zebra/zebra_srte.h \
zebra/zebra_vrf.h \
@@ -217,6 +220,7 @@ endif
nodist_zebra_zebra_SOURCES = \
yang/frr-zebra.yang.c \
+ yang/frr-zebra-route-map.yang.c \
# end
zebra_zebra_cumulus_mlag_la_SOURCES = zebra/zebra_mlag_private.c
diff --git a/zebra/zebra_nb.c b/zebra/zebra_nb.c
index bdeb84486..90d4ee7ce 100644
--- a/zebra/zebra_nb.c
+++ b/zebra/zebra_nb.c
@@ -644,48 +644,6 @@ const struct frr_yang_module_info frr_zebra_info = {
}
},
{
- .xpath = "/frr-route-map:lib/route-map/entry/match-condition/frr-zebra:ipv4-prefix-length",
- .cbs = {
- .modify = lib_route_map_entry_match_condition_ipv4_prefix_length_modify,
- .destroy = lib_route_map_entry_match_condition_ipv4_prefix_length_destroy,
- }
- },
- {
- .xpath = "/frr-route-map:lib/route-map/entry/match-condition/frr-zebra:ipv6-prefix-length",
- .cbs = {
- .modify = lib_route_map_entry_match_condition_ipv6_prefix_length_modify,
- .destroy = lib_route_map_entry_match_condition_ipv6_prefix_length_destroy,
- }
- },
- {
- .xpath = "/frr-route-map:lib/route-map/entry/match-condition/frr-zebra:source-protocol",
- .cbs = {
- .modify = lib_route_map_entry_match_condition_source_protocol_modify,
- .destroy = lib_route_map_entry_match_condition_source_protocol_destroy,
- }
- },
- {
- .xpath = "/frr-route-map:lib/route-map/entry/match-condition/frr-zebra:source-instance",
- .cbs = {
- .modify = lib_route_map_entry_match_condition_source_instance_modify,
- .destroy = lib_route_map_entry_match_condition_source_instance_destroy,
- }
- },
- {
- .xpath = "/frr-route-map:lib/route-map/entry/set-action/frr-zebra:source-v4",
- .cbs = {
- .modify = lib_route_map_entry_set_action_source_v4_modify,
- .destroy = lib_route_map_entry_set_action_source_v4_destroy,
- }
- },
- {
- .xpath = "/frr-route-map:lib/route-map/entry/set-action/frr-zebra:source-v6",
- .cbs = {
- .modify = lib_route_map_entry_set_action_source_v6_modify,
- .destroy = lib_route_map_entry_set_action_source_v6_destroy,
- }
- },
- {
.xpath = NULL,
},
}
diff --git a/zebra/zebra_nb.h b/zebra/zebra_nb.h
index 79632dc83..95907059a 100644
--- a/zebra/zebra_nb.h
+++ b/zebra/zebra_nb.h
@@ -109,30 +109,6 @@ int lib_interface_zebra_shutdown_modify(struct nb_cb_modify_args *args);
int lib_interface_zebra_shutdown_destroy(struct nb_cb_destroy_args *args);
int lib_interface_zebra_bandwidth_modify(struct nb_cb_modify_args *args);
int lib_interface_zebra_bandwidth_destroy(struct nb_cb_destroy_args *args);
-int lib_route_map_entry_match_condition_ipv4_prefix_length_modify(
- struct nb_cb_modify_args *args);
-int lib_route_map_entry_match_condition_ipv4_prefix_length_destroy(
- struct nb_cb_destroy_args *args);
-int lib_route_map_entry_match_condition_ipv6_prefix_length_modify(
- struct nb_cb_modify_args *args);
-int lib_route_map_entry_match_condition_ipv6_prefix_length_destroy(
- struct nb_cb_destroy_args *args);
-int lib_route_map_entry_match_condition_source_protocol_modify(
- struct nb_cb_modify_args *args);
-int lib_route_map_entry_match_condition_source_protocol_destroy(
- struct nb_cb_destroy_args *args);
-int lib_route_map_entry_match_condition_source_instance_modify(
- struct nb_cb_modify_args *args);
-int lib_route_map_entry_match_condition_source_instance_destroy(
- struct nb_cb_destroy_args *args);
-int lib_route_map_entry_set_action_source_v4_modify(
- struct nb_cb_modify_args *args);
-int lib_route_map_entry_set_action_source_v4_destroy(
- struct nb_cb_destroy_args *args);
-int lib_route_map_entry_set_action_source_v6_modify(
- struct nb_cb_modify_args *args);
-int lib_route_map_entry_set_action_source_v6_destroy(
- struct nb_cb_destroy_args *args);
struct yang_data *
lib_interface_zebra_state_up_count_get_elem(struct nb_cb_get_elem_args *args);
struct yang_data *
diff --git a/zebra/zebra_nb_config.c b/zebra/zebra_nb_config.c
index ba9f96b7d..e23a51516 100644
--- a/zebra/zebra_nb_config.c
+++ b/zebra/zebra_nb_config.c
@@ -1294,323 +1294,3 @@ int lib_vrf_zebra_prefix_only_modify(struct nb_cb_modify_args *args)
return NB_OK;
}
-
-/*
- * XPath:
- * /frr-route-map:lib/route-map/entry/match-condition/frr-zebra:ipv4-prefix-length
- */
-int lib_route_map_entry_match_condition_ipv4_prefix_length_modify(
- struct nb_cb_modify_args *args)
-{
- struct routemap_hook_context *rhc;
- const char *length;
- int condition, rv;
-
- if (args->event != NB_EV_APPLY)
- return NB_OK;
-
- /* Add configuration. */
- rhc = nb_running_get_entry(args->dnode, NULL, true);
- length = yang_dnode_get_string(args->dnode, NULL);
- condition =
- yang_dnode_get_enum(args->dnode, "../frr-route-map:condition");
-
- /* Set destroy information. */
- switch (condition) {
- case 100: /* ipv4-prefix-length */
- rhc->rhc_rule = "ip address prefix-len";
- break;
-
- case 102: /* ipv4-next-hop-prefix-length */
- rhc->rhc_rule = "ip next-hop prefix-len";
- break;
- }
- rhc->rhc_mhook = generic_match_delete;
- rhc->rhc_event = RMAP_EVENT_MATCH_DELETED;
-
- rv = generic_match_add(NULL, rhc->rhc_rmi, rhc->rhc_rule, length,
- RMAP_EVENT_MATCH_ADDED);
- if (rv != CMD_SUCCESS) {
- rhc->rhc_mhook = NULL;
- return NB_ERR_INCONSISTENCY;
- }
-
- return NB_OK;
-}
-
-int lib_route_map_entry_match_condition_ipv4_prefix_length_destroy(
- struct nb_cb_destroy_args *args)
-{
- return lib_route_map_entry_match_destroy(args);
-}
-
-/*
- * XPath:
- * /frr-route-map:lib/route-map/entry/match-condition/frr-zebra:ipv6-prefix-length
- */
-int lib_route_map_entry_match_condition_ipv6_prefix_length_modify(
- struct nb_cb_modify_args *args)
-{
- struct routemap_hook_context *rhc;
- const char *length;
- int rv;
-
- if (args->event != NB_EV_APPLY)
- return NB_OK;
-
- /* Add configuration. */
- rhc = nb_running_get_entry(args->dnode, NULL, true);
- length = yang_dnode_get_string(args->dnode, NULL);
-
- /* Set destroy information. */
- rhc->rhc_mhook = generic_match_delete;
- rhc->rhc_rule = "ipv6 address prefix-len";
- rhc->rhc_event = RMAP_EVENT_MATCH_DELETED;
-
- rv = generic_match_add(NULL, rhc->rhc_rmi, "ipv6 address prefix-len",
- length, RMAP_EVENT_MATCH_ADDED);
- if (rv != CMD_SUCCESS) {
- rhc->rhc_mhook = NULL;
- return NB_ERR_INCONSISTENCY;
- }
-
- return NB_OK;
-}
-
-int lib_route_map_entry_match_condition_ipv6_prefix_length_destroy(
- struct nb_cb_destroy_args *args)
-{
- return lib_route_map_entry_match_destroy(args);
-}
-
-/*
- * XPath:
- * /frr-route-map:lib/route-map/entry/match-condition/frr-zebra:source-protocol
- */
-int lib_route_map_entry_match_condition_source_protocol_modify(
- struct nb_cb_modify_args *args)
-{
- struct routemap_hook_context *rhc;
- const char *type;
- int rv;
-
- switch (args->event) {
- case NB_EV_VALIDATE:
- type = yang_dnode_get_string(args->dnode, NULL);
- if (proto_name2num(type) == -1) {
- snprintf(args->errmsg, args->errmsg_len,
- "invalid protocol: %s", type);
- return NB_ERR_VALIDATION;
- }
- return NB_OK;
- case NB_EV_PREPARE:
- case NB_EV_ABORT:
- return NB_OK;
- case NB_EV_APPLY:
- /* NOTHING */
- break;
- }
-
- /* Add configuration. */
- rhc = nb_running_get_entry(args->dnode, NULL, true);
- type = yang_dnode_get_string(args->dnode, NULL);
-
- /* Set destroy information. */
- rhc->rhc_mhook = generic_match_delete;
- rhc->rhc_rule = "source-protocol";
- rhc->rhc_event = RMAP_EVENT_MATCH_DELETED;
-
- rv = generic_match_add(NULL, rhc->rhc_rmi, "source-protocol", type,
- RMAP_EVENT_MATCH_ADDED);
- if (rv != CMD_SUCCESS) {
- rhc->rhc_mhook = NULL;
- return NB_ERR_INCONSISTENCY;
- }
-
- return NB_OK;
-}
-
-int lib_route_map_entry_match_condition_source_protocol_destroy(
- struct nb_cb_destroy_args *args)
-{
- return lib_route_map_entry_match_destroy(args);
-}
-
-/*
- * XPath:
- * /frr-route-map:lib/route-map/entry/match-condition/frr-zebra:source-instance
- */
-int lib_route_map_entry_match_condition_source_instance_modify(
- struct nb_cb_modify_args *args)
-{
- struct routemap_hook_context *rhc;
- const char *type;
- int rv;
-
- if (args->event != NB_EV_APPLY)
- return NB_OK;
-
- /* Add configuration. */
- rhc = nb_running_get_entry(args->dnode, NULL, true);
- type = yang_dnode_get_string(args->dnode, NULL);
-
- /* Set destroy information. */
- rhc->rhc_mhook = generic_match_delete;
- rhc->rhc_rule = "source-instance";
- rhc->rhc_event = RMAP_EVENT_MATCH_DELETED;
-
- rv = generic_match_add(NULL, rhc->rhc_rmi, "source-instance", type,
- RMAP_EVENT_MATCH_ADDED);
- if (rv != CMD_SUCCESS) {
- rhc->rhc_mhook = NULL;
- return NB_ERR_INCONSISTENCY;
- }
-
- return NB_OK;
-}
-
-int lib_route_map_entry_match_condition_source_instance_destroy(
- struct nb_cb_destroy_args *args)
-{
- return lib_route_map_entry_match_destroy(args);
-}
-
-/*
- * XPath: /frr-route-map:lib/route-map/entry/set-action/frr-zebra:source-v4
- */
-int lib_route_map_entry_set_action_source_v4_modify(
- struct nb_cb_modify_args *args)
-{
- struct routemap_hook_context *rhc;
- struct interface *pif = NULL;
- const char *source;
- struct vrf *vrf;
- struct prefix p;
- int rv;
-
- switch (args->event) {
- case NB_EV_VALIDATE:
- memset(&p, 0, sizeof(p));
- yang_dnode_get_ipv4p(&p, args->dnode, NULL);
- if (zebra_check_addr(&p) == 0) {
- snprintf(args->errmsg, args->errmsg_len,
- "invalid IPv4 address: %s",
- yang_dnode_get_string(args->dnode, NULL));
- return NB_ERR_VALIDATION;
- }
-
- RB_FOREACH (vrf, vrf_id_head, &vrfs_by_id) {
- pif = if_lookup_exact_address(&p.u.prefix4, AF_INET,
- vrf->vrf_id);
- if (pif != NULL)
- break;
- }
- /*
- * On startup the local address *may* not have come up
- * yet. We need to allow startup configuration of
- * set src or we are fudged. Log it for future fun
- */
- if (pif == NULL)
- zlog_warn("set src %pI4 is not a local address",
- &p.u.prefix4);
- return NB_OK;
- case NB_EV_PREPARE:
- case NB_EV_ABORT:
- return NB_OK;
- case NB_EV_APPLY:
- /* NOTHING */
- break;
- }
-
- /* Add configuration. */
- rhc = nb_running_get_entry(args->dnode, NULL, true);
- source = yang_dnode_get_string(args->dnode, NULL);
-
- /* Set destroy information. */
- rhc->rhc_shook = generic_set_delete;
- rhc->rhc_rule = "src";
-
- rv = generic_set_add(NULL, rhc->rhc_rmi, "src", source);
- if (rv != CMD_SUCCESS) {
- rhc->rhc_shook = NULL;
- return NB_ERR_INCONSISTENCY;
- }
-
- return NB_OK;
-}
-
-int lib_route_map_entry_set_action_source_v4_destroy(
- struct nb_cb_destroy_args *args)
-{
- return lib_route_map_entry_set_destroy(args);
-}
-
-/*
- * XPath: /frr-route-map:lib/route-map/entry/set-action/frr-zebra:source-v6
- */
-int lib_route_map_entry_set_action_source_v6_modify(
- struct nb_cb_modify_args *args)
-{
- struct routemap_hook_context *rhc;
- struct interface *pif = NULL;
- const char *source;
- struct vrf *vrf;
- struct prefix p;
- int rv;
-
- switch (args->event) {
- case NB_EV_VALIDATE:
- memset(&p, 0, sizeof(p));
- yang_dnode_get_ipv6p(&p, args->dnode, NULL);
- if (zebra_check_addr(&p) == 0) {
- snprintf(args->errmsg, args->errmsg_len,
- "invalid IPv6 address: %s",
- yang_dnode_get_string(args->dnode, NULL));
- return NB_ERR_VALIDATION;
- }
-
- RB_FOREACH (vrf, vrf_id_head, &vrfs_by_id) {
- pif = if_lookup_exact_address(&p.u.prefix6, AF_INET6,
- vrf->vrf_id);
- if (pif != NULL)
- break;
- }
- /*
- * On startup the local address *may* not have come up
- * yet. We need to allow startup configuration of
- * set src or we are fudged. Log it for future fun
- */
- if (pif == NULL)
- zlog_warn("set src %pI6 is not a local address",
- &p.u.prefix6);
- return NB_OK;
- case NB_EV_PREPARE:
- case NB_EV_ABORT:
- return NB_OK;
- case NB_EV_APPLY:
- /* NOTHING */
- break;
- }
-
- /* Add configuration. */
- rhc = nb_running_get_entry(args->dnode, NULL, true);
- source = yang_dnode_get_string(args->dnode, NULL);
-
- /* Set destroy information. */
- rhc->rhc_shook = generic_set_delete;
- rhc->rhc_rule = "src";
-
- rv = generic_set_add(NULL, rhc->rhc_rmi, "src", source);
- if (rv != CMD_SUCCESS) {
- rhc->rhc_shook = NULL;
- return NB_ERR_INCONSISTENCY;
- }
-
- return NB_OK;
-}
-
-int lib_route_map_entry_set_action_source_v6_destroy(
- struct nb_cb_destroy_args *args)
-{
- return lib_route_map_entry_set_destroy(args);
-}
diff --git a/zebra/zebra_routemap.c b/zebra/zebra_routemap.c
index c9660c730..6a42c682a 100644
--- a/zebra/zebra_routemap.c
+++ b/zebra/zebra_routemap.c
@@ -357,12 +357,15 @@ DEFPY_YANG(
"Match prefix length of IP address\n"
"Prefix length\n")
{
- const char *xpath = "./match-condition[condition='ipv4-prefix-length']";
+ const char *xpath =
+ "./match-condition[condition='frr-zebra-route-map:ipv4-prefix-length']";
char xpath_value[XPATH_MAXLEN];
nb_cli_enqueue_change(vty, xpath, NB_OP_CREATE, NULL);
- snprintf(xpath_value, sizeof(xpath_value),
- "%s/frr-zebra:ipv4-prefix-length", xpath);
+ snprintf(
+ xpath_value, sizeof(xpath_value),
+ "%s/rmap-match-condition/frr-zebra-route-map:ipv4-prefix-length",
+ xpath);
nb_cli_enqueue_change(vty, xpath_value, NB_OP_MODIFY, length_str);
return nb_cli_apply_changes(vty, NULL);
@@ -378,7 +381,8 @@ DEFPY_YANG(
"Match prefix length of IP address\n"
"Prefix length\n")
{
- const char *xpath = "./match-condition[condition='ipv4-prefix-length']";
+ const char *xpath =
+ "./match-condition[condition='frr-zebra-route-map:ipv4-prefix-length']";
nb_cli_enqueue_change(vty, xpath, NB_OP_DESTROY, NULL);
@@ -394,12 +398,15 @@ DEFPY_YANG(
"Match prefix length of IPv6 address\n"
"Prefix length\n")
{
- const char *xpath = "./match-condition[condition='ipv6-prefix-length']";
+ const char *xpath =
+ "./match-condition[condition='frr-zebra-route-map:ipv6-prefix-length']";
char xpath_value[XPATH_MAXLEN];
nb_cli_enqueue_change(vty, xpath, NB_OP_CREATE, NULL);
- snprintf(xpath_value, sizeof(xpath_value),
- "%s/frr-zebra:ipv6-prefix-length", xpath);
+ snprintf(
+ xpath_value, sizeof(xpath_value),
+ "%s/rmap-match-condition/frr-zebra-route-map:ipv6-prefix-length",
+ xpath);
nb_cli_enqueue_change(vty, xpath_value, NB_OP_MODIFY, length_str);
return nb_cli_apply_changes(vty, NULL);
@@ -415,7 +422,8 @@ DEFPY_YANG(
"Match prefix length of IPv6 address\n"
"Prefix length\n")
{
- const char *xpath = "./match-condition[condition='ipv6-prefix-length']";
+ const char *xpath =
+ "./match-condition[condition='frr-zebra-route-map:ipv6-prefix-length']";
nb_cli_enqueue_change(vty, xpath, NB_OP_DESTROY, NULL);
@@ -432,12 +440,14 @@ DEFPY_YANG(
"Prefix length\n")
{
const char *xpath =
- "./match-condition[condition='ipv4-next-hop-prefix-length']";
+ "./match-condition[condition='frr-zebra-route-map:ipv4-next-hop-prefix-length']";
char xpath_value[XPATH_MAXLEN];
nb_cli_enqueue_change(vty, xpath, NB_OP_CREATE, NULL);
- snprintf(xpath_value, sizeof(xpath_value),
- "%s/frr-zebra:ipv4-prefix-length", xpath);
+ snprintf(
+ xpath_value, sizeof(xpath_value),
+ "%s/rmap-match-condition/frr-zebra-route-map:ipv4-prefix-length",
+ xpath);
nb_cli_enqueue_change(vty, xpath_value, NB_OP_MODIFY, length_str);
return nb_cli_apply_changes(vty, NULL);
@@ -454,7 +464,7 @@ DEFPY_YANG(
"Prefix length\n")
{
const char *xpath =
- "./match-condition[condition='ipv4-next-hop-prefix-length']";
+ "./match-condition[condition='frr-zebra-route-map:ipv4-next-hop-prefix-length']";
nb_cli_enqueue_change(vty, xpath, NB_OP_DESTROY, NULL);
@@ -468,12 +478,14 @@ DEFPY_YANG(
"Match protocol via which the route was learnt\n"
FRR_REDIST_HELP_STR_ZEBRA)
{
- const char *xpath = "./match-condition[condition='source-protocol']";
+ const char *xpath =
+ "./match-condition[condition='frr-zebra-route-map:source-protocol']";
char xpath_value[XPATH_MAXLEN];
nb_cli_enqueue_change(vty, xpath, NB_OP_CREATE, NULL);
snprintf(xpath_value, sizeof(xpath_value),
- "%s/frr-zebra:source-protocol", xpath);
+ "%s/rmap-match-condition/frr-zebra-route-map:source-protocol",
+ xpath);
nb_cli_enqueue_change(vty, xpath_value, NB_OP_MODIFY, proto);
return nb_cli_apply_changes(vty, NULL);
@@ -487,7 +499,8 @@ DEFPY_YANG(
"Match protocol via which the route was learnt\n"
FRR_REDIST_HELP_STR_ZEBRA)
{
- const char *xpath = "./match-condition[condition='source-protocol']";
+ const char *xpath =
+ "./match-condition[condition='frr-zebra-route-map:source-protocol']";
nb_cli_enqueue_change(vty, xpath, NB_OP_DESTROY, NULL);
@@ -501,12 +514,14 @@ DEFPY_YANG(
"Match the protocol's instance number\n"
"The instance number\n")
{
- const char *xpath = "./match-condition[condition='source-instance']";
+ const char *xpath =
+ "./match-condition[condition='frr-zebra-route-map:source-instance']";
char xpath_value[XPATH_MAXLEN];
nb_cli_enqueue_change(vty, xpath, NB_OP_CREATE, NULL);
snprintf(xpath_value, sizeof(xpath_value),
- "%s/frr-zebra:source-instance", xpath);
+ "%s/rmap-match-condition/frr-zebra-route-map:source-instance",
+ xpath);
nb_cli_enqueue_change(vty, xpath_value, NB_OP_MODIFY, instance_str);
return nb_cli_apply_changes(vty, NULL);
@@ -519,7 +534,8 @@ DEFPY_YANG(
"Match the protocol's instance number\n"
"The instance number\n")
{
- const char *xpath = "./match-condition[condition='source-instance']";
+ const char *xpath =
+ "./match-condition[condition='frr-zebra-route-map:source-instance']";
nb_cli_enqueue_change(vty, xpath, NB_OP_DESTROY, NULL);
@@ -536,18 +552,23 @@ DEFPY_YANG(
"IPv4 src address\n"
"IPv6 src address\n")
{
- const char *xpath = "./set-action[action='source']";
+ const char *xpath =
+ "./set-action[action='frr-zebra-route-map:src-address']";
char xpath_value[XPATH_MAXLEN];
nb_cli_enqueue_change(vty, xpath, NB_OP_CREATE, NULL);
if (addrv4_str) {
- snprintf(xpath_value, sizeof(xpath_value),
- "%s/frr-zebra:source-v4", xpath);
+ snprintf(
+ xpath_value, sizeof(xpath_value),
+ "%s/rmap-set-action/frr-zebra-route-map:ipv4-src-address",
+ xpath);
nb_cli_enqueue_change(vty, xpath_value, NB_OP_MODIFY,
addrv4_str);
} else {
- snprintf(xpath_value, sizeof(xpath_value),
- "%s/frr-zebra:source-v6", xpath);
+ snprintf(
+ xpath_value, sizeof(xpath_value),
+ "%s/rmap-set-action/frr-zebra-route-map:ipv6-src-address",
+ xpath);
nb_cli_enqueue_change(vty, xpath_value, NB_OP_MODIFY,
addrv6_str);
}
@@ -564,14 +585,15 @@ DEFPY_YANG(
"IPv4 address\n"
"IPv6 address\n")
{
- const char *xpath = "./set-action[action='source']";
+ const char *xpath =
+ "./set-action[action='frr-zebra-route-map:src-address']";
nb_cli_enqueue_change(vty, xpath, NB_OP_DESTROY, NULL);
return nb_cli_apply_changes(vty, NULL);
}
-DEFUN (zebra_route_map_timer,
+DEFUN_YANG (zebra_route_map_timer,
zebra_route_map_timer_cmd,
"zebra route-map delay-timer (0-600)",
ZEBRA_STR
@@ -588,7 +610,7 @@ DEFUN (zebra_route_map_timer,
return (CMD_SUCCESS);
}
-DEFUN (no_zebra_route_map_timer,
+DEFUN_YANG (no_zebra_route_map_timer,
no_zebra_route_map_timer_cmd,
"no zebra route-map delay-timer [(0-600)]",
NO_STR
diff --git a/zebra/zebra_routemap.h b/zebra/zebra_routemap.h
index c016d9587..3f58e14e1 100644
--- a/zebra/zebra_routemap.h
+++ b/zebra/zebra_routemap.h
@@ -55,4 +55,6 @@ zebra_nht_route_map_check(afi_t afi, int client_proto, const struct prefix *p,
#endif
extern void zebra_routemap_finish(void);
+
+extern const struct frr_yang_module_info frr_zebra_route_map_info;
#endif
diff --git a/zebra/zebra_routemap_nb.c b/zebra/zebra_routemap_nb.c
new file mode 100644
index 000000000..c82c34dd5
--- /dev/null
+++ b/zebra/zebra_routemap_nb.c
@@ -0,0 +1,74 @@
+/*
+ * Copyright (C) 2020 Vmware
+ * Sarita Patra
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the Free
+ * Software Foundation; either version 2 of the License, or (at your option)
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; see the file COPYING; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "northbound.h"
+#include "libfrr.h"
+#include "zebra_routemap_nb.h"
+
+/* clang-format off */
+const struct frr_yang_module_info frr_zebra_route_map_info = {
+ .name = "frr-zebra-route-map",
+ .nodes = {
+ {
+ .xpath = "/frr-route-map:lib/route-map/entry/match-condition/rmap-match-condition/frr-zebra-route-map:ipv4-prefix-length",
+ .cbs = {
+ .modify = lib_route_map_entry_match_condition_rmap_match_condition_ipv4_prefix_length_modify,
+ .destroy = lib_route_map_entry_match_condition_rmap_match_condition_ipv4_prefix_length_destroy,
+ }
+ },
+ {
+ .xpath = "/frr-route-map:lib/route-map/entry/match-condition/rmap-match-condition/frr-zebra-route-map:ipv6-prefix-length",
+ .cbs = {
+ .modify = lib_route_map_entry_match_condition_rmap_match_condition_ipv6_prefix_length_modify,
+ .destroy = lib_route_map_entry_match_condition_rmap_match_condition_ipv6_prefix_length_destroy,
+ }
+ },
+ {
+ .xpath = "/frr-route-map:lib/route-map/entry/match-condition/rmap-match-condition/frr-zebra-route-map:source-instance",
+ .cbs = {
+ .modify = lib_route_map_entry_match_condition_rmap_match_condition_source_instance_modify,
+ .destroy = lib_route_map_entry_match_condition_rmap_match_condition_source_instance_destroy,
+ }
+ },
+ {
+ .xpath = "/frr-route-map:lib/route-map/entry/match-condition/rmap-match-condition/frr-zebra-route-map:source-protocol",
+ .cbs = {
+ .modify = lib_route_map_entry_match_condition_rmap_match_condition_source_protocol_modify,
+ .destroy = lib_route_map_entry_match_condition_rmap_match_condition_source_protocol_destroy,
+ }
+ },
+ {
+ .xpath = "/frr-route-map:lib/route-map/entry/set-action/rmap-set-action/frr-zebra-route-map:ipv4-src-address",
+ .cbs = {
+ .modify = lib_route_map_entry_set_action_rmap_set_action_ipv4_src_address_modify,
+ .destroy = lib_route_map_entry_set_action_rmap_set_action_ipv4_src_address_destroy,
+ }
+ },
+ {
+ .xpath = "/frr-route-map:lib/route-map/entry/set-action/rmap-set-action/frr-zebra-route-map:ipv6-src-address",
+ .cbs = {
+ .modify = lib_route_map_entry_set_action_rmap_set_action_ipv6_src_address_modify,
+ .destroy = lib_route_map_entry_set_action_rmap_set_action_ipv6_src_address_destroy,
+ }
+ },
+ {
+ .xpath = NULL,
+ },
+ }
+};
diff --git a/zebra/zebra_routemap_nb.h b/zebra/zebra_routemap_nb.h
new file mode 100644
index 000000000..a43f2b2ae
--- /dev/null
+++ b/zebra/zebra_routemap_nb.h
@@ -0,0 +1,45 @@
+/*
+ * Copyright (C) 2020 Vmware
+ * Sarita Patra
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the Free
+ * Software Foundation; either version 2 of the License, or (at your option)
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; see the file COPYING; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef _FRR_ZEBRA_ROUTEMAP_NB_H_
+#define _FRR_ZEBRA_ROUTEMAP_NB_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* prototypes */
+int lib_route_map_entry_match_condition_rmap_match_condition_ipv4_prefix_length_modify(struct nb_cb_modify_args *args);
+int lib_route_map_entry_match_condition_rmap_match_condition_ipv4_prefix_length_destroy(struct nb_cb_destroy_args *args);
+int lib_route_map_entry_match_condition_rmap_match_condition_ipv6_prefix_length_modify(struct nb_cb_modify_args *args);
+int lib_route_map_entry_match_condition_rmap_match_condition_ipv6_prefix_length_destroy(struct nb_cb_destroy_args *args);
+int lib_route_map_entry_match_condition_rmap_match_condition_source_instance_modify(struct nb_cb_modify_args *args);
+int lib_route_map_entry_match_condition_rmap_match_condition_source_instance_destroy(struct nb_cb_destroy_args *args);
+int lib_route_map_entry_match_condition_rmap_match_condition_source_protocol_modify(struct nb_cb_modify_args *args);
+int lib_route_map_entry_match_condition_rmap_match_condition_source_protocol_destroy(struct nb_cb_destroy_args *args);
+int lib_route_map_entry_set_action_rmap_set_action_ipv4_src_address_modify(struct nb_cb_modify_args *args);
+int lib_route_map_entry_set_action_rmap_set_action_ipv4_src_address_destroy(struct nb_cb_destroy_args *args);
+int lib_route_map_entry_set_action_rmap_set_action_ipv6_src_address_modify(struct nb_cb_modify_args *args);
+int lib_route_map_entry_set_action_rmap_set_action_ipv6_src_address_destroy(struct nb_cb_destroy_args *args);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/zebra/zebra_routemap_nb_config.c b/zebra/zebra_routemap_nb_config.c
new file mode 100644
index 000000000..8f5660610
--- /dev/null
+++ b/zebra/zebra_routemap_nb_config.c
@@ -0,0 +1,396 @@
+#include <zebra.h>
+
+#include "lib/command.h"
+#include "lib/log.h"
+#include "lib/northbound.h"
+#include "lib/routemap.h"
+#include "zebra/rib.h"
+#include "zebra/zebra_routemap_nb.h"
+
+/*
+ * XPath: /frr-route-map:lib/route-map/entry/match-condition/rmap-match-condition/frr-zebra-route-map:ipv4-prefix-length
+ */
+int
+lib_route_map_entry_match_condition_rmap_match_condition_ipv4_prefix_length_modify(
+ struct nb_cb_modify_args *args)
+{
+ struct routemap_hook_context *rhc;
+ const char *length;
+ int rv;
+ const char *condition;
+
+ switch (args->event) {
+ case NB_EV_VALIDATE:
+ case NB_EV_PREPARE:
+ case NB_EV_ABORT:
+ return NB_OK;
+ case NB_EV_APPLY:
+ /* Add configuration. */
+ rhc = nb_running_get_entry(args->dnode, NULL, true);
+ length = yang_dnode_get_string(args->dnode, NULL);
+ condition = yang_dnode_get_string(args->dnode,
+ "../../frr-route-map:condition");
+
+ if (IS_MATCH_IPv4_PREFIX_LEN(condition))
+ rhc->rhc_rule = "ip address prefix-len";
+ else if (IS_MATCH_IPv4_NH_PREFIX_LEN(condition))
+ rhc->rhc_rule = "ip next-hop prefix-len";
+
+ rhc->rhc_mhook = generic_match_delete;
+ rhc->rhc_event = RMAP_EVENT_MATCH_DELETED;
+
+ rv = generic_match_add(rhc->rhc_rmi, rhc->rhc_rule,
+ length, RMAP_EVENT_MATCH_ADDED,
+ args->errmsg, args->errmsg_len);
+ if (rv != CMD_SUCCESS) {
+ rhc->rhc_mhook = NULL;
+ return NB_ERR_INCONSISTENCY;
+ }
+ }
+
+ return NB_OK;
+}
+
+int
+lib_route_map_entry_match_condition_rmap_match_condition_ipv4_prefix_length_destroy(
+ struct nb_cb_destroy_args *args)
+{
+ switch (args->event) {
+ case NB_EV_VALIDATE:
+ case NB_EV_PREPARE:
+ case NB_EV_ABORT:
+ break;
+ case NB_EV_APPLY:
+ return lib_route_map_entry_match_destroy(args);
+ }
+
+ return NB_OK;
+}
+
+/*
+ * XPath: /frr-route-map:lib/route-map/entry/match-condition/rmap-match-condition/frr-zebra-route-map:ipv6-prefix-length
+ */
+int
+lib_route_map_entry_match_condition_rmap_match_condition_ipv6_prefix_length_modify(
+ struct nb_cb_modify_args *args)
+{
+ struct routemap_hook_context *rhc;
+ const char *length;
+ int rv;
+
+ switch (args->event) {
+ case NB_EV_VALIDATE:
+ case NB_EV_PREPARE:
+ case NB_EV_ABORT:
+ return NB_OK;
+ case NB_EV_APPLY:
+ /* Add configuration. */
+ rhc = nb_running_get_entry(args->dnode, NULL, true);
+ length = yang_dnode_get_string(args->dnode, NULL);
+
+ /* Set destroy information. */
+ rhc->rhc_mhook = generic_match_delete;
+ rhc->rhc_rule = "ipv6 address prefix-len";
+ rhc->rhc_event = RMAP_EVENT_MATCH_DELETED;
+
+ rv = generic_match_add(rhc->rhc_rmi, "ipv6 address prefix-len",
+ length, RMAP_EVENT_MATCH_ADDED,
+ args->errmsg, args->errmsg_len);
+ if (rv != CMD_SUCCESS) {
+ rhc->rhc_mhook = NULL;
+ return NB_ERR_INCONSISTENCY;
+ }
+ }
+
+ return NB_OK;
+}
+
+int
+lib_route_map_entry_match_condition_rmap_match_condition_ipv6_prefix_length_destroy(
+ struct nb_cb_destroy_args *args)
+{
+ switch (args->event) {
+ case NB_EV_VALIDATE:
+ case NB_EV_PREPARE:
+ case NB_EV_ABORT:
+ break;
+ case NB_EV_APPLY:
+ return lib_route_map_entry_match_destroy(args);
+ }
+
+ return NB_OK;
+
+}
+
+/*
+ * XPath: /frr-route-map:lib/route-map/entry/match-condition/rmap-match-condition/frr-zebra-route-map:source-instance
+ */
+int
+lib_route_map_entry_match_condition_rmap_match_condition_source_instance_modify(
+ struct nb_cb_modify_args *args)
+{
+ struct routemap_hook_context *rhc;
+ const char *type;
+ int rv;
+
+ switch (args->event) {
+ case NB_EV_VALIDATE:
+ case NB_EV_PREPARE:
+ case NB_EV_ABORT:
+ break;
+ case NB_EV_APPLY:
+ /* Add configuration. */
+ rhc = nb_running_get_entry(args->dnode, NULL, true);
+ type = yang_dnode_get_string(args->dnode, NULL);
+
+ /* Set destroy information. */
+ rhc->rhc_mhook = generic_match_delete;
+ rhc->rhc_rule = "source-instance";
+ rhc->rhc_event = RMAP_EVENT_MATCH_DELETED;
+
+ rv = generic_match_add(rhc->rhc_rmi, "source-instance",
+ type, RMAP_EVENT_MATCH_ADDED,
+ args->errmsg, args->errmsg_len);
+ if (rv != CMD_SUCCESS) {
+ rhc->rhc_mhook = NULL;
+ return NB_ERR_INCONSISTENCY;
+ }
+ }
+
+ return NB_OK;
+}
+
+int
+lib_route_map_entry_match_condition_rmap_match_condition_source_instance_destroy(
+ struct nb_cb_destroy_args *args)
+{
+ switch (args->event) {
+ case NB_EV_VALIDATE:
+ case NB_EV_PREPARE:
+ case NB_EV_ABORT:
+ break;
+ case NB_EV_APPLY:
+ return lib_route_map_entry_match_destroy(args);
+ }
+
+ return NB_OK;
+}
+
+/*
+ * XPath: /frr-route-map:lib/route-map/entry/match-condition/rmap-match-condition/frr-zebra-route-map:source-protocol
+ */
+int
+lib_route_map_entry_match_condition_rmap_match_condition_source_protocol_modify(
+ struct nb_cb_modify_args *args)
+{
+ struct routemap_hook_context *rhc;
+ const char *type;
+ int rv;
+
+ switch (args->event) {
+ case NB_EV_VALIDATE:
+ type = yang_dnode_get_string(args->dnode, NULL);
+ if (proto_name2num(type) == -1) {
+ zlog_warn("%s: invalid protocol: %s", __func__, type);
+ return NB_ERR_VALIDATION;
+ }
+ return NB_OK;
+ case NB_EV_PREPARE:
+ case NB_EV_ABORT:
+ return NB_OK;
+ case NB_EV_APPLY:
+ /* NOTHING */
+ break;
+ }
+
+ /* Add configuration. */
+ rhc = nb_running_get_entry(args->dnode, NULL, true);
+ type = yang_dnode_get_string(args->dnode, NULL);
+
+ /* Set destroy information. */
+ rhc->rhc_mhook = generic_match_delete;
+ rhc->rhc_rule = "source-protocol";
+ rhc->rhc_event = RMAP_EVENT_MATCH_DELETED;
+
+ rv = generic_match_add(rhc->rhc_rmi, "source-protocol", type,
+ RMAP_EVENT_MATCH_ADDED,
+ args->errmsg, args->errmsg_len);
+ if (rv != CMD_SUCCESS) {
+ rhc->rhc_mhook = NULL;
+ return NB_ERR_INCONSISTENCY;
+ }
+
+ return NB_OK;
+}
+
+int
+lib_route_map_entry_match_condition_rmap_match_condition_source_protocol_destroy(
+ struct nb_cb_destroy_args *args)
+{
+ switch (args->event) {
+ case NB_EV_VALIDATE:
+ case NB_EV_PREPARE:
+ case NB_EV_ABORT:
+ break;
+ case NB_EV_APPLY:
+ return lib_route_map_entry_match_destroy(args);
+ }
+
+ return NB_OK;
+}
+
+/*
+ * XPath: /frr-route-map:lib/route-map/entry/set-action/rmap-set-action/frr-zebra-route-map:ipv4-src-address
+ */
+int
+lib_route_map_entry_set_action_rmap_set_action_ipv4_src_address_modify(
+ struct nb_cb_modify_args *args)
+{
+ struct routemap_hook_context *rhc;
+ struct interface *pif = NULL;
+ const char *source;
+ struct vrf *vrf;
+ struct prefix p;
+ int rv;
+
+ switch (args->event) {
+ case NB_EV_VALIDATE:
+ memset(&p, 0, sizeof(p));
+ yang_dnode_get_ipv4p(&p, args->dnode, NULL);
+ if (zebra_check_addr(&p) == 0) {
+ zlog_warn("%s: invalid IPv4 address: %s", __func__,
+ yang_dnode_get_string(args->dnode, NULL));
+ return NB_ERR_VALIDATION;
+ }
+
+ RB_FOREACH(vrf, vrf_id_head, &vrfs_by_id) {
+ pif = if_lookup_exact_address(&p.u.prefix4, AF_INET,
+ vrf->vrf_id);
+ if (pif != NULL)
+ break;
+ }
+ if (pif == NULL) {
+ zlog_warn("%s: is not a local address: %s", __func__,
+ yang_dnode_get_string(args->dnode, NULL));
+ return NB_ERR_VALIDATION;
+ }
+ return NB_OK;
+ case NB_EV_PREPARE:
+ case NB_EV_ABORT:
+ return NB_OK;
+ case NB_EV_APPLY:
+ /* NOTHING */
+ break;
+ }
+
+ /* Add configuration. */
+ rhc = nb_running_get_entry(args->dnode, NULL, true);
+ source = yang_dnode_get_string(args->dnode, NULL);
+
+ /* Set destroy information. */
+ rhc->rhc_shook = generic_set_delete;
+ rhc->rhc_rule = "src";
+
+ rv = generic_set_add(rhc->rhc_rmi, "src", source,
+ args->errmsg, args->errmsg_len);
+ if (rv != CMD_SUCCESS) {
+ rhc->rhc_shook = NULL;
+ return NB_ERR_INCONSISTENCY;
+ }
+
+ return NB_OK;
+}
+
+int
+lib_route_map_entry_set_action_rmap_set_action_ipv4_src_address_destroy(
+ struct nb_cb_destroy_args *args)
+{
+ switch (args->event) {
+ case NB_EV_VALIDATE:
+ case NB_EV_PREPARE:
+ case NB_EV_ABORT:
+ break;
+ case NB_EV_APPLY:
+ return lib_route_map_entry_set_destroy(args);
+ }
+
+ return NB_OK;
+}
+
+/*
+ * XPath: /frr-route-map:lib/route-map/entry/set-action/rmap-set-action/frr-zebra-route-map:ipv6-src-address
+ */
+int
+lib_route_map_entry_set_action_rmap_set_action_ipv6_src_address_modify(
+ struct nb_cb_modify_args *args)
+{
+ struct routemap_hook_context *rhc;
+ struct interface *pif = NULL;
+ const char *source;
+ struct vrf *vrf;
+ struct prefix p;
+ int rv;
+
+ switch (args->event) {
+ case NB_EV_VALIDATE:
+ memset(&p, 0, sizeof(p));
+ yang_dnode_get_ipv6p(&p, args->dnode, NULL);
+ if (zebra_check_addr(&p) == 0) {
+ zlog_warn("%s: invalid IPv6 address: %s", __func__,
+ yang_dnode_get_string(args->dnode, NULL));
+ return NB_ERR_VALIDATION;
+ }
+
+ RB_FOREACH(vrf, vrf_id_head, &vrfs_by_id) {
+ pif = if_lookup_exact_address(&p.u.prefix6, AF_INET6,
+ vrf->vrf_id);
+ if (pif != NULL)
+ break;
+ }
+ if (pif == NULL) {
+ zlog_warn("%s: is not a local address: %s", __func__,
+ yang_dnode_get_string(args->dnode, NULL));
+ return NB_ERR_VALIDATION;
+ }
+ return NB_OK;
+ case NB_EV_PREPARE:
+ case NB_EV_ABORT:
+ return NB_OK;
+ case NB_EV_APPLY:
+ /* NOTHING */
+ break;
+ }
+
+ /* Add configuration. */
+ rhc = nb_running_get_entry(args->dnode, NULL, true);
+ source = yang_dnode_get_string(args->dnode, NULL);
+
+ /* Set destroy information. */
+ rhc->rhc_shook = generic_set_delete;
+ rhc->rhc_rule = "src";
+
+ rv = generic_set_add(rhc->rhc_rmi, "src", source,
+ args->errmsg, args->errmsg_len);
+ if (rv != CMD_SUCCESS) {
+ rhc->rhc_shook = NULL;
+ return NB_ERR_INCONSISTENCY;
+ }
+
+ return NB_OK;
+}
+
+int
+lib_route_map_entry_set_action_rmap_set_action_ipv6_src_address_destroy(
+ struct nb_cb_destroy_args *args)
+{
+ switch (args->event) {
+ case NB_EV_VALIDATE:
+ case NB_EV_PREPARE:
+ case NB_EV_ABORT:
+ break;
+ case NB_EV_APPLY:
+ return lib_route_map_entry_set_destroy(args);
+ }
+
+ return NB_OK;
+}