Skip to content

Commit

Permalink
Merge pull request #17059 from opensourcerouting/fix/move_match_ipv6_…
Browse files Browse the repository at this point in the history
…next-hop_acl_to_routemap_lib

bgpd: Move some non BGP-specific route-map functions to lib
  • Loading branch information
donaldsharp authored Oct 11, 2024
2 parents 5549011 + b9a9be4 commit adc0f00
Show file tree
Hide file tree
Showing 2 changed files with 73 additions and 80 deletions.
80 changes: 0 additions & 80 deletions bgpd/bgp_routemap.c
Original file line number Diff line number Diff line change
Expand Up @@ -7232,43 +7232,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",
Expand Down Expand Up @@ -7326,45 +7289,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",
Expand Down Expand Up @@ -8037,12 +7961,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);
Expand Down
73 changes: 73 additions & 0 deletions lib/routemap_cli.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 <blackhole>$type",
Expand Down Expand Up @@ -1665,6 +1733,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);

Expand Down

0 comments on commit adc0f00

Please sign in to comment.