From 524ad5c71f4063c5d39c3f75ee4e48870cd69091 Mon Sep 17 00:00:00 2001 From: Donatas Abraitis Date: Thu, 10 Oct 2024 16:50:38 +0300 Subject: [PATCH] bgpd: Move some non BGP-specific route-map functions to lib They are managed under `frr-route-map`, not under `frr-bgp-route-map`. Fixes: https://github.com/FRRouting/frr/issues/17055 Signed-off-by: Donatas Abraitis (cherry picked from commit b9a9be492e8dde39a0040bd1140893ccab83c2be) --- bgpd/bgp_routemap.c | 80 --------------------------------------------- lib/routemap_cli.c | 73 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 73 insertions(+), 80 deletions(-) diff --git a/bgpd/bgp_routemap.c b/bgpd/bgp_routemap.c index 556f820db00a..4a671db934da 100644 --- a/bgpd/bgp_routemap.c +++ b/bgpd/bgp_routemap.c @@ -7218,43 +7218,6 @@ DEFUN_YANG (no_set_aggregator_as, return nb_cli_apply_changes(vty, NULL); } -DEFUN_YANG (match_ipv6_next_hop, - match_ipv6_next_hop_cmd, - "match ipv6 next-hop ACCESSLIST6_NAME", - MATCH_STR - IPV6_STR - "Match IPv6 next-hop address of route\n" - "IPv6 access-list name\n") -{ - const char *xpath = - "./match-condition[condition='frr-route-map:ipv6-next-hop-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/list-name", xpath); - nb_cli_enqueue_change(vty, xpath_value, NB_OP_MODIFY, - argv[argc - 1]->arg); - - return nb_cli_apply_changes(vty, NULL); -} - -DEFUN_YANG (no_match_ipv6_next_hop, - no_match_ipv6_next_hop_cmd, - "no match ipv6 next-hop [ACCESSLIST6_NAME]", - NO_STR - MATCH_STR - IPV6_STR - "Match IPv6 next-hop address of route\n" - "IPv6 access-list name\n") -{ - const char *xpath = - "./match-condition[condition='frr-route-map:ipv6-next-hop-list']"; - - nb_cli_enqueue_change(vty, xpath, NB_OP_DESTROY, NULL); - return nb_cli_apply_changes(vty, NULL); -} - DEFUN_YANG (match_ipv6_next_hop_address, match_ipv6_next_hop_address_cmd, "match ipv6 next-hop address X:X::X:X", @@ -7312,45 +7275,6 @@ ALIAS_HIDDEN (no_match_ipv6_next_hop_address, "Match IPv6 next-hop address of route\n" "IPv6 address of next hop\n") -DEFUN_YANG (match_ipv6_next_hop_prefix_list, - match_ipv6_next_hop_prefix_list_cmd, - "match ipv6 next-hop prefix-list PREFIXLIST_NAME", - MATCH_STR - IPV6_STR - "Match IPv6 next-hop address of route\n" - "Match entries by prefix-list\n" - "IPv6 prefix-list name\n") -{ - const char *xpath = - "./match-condition[condition='frr-route-map:ipv6-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/rmap-match-condition/list-name", xpath); - nb_cli_enqueue_change(vty, xpath_value, NB_OP_MODIFY, - argv[argc - 1]->arg); - - return nb_cli_apply_changes(vty, NULL); -} - -DEFUN_YANG (no_match_ipv6_next_hop_prefix_list, - no_match_ipv6_next_hop_prefix_list_cmd, - "no match ipv6 next-hop prefix-list [PREFIXLIST_NAME]", - NO_STR - MATCH_STR - IPV6_STR - "Match IPv6 next-hop address of route\n" - "Match entries by prefix-list\n" - "IPv6 prefix-list name\n") -{ - const char *xpath = - "./match-condition[condition='frr-route-map:ipv6-next-hop-prefix-list']"; - - nb_cli_enqueue_change(vty, xpath, NB_OP_DESTROY, NULL); - return nb_cli_apply_changes(vty, NULL); -} - DEFPY_YANG (match_ipv4_next_hop, match_ipv4_next_hop_cmd, "match ip next-hop address A.B.C.D", @@ -8023,12 +7947,8 @@ void bgp_route_map_init(void) route_map_install_set(&route_set_ipv6_nexthop_peer_cmd); route_map_install_match(&route_match_rpki_extcommunity_cmd); - install_element(RMAP_NODE, &match_ipv6_next_hop_cmd); install_element(RMAP_NODE, &match_ipv6_next_hop_address_cmd); - install_element(RMAP_NODE, &match_ipv6_next_hop_prefix_list_cmd); - install_element(RMAP_NODE, &no_match_ipv6_next_hop_cmd); install_element(RMAP_NODE, &no_match_ipv6_next_hop_address_cmd); - install_element(RMAP_NODE, &no_match_ipv6_next_hop_prefix_list_cmd); install_element(RMAP_NODE, &match_ipv6_next_hop_old_cmd); install_element(RMAP_NODE, &no_match_ipv6_next_hop_old_cmd); install_element(RMAP_NODE, &match_ipv4_next_hop_cmd); diff --git a/lib/routemap_cli.c b/lib/routemap_cli.c index 20a157e95539..9ea27787f5ed 100644 --- a/lib/routemap_cli.c +++ b/lib/routemap_cli.c @@ -417,6 +417,74 @@ DEFPY_YANG( return nb_cli_apply_changes(vty, NULL); } +DEFUN_YANG (match_ipv6_next_hop, + match_ipv6_next_hop_cmd, + "match ipv6 next-hop ACCESSLIST6_NAME", + MATCH_STR + IPV6_STR + "Match IPv6 next-hop address of route\n" + "IPv6 access-list name\n") +{ + const char *xpath = "./match-condition[condition='frr-route-map:ipv6-next-hop-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/list-name", xpath); + nb_cli_enqueue_change(vty, xpath_value, NB_OP_MODIFY, argv[argc - 1]->arg); + + return nb_cli_apply_changes(vty, NULL); +} + +DEFUN_YANG (no_match_ipv6_next_hop, + no_match_ipv6_next_hop_cmd, + "no match ipv6 next-hop [ACCESSLIST6_NAME]", + NO_STR + MATCH_STR + IPV6_STR + "Match IPv6 next-hop address of route\n" + "IPv6 access-list name\n") +{ + const char *xpath = "./match-condition[condition='frr-route-map:ipv6-next-hop-list']"; + + nb_cli_enqueue_change(vty, xpath, NB_OP_DESTROY, NULL); + return nb_cli_apply_changes(vty, NULL); +} + +DEFUN_YANG (match_ipv6_next_hop_prefix_list, + match_ipv6_next_hop_prefix_list_cmd, + "match ipv6 next-hop prefix-list PREFIXLIST_NAME", + MATCH_STR + IPV6_STR + "Match IPv6 next-hop address of route\n" + "Match entries by prefix-list\n" + "IPv6 prefix-list name\n") +{ + const char *xpath = "./match-condition[condition='frr-route-map:ipv6-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/rmap-match-condition/list-name", xpath); + nb_cli_enqueue_change(vty, xpath_value, NB_OP_MODIFY, argv[argc - 1]->arg); + + return nb_cli_apply_changes(vty, NULL); +} + +DEFUN_YANG (no_match_ipv6_next_hop_prefix_list, + no_match_ipv6_next_hop_prefix_list_cmd, + "no match ipv6 next-hop prefix-list [PREFIXLIST_NAME]", + NO_STR + MATCH_STR + IPV6_STR + "Match IPv6 next-hop address of route\n" + "Match entries by prefix-list\n" + "IPv6 prefix-list name\n") +{ + const char *xpath = "./match-condition[condition='frr-route-map:ipv6-next-hop-prefix-list']"; + + nb_cli_enqueue_change(vty, xpath, NB_OP_DESTROY, NULL); + return nb_cli_apply_changes(vty, NULL); +} + DEFPY_YANG( match_ipv6_next_hop_type, match_ipv6_next_hop_type_cmd, "match ipv6 next-hop type $type", @@ -1644,6 +1712,11 @@ void route_map_cli_init(void) install_element(RMAP_NODE, &match_ipv6_next_hop_type_cmd); install_element(RMAP_NODE, &no_match_ipv6_next_hop_type_cmd); + install_element(RMAP_NODE, &match_ipv6_next_hop_cmd); + install_element(RMAP_NODE, &match_ipv6_next_hop_prefix_list_cmd); + install_element(RMAP_NODE, &no_match_ipv6_next_hop_cmd); + install_element(RMAP_NODE, &no_match_ipv6_next_hop_prefix_list_cmd); + install_element(RMAP_NODE, &match_metric_cmd); install_element(RMAP_NODE, &no_match_metric_cmd);