diff options
author | Philippe Guibert <philippe.guibert@6wind.com> | 2018-06-22 16:03:11 +0200 |
---|---|---|
committer | Philippe Guibert <philippe.guibert@6wind.com> | 2018-08-28 16:23:50 +0200 |
commit | dd1147028ad9e461644116b68b38f31b26b4bd2d (patch) | |
tree | 3631b6712775918570dd528d985b2bafc0382fb6 /lib | |
parent | lib: set default vrf name at startup (diff) | |
download | frr-dd1147028ad9e461644116b68b38f31b26b4bd2d.tar.xz frr-dd1147028ad9e461644116b68b38f31b26b4bd2d.zip |
lib: protect newly created vrfs against default vrf naming.
Prevent from creating vrf, if the default vrf name is the same as the
vrf to be created.
Also, prevent at startup from creating default vrf with a name already
used in vrf list.
Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/vrf.c | 10 |
1 files changed, 9 insertions, 1 deletions
@@ -39,7 +39,7 @@ /* default VRF ID value used when VRF backend is not NETNS */ #define VRF_DEFAULT_INTERNAL 0 -#define VRF_DEFAULT_NAME_INTERNAL "Default-IP-Routing-Table" +#define VRF_DEFAULT_NAME_INTERNAL "default" DEFINE_MTYPE_STATIC(LIB, VRF, "VRF") DEFINE_MTYPE_STATIC(LIB, VRF_BITMAP, "VRF bit-map") @@ -168,6 +168,13 @@ struct vrf *vrf_get(vrf_id_t vrf_id, const char *name) */ if (name) vrf = vrf_lookup_by_name(name); + if (vrf && vrf_id != VRF_UNKNOWN + && vrf->vrf_id != VRF_UNKNOWN + && vrf->vrf_id != vrf_id) { + zlog_debug("VRF_GET: avoid %s creation(%u), same name exists (%u)", + name, vrf_id, vrf->vrf_id); + return NULL; + } /* Try to find VRF both by ID and name */ if (!vrf && vrf_id != VRF_UNKNOWN) vrf = vrf_lookup_by_id(vrf_id); @@ -888,6 +895,7 @@ void vrf_cmd_init(int (*writefunc)(struct vty *vty), void vrf_set_default_name(const char *default_name) { struct vrf *def_vrf; + struct vrf *vrf_with_default_name = NULL; def_vrf = vrf_lookup_by_id(VRF_DEFAULT); assert(default_name); |