summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/zclient.c7
-rw-r--r--lib/zclient.h6
-rw-r--r--tests/topotests/zebra_rib/r1/import_mrib_table_2.json8
-rw-r--r--tests/topotests/zebra_rib/r1/import_mrib_table_3.json10
-rw-r--r--tests/topotests/zebra_rib/r1/import_mrib_table_4.json8
-rw-r--r--tests/topotests/zebra_rib/r1/import_table_2.json8
-rw-r--r--tests/topotests/zebra_rib/r1/import_table_3.json10
-rw-r--r--tests/topotests/zebra_rib/r1/import_table_4.json8
-rw-r--r--zebra/zebra_vrf.c12
9 files changed, 48 insertions, 29 deletions
diff --git a/lib/zclient.c b/lib/zclient.c
index f0476867be..bdb62befb9 100644
--- a/lib/zclient.c
+++ b/lib/zclient.c
@@ -1362,6 +1362,8 @@ int zapi_route_encode(uint8_t cmd, struct stream *s, struct zapi_route *api)
stream_putc(s, api->type);
stream_putw(s, api->instance);
+ if (CHECK_FLAG(api->message, ZAPI_MESSAGE_TABLEID))
+ SET_FLAG(api->flags, ZEBRA_FLAG_TABLEID);
stream_putl(s, api->flags);
stream_putl(s, api->message);
@@ -1421,6 +1423,8 @@ int zapi_route_encode(uint8_t cmd, struct stream *s, struct zapi_route *api)
return -1;
}
+ if (CHECK_FLAG(api->message, ZAPI_MESSAGE_TABLEID))
+ SET_FLAG(api->flags, ZEBRA_FLAG_TABLEID);
if (zapi_nexthop_encode(s, api_nh, api->flags,
api->message)
!= 0)
@@ -1460,6 +1464,9 @@ int zapi_route_encode(uint8_t cmd, struct stream *s, struct zapi_route *api)
return -1;
}
+ if (CHECK_FLAG(api->message, ZAPI_MESSAGE_TABLEID))
+ SET_FLAG(api->flags, ZEBRA_FLAG_TABLEID);
+
if (zapi_nexthop_encode(s, api_nh, api->flags,
api->message)
!= 0)
diff --git a/lib/zclient.h b/lib/zclient.h
index 43521d6e2e..8719af1d03 100644
--- a/lib/zclient.h
+++ b/lib/zclient.h
@@ -578,6 +578,12 @@ struct zapi_route {
* kernel (NLM_F_APPEND at the very least )
*/
#define ZEBRA_FLAG_OUTOFSYNC 0x400
+/*
+ * This flag lets us know that the route entry is
+ * associated to the table ID and must remain when the
+ * table ID is de-associated from a VRF.
+ */
+#define ZEBRA_FLAG_TABLEID 0x800
/* The older XXX_MESSAGE flags live here */
uint32_t message;
diff --git a/tests/topotests/zebra_rib/r1/import_mrib_table_2.json b/tests/topotests/zebra_rib/r1/import_mrib_table_2.json
index 61aaaede6e..03e4163269 100644
--- a/tests/topotests/zebra_rib/r1/import_mrib_table_2.json
+++ b/tests/topotests/zebra_rib/r1/import_mrib_table_2.json
@@ -68,7 +68,7 @@
"installed": true,
"table": 254,
"internalStatus": 16,
- "internalFlags": 9,
+ "internalFlags": 2057,
"nexthops": [
{
"flags": 3,
@@ -97,7 +97,7 @@
"installed": true,
"table": 254,
"internalStatus": 16,
- "internalFlags": 9,
+ "internalFlags": 2057,
"nexthops": [
{
"flags": 3,
@@ -126,7 +126,7 @@
"installed": true,
"table": 254,
"internalStatus": 16,
- "internalFlags": 9,
+ "internalFlags": 2057,
"nexthops": [
{
"flags": 3,
@@ -155,7 +155,7 @@
"installed": true,
"table": 254,
"internalStatus": 16,
- "internalFlags": 9,
+ "internalFlags": 2057,
"nexthops": [
{
"flags": 3,
diff --git a/tests/topotests/zebra_rib/r1/import_mrib_table_3.json b/tests/topotests/zebra_rib/r1/import_mrib_table_3.json
index 27a0b9f264..dd1774cd84 100644
--- a/tests/topotests/zebra_rib/r1/import_mrib_table_3.json
+++ b/tests/topotests/zebra_rib/r1/import_mrib_table_3.json
@@ -68,7 +68,7 @@
"installed": true,
"table": 254,
"internalStatus": 16,
- "internalFlags": 9,
+ "internalFlags": 2057,
"nexthops": [
{
"flags": 3,
@@ -97,7 +97,7 @@
"installed": true,
"table": 254,
"internalStatus": 16,
- "internalFlags": 9,
+ "internalFlags": 2057,
"nexthops": [
{
"flags": 3,
@@ -126,7 +126,7 @@
"installed": true,
"table": 254,
"internalStatus": 16,
- "internalFlags": 9,
+ "internalFlags": 2057,
"nexthops": [
{
"flags": 3,
@@ -155,7 +155,7 @@
"installed": true,
"table": 254,
"internalStatus": 16,
- "internalFlags": 9,
+ "internalFlags": 2057,
"nexthops": [
{
"flags": 3,
@@ -238,7 +238,7 @@
"installed": true,
"table": 254,
"internalStatus": 16,
- "internalFlags": 9,
+ "internalFlags": 2057,
"nexthops": [
{
"flags": 3,
diff --git a/tests/topotests/zebra_rib/r1/import_mrib_table_4.json b/tests/topotests/zebra_rib/r1/import_mrib_table_4.json
index 5a8f0eecd5..9a318f9f00 100644
--- a/tests/topotests/zebra_rib/r1/import_mrib_table_4.json
+++ b/tests/topotests/zebra_rib/r1/import_mrib_table_4.json
@@ -68,7 +68,7 @@
"installed": true,
"table": 254,
"internalStatus": 16,
- "internalFlags": 9,
+ "internalFlags": 2057,
"nexthops": [
{
"flags": 3,
@@ -97,7 +97,7 @@
"installed": true,
"table": 254,
"internalStatus": 16,
- "internalFlags": 9,
+ "internalFlags": 2057,
"nexthops": [
{
"flags": 3,
@@ -126,7 +126,7 @@
"installed": true,
"table": 254,
"internalStatus": 16,
- "internalFlags": 9,
+ "internalFlags": 2057,
"nexthops": [
{
"flags": 3,
@@ -155,7 +155,7 @@
"installed": true,
"table": 254,
"internalStatus": 16,
- "internalFlags": 9,
+ "internalFlags": 2057,
"nexthops": [
{
"flags": 3,
diff --git a/tests/topotests/zebra_rib/r1/import_table_2.json b/tests/topotests/zebra_rib/r1/import_table_2.json
index 61aaaede6e..03e4163269 100644
--- a/tests/topotests/zebra_rib/r1/import_table_2.json
+++ b/tests/topotests/zebra_rib/r1/import_table_2.json
@@ -68,7 +68,7 @@
"installed": true,
"table": 254,
"internalStatus": 16,
- "internalFlags": 9,
+ "internalFlags": 2057,
"nexthops": [
{
"flags": 3,
@@ -97,7 +97,7 @@
"installed": true,
"table": 254,
"internalStatus": 16,
- "internalFlags": 9,
+ "internalFlags": 2057,
"nexthops": [
{
"flags": 3,
@@ -126,7 +126,7 @@
"installed": true,
"table": 254,
"internalStatus": 16,
- "internalFlags": 9,
+ "internalFlags": 2057,
"nexthops": [
{
"flags": 3,
@@ -155,7 +155,7 @@
"installed": true,
"table": 254,
"internalStatus": 16,
- "internalFlags": 9,
+ "internalFlags": 2057,
"nexthops": [
{
"flags": 3,
diff --git a/tests/topotests/zebra_rib/r1/import_table_3.json b/tests/topotests/zebra_rib/r1/import_table_3.json
index 27a0b9f264..dd1774cd84 100644
--- a/tests/topotests/zebra_rib/r1/import_table_3.json
+++ b/tests/topotests/zebra_rib/r1/import_table_3.json
@@ -68,7 +68,7 @@
"installed": true,
"table": 254,
"internalStatus": 16,
- "internalFlags": 9,
+ "internalFlags": 2057,
"nexthops": [
{
"flags": 3,
@@ -97,7 +97,7 @@
"installed": true,
"table": 254,
"internalStatus": 16,
- "internalFlags": 9,
+ "internalFlags": 2057,
"nexthops": [
{
"flags": 3,
@@ -126,7 +126,7 @@
"installed": true,
"table": 254,
"internalStatus": 16,
- "internalFlags": 9,
+ "internalFlags": 2057,
"nexthops": [
{
"flags": 3,
@@ -155,7 +155,7 @@
"installed": true,
"table": 254,
"internalStatus": 16,
- "internalFlags": 9,
+ "internalFlags": 2057,
"nexthops": [
{
"flags": 3,
@@ -238,7 +238,7 @@
"installed": true,
"table": 254,
"internalStatus": 16,
- "internalFlags": 9,
+ "internalFlags": 2057,
"nexthops": [
{
"flags": 3,
diff --git a/tests/topotests/zebra_rib/r1/import_table_4.json b/tests/topotests/zebra_rib/r1/import_table_4.json
index 5a8f0eecd5..9a318f9f00 100644
--- a/tests/topotests/zebra_rib/r1/import_table_4.json
+++ b/tests/topotests/zebra_rib/r1/import_table_4.json
@@ -68,7 +68,7 @@
"installed": true,
"table": 254,
"internalStatus": 16,
- "internalFlags": 9,
+ "internalFlags": 2057,
"nexthops": [
{
"flags": 3,
@@ -97,7 +97,7 @@
"installed": true,
"table": 254,
"internalStatus": 16,
- "internalFlags": 9,
+ "internalFlags": 2057,
"nexthops": [
{
"flags": 3,
@@ -126,7 +126,7 @@
"installed": true,
"table": 254,
"internalStatus": 16,
- "internalFlags": 9,
+ "internalFlags": 2057,
"nexthops": [
{
"flags": 3,
@@ -155,7 +155,7 @@
"installed": true,
"table": 254,
"internalStatus": 16,
- "internalFlags": 9,
+ "internalFlags": 2057,
"nexthops": [
{
"flags": 3,
diff --git a/zebra/zebra_vrf.c b/zebra/zebra_vrf.c
index faafcf7892..d652c57388 100644
--- a/zebra/zebra_vrf.c
+++ b/zebra/zebra_vrf.c
@@ -191,13 +191,19 @@ static void zebra_vrf_disable_update_vrfid(struct zebra_vrf *zvrf, afi_t afi, sa
/* Assign the kernel route entries to the default VRF,
* even though they are not actually owned by it.
*
- * Remove route nodes that have been created by FRR daemons.
- * They are not needed if the VRF is disabled.
+ * Remove route nodes that were created by FRR daemons,
+ * unless they are associated with the table rather than the VRF.
+ * Routes associated with the VRF are not needed once the VRF is
+ * disabled.
*/
rn_delete = true;
RNODE_FOREACH_RE_SAFE (rn, re, nre) {
- if (re->type == ZEBRA_ROUTE_KERNEL) {
+ if (re->type == ZEBRA_ROUTE_KERNEL ||
+ CHECK_FLAG(re->flags, ZEBRA_FLAG_TABLEID)) {
nexthop_vrf_update(rn, re, VRF_DEFAULT);
+ if (CHECK_FLAG(re->flags, ZEBRA_FLAG_TABLEID))
+ /* reinstall routes */
+ rib_install_kernel(rn, re, NULL);
rn_delete = false;
} else
rib_unlink(rn, re);