summaryrefslogtreecommitdiff
path: root/lib/if.c
diff options
context:
space:
mode:
authorStephen Worley <sworley@cumulusnetworks.com>2019-10-09 19:35:46 -0400
committerStephen Worley <sworley@cumulusnetworks.com>2019-10-09 20:09:49 -0400
commit9685b1e414118391825ad56faa8879d279eebeb6 (patch)
tree88c36e39fa477288b15ac71b758785c6ed9293bc /lib/if.c
parentdb8d54b0981ec5c642da708dcb188d5d6243a5cc (diff)
lib: Don't add/del from name tree if name isnt set
If the name has not been set yet (we were only passed the ifindex in some cases like with master/slave timings) then do not add/del it from the ifname rb tree on the vrf struct. Doing so causes duplicate entries on the tree and infinte loops can happen when iterating over it. Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
Diffstat (limited to 'lib/if.c')
-rw-r--r--lib/if.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/lib/if.c b/lib/if.c
index f2b45512da..590893b68c 100644
--- a/lib/if.c
+++ b/lib/if.c
@@ -221,7 +221,9 @@ void if_update_to_new_vrf(struct interface *ifp, vrf_id_t vrf_id)
/* remove interface from old master vrf list */
old_vrf = vrf_lookup_by_id(ifp->vrf_id);
if (old_vrf) {
- IFNAME_RB_REMOVE(old_vrf, ifp);
+ if (ifp->name[0] != '\0')
+ IFNAME_RB_REMOVE(old_vrf, ifp);
+
if (ifp->ifindex != IFINDEX_INTERNAL)
IFINDEX_RB_REMOVE(old_vrf, ifp);
}
@@ -229,7 +231,9 @@ void if_update_to_new_vrf(struct interface *ifp, vrf_id_t vrf_id)
ifp->vrf_id = vrf_id;
vrf = vrf_get(ifp->vrf_id, NULL);
- IFNAME_RB_INSERT(vrf, ifp);
+ if (ifp->name[0] != '\0')
+ IFNAME_RB_INSERT(vrf, ifp);
+
if (ifp->ifindex != IFINDEX_INTERNAL)
IFINDEX_RB_INSERT(vrf, ifp);