network/bridge: fix UseBPDU= and AllowPortToBeRoot=

Fixes bugs caused by 7f9915f0de.

Fixes #24268.
This commit is contained in:
Yu Watanabe 2022-08-13 05:08:38 +09:00
parent e3e7185a70
commit 3f504b892b
3 changed files with 8 additions and 8 deletions

View File

@ -232,7 +232,7 @@ static int link_configure_fill_message(
return r;
if (link->network->use_bpdu >= 0) {
r = sd_netlink_message_append_u8(req, IFLA_BRPORT_GUARD, link->network->use_bpdu);
r = sd_netlink_message_append_u8(req, IFLA_BRPORT_GUARD, !link->network->use_bpdu);
if (r < 0)
return r;
}
@ -256,7 +256,7 @@ static int link_configure_fill_message(
}
if (link->network->allow_port_to_be_root >= 0) {
r = sd_netlink_message_append_u8(req, IFLA_BRPORT_PROTECT, link->network->allow_port_to_be_root);
r = sd_netlink_message_append_u8(req, IFLA_BRPORT_PROTECT, !link->network->allow_port_to_be_root);
if (r < 0)
return r;
}

View File

@ -291,8 +291,8 @@ Priority=23
self.assertEqual(self.read_attr('port2', 'brport/path_cost'), '555')
self.assertEqual(self.read_attr('port2', 'brport/multicast_fast_leave'), '1')
self.assertEqual(self.read_attr('port2', 'brport/unicast_flood'), '1')
self.assertEqual(self.read_attr('port2', 'brport/bpdu_guard'), '1')
self.assertEqual(self.read_attr('port2', 'brport/root_block'), '1')
self.assertEqual(self.read_attr('port2', 'brport/bpdu_guard'), '0')
self.assertEqual(self.read_attr('port2', 'brport/root_block'), '0')
class ClientTestBase(NetworkdTestingUtilities):
"""Provide common methods for testing networkd against servers."""

View File

@ -3786,8 +3786,8 @@ class NetworkdBridgeTests(unittest.TestCase, Utilities):
self.check_bridge_port_attr('bridge99', 'dummy98', 'neigh_suppress', '1', allow_enoent=True)
self.check_bridge_port_attr('bridge99', 'dummy98', 'learning', '0')
self.check_bridge_port_attr('bridge99', 'dummy98', 'priority', '23')
self.check_bridge_port_attr('bridge99', 'dummy98', 'bpdu_guard', '1')
self.check_bridge_port_attr('bridge99', 'dummy98', 'root_block', '1')
self.check_bridge_port_attr('bridge99', 'dummy98', 'bpdu_guard', '0')
self.check_bridge_port_attr('bridge99', 'dummy98', 'root_block', '0')
def test_bridge_property(self):
copy_network_unit('11-dummy.netdev', '12-dummy.netdev', '26-bridge.netdev',
@ -3823,8 +3823,8 @@ class NetworkdBridgeTests(unittest.TestCase, Utilities):
self.check_bridge_port_attr('bridge99', 'dummy98', 'neigh_suppress', '1', allow_enoent=True)
self.check_bridge_port_attr('bridge99', 'dummy98', 'learning', '0')
self.check_bridge_port_attr('bridge99', 'dummy98', 'priority', '23')
self.check_bridge_port_attr('bridge99', 'dummy98', 'bpdu_guard', '1')
self.check_bridge_port_attr('bridge99', 'dummy98', 'root_block', '1')
self.check_bridge_port_attr('bridge99', 'dummy98', 'bpdu_guard', '0')
self.check_bridge_port_attr('bridge99', 'dummy98', 'root_block', '0')
output = check_output('bridge -d link show test1')
print(output)