From 06dc900efa69bbebe1cff59112b4cfd40ed6b3b5 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. (cherry picked from commit 3f504b892b92f54087feeb3fb35e3938567d7fa0) --- 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 97c6848717..71ecaf4abf 100644 --- a/src/network/networkd-setlink.c +++ b/src/network/networkd-setlink.c @@ -230,7 +230,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; } @@ -254,7 +254,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 4b5ba622fa..0a5ba11f89 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 989020e0c6..37d2151a8d 100755 --- a/test/test-network/systemd-networkd-tests.py +++ b/test/test-network/systemd-networkd-tests.py @@ -3892,8 +3892,8 @@ class NetworkdBridgeTests(unittest.TestCase, Utilities): self.assertEqual(read_bridge_port_attr('bridge99', 'dummy98', 'neigh_suppress'), '1') self.assertEqual(read_bridge_port_attr('bridge99', 'dummy98', 'learning'), '0') self.assertEqual(read_bridge_port_attr('bridge99', 'dummy98', 'priority'), '23') - self.assertEqual(read_bridge_port_attr('bridge99', 'dummy98', 'bpdu_guard'), '1') - self.assertEqual(read_bridge_port_attr('bridge99', 'dummy98', 'root_block'), '1') + self.assertEqual(read_bridge_port_attr('bridge99', 'dummy98', 'bpdu_guard'), '0') + self.assertEqual(read_bridge_port_attr('bridge99', 'dummy98', 'root_block'), '0') def test_bridge_property(self): copy_unit_to_networkd_unit_path('11-dummy.netdev', '12-dummy.netdev', '26-bridge.netdev', @@ -3931,8 +3931,8 @@ class NetworkdBridgeTests(unittest.TestCase, Utilities): self.assertEqual(read_bridge_port_attr('bridge99', 'dummy98', 'neigh_suppress'), '1') self.assertEqual(read_bridge_port_attr('bridge99', 'dummy98', 'learning'), '0') self.assertEqual(read_bridge_port_attr('bridge99', 'dummy98', 'priority'), '23') - self.assertEqual(read_bridge_port_attr('bridge99', 'dummy98', 'bpdu_guard'), '1') - self.assertEqual(read_bridge_port_attr('bridge99', 'dummy98', 'root_block'), '1') + self.assertEqual(read_bridge_port_attr('bridge99', 'dummy98', 'bpdu_guard'), '0') + self.assertEqual(read_bridge_port_attr('bridge99', 'dummy98', 'root_block'), '0') output = check_output('bridge -d link show test1') print(output)