diff options
author | Igor Ryzhov <iryzhov@nfware.com> | 2021-05-05 18:26:19 +0200 |
---|---|---|
committer | Igor Ryzhov <iryzhov@nfware.com> | 2021-05-05 18:31:22 +0200 |
commit | 7bced643b977e48bc36791614c949ddf19bc97a1 (patch) | |
tree | 0148ac46b87388d552f4499987d8299604446a20 /ospfd/ospf_zebra.c | |
parent | ospfd: deregister vrf from zebra when vrf is disabled (diff) | |
download | frr-7bced643b977e48bc36791614c949ddf19bc97a1.tar.xz frr-7bced643b977e48bc36791614c949ddf19bc97a1.zip |
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_zebra.c')
-rw-r--r-- | ospfd/ospf_zebra.c | 56 |
1 files changed, 22 insertions, 34 deletions
diff --git a/ospfd/ospf_zebra.c b/ospfd/ospf_zebra.c index a2ce4d1ce..2911052da 100644 --- a/ospfd/ospf_zebra.c +++ b/ospfd/ospf_zebra.c @@ -773,45 +773,36 @@ int ospf_is_type_redistributed(struct ospf *ospf, int type, ospf->vrf_id)))); } -int ospf_redistribute_set(struct ospf *ospf, int type, unsigned short instance, - int mtype, int mvalue) +int ospf_redistribute_update(struct ospf *ospf, struct ospf_redist *red, + int type, unsigned short instance, int mtype, + int mvalue) { int force = 0; - struct ospf_redist *red; - - red = ospf_redist_lookup(ospf, type, instance); - if (red == NULL) { - zlog_err( - "Redistribute[%s][%d]: Lookup failed Type[%d] , Metric[%d]", - ospf_redist_string(type), instance, - metric_type(ospf, type, instance), - metric_value(ospf, type, instance)); - return CMD_WARNING_CONFIG_FAILED; + if (mtype != red->dmetric.type) { + red->dmetric.type = mtype; + force = LSA_REFRESH_FORCE; + } + if (mvalue != red->dmetric.value) { + red->dmetric.value = mvalue; + force = LSA_REFRESH_FORCE; } - if (ospf_is_type_redistributed(ospf, type, instance)) { - if (mtype != red->dmetric.type) { - red->dmetric.type = mtype; - force = LSA_REFRESH_FORCE; - } - if (mvalue != red->dmetric.value) { - red->dmetric.value = mvalue; - force = LSA_REFRESH_FORCE; - } - - ospf_external_lsa_refresh_type(ospf, type, instance, force); + ospf_external_lsa_refresh_type(ospf, type, instance, force); - if (IS_DEBUG_OSPF(zebra, ZEBRA_REDISTRIBUTE)) - zlog_debug( - "Redistribute[%s][%d]: Refresh Type[%d], Metric[%d]", - ospf_redist_string(type), instance, - metric_type(ospf, type, instance), - metric_value(ospf, type, instance)); + if (IS_DEBUG_OSPF(zebra, ZEBRA_REDISTRIBUTE)) + zlog_debug( + "Redistribute[%s][%d]: Refresh Type[%d], Metric[%d]", + ospf_redist_string(type), instance, + metric_type(ospf, type, instance), + metric_value(ospf, type, instance)); - return CMD_SUCCESS; - } + return CMD_SUCCESS; +} +int ospf_redistribute_set(struct ospf *ospf, struct ospf_redist *red, int type, + unsigned short instance, int mtype, int mvalue) +{ red->dmetric.type = mtype; red->dmetric.value = mvalue; @@ -838,9 +829,6 @@ int ospf_redistribute_unset(struct ospf *ospf, int type, if (type == zclient->redist_default && instance == zclient->instance) return CMD_SUCCESS; - if (!ospf_is_type_redistributed(ospf, type, instance)) - return CMD_SUCCESS; - zclient_redistribute(ZEBRA_REDISTRIBUTE_DELETE, zclient, AFI_IP, type, instance, ospf->vrf_id); |