Skip to content

Commit

Permalink
cnetlink: only check bridge for vlan_filtering on creation
Browse files Browse the repository at this point in the history
We don't need to check for vlan_filtering being enabled every time we
attach a port to the bridge, only on the first attachement of a port to
the bridge.

We don't handle vlan_filtering state changes, so even if it was disabled
later, we wouldn't be able to do anything about it. So let's only check
the state once when populating cnetlink::bridge.

Fixes: f93b9b5 ("cnetlink: just ignore bridges with unsupported configuration")
Signed-off-by: Jonas Gorski <[email protected]>
  • Loading branch information
KanjiMonster committed Apr 25, 2024
1 parent 1966d9a commit dd904ef
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions src/netlink/cnetlink.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1292,7 +1292,6 @@ void cnetlink::link_created(rtnl_link *link) noexcept {
case LT_BRIDGE_SLAVE: // a new bridge slave was created
try {
auto master = rtnl_link_get_master(link);
uint8_t vlan_filtering = 0;

// check for new bridge slaves
if (master == 0) {
Expand Down Expand Up @@ -1321,22 +1320,23 @@ void cnetlink::link_created(rtnl_link *link) noexcept {
auto br_link = get_link_by_ifindex(master);
LOG(INFO) << __FUNCTION__ << ": using bridge " << br_link.get();

// we only support vlan aware bridges
if (rtnl_link_bridge_get_vlan_filtering(br_link.get(), &vlan_filtering) <
0 ||
vlan_filtering != 1) {
LOG(WARNING)
<< __FUNCTION__
<< ": unsupported bridge: configured with vlan_filtering 0";
ignored_bridges.insert(master);
return;
}

bool new_bridge = false;
// slave interface
// use only the first bridge an interface is attached to
// XXX TODO more bridges!
if (bridge == nullptr) {
uint8_t vlan_filtering = 0;

// we only support vlan aware bridges
if (rtnl_link_bridge_get_vlan_filtering(br_link.get(),
&vlan_filtering) < 0 ||
vlan_filtering != 1) {
LOG(WARNING)
<< __FUNCTION__
<< ": unsupported bridge: configured with vlan_filtering 0";
ignored_bridges.insert(master);
return;
}
bridge = new nl_bridge(this->swi, port_man, this, vlan, vxlan);
bridge->set_bridge_interface(br_link.get());
vxlan->register_bridge(bridge);
Expand Down

0 comments on commit dd904ef

Please sign in to comment.