diff options
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/vrf.c | 12 | ||||
| -rw-r--r-- | lib/vrf.h | 2 | ||||
| -rw-r--r-- | lib/zclient.c | 2 |
3 files changed, 12 insertions, 4 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 b879326d71..beb3ca4f34 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); } |
