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))
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,
int metric = -1;
unsigned short instance;
struct ospf_redist *red;
+ bool update = false;
source = proto_redistnum(AFI_IP, argv[idx_ospf_table]->text);
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))
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,
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;
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);
unsigned short);
extern void ospf_redist_del(struct ospf *, uint8_t, unsigned short);
-extern int ospf_redistribute_set(struct ospf *, int, unsigned short, int, int);
+extern int ospf_redistribute_update(struct ospf *, struct ospf_redist *, int,
+ unsigned short, int, int);
+extern int ospf_redistribute_set(struct ospf *, struct ospf_redist *, int,
+ unsigned short, int, int);
extern int ospf_redistribute_unset(struct ospf *, int, unsigned short);
extern int ospf_redistribute_default_set(struct ospf *, int, int, int);
-extern int ospf_redistribute_default_unset(struct ospf *);
extern int ospf_distribute_list_out_set(struct ospf *, int, const char *);
extern int ospf_distribute_list_out_unset(struct ospf *, int, const char *);
extern void ospf_routemap_set(struct ospf_redist *, const char *);