summaryrefslogtreecommitdiff
path: root/lib/vrf.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/vrf.c')
-rw-r--r--lib/vrf.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/lib/vrf.c b/lib/vrf.c
index 229f19f29a..862a3da067 100644
--- a/lib/vrf.c
+++ b/lib/vrf.c
@@ -176,6 +176,24 @@ struct vrf *vrf_get(vrf_id_t vrf_id, const char *name)
name, vrf_id, vrf->vrf_id);
return NULL;
}
+ /* look for duplicates. case is followine one:
+ * - a vrf is configured per name -> vrfA
+ * - netlink discovery creates a vrf with vrf_id ->vrfB
+ * - then, netlink discovers vrf, and associated vrf_id and name
+ * -> so vrfA and vrfB must be merged
+ */
+ if (vrf && vrf_id != VRF_UNKNOWN
+ && vrf->vrf_id == VRF_UNKNOWN) {
+ struct vrf *vrf2 = vrf_lookup_by_id(vrf_id);
+ struct interface *ifp;
+
+ if (vrf2 && !vrf2->name && vrf2 != vrf) {
+ /* move vrf2 context to vrf */
+ FOR_ALL_INTERFACES (vrf2, ifp)
+ if_update_to_new_vrf(ifp, vrf);
+ vrf_delete(vrf2);
+ }
+ }
/* Try to find VRF both by ID and name */
if (!vrf && vrf_id != VRF_UNKNOWN)
vrf = vrf_lookup_by_id(vrf_id);