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 not available under
ipv6 unicast address family. Fix this by adding the 'table-direct'
support under the ipv6 redistribute command.

Fixes: 5694722c8a1a ("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 4, 2024
1 parent 9feb1aa commit d0682fe
Showing 1 changed file with 81 additions and 0 deletions.
81 changes: 81 additions & 0 deletions bgpd/bgp_vty.c
Original file line number Diff line number Diff line change
Expand Up @@ -17679,6 +17679,85 @@ 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) [{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);
int idx_number = 2;
unsigned short table_id;
bool changed = false;
struct route_map *route_map = NULL;
struct bgp_redist *red;

table_id = strtoul(argv[idx_number]->arg, NULL, 10);

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 %u 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);
}

DEFUN(no_bgp_redistribute_ipv6_table, no_bgp_redistribute_ipv6_table_cmd,
"no redistribute table-direct (1-65535) [{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);
int idx_number = 3;
unsigned short table_id;

table_id = strtoul(argv[idx_number]->arg, NULL, 10);

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 %u 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 @@ -21299,6 +21378,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 d0682fe

Please sign in to comment.