]> git.puffer.fish Git - matthieu/frr.git/commitdiff
bgpd: add redistribute table-direct command for ipv6-unicast
authorPhilippe Guibert <philippe.guibert@6wind.com>
Mon, 18 Sep 2023 09:24:42 +0000 (11:24 +0200)
committerton31337 <3352707+ton31337@users.noreply.github.com>
Tue, 16 Apr 2024 15:12:58 +0000 (15:12 +0000)
The 'table-direct' redistribute command is available for ipv4 unicast but
not for ipv6 unicast.

Add the command to ipv6 unicast as well.

Fixes: b6367f8460 ("bgpd: add redistribute table-direct support")
Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com>
bgpd/bgp_vty.c

index 9faba65a5886d665dc99dcabbc017a6534966528..05d3c097b7956df08ca936eb2ce0e47bfd2eb966 100644 (file)
@@ -17711,6 +17711,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",
@@ -21368,6 +21438,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);