]> git.proxmox.com Git - mirror_frr.git/blobdiff - bgpd/bgp_routemap.c
Merge pull request #13368 from Keelan10/nhrpd-memory-leak
[mirror_frr.git] / bgpd / bgp_routemap.c
index 32ecb083beca51ccd503d4bdf407b5770ac583c5..10fc3ecda4455abb5e9ed8f4f3566dd950baf4de 100644 (file)
@@ -2867,6 +2867,29 @@ static const struct route_map_rule_cmd route_set_ecommunity_soo_cmd = {
        route_set_ecommunity_free,
 };
 
+static void *route_set_ecommunity_nt_compile(const char *arg)
+{
+       struct rmap_ecom_set *rcs;
+       struct ecommunity *ecom;
+
+       ecom = ecommunity_str2com(arg, ECOMMUNITY_NODE_TARGET, 0);
+       if (!ecom)
+               return NULL;
+
+       rcs = XCALLOC(MTYPE_ROUTE_MAP_COMPILED, sizeof(struct rmap_ecom_set));
+       rcs->ecom = ecommunity_intern(ecom);
+       rcs->none = false;
+
+       return rcs;
+}
+
+static const struct route_map_rule_cmd route_set_ecommunity_nt_cmd = {
+       "extcommunity nt",
+       route_set_ecommunity,
+       route_set_ecommunity_nt_compile,
+       route_set_ecommunity_free,
+};
+
 /* `set extcommunity bandwidth' */
 
 struct rmap_ecomm_lb_set {
@@ -6418,6 +6441,55 @@ ALIAS_YANG (no_set_ecommunity_lb,
             "BGP extended community attribute\n"
             "Link bandwidth extended community\n")
 
+DEFPY_YANG (set_ecommunity_nt,
+           set_ecommunity_nt_cmd,
+           "set extcommunity nt RTLIST...",
+           SET_STR
+           "BGP extended community attribute\n"
+           "Node Target extended community\n"
+           "Node Target ID\n")
+{
+       int idx_nt = 3;
+       char *str;
+       int ret;
+       const char *xpath =
+               "./set-action[action='frr-bgp-route-map:set-extcommunity-nt']";
+       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-nt", xpath);
+       str = argv_concat(argv, argc, idx_nt);
+       nb_cli_enqueue_change(vty, xpath_value, NB_OP_MODIFY, str);
+       ret = nb_cli_apply_changes(vty, NULL);
+       XFREE(MTYPE_TMP, str);
+       return ret;
+}
+
+DEFPY_YANG (no_set_ecommunity_nt,
+           no_set_ecommunity_nt_cmd,
+           "no set extcommunity nt RTLIST...",
+           NO_STR
+           SET_STR
+           "BGP extended community attribute\n"
+           "Node Target extended community\n"
+           "Node Target ID\n")
+{
+       const char *xpath =
+               "./set-action[action='frr-bgp-route-map:set-extcommunity-nt']";
+       nb_cli_enqueue_change(vty, xpath, NB_OP_DESTROY, NULL);
+       return nb_cli_apply_changes(vty, NULL);
+}
+
+ALIAS_YANG (no_set_ecommunity_nt,
+            no_set_ecommunity_nt_short_cmd,
+            "no set extcommunity nt",
+            NO_STR
+            SET_STR
+            "BGP extended community attribute\n"
+            "Node Target extended community\n")
+
 DEFUN_YANG (set_origin,
            set_origin_cmd,
            "set origin <egp|igp|incomplete>",
@@ -7223,6 +7295,7 @@ void bgp_route_map_init(void)
        route_map_install_set(&route_set_vpnv6_nexthop_cmd);
        route_map_install_set(&route_set_originator_id_cmd);
        route_map_install_set(&route_set_ecommunity_rt_cmd);
+       route_map_install_set(&route_set_ecommunity_nt_cmd);
        route_map_install_set(&route_set_ecommunity_soo_cmd);
        route_map_install_set(&route_set_ecommunity_lb_cmd);
        route_map_install_set(&route_set_ecommunity_none_cmd);
@@ -7325,6 +7398,9 @@ void bgp_route_map_init(void)
        install_element(RMAP_NODE, &no_set_ecommunity_lb_short_cmd);
        install_element(RMAP_NODE, &set_ecommunity_none_cmd);
        install_element(RMAP_NODE, &no_set_ecommunity_none_cmd);
+       install_element(RMAP_NODE, &set_ecommunity_nt_cmd);
+       install_element(RMAP_NODE, &no_set_ecommunity_nt_cmd);
+       install_element(RMAP_NODE, &no_set_ecommunity_nt_short_cmd);
 #ifdef KEEP_OLD_VPN_COMMANDS
        install_element(RMAP_NODE, &set_vpn_nexthop_cmd);
        install_element(RMAP_NODE, &no_set_vpn_nexthop_cmd);