summaryrefslogtreecommitdiffstats
path: root/bgpd
diff options
context:
space:
mode:
authorRuss White <russ@riw.us>2023-10-31 18:23:57 +0100
committerGitHub <noreply@github.com>2023-10-31 18:23:57 +0100
commit644386fe4824a9d0fbf02fe7df2de7fcb1fc2173 (patch)
treeb07db5247b8fb99ea74a3b1e1d3b524054e0378b /bgpd
parentMerge pull request #14699 from FRIDM636/no_commands_pcep_msd (diff)
parenttopotests: add bgp_redistribute_table test (diff)
downloadfrr-644386fe4824a9d0fbf02fe7df2de7fcb1fc2173.tar.xz
frr-644386fe4824a9d0fbf02fe7df2de7fcb1fc2173.zip
Merge pull request #14388 from pguibert6WIND/redistribute_table_bgp_2
Redistribute table bgp without copying data to the default routing table
Diffstat (limited to 'bgpd')
-rw-r--r--bgpd/bgp_vty.c129
-rw-r--r--bgpd/bgp_zebra.c3
2 files changed, 108 insertions, 24 deletions
diff --git a/bgpd/bgp_vty.c b/bgpd/bgp_vty.c
index bcf1b81a1..36e216cb1 100644
--- a/bgpd/bgp_vty.c
+++ b/bgpd/bgp_vty.c
@@ -16900,10 +16900,11 @@ ALIAS_HIDDEN(
DEFUN (bgp_redistribute_ipv4_ospf,
bgp_redistribute_ipv4_ospf_cmd,
- "redistribute <ospf|table> (1-65535)",
+ "redistribute <ospf|table|table-direct> (1-65535)",
"Redistribute information from another routing protocol\n"
"Open Shortest Path First (OSPFv2)\n"
"Non-main Kernel Routing Table\n"
+ "Non-main Kernel Routing Table - Direct\n"
"Instance ID/Table ID\n")
{
VTY_DECLVAR_CONTEXT(bgp, bgp);
@@ -16923,7 +16924,18 @@ DEFUN (bgp_redistribute_ipv4_ospf,
argv[idx_ospf_table]->arg);
return CMD_WARNING_CONFIG_FAILED;
}
- protocol = ZEBRA_ROUTE_TABLE;
+ if (strncmp(argv[idx_ospf_table]->arg, "table-direct",
+ strlen("table-direct")) == 0) {
+ protocol = ZEBRA_ROUTE_TABLE_DIRECT;
+ if (instance == RT_TABLE_MAIN ||
+ instance == RT_TABLE_LOCAL) {
+ vty_out(vty,
+ "%% 'table-direct', can not use %u routing table\n",
+ instance);
+ return CMD_WARNING_CONFIG_FAILED;
+ }
+ } else
+ protocol = ZEBRA_ROUTE_TABLE;
}
bgp_redist_add(bgp, AFI_IP, protocol, instance);
@@ -16931,18 +16943,20 @@ DEFUN (bgp_redistribute_ipv4_ospf,
}
ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf, bgp_redistribute_ipv4_ospf_hidden_cmd,
- "redistribute <ospf|table> (1-65535)",
+ "redistribute <ospf|table|table-direct> (1-65535)",
"Redistribute information from another routing protocol\n"
"Open Shortest Path First (OSPFv2)\n"
"Non-main Kernel Routing Table\n"
+ "Non-main Kernel Routing Table - Direct\n"
"Instance ID/Table ID\n")
DEFUN (bgp_redistribute_ipv4_ospf_rmap,
bgp_redistribute_ipv4_ospf_rmap_cmd,
- "redistribute <ospf|table> (1-65535) route-map RMAP_NAME",
+ "redistribute <ospf|table|table-direct> (1-65535) route-map RMAP_NAME",
"Redistribute information from another routing protocol\n"
"Open Shortest Path First (OSPFv2)\n"
"Non-main Kernel Routing Table\n"
+ "Non-main Kernel Routing Table - Direct\n"
"Instance ID/Table ID\n"
"Route map reference\n"
"Pointer to route-map entries\n")
@@ -16958,6 +16972,8 @@ DEFUN (bgp_redistribute_ipv4_ospf_rmap,
struct route_map *route_map =
route_map_lookup_warn_noexist(vty, argv[idx_word]->arg);
+ instance = strtoul(argv[idx_number]->arg, NULL, 10);
+
if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0)
protocol = ZEBRA_ROUTE_OSPF;
else {
@@ -16967,10 +16983,20 @@ DEFUN (bgp_redistribute_ipv4_ospf_rmap,
argv[idx_ospf_table]->arg);
return CMD_WARNING_CONFIG_FAILED;
}
- protocol = ZEBRA_ROUTE_TABLE;
+ if (strncmp(argv[idx_ospf_table]->arg, "table-direct",
+ strlen("table-direct")) == 0) {
+ protocol = ZEBRA_ROUTE_TABLE_DIRECT;
+ if (instance == RT_TABLE_MAIN ||
+ instance == RT_TABLE_LOCAL) {
+ vty_out(vty,
+ "%% 'table-direct', can not use %u routing table\n",
+ instance);
+ return CMD_WARNING_CONFIG_FAILED;
+ }
+ } else
+ protocol = ZEBRA_ROUTE_TABLE;
}
- instance = strtoul(argv[idx_number]->arg, NULL, 10);
red = bgp_redist_add(bgp, AFI_IP, protocol, instance);
changed =
bgp_redistribute_rmap_set(red, argv[idx_word]->arg, route_map);
@@ -16979,20 +17005,22 @@ DEFUN (bgp_redistribute_ipv4_ospf_rmap,
ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf_rmap,
bgp_redistribute_ipv4_ospf_rmap_hidden_cmd,
- "redistribute <ospf|table> (1-65535) route-map RMAP_NAME",
+ "redistribute <ospf|table|table-direct> (1-65535) route-map RMAP_NAME",
"Redistribute information from another routing protocol\n"
"Open Shortest Path First (OSPFv2)\n"
"Non-main Kernel Routing Table\n"
+ "Non-main Kernel Routing Table - Direct\n"
"Instance ID/Table ID\n"
"Route map reference\n"
"Pointer to route-map entries\n")
DEFUN (bgp_redistribute_ipv4_ospf_metric,
bgp_redistribute_ipv4_ospf_metric_cmd,
- "redistribute <ospf|table> (1-65535) metric (0-4294967295)",
+ "redistribute <ospf|table|table-direct> (1-65535) metric (0-4294967295)",
"Redistribute information from another routing protocol\n"
"Open Shortest Path First (OSPFv2)\n"
"Non-main Kernel Routing Table\n"
+ "Non-main Kernel Routing Table - Direct\n"
"Instance ID/Table ID\n"
"Metric for redistributed routes\n"
"Default metric\n")
@@ -17007,6 +17035,8 @@ DEFUN (bgp_redistribute_ipv4_ospf_metric,
int protocol;
bool changed;
+ instance = strtoul(argv[idx_number]->arg, NULL, 10);
+
if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0)
protocol = ZEBRA_ROUTE_OSPF;
else {
@@ -17016,10 +17046,20 @@ DEFUN (bgp_redistribute_ipv4_ospf_metric,
argv[idx_ospf_table]->arg);
return CMD_WARNING_CONFIG_FAILED;
}
- protocol = ZEBRA_ROUTE_TABLE;
+ if (strncmp(argv[idx_ospf_table]->arg, "table-direct",
+ strlen("table-direct")) == 0) {
+ protocol = ZEBRA_ROUTE_TABLE_DIRECT;
+ if (instance == RT_TABLE_MAIN ||
+ instance == RT_TABLE_LOCAL) {
+ vty_out(vty,
+ "%% 'table-direct', can not use %u routing table\n",
+ instance);
+ return CMD_WARNING_CONFIG_FAILED;
+ }
+ } else
+ protocol = ZEBRA_ROUTE_TABLE;
}
- instance = strtoul(argv[idx_number]->arg, NULL, 10);
metric = strtoul(argv[idx_number_2]->arg, NULL, 10);
red = bgp_redist_add(bgp, AFI_IP, protocol, instance);
@@ -17030,20 +17070,22 @@ DEFUN (bgp_redistribute_ipv4_ospf_metric,
ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf_metric,
bgp_redistribute_ipv4_ospf_metric_hidden_cmd,
- "redistribute <ospf|table> (1-65535) metric (0-4294967295)",
+ "redistribute <ospf|table|table-direct> (1-65535) metric (0-4294967295)",
"Redistribute information from another routing protocol\n"
"Open Shortest Path First (OSPFv2)\n"
"Non-main Kernel Routing Table\n"
+ "Non-main Kernel Routing Table - Direct\n"
"Instance ID/Table ID\n"
"Metric for redistributed routes\n"
"Default metric\n")
DEFUN (bgp_redistribute_ipv4_ospf_rmap_metric,
bgp_redistribute_ipv4_ospf_rmap_metric_cmd,
- "redistribute <ospf|table> (1-65535) route-map RMAP_NAME metric (0-4294967295)",
+ "redistribute <ospf|table|table-direct> (1-65535) route-map RMAP_NAME metric (0-4294967295)",
"Redistribute information from another routing protocol\n"
"Open Shortest Path First (OSPFv2)\n"
"Non-main Kernel Routing Table\n"
+ "Non-main Kernel Routing Table - Direct\n"
"Instance ID/Table ID\n"
"Route map reference\n"
"Pointer to route-map entries\n"
@@ -17063,6 +17105,8 @@ DEFUN (bgp_redistribute_ipv4_ospf_rmap_metric,
struct route_map *route_map =
route_map_lookup_warn_noexist(vty, argv[idx_word]->arg);
+ instance = strtoul(argv[idx_number]->arg, NULL, 10);
+
if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0)
protocol = ZEBRA_ROUTE_OSPF;
else {
@@ -17072,10 +17116,20 @@ DEFUN (bgp_redistribute_ipv4_ospf_rmap_metric,
argv[idx_ospf_table]->arg);
return CMD_WARNING_CONFIG_FAILED;
}
- protocol = ZEBRA_ROUTE_TABLE;
+ if (strncmp(argv[idx_ospf_table]->arg, "table-direct",
+ strlen("table-direct")) == 0) {
+ protocol = ZEBRA_ROUTE_TABLE_DIRECT;
+ if (instance == RT_TABLE_MAIN ||
+ instance == RT_TABLE_LOCAL) {
+ vty_out(vty,
+ "%% 'table-direct', can not use %u routing table\n",
+ instance);
+ return CMD_WARNING_CONFIG_FAILED;
+ }
+ } else
+ protocol = ZEBRA_ROUTE_TABLE;
}
- instance = strtoul(argv[idx_number]->arg, NULL, 10);
metric = strtoul(argv[idx_number_2]->arg, NULL, 10);
red = bgp_redist_add(bgp, AFI_IP, protocol, instance);
@@ -17089,10 +17143,11 @@ DEFUN (bgp_redistribute_ipv4_ospf_rmap_metric,
ALIAS_HIDDEN(
bgp_redistribute_ipv4_ospf_rmap_metric,
bgp_redistribute_ipv4_ospf_rmap_metric_hidden_cmd,
- "redistribute <ospf|table> (1-65535) route-map RMAP_NAME metric (0-4294967295)",
+ "redistribute <ospf|table|table-direct> (1-65535) route-map RMAP_NAME metric (0-4294967295)",
"Redistribute information from another routing protocol\n"
"Open Shortest Path First (OSPFv2)\n"
"Non-main Kernel Routing Table\n"
+ "Non-main Kernel Routing Table - Direct\n"
"Instance ID/Table ID\n"
"Route map reference\n"
"Pointer to route-map entries\n"
@@ -17101,10 +17156,11 @@ ALIAS_HIDDEN(
DEFUN (bgp_redistribute_ipv4_ospf_metric_rmap,
bgp_redistribute_ipv4_ospf_metric_rmap_cmd,
- "redistribute <ospf|table> (1-65535) metric (0-4294967295) route-map RMAP_NAME",
+ "redistribute <ospf|table|table-direct> (1-65535) metric (0-4294967295) route-map RMAP_NAME",
"Redistribute information from another routing protocol\n"
"Open Shortest Path First (OSPFv2)\n"
"Non-main Kernel Routing Table\n"
+ "Non-main Kernel Routing Table - Direct\n"
"Instance ID/Table ID\n"
"Metric for redistributed routes\n"
"Default metric\n"
@@ -17124,6 +17180,8 @@ DEFUN (bgp_redistribute_ipv4_ospf_metric_rmap,
struct route_map *route_map =
route_map_lookup_warn_noexist(vty, argv[idx_word]->arg);
+ instance = strtoul(argv[idx_number]->arg, NULL, 10);
+
if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0)
protocol = ZEBRA_ROUTE_OSPF;
else {
@@ -17132,8 +17190,18 @@ DEFUN (bgp_redistribute_ipv4_ospf_metric_rmap,
"%% Only default BGP instance can use '%s'\n",
argv[idx_ospf_table]->arg);
return CMD_WARNING_CONFIG_FAILED;
- }
- protocol = ZEBRA_ROUTE_TABLE;
+ } else if (strncmp(argv[idx_ospf_table]->arg, "table-direct",
+ strlen("table-direct")) == 0) {
+ protocol = ZEBRA_ROUTE_TABLE_DIRECT;
+ if (instance == RT_TABLE_MAIN ||
+ instance == RT_TABLE_LOCAL) {
+ vty_out(vty,
+ "%% 'table-direct', can not use %u routing table\n",
+ instance);
+ return CMD_WARNING_CONFIG_FAILED;
+ }
+ } else
+ protocol = ZEBRA_ROUTE_TABLE;
}
instance = strtoul(argv[idx_number]->arg, NULL, 10);
@@ -17150,10 +17218,11 @@ DEFUN (bgp_redistribute_ipv4_ospf_metric_rmap,
ALIAS_HIDDEN(
bgp_redistribute_ipv4_ospf_metric_rmap,
bgp_redistribute_ipv4_ospf_metric_rmap_hidden_cmd,
- "redistribute <ospf|table> (1-65535) metric (0-4294967295) route-map RMAP_NAME",
+ "redistribute <ospf|table|table-direct> (1-65535) metric (0-4294967295) route-map RMAP_NAME",
"Redistribute information from another routing protocol\n"
"Open Shortest Path First (OSPFv2)\n"
"Non-main Kernel Routing Table\n"
+ "Non-main Kernel Routing Table - Direct\n"
"Instance ID/Table ID\n"
"Metric for redistributed routes\n"
"Default metric\n"
@@ -17162,11 +17231,12 @@ ALIAS_HIDDEN(
DEFUN (no_bgp_redistribute_ipv4_ospf,
no_bgp_redistribute_ipv4_ospf_cmd,
- "no redistribute <ospf|table> (1-65535) [{metric (0-4294967295)|route-map RMAP_NAME}]",
+ "no redistribute <ospf|table|table-direct> (1-65535) [{metric (0-4294967295)|route-map RMAP_NAME}]",
NO_STR
"Redistribute information from another routing protocol\n"
"Open Shortest Path First (OSPFv2)\n"
"Non-main Kernel Routing Table\n"
+ "Non-main Kernel Routing Table - Direct\n"
"Instance ID/Table ID\n"
"Metric for redistributed routes\n"
"Default metric\n"
@@ -17179,6 +17249,8 @@ DEFUN (no_bgp_redistribute_ipv4_ospf,
unsigned short instance;
int protocol;
+ instance = strtoul(argv[idx_number]->arg, NULL, 10);
+
if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0)
protocol = ZEBRA_ROUTE_OSPF;
else {
@@ -17188,21 +17260,32 @@ DEFUN (no_bgp_redistribute_ipv4_ospf,
argv[idx_ospf_table]->arg);
return CMD_WARNING_CONFIG_FAILED;
}
- protocol = ZEBRA_ROUTE_TABLE;
+ if (strncmp(argv[idx_ospf_table]->arg, "table-direct",
+ strlen("table-direct")) == 0) {
+ protocol = ZEBRA_ROUTE_TABLE_DIRECT;
+ if (instance == RT_TABLE_MAIN ||
+ instance == RT_TABLE_LOCAL) {
+ vty_out(vty,
+ "%% 'table-direct', can not use %u routing table\n",
+ instance);
+ return CMD_WARNING_CONFIG_FAILED;
+ }
+ } else
+ protocol = ZEBRA_ROUTE_TABLE;
}
- instance = strtoul(argv[idx_number]->arg, NULL, 10);
bgp_redistribute_unset(bgp, AFI_IP, protocol, instance);
return CMD_SUCCESS;
}
ALIAS_HIDDEN(
no_bgp_redistribute_ipv4_ospf, no_bgp_redistribute_ipv4_ospf_hidden_cmd,
- "no redistribute <ospf|table> (1-65535) [{metric (0-4294967295)|route-map RMAP_NAME}]",
+ "no redistribute <ospf|table|table-direct> (1-65535) [{metric (0-4294967295)|route-map RMAP_NAME}]",
NO_STR
"Redistribute information from another routing protocol\n"
"Open Shortest Path First (OSPFv2)\n"
"Non-main Kernel Routing Table\n"
+ "Non-main Kernel Routing Table - Direct\n"
"Instance ID/Table ID\n"
"Metric for redistributed routes\n"
"Default metric\n"
diff --git a/bgpd/bgp_zebra.c b/bgpd/bgp_zebra.c
index e53416044..ff8a87d76 100644
--- a/bgpd/bgp_zebra.c
+++ b/bgpd/bgp_zebra.c
@@ -2051,7 +2051,8 @@ void bgp_redistribute_unset(struct bgp *bgp, afi_t afi, int type,
struct listnode *node, *nnode;
struct bgp_redist *red;
- if (type != ZEBRA_ROUTE_TABLE || instance != 0)
+ if ((type != ZEBRA_ROUTE_TABLE && type != ZEBRA_ROUTE_TABLE_DIRECT) ||
+ instance != 0)
return _bgp_redistribute_unset(bgp, afi, type, instance);
/* walk over instance */