Skip to content

Commit

Permalink
nl_l3::del_l3_neigh_egress(): remove created VLAN as well
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
KanjiMonster committed Aug 20, 2024
1 parent 70d828c commit b8326a7
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/netlink/nl_l3.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down Expand Up @@ -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);
}
}

Expand All @@ -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) {
Expand Down

0 comments on commit b8326a7

Please sign in to comment.