From b8326a7d5a25a67e5405e592c800a07312991ca9 Mon Sep 17 00:00:00 2001 From: Jonas Gorski Date: Tue, 20 Aug 2024 15:31:47 +0200 Subject: [PATCH] nl_l3::del_l3_neigh_egress(): remove created VLAN as well In add_l3_neigh_egress() we add a VLAN (reference), but we never remove it in del_l3_neigh_egress(). This creates a reference imbalance, and causes the vlan to be never deleted once there was a neighbor on an interface. Fix this by removing the VLAN on removal as well. Signed-off-by: Jonas Gorski --- src/netlink/nl_l3.cc | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/netlink/nl_l3.cc b/src/netlink/nl_l3.cc index a52a2d24..1fa3c491 100644 --- a/src/netlink/nl_l3.cc +++ b/src/netlink/nl_l3.cc @@ -683,6 +683,7 @@ int nl_l3::del_l3_neigh_egress(struct rtnl_neigh *n) { return -EINVAL; uint16_t vid = vlan->get_vid(link.get()); + auto tagged = !!rtnl_link_is_vlan(link.get()); auto s_mac = rtnl_link_get_addr(link.get()); if (nl->is_bridge_interface(ifindex)) { @@ -714,6 +715,7 @@ int nl_l3::del_l3_neigh_egress(struct rtnl_neigh *n) { } ifindex = nl->get_ifindex_by_port_id(portid); + link = nl->get_link_by_ifindex(ifindex); } } @@ -726,8 +728,7 @@ int nl_l3::del_l3_neigh_egress(struct rtnl_neigh *n) { << ": failed to remove l3 egress ifindex=" << ifindex << " vid=" << vid; } - - return rv; + return vlan->remove_vlan(link, vid, tagged); } int nl_l3::add_l3_neigh(struct rtnl_neigh *n) {