diff options
author | Philippe Guibert <philippe.guibert@6wind.com> | 2019-04-02 18:40:35 +0200 |
---|---|---|
committer | Philippe Guibert <philippe.guibert@6wind.com> | 2019-06-12 08:37:58 +0200 |
commit | 921a85ba8c92eea6e104dea002870e323e5a19b5 (patch) | |
tree | c42a5c6de193adc9c6b4e037a90b7d5a7aa7693a /lib/vrf.c | |
parent | zebra, lib: upon entering interface, create vrf context (diff) | |
download | frr-921a85ba8c92eea6e104dea002870e323e5a19b5.tar.xz frr-921a85ba8c92eea6e104dea002870e323e5a19b5.zip |
zebra, ifp: on netlink discovery, anticipate the vrf creation
there may be cases where the vrf is yet allocated from the vty, and the
discovery process did not make the relationship between the vrf_id and
the name of the vrf. For instance, by parsing an interface belonging to
vrf-id X, it is not sure that vrf-id X and vrfname XX are talking about
the same vrf. For that, lets allocate the vrf, and lets try to detect
there is a duplicate case in vrf, so that the merge can be done without
any impact for the user.
Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
Diffstat (limited to 'lib/vrf.c')
-rw-r--r-- | lib/vrf.c | 18 |
1 files changed, 18 insertions, 0 deletions
@@ -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); |