mirror of
https://github.com/systemd/systemd.git
synced 2025-01-05 13:18:06 +03:00
Merge pull request #10928 from yuwata/fix-9940
network: also load foo.netdev.d/*.conf
This commit is contained in:
commit
f5d9a12780
@ -705,10 +705,10 @@ int netdev_load_one(Manager *manager, const char *filename) {
|
||||
if (NETDEV_VTABLE(netdev)->init)
|
||||
NETDEV_VTABLE(netdev)->init(netdev);
|
||||
|
||||
r = config_parse(NULL, filename, file,
|
||||
NETDEV_VTABLE(netdev)->sections,
|
||||
config_item_perf_lookup, network_netdev_gperf_lookup,
|
||||
CONFIG_PARSE_WARN, netdev);
|
||||
r = config_parse_many(filename, network_dirs, dropin_dirname,
|
||||
NETDEV_VTABLE(netdev)->sections,
|
||||
config_item_perf_lookup, network_netdev_gperf_lookup,
|
||||
CONFIG_PARSE_WARN, netdev);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
|
4
test/test-network/conf/10-dropin-test.netdev
Normal file
4
test/test-network/conf/10-dropin-test.netdev
Normal file
@ -0,0 +1,4 @@
|
||||
[NetDev]
|
||||
Name=hoge
|
||||
Kind=dummy
|
||||
MACAddress=00:50:56:c0:00:18
|
2
test/test-network/conf/10-dropin-test.netdev.d/mac.conf
Normal file
2
test/test-network/conf/10-dropin-test.netdev.d/mac.conf
Normal file
@ -0,0 +1,2 @@
|
||||
[NetDev]
|
||||
MACAddress=00:50:56:c0:00:28
|
2
test/test-network/conf/10-dropin-test.netdev.d/name.conf
Normal file
2
test/test-network/conf/10-dropin-test.netdev.d/name.conf
Normal file
@ -0,0 +1,2 @@
|
||||
[NetDev]
|
||||
Name=dropin-test
|
@ -1,10 +1,3 @@
|
||||
[NetDev]
|
||||
Name=vlan99
|
||||
Kind=vlan
|
||||
|
||||
[VLAN]
|
||||
Id=99
|
||||
GVRP=true
|
||||
MVRP=true
|
||||
LooseBinding=true
|
||||
ReorderHeader=true
|
||||
|
6
test/test-network/conf/21-vlan.netdev.d/override.conf
Normal file
6
test/test-network/conf/21-vlan.netdev.d/override.conf
Normal file
@ -0,0 +1,6 @@
|
||||
[VLAN]
|
||||
Id=99
|
||||
GVRP=true
|
||||
MVRP=true
|
||||
LooseBinding=true
|
||||
ReorderHeader=true
|
@ -1,5 +1,2 @@
|
||||
[Match]
|
||||
Name=test1
|
||||
|
||||
[Network]
|
||||
VLAN=vlan99
|
||||
|
2
test/test-network/conf/21-vlan.network.d/override.conf
Normal file
2
test/test-network/conf/21-vlan.network.d/override.conf
Normal file
@ -0,0 +1,2 @@
|
||||
[Network]
|
||||
VLAN=vlan99
|
@ -74,11 +74,15 @@ class Utilities():
|
||||
def copy_unit_to_networkd_unit_path(self, *units):
|
||||
for unit in units:
|
||||
shutil.copy(os.path.join(networkd_ci_path, unit), network_unit_file_path)
|
||||
if (os.path.exists(os.path.join(networkd_ci_path, unit + '.d'))):
|
||||
copytree(os.path.join(networkd_ci_path, unit + '.d'), os.path.join(network_unit_file_path, unit + '.d'))
|
||||
|
||||
def remove_unit_from_networkd_path(self, units):
|
||||
for unit in units:
|
||||
if (os.path.exists(os.path.join(network_unit_file_path, unit))):
|
||||
os.remove(os.path.join(network_unit_file_path, unit))
|
||||
if (os.path.exists(os.path.join(network_unit_file_path, unit + '.d'))):
|
||||
shutil.rmtree(os.path.join(network_unit_file_path, unit + '.d'))
|
||||
|
||||
def start_dnsmasq(self):
|
||||
subprocess.check_call('dnsmasq -8 /var/run/networkd-ci/test-dnsmasq-log-file --log-queries=extra --log-dhcp --pid-file=/var/run/networkd-ci/test-test-dnsmasq.pid --conf-file=/dev/null --interface=veth-peer --enable-ra --dhcp-range=2600::10,2600::20 --dhcp-range=192.168.5.10,192.168.5.200 -R --dhcp-leasefile=/var/run/networkd-ci/lease --dhcp-option=26,1492 --dhcp-option=option:router,192.168.5.1 --dhcp-option=33,192.168.5.4,192.168.5.5', shell=True)
|
||||
@ -149,7 +153,7 @@ class NetworkdNetDevTests(unittest.TestCase, Utilities):
|
||||
links =['bridge99', 'bond99', 'bond99', 'vlan99', 'test1', 'macvtap99',
|
||||
'macvlan99', 'ipvlan99', 'vxlan99', 'veth99', 'vrf99', 'tun99',
|
||||
'tap99', 'vcan99', 'geneve99', 'dummy98', 'ipiptun99', 'sittun99', '6rdtun99',
|
||||
'gretap99', 'vtitun99', 'vti6tun99','ip6tnl99', 'gretun99', 'ip6gretap99', 'wg99']
|
||||
'gretap99', 'vtitun99', 'vti6tun99','ip6tnl99', 'gretun99', 'ip6gretap99', 'wg99', 'dropin-test']
|
||||
|
||||
units = ['25-bridge.netdev', '25-bond.netdev', '21-vlan.netdev', '11-dummy.netdev', '21-vlan.network',
|
||||
'21-macvtap.netdev', 'macvtap.network', '21-macvlan.netdev', 'macvlan.network', 'vxlan.network',
|
||||
@ -159,7 +163,7 @@ class NetworkdNetDevTests(unittest.TestCase, Utilities):
|
||||
'25-gre-tunnel.netdev', '25-gretap-tunnel.netdev', '25-vti-tunnel.netdev', '25-vti6-tunnel.netdev',
|
||||
'12-dummy.netdev', 'gre.network', 'ipip.network', 'ip6gretap.network', 'gretun.network',
|
||||
'ip6tnl.network', '25-tap.netdev', 'vti6.network', 'vti.network', 'gretap.network', 'sit.network',
|
||||
'25-ipip-tunnel-independent.netdev', '25-wireguard.netdev', '6rd.network']
|
||||
'25-ipip-tunnel-independent.netdev', '25-wireguard.netdev', '6rd.network', '10-dropin-test.netdev']
|
||||
|
||||
def setUp(self):
|
||||
self.link_remove(self.links)
|
||||
@ -168,6 +172,17 @@ class NetworkdNetDevTests(unittest.TestCase, Utilities):
|
||||
self.link_remove(self.links)
|
||||
self.remove_unit_from_networkd_path(self.units)
|
||||
|
||||
def test_dropin(self):
|
||||
self.copy_unit_to_networkd_unit_path('10-dropin-test.netdev')
|
||||
|
||||
self.start_networkd()
|
||||
|
||||
self.assertTrue(self.link_exits('dropin-test'))
|
||||
|
||||
output = subprocess.check_output(['ip', 'link', 'show', 'dropin-test']).rstrip().decode('utf-8')
|
||||
print(output)
|
||||
self.assertRegex(output, '00:50:56:c0:00:28')
|
||||
|
||||
def test_bridge(self):
|
||||
self.copy_unit_to_networkd_unit_path('25-bridge.netdev')
|
||||
self.start_networkd()
|
||||
|
Loading…
Reference in New Issue
Block a user