mirror of
https://github.com/systemd/systemd.git
synced 2024-12-25 01:34:28 +03:00
network: also log drop-in config files
We have already show used drop-in config files in networkctl, but also showing that in log may be useful. Closes #30483.
This commit is contained in:
parent
935cf7b3a1
commit
b993e7e72e
@ -1241,10 +1241,20 @@ int link_reconfigure_impl(Link *link, bool force) {
|
||||
return 0;
|
||||
|
||||
if (network) {
|
||||
_cleanup_free_ char *joined = strv_join(network->dropins, ", ");
|
||||
|
||||
if (link->state == LINK_STATE_INITIALIZED)
|
||||
log_link_info(link, "Configuring with %s.", network->filename);
|
||||
log_link_info(link, "Configuring with %s%s%s%s.",
|
||||
network->filename,
|
||||
isempty(joined) ? "" : " (dropins: ",
|
||||
joined,
|
||||
isempty(joined) ? "" : ")");
|
||||
else
|
||||
log_link_info(link, "Reconfiguring with %s.", network->filename);
|
||||
log_link_info(link, "Reconfiguring with %s%s%s%s.",
|
||||
network->filename,
|
||||
isempty(joined) ? "" : " (dropins: ",
|
||||
joined,
|
||||
isempty(joined) ? "" : ")");
|
||||
} else
|
||||
log_link_full(link, link->state == LINK_STATE_INITIALIZED ? LOG_DEBUG : LOG_INFO,
|
||||
"Unmanaging interface.");
|
||||
|
20
test/test-network/conf/11-test-unit-file.link
Normal file
20
test/test-network/conf/11-test-unit-file.link
Normal file
@ -0,0 +1,20 @@
|
||||
# SPDX-License-Identifier: MIT-0
|
||||
#
|
||||
# This config file is installed as part of systemd.
|
||||
# It may be freely copied and edited (following the MIT No Attribution license).
|
||||
#
|
||||
# To make local modifications, one of the following methods may be used:
|
||||
# 1. add a drop-in file that extends this file by creating the
|
||||
# /etc/systemd/network/99-default.link.d/ directory and creating a
|
||||
# new .conf file there.
|
||||
# 2. copy this file into /etc/systemd/network or one of the other paths checked
|
||||
# by systemd-udevd and edit it there.
|
||||
# This file should not be edited in place, because it'll be overwritten on upgrades.
|
||||
|
||||
[Match]
|
||||
OriginalName=*
|
||||
|
||||
[Link]
|
||||
NamePolicy=keep kernel database onboard slot path
|
||||
AlternativeNamesPolicy=database onboard slot path
|
||||
MACAddressPolicy=persistent
|
@ -0,0 +1,2 @@
|
||||
# SPDX-License-Identifier: LGPL-2.1-or-later
|
||||
[Link]
|
4
test/test-network/conf/11-test-unit-file.netdev
Normal file
4
test/test-network/conf/11-test-unit-file.netdev
Normal file
@ -0,0 +1,4 @@
|
||||
# SPDX-License-Identifier: LGPL-2.1-or-later
|
||||
[NetDev]
|
||||
Name=test1
|
||||
Kind=dummy
|
@ -0,0 +1,2 @@
|
||||
# SPDX-License-Identifier: LGPL-2.1-or-later
|
||||
[NetDev]
|
6
test/test-network/conf/11-test-unit-file.network
Normal file
6
test/test-network/conf/11-test-unit-file.network
Normal file
@ -0,0 +1,6 @@
|
||||
# SPDX-License-Identifier: LGPL-2.1-or-later
|
||||
[Match]
|
||||
Name=test1
|
||||
|
||||
[Network]
|
||||
IPv6AcceptRA=no
|
@ -0,0 +1,2 @@
|
||||
# SPDX-License-Identifier: LGPL-2.1-or-later
|
||||
[Network]
|
@ -1238,15 +1238,20 @@ class NetworkctlTests(unittest.TestCase, Utilities):
|
||||
print(output)
|
||||
self.assertRegex(output, 'Type: loopback')
|
||||
|
||||
def test_udev_link_file(self):
|
||||
copy_network_unit('11-dummy.netdev', '11-dummy.network', '25-default.link')
|
||||
def test_unit_file(self):
|
||||
copy_network_unit('11-test-unit-file.netdev', '11-test-unit-file.network', '11-test-unit-file.link')
|
||||
start_networkd()
|
||||
self.wait_online(['test1:degraded'])
|
||||
|
||||
output = check_output(*networkctl_cmd, '-n', '0', 'status', 'test1', env=env)
|
||||
print(output)
|
||||
self.assertRegex(output, r'Link File: /run/systemd/network/25-default.link')
|
||||
self.assertRegex(output, r'Network File: /run/systemd/network/11-dummy.network')
|
||||
self.assertIn('Link File: /run/systemd/network/11-test-unit-file.link', output)
|
||||
self.assertIn('/run/systemd/network/11-test-unit-file.link.d/dropin.conf', output)
|
||||
self.assertIn('Network File: /run/systemd/network/11-test-unit-file.network', output)
|
||||
self.assertIn('/run/systemd/network/11-test-unit-file.network.d/dropin.conf', output)
|
||||
|
||||
output = read_networkd_log()
|
||||
self.assertIn('test1: Configuring with /run/systemd/network/11-test-unit-file.network (dropins: /run/systemd/network/11-test-unit-file.network.d/dropin.conf).', output)
|
||||
|
||||
# This test may be run on the system that has older udevd than 70f32a260b5ebb68c19ecadf5d69b3844896ba55 (v249).
|
||||
# In that case, the udev DB for the loopback network interface may already have ID_NET_LINK_FILE property.
|
||||
@ -1254,8 +1259,8 @@ class NetworkctlTests(unittest.TestCase, Utilities):
|
||||
check_output(*udevadm_cmd, 'trigger', '--settle', '--action=add', '/sys/class/net/lo')
|
||||
output = check_output(*networkctl_cmd, '-n', '0', 'status', 'lo', env=env)
|
||||
print(output)
|
||||
self.assertRegex(output, r'Link File: n/a')
|
||||
self.assertRegex(output, r'Network File: n/a')
|
||||
self.assertIn('Link File: n/a', output)
|
||||
self.assertIn('Network File: n/a', output)
|
||||
|
||||
def test_delete_links(self):
|
||||
copy_network_unit('11-dummy.netdev', '11-dummy.network',
|
||||
|
Loading…
Reference in New Issue
Block a user