diff options
-rw-r--r-- | lib/vrf.c | 12 | ||||
-rw-r--r-- | lib/vrf.h | 2 | ||||
-rw-r--r-- | lib/zclient.c | 2 | ||||
-rw-r--r-- | zebra/main.c | 2 | ||||
-rw-r--r-- | zebra/zebra_netns_notify.c | 4 |
5 files changed, 15 insertions, 7 deletions
@@ -894,14 +894,20 @@ void vrf_cmd_init(int (*writefunc)(struct vty *vty), } } -void vrf_set_default_name(const char *default_name) +void vrf_set_default_name(const char *default_name, bool force) { struct vrf *def_vrf; struct vrf *vrf_with_default_name = NULL; + static bool def_vrf_forced; def_vrf = vrf_lookup_by_id(VRF_DEFAULT); assert(default_name); - vrf_with_default_name = vrf_lookup_by_name(default_name); + if (def_vrf && !force && def_vrf_forced) { + zlog_debug("VRF: %s, avoid changing name to %s, previously forced (%u)", + def_vrf->name, default_name, + def_vrf->vrf_id); + return; + } if (vrf_with_default_name && vrf_with_default_name != def_vrf) { /* vrf name already used by an other VRF */ zlog_debug("VRF: %s, avoid changing name to %s, same name exists (%u)", @@ -911,6 +917,8 @@ void vrf_set_default_name(const char *default_name) } snprintf(vrf_default_name, VRF_NAMSIZ, "%s", default_name); if (def_vrf) { + if (force) + def_vrf_forced = true; RB_REMOVE(vrf_name_head, &vrfs_by_name, def_vrf); strlcpy(def_vrf->data.l.netns_name, vrf_default_name, NS_NAMSIZ); @@ -236,7 +236,7 @@ extern vrf_id_t vrf_get_default_id(void); /* The default VRF ID */ #define VRF_DEFAULT vrf_get_default_id() -extern void vrf_set_default_name(const char *default_name); +extern void vrf_set_default_name(const char *default_name, bool force); extern const char *vrf_get_default_name(void); #define VRF_DEFAULT_NAME vrf_get_default_name() diff --git a/lib/zclient.c b/lib/zclient.c index b879326d7..beb3ca4f3 100644 --- a/lib/zclient.c +++ b/lib/zclient.c @@ -1370,7 +1370,7 @@ static void zclient_vrf_add(struct zclient *zclient, vrf_id_t vrf_id) memcpy(vrf->data.l.netns_name, data.l.netns_name, NS_NAMSIZ); /* overwrite default vrf */ if (vrf_id == VRF_DEFAULT) - vrf_set_default_name(vrfname_tmp); + vrf_set_default_name(vrfname_tmp, false); vrf_enable(vrf); } diff --git a/zebra/main.c b/zebra/main.c index 5628b5e02..2e92a7838 100644 --- a/zebra/main.c +++ b/zebra/main.c @@ -336,7 +336,7 @@ int main(int argc, char **argv) } break; case 'o': - vrf_set_default_name(optarg); + vrf_set_default_name(optarg, true); break; case 'z': zserv_path = optarg; diff --git a/zebra/zebra_netns_notify.c b/zebra/zebra_netns_notify.c index 4d2aefa23..3f69b9841 100644 --- a/zebra/zebra_netns_notify.c +++ b/zebra/zebra_netns_notify.c @@ -219,7 +219,7 @@ static int zebra_ns_ready_read(struct thread *t) zlog_warn( "NS notify : NS %s is default VRF." " Updating VRF Name", basename(netnspath)); - vrf_set_default_name(basename(netnspath)); + vrf_set_default_name(basename(netnspath), false); return zebra_ns_continue_read(zns_info, 1); } @@ -314,7 +314,7 @@ void zebra_ns_notify_parse(void) zlog_warn( "NS notify : NS %s is default VRF." " Updating VRF Name", dent->d_name); - vrf_set_default_name(dent->d_name); + vrf_set_default_name(dent->d_name, false); continue; } zebra_ns_notify_create_context_from_entry_name(dent->d_name); |