From 3f504b892b92f54087feeb3fb35e3938567d7fa0 Mon Sep 17 00:00:00 2001 From: Yu Watanabe Date: Sat, 13 Aug 2022 05:08:38 +0900 Subject: [PATCH] network/bridge: fix UseBPDU= and AllowPortToBeRoot= Fixes bugs caused by 7f9915f0de67f3a10a4b22810d119da65af8c84a. Fixes #24268. --- src/network/networkd-setlink.c | 4 ++-- test/networkd-test.py | 4 ++-- test/test-network/systemd-networkd-tests.py | 8 ++++---- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/network/networkd-setlink.c b/src/network/networkd-setlink.c index 4c0d3d23c3d..f9d774eee9e 100644 --- a/src/network/networkd-setlink.c +++ b/src/network/networkd-setlink.c @@ -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; } diff --git a/test/networkd-test.py b/test/networkd-test.py index 4b5ba622fa6..0a5ba11f89e 100755 --- a/test/networkd-test.py +++ b/test/networkd-test.py @@ -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.""" diff --git a/test/test-network/systemd-networkd-tests.py b/test/test-network/systemd-networkd-tests.py index ca96f794282..f3ec22aeee4 100755 --- a/test/test-network/systemd-networkd-tests.py +++ b/test/test-network/systemd-networkd-tests.py @@ -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)