mirror of
https://github.com/systemd/systemd.git
synced 2025-01-09 01:18:19 +03:00
networkd: Replace existing objects instead of doing nothing if they exist
Currently, if for example a traffic control object already exist, networkd will silently do nothing, even if the settings in the network file for the traffic control object have changed. Let's instead replace the object if it already exists so that new settings from the network file are applied as expected. Fixes #31226
This commit is contained in:
parent
304e2419c7
commit
21d9eeb5e6
@ -892,7 +892,7 @@ int sd_rtnl_message_new_addrlabel(
|
||||
return r;
|
||||
|
||||
if (nlmsg_type == RTM_NEWADDRLABEL)
|
||||
(*ret)->hdr->nlmsg_flags |= NLM_F_CREATE | NLM_F_EXCL;
|
||||
(*ret)->hdr->nlmsg_flags |= NLM_F_CREATE | NLM_F_REPLACE;
|
||||
|
||||
addrlabel = NLMSG_DATA((*ret)->hdr);
|
||||
|
||||
@ -1143,7 +1143,7 @@ int sd_rtnl_message_new_traffic_control(
|
||||
return r;
|
||||
|
||||
if (IN_SET(nlmsg_type, RTM_NEWQDISC, RTM_NEWTCLASS))
|
||||
(*ret)->hdr->nlmsg_flags |= NLM_F_CREATE | NLM_F_EXCL;
|
||||
(*ret)->hdr->nlmsg_flags |= NLM_F_CREATE | NLM_F_REPLACE;
|
||||
|
||||
tcm = NLMSG_DATA((*ret)->hdr);
|
||||
tcm->tcm_ifindex = ifindex;
|
||||
@ -1212,7 +1212,7 @@ int sd_rtnl_message_new_mdb(
|
||||
return r;
|
||||
|
||||
if (nlmsg_type == RTM_NEWMDB)
|
||||
(*ret)->hdr->nlmsg_flags |= NLM_F_CREATE | NLM_F_EXCL;
|
||||
(*ret)->hdr->nlmsg_flags |= NLM_F_CREATE | NLM_F_REPLACE;
|
||||
|
||||
bpm = NLMSG_DATA((*ret)->hdr);
|
||||
bpm->family = AF_BRIDGE;
|
||||
|
@ -4489,6 +4489,17 @@ class NetworkdTCTests(unittest.TestCase, Utilities):
|
||||
self.assertIn('rtt 1s', output)
|
||||
self.assertIn('ack-filter-aggressive', output)
|
||||
|
||||
# Test for replacing existing qdisc. See #31226.
|
||||
with open(os.path.join(network_unit_dir, '25-qdisc-cake.network'), mode='a', encoding='utf-8') as f:
|
||||
f.write('Bandwidth=250M\n')
|
||||
|
||||
networkctl_reload()
|
||||
self.wait_online('dummy98:routable')
|
||||
|
||||
output = check_output('tc qdisc show dev dummy98')
|
||||
print(output)
|
||||
self.assertIn('bandwidth 250Mbit', output)
|
||||
|
||||
@expectedFailureIfModuleIsNotAvailable('sch_codel')
|
||||
def test_qdisc_codel(self):
|
||||
copy_network_unit('25-qdisc-codel.network', '12-dummy.netdev')
|
||||
|
Loading…
Reference in New Issue
Block a user