summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorPhilippe Guibert <philippe.guibert@6wind.com>2018-03-20 10:59:48 +0100
committerPhilippe Guibert <philippe.guibert@6wind.com>2018-04-13 16:40:32 +0200
commit0c2bac388029e12e4c21177cda02e72712f28efb (patch)
treea47da6a40357519191846aba4d09b694621187ca /lib
parentMerge pull request #2039 from qlyoung/docuser (diff)
downloadfrr-0c2bac388029e12e4c21177cda02e72712f28efb.tar.xz
frr-0c2bac388029e12e4c21177cda02e72712f28efb.zip
lib: a vrf is searched first by its name, than its vrf id
Because at startup, remote daemons attempt to create default VRF, the VRF_ID may be set to unknown. In that case, an event will be triggered later by zebra to inform remote daemon that the vrf id of that VRF has changed to valid value. In that case, two instances of default VRF must not be created. By looking first at vrf name, this avoids having two instances. Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
Diffstat (limited to 'lib')
-rw-r--r--lib/vrf.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/lib/vrf.c b/lib/vrf.c
index 1ed96cd0a..8593cf289 100644
--- a/lib/vrf.c
+++ b/lib/vrf.c
@@ -159,11 +159,13 @@ struct vrf *vrf_get(vrf_id_t vrf_id, const char *name)
if (!name && vrf_id == VRF_UNKNOWN)
return NULL;
+ /* attempt to find already available VRF
+ */
+ if (name)
+ vrf = vrf_lookup_by_name(name);
/* Try to find VRF both by ID and name */
- if (vrf_id != VRF_UNKNOWN)
+ if (!vrf && vrf_id != VRF_UNKNOWN)
vrf = vrf_lookup_by_id(vrf_id);
- if (!vrf && name)
- vrf = vrf_lookup_by_name(name);
if (vrf == NULL) {
vrf = XCALLOC(MTYPE_VRF, sizeof(struct vrf));