Skip to content

Commit

Permalink
bgpd: add redistribute table-direct command for ipv6-unicast
Browse files Browse the repository at this point in the history
The 'table-direct' redistribute command is available for ipv4 unicast but
not for ipv6 unicast.

Add the command to ipv6 unicast as well.

Fixes: b6367f8 ("bgpd: add redistribute table-direct support")
Signed-off-by: Philippe Guibert <[email protected]>
Signed-off-by: Louis Scalbert <[email protected]>
  • Loading branch information
pguibert6WIND authored and louis-6wind committed Mar 19, 2024
1 parent 8341f64 commit a67ff9c
Showing 1 changed file with 72 additions and 0 deletions.
72 changes: 72 additions & 0 deletions bgpd/bgp_vty.c
Original file line number Diff line number Diff line change
Expand Up @@ -17664,6 +17664,76 @@ DEFUN (bgp_redistribute_ipv6_rmap_metric,
return bgp_redistribute_set(bgp, AFI_IP6, type, 0, changed);
}

DEFPY(bgp_redistribute_ipv6_table, bgp_redistribute_ipv6_table_cmd,
"redistribute table-direct (1-65535)$table_id [{metric$metric (0-4294967295)$metric_val|route-map WORD$rmap}]",
"Redistribute information from another routing protocol\n"
"Non-main Kernel Routing Table - Direct\n"
"Table ID\n"
"Metric for redistributed routes\n"
"Default metric\n"
"Route map reference\n"
"Pointer to route-map entries\n")
{
VTY_DECLVAR_CONTEXT(bgp, bgp);
bool changed = false;
struct route_map *route_map = NULL;
struct bgp_redist *red;

if (rmap)
route_map = route_map_lookup_warn_noexist(vty, rmap);

if (bgp->vrf_id != VRF_DEFAULT) {
vty_out(vty,
"%% Only default BGP instance can use 'table-direct'\n");
return CMD_WARNING_CONFIG_FAILED;
}
if (table_id == RT_TABLE_MAIN || table_id == RT_TABLE_LOCAL) {
vty_out(vty,
"%% 'table-direct', can not use %lu routing table\n",
table_id);
return CMD_WARNING_CONFIG_FAILED;
}

red = bgp_redist_add(bgp, AFI_IP6, ZEBRA_ROUTE_TABLE_DIRECT, table_id);
if (rmap)
changed = bgp_redistribute_rmap_set(red, rmap, route_map);
if (metric)
changed |= bgp_redistribute_metric_set(bgp, red, AFI_IP6,
ZEBRA_ROUTE_TABLE_DIRECT,
metric_val);
return bgp_redistribute_set(bgp, AFI_IP6, ZEBRA_ROUTE_TABLE_DIRECT,
table_id, changed);
}

DEFPY(no_bgp_redistribute_ipv6_table, no_bgp_redistribute_ipv6_table_cmd,
"no redistribute table-direct (1-65535)$table_id [{metric (0-4294967295)|route-map WORD}]",
NO_STR
"Redistribute information from another routing protocol\n"
"Non-main Kernel Routing Table - Direct\n"
"Table ID\n"
"Metric for redistributed routes\n"
"Default metric\n"
"Route map reference\n"
"Pointer to route-map entries\n")
{
VTY_DECLVAR_CONTEXT(bgp, bgp);

if (bgp->vrf_id != VRF_DEFAULT) {
vty_out(vty,
"%% Only default BGP instance can use 'table-direct'\n");
return CMD_WARNING_CONFIG_FAILED;
}
if (table_id == RT_TABLE_MAIN || table_id == RT_TABLE_LOCAL) {
vty_out(vty,
"%% 'table-direct', can not use %lu routing table\n",
table_id);
return CMD_WARNING_CONFIG_FAILED;
}

bgp_redistribute_unset(bgp, AFI_IP6, ZEBRA_ROUTE_TABLE_DIRECT, table_id);
return CMD_SUCCESS;
}

DEFUN (bgp_redistribute_ipv6_metric_rmap,
bgp_redistribute_ipv6_metric_rmap_cmd,
"redistribute " FRR_IP6_REDIST_STR_BGPD " metric (0-4294967295) route-map RMAP_NAME",
Expand Down Expand Up @@ -21294,6 +21364,8 @@ void bgp_vty_init(void)
install_element(BGP_IPV6_NODE, &bgp_redistribute_ipv6_metric_cmd);
install_element(BGP_IPV6_NODE, &bgp_redistribute_ipv6_rmap_metric_cmd);
install_element(BGP_IPV6_NODE, &bgp_redistribute_ipv6_metric_rmap_cmd);
install_element(BGP_IPV6_NODE, &bgp_redistribute_ipv6_table_cmd);
install_element(BGP_IPV6_NODE, &no_bgp_redistribute_ipv6_table_cmd);

/* import|export vpn [route-map RMAP_NAME] */
install_element(BGP_IPV4_NODE, &bgp_imexport_vpn_cmd);
Expand Down

0 comments on commit a67ff9c

Please sign in to comment.