summaryrefslogtreecommitdiff
path: root/ospfd/ospf_vty.c
diff options
context:
space:
mode:
authorIgor Ryzhov <iryzhov@nfware.com>2021-05-05 19:26:19 +0300
committerIgor Ryzhov <iryzhov@nfware.com>2021-05-05 19:31:22 +0300
commit7bced643b977e48bc36791614c949ddf19bc97a1 (patch)
tree0148ac46b87388d552f4499987d8299604446a20 /ospfd/ospf_vty.c
parentde11c1bc24d4c729ed715fd5fddc0478d7d6d466 (diff)
ospfd: fix redistribution config when vrf doesn't exist
Currently ospfd relies on vrf bitmaps in zclient to check that the redistribution is configured. This doesn't work when the VRF for OSPF instance doesn't exist yet, because vrf bitmaps ignore VRF_UNKNOWN id. Because of this, the following problems occur when the VRF doesn't exist: - repeated "redistribute smth" command is processed as a first-time instead of an update - "no redistribute smth" doesn't work at all This commit fixes both issues by relying on internal redistribution config instead of zclient vrf bitmaps. Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
Diffstat (limited to 'ospfd/ospf_vty.c')
-rw-r--r--ospfd/ospf_vty.c31
1 files changed, 26 insertions, 5 deletions
diff --git a/ospfd/ospf_vty.c b/ospfd/ospf_vty.c
index 57ef6029ad..50943c4ccf 100644
--- a/ospfd/ospf_vty.c
+++ b/ospfd/ospf_vty.c
@@ -9111,14 +9111,13 @@ DEFUN (ospf_redistribute_source,
int metric = -1;
struct ospf_redist *red;
int idx = 0;
+ bool update = false;
/* Get distribute source. */
source = proto_redistnum(AFI_IP, argv[idx_protocol]->text);
if (source < 0)
return CMD_WARNING_CONFIG_FAILED;
- red = ospf_redist_add(ospf, source, 0);
-
/* Get metric value. */
if (argv_find(argv, argc, "(0-16777214)", &idx)) {
if (!str2metric(argv[idx]->arg, &metric))
@@ -9131,13 +9130,25 @@ DEFUN (ospf_redistribute_source,
return CMD_WARNING_CONFIG_FAILED;
}
idx = 1;
+
+ red = ospf_redist_lookup(ospf, source, 0);
+ if (!red)
+ red = ospf_redist_add(ospf, source, 0);
+ else
+ update = true;
+
/* Get route-map */
if (argv_find(argv, argc, "WORD", &idx)) {
ospf_routemap_set(red, argv[idx]->arg);
} else
ospf_routemap_unset(red);
- return ospf_redistribute_set(ospf, source, 0, type, metric);
+ if (update)
+ return ospf_redistribute_update(ospf, red, source, 0, type,
+ metric);
+ else
+ return ospf_redistribute_set(ospf, red, source, 0, type,
+ metric);
}
DEFUN (no_ospf_redistribute_source,
@@ -9195,6 +9206,7 @@ DEFUN (ospf_redistribute_instance_source,
int metric = -1;
unsigned short instance;
struct ospf_redist *red;
+ bool update = false;
source = proto_redistnum(AFI_IP, argv[idx_ospf_table]->text);
@@ -9227,7 +9239,11 @@ DEFUN (ospf_redistribute_instance_source,
if (!str2metric_type(argv[idx + 1]->arg, &type))
return CMD_WARNING_CONFIG_FAILED;
- red = ospf_redist_add(ospf, source, instance);
+ red = ospf_redist_lookup(ospf, source, instance);
+ if (!red)
+ red = ospf_redist_add(ospf, source, instance);
+ else
+ update = true;
idx = 3;
if (argv_find(argv, argc, "route-map", &idx))
@@ -9235,7 +9251,12 @@ DEFUN (ospf_redistribute_instance_source,
else
ospf_routemap_unset(red);
- return ospf_redistribute_set(ospf, source, instance, type, metric);
+ if (update)
+ return ospf_redistribute_update(ospf, red, source, instance,
+ type, metric);
+ else
+ return ospf_redistribute_set(ospf, red, source, instance, type,
+ metric);
}
DEFUN (no_ospf_redistribute_instance_source,