1
0
mirror of https://github.com/systemd/systemd synced 2025-10-06 00:13:24 +02:00
Commit Graph

857 Commits

Author SHA1 Message Date
Lennart Poettering
f2a365b982 network/dhcp-server: improvements for saving/loading leases (#37835) 2025-06-17 14:31:22 +02:00
Yu Watanabe
312e3835ee test-network: add tests for tunnel mode 2025-06-16 17:01:37 +09:00
Yu Watanabe
ce5a54ed9b test-network: add test case for issue #37714
I cannot reproduce the issue with the current git HEAD.
Let's add a test case that is used by the reporter of the issue.
2025-06-15 09:33:23 +09:00
Yu Watanabe
009d64dddd test-network: add test case for PersistLeases=runtime 2025-06-14 03:42:24 +09:00
Avram Dorfman
fb9076b994 test-network: add test case for bootp
Co-authored-by: Yu Watanabe <watanabe.yu+github@gmail.com>
2025-06-13 14:15:04 +09:00
Yu Watanabe
78f8d5ed71 network: also check ID_NET_MANAGED_BY property on reconfigure
Previously, the property was checked only when an uevent is received,
so even if an interface has ID_NET_MANAGED_BY property, the interface
will be configured by networkd when reconfiguration is triggered e.g.
when interface state is changed.

Follow-up for ba87a61d05.
Fixes #36997.
2025-06-12 14:24:50 +09:00
Yu Watanabe
c6aae2cd8a test-network: add test case for issue #32186
The reporter said that the issue is caused by BindCarrier=, but
I cannot reproduce it. Anyway, let's test it.
2025-06-11 17:32:46 +09:00
Yu Watanabe
8882519583 test-network: read the current link flags of bond interface
Follow-up for 2700d2c7dc.
2025-06-11 17:18:43 +09:00
Yu Watanabe
356e9bc018 test-network: extend comments how to run the test 2025-06-04 16:46:41 +01:00
Yu Watanabe
ff6f0a58c5 test-network: replace unnecessary assertRegex() with assertIn()
This fixes the following warning:
```
/tmp/systemd/test/test-network/systemd-networkd-tests.py:5107: SyntaxWarning: invalid escape sequence '\.'
  self.assertRegex(output, 'inet 10\.234\.77\.111/32.*dummy98')
```

Follow-up for 6479204e56.
2025-05-28 04:38:56 +09:00
Yu Watanabe
b1bed07d84 test-network: add test case for issue #37629 2025-05-28 04:38:56 +09:00
Luca Boccassi
f9a85b7490 test: fix test_qdisc_tbf regex with iproute2 v6.15
iproute2 v6.15 fixed some rounding errors in the reported stats:

https://git.kernel.org/pub/scm/network/iproute2/iproute2.git/commit/?id=d947f365602b30657d1b797e7464000d0ab88d5a

so the current regex doesn't work anymore. Fix it to check for both
old and new values.

systemd-networkd-tests.py[523]: FAIL: test_qdisc_tbf (__main__.NetworkdTCTests.test_qdisc_tbf)
systemd-networkd-tests.py[523]: ----------------------------------------------------------------------
systemd-networkd-tests.py[523]: Traceback (most recent call last):
systemd-networkd-tests.py[523]:   File "/usr/lib/systemd/tests/testdata/test-network/systemd-networkd-tests.py", line 5402, in test_qdisc_tbf
systemd-networkd-tests.py[523]:     self.assertRegex(output, 'rate 1Gbit burst 5000b peakrate 100Gbit minburst 987500b lat 70(.0)?ms')
systemd-networkd-tests.py[523]:     ~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
systemd-networkd-tests.py[523]: AssertionError: Regex didn't match: 'rate 1Gbit burst 5000b peakrate 100Gbit minburst 987500b lat 70(.0)?ms' not found in 'qdisc tbf 35: root refcnt 2 rate 1Gbit burst 5000b peakrate 100Gbit minburst 999200b lat 70ms \nqdisc pfifo 37: parent 35: limit 100000p'
2025-05-27 17:24:47 +01:00
Matteo Croce
6288739eaf networkd: print a meaningful error on failure
test_keep_configuration_on_restart() works, but the error printed is
misleading because self.assertNotEmpty() doesn't exist.

Add a working assert statement so, when the unmanaged interface is
altered, the test fails with a meaningful error, like:

        ### ip monitor dev unmanaged0 BEGIN
        222:33::/64 proto kernel metric 256 pref medium
        FAIL
        [...]
        Traceback (most recent call last):
          File "/work/src/test/test-network/systemd-networkd-tests.py", line 5085, in test_keep_configuration_on_restart
            self.assertEqual(line, '')
        AssertionError: '222:33::/64 proto kernel metric 256 pref medium' != ''
        - 222:33::/64 proto kernel metric 256 pref medium

While at it, strip the trailing newline so we can print easily the
string (and in future build more a robust regexp which uses the $ token)
2025-05-22 09:33:39 +02:00
Matteo Croce
bcb9e72b6b networkd: ensure that unmanaged interfaces aren't touched
Extend the test_keep_configuration_on_restart in order to check
that the unmanaged interface isn't altered in any way.
2025-05-22 03:04:40 +09:00
Matteo Croce
6479204e56 networkd: add test to ensure that untracked addresses are kept
Users can alter the network configuration manually, but networkd should
not interfere with manually set addresses and routes.
2025-05-20 14:14:53 +02:00
Beniamino Galvani
ec65c29e51 network: fix handling of routing policy rule fwmask
The firewall mask should be applied even if the mark is 0, to allow defining a
value of e.g. 0/255.

Fixes #36973
2025-04-17 09:18:54 +09:00
Beniamino Galvani
f7996e2a33 network: add support for HSR netdev
Add support for creating HSR/PRP interfaces. HSR (High-availability Seamless
Redundancy) and PRP (Parallel Redundancy Protocol) are two protocols that
provide seamless failover against failure of any single network component. They
are both implemented by the "hsr" kernel driver.
2025-04-05 05:23:53 +09:00
Luca Boccassi
da24983526 test: skip networkd tests if networkd/resolved are disabled at build time 2025-03-30 10:18:18 +02:00
Erik Larsson
c88adbc01d networkd: add support for setting vlan_tunnel on bridge ports 2025-03-24 17:15:19 +09:00
Erik Larsson
6e529860ba networkd: add support for externally managed vxlan devices
With this a vxlan interface can be created which is managed by
for example a EVPN control plane.
2025-03-20 20:29:47 +09:00
Matteo Croce
912a48572d test-network: check that network configuration is stable with KeepConfiguration=yes
Check that when networkd restarts, and the network configures
KeepConfiguration=yes, the network configuration is never changed.

Ensure this by dumping the `ip monitor` output when networkd is restarting.

Co-authored-by: Yu Watanabe <watanabe.yu+github@gmail.com>
2025-03-15 10:26:20 +09:00
Yu Watanabe
51e60dac12 test-network: drop deprecated ExecStart= modifier 2025-03-05 18:17:19 +09:00
Yu Watanabe
94dc76c996 test-network: extend test case for static routes
- split out verifications into two functions,
- also check the following scenarios:
  * unmanaging an existing interface,
  * re-managing an unmanaged interface,
  * adding a new unmanaged interface,
  * removing an unmanaged interface.
2025-02-28 08:51:14 +01:00
Yu Watanabe
1cac0676da test-network: add test case for KeepConfiguration=yes with RTPROT_BOOT
For issue #36411.
2025-02-18 23:01:53 +09:00
Luca Boccassi
382e8a03ca network: allow to configure routing policy rule even if requesting interface is not activated yet (#36257)
Fixes a regression caused by 4f8b153d90
(v257).
Fixes #36244.
2025-02-07 22:56:36 +00:00
Luca Boccassi
2ee81b556f network/route: improve Gateway=_dhcp4 handling (#36183)
- Also configures route to the gateway and prefix route in the specified
table, if necessary.
- Also set preferred source address of the route.

Closes #36168.
2025-02-05 12:19:01 +00:00
Yu Watanabe
a10172b035 test-network: add test case for issue #35874 2025-02-05 09:40:31 +09:00
Yu Watanabe
f7ae28fcec test-network: add test case for requesting routing policy rules by multiple interfaces
For issue #36244.
2025-02-04 12:28:59 +09:00
Yu Watanabe
d90c01d02c network: bridge: add support for configuring locked ports (#36150)
"Recently" (as of 5.18) the Linux kernel gained the ability of locking
bridge ports to restrict network access to authenticated hosts only.

This is implemented by disabling automated learning and dropping
incoming traffic from unknown hosts. User space is then expected to add
fdb entries for authenticated hosts. Once a fdb entry exist, traffic for
that host will be forwarded as expected.

This was later extended with "Mac Authentication Bypass", where the
locking was extended to fdb entries. In this mode the kernel adds fdb
entries again automatically, but they are locked by default.

To properly configure this, add two network options and one netdev
option:

* `LinkLocalLearning=` to prevent the kernel from creating unlocked
entries based on link-local traffic, which would bypass any
authentication. Needed when enabling learning on a locked port.
* `Locked=` to allow setting a bridge port to locked.
* `MACAuthenticationBypass=` to allow enabling Mac Authentication
 Bypass on a port. Requires learning to be enabled on the port as well
 (and consequently `LinkLocalLearning` disabled on the bridge).

An authenticator (e.g. hostapd) is still needed to do the actual
authentication, the kernel only provides the access control.
2025-01-29 04:16:20 +09:00
Nick Rosbrook
d6608da1e6 networkd-test: add basic tests for systemd-networkd-wait-online --dns 2025-01-28 08:49:49 -05:00
Jonas Gorski
08a26ecc47 network: bridge: add support for IFLA_BRPORT_MAB
Since linux commit a35ec8e38cdd1766f29924ca391a01de20163931 ("bridge:
Add MAC Authentication Bypass (MAB) support"), included since v6.2, it
is possible to enable MAC Authentication Bypass for bridge ports. In
this mode the locked port learns again, but the learned fdb entries are
locked, allowing user space to unlock hosts based seen MAC addresses.

This requires learning to be enabled on the port, and link-local
learning disabled for the bridge.

Add support to systemd-network for setting the new attribute for bridge
ports.
2025-01-28 12:22:26 +01:00
Jonas Gorski
a434de6056 network: bridge: add support for IFLA_BRPORT_LOCKED
Since linux commit a21d9a670d81103db7f788de1a4a4a6e4b891a0b ("net:
bridge: Add support for bridge port in locked mode"), included since
v5.18,  it is possible to set bridge ports to locked.

Locked ports do not learn automatically, and discard any traffic from
unknown source MACs. To allow traffic, the userspace authenticator is
expected to create fdb entries for authenticated hosts.

Add support to systemd-network for setting the new attribute for bridge
ports.
2025-01-28 10:38:01 +01:00
Jonas Gorski
d7de242ce7 network: bridge: add support for NO_LL_LEARN
When using locked ports on a bridge link-local learning needs to be
disabled to prevent the kernel from learning and automatically unlocking
hosts based on link-local traffic.

So add support for enabling NO_LL_LEARN for bridges.
2025-01-28 10:38:01 +01:00
Yu Watanabe
2ea15435fd test-network: add test case for Gateway=_dhcp4 with Table= 2025-01-27 08:39:09 +09:00
Yu Watanabe
60ce6a3413 test-network: add test case for [IPv6RoutePrefix] Preference= 2025-01-22 20:48:31 +00:00
Yu Watanabe
220f7aac8c test-network: drop workaround for old CentOS release 2025-01-07 02:06:04 +09:00
Yu Watanabe
1761c35275 test-network: nowadays it runs not only on CentOS 2025-01-07 02:06:04 +09:00
Yu Watanabe
5e5fe05896 test-network: add test cases for global [DHCPv4] ClientIdentifier= setting 2024-12-30 11:19:02 +09:00
Yu Watanabe
af44a16ec7 test-network: add test case for MPLSRouting=yes 2024-12-13 15:36:45 +00:00
Yu Watanabe
456727b5d4 test-network: check status of networkd after everything cleared on tear down
Otherwise, if networkd is failed, e.g. .network files that triggered the
failure will remain, and the next test case will start with previous
.network files. So, most subsequent test will fail.
2024-12-10 11:01:53 +09:00
Daan De Meyer
c45174f05d ci: Implement coverage on top of mkosi 2024-12-05 00:21:57 +01:00
Yu Watanabe
2b397d43ab test-network: actually check metric and preference
Otherwise, nexthop ID may contain e.g. 300, then
===
AssertionError: '300' unexpectedly found in
'default nhid 3860882700 via fe80::1034:56ff:fe78:9a99 proto ra metric 512 expires 1798sec pref high\n
 default nhid 2639230080 via fe80::1034:56ff:fe78:9a98 proto ra metric 2048 expires 1798sec pref low'
===
2024-11-21 03:43:35 +09:00
Yu Watanabe
c295b558bf test-network: add test case for IPv6 Core Conformance test v6LC.2.2.23 2024-11-19 04:48:39 +09:00
Yu Watanabe
16ccdc3748 test-network: split out check_router_preference() from test_router_preference()
This also drop high2.network and low2.network, and edit high.network and
low.network during the test.
2024-11-19 04:44:59 +09:00
Yu Watanabe
360e59ed1c network/ndisc: fix coalescing of ndisc routes when multiple router exists (#35119)
Fixes #33470.
2024-11-15 00:10:22 +09:00
Luca Boccassi
6a479f0d63 network/netdev: follow-ups for reloading .netdev files (#34979)
Follow-ups for #34909.
2024-11-14 11:36:26 +00:00
Yu Watanabe
0f8afaf94d network/ndisc: dynamically configure nexthops when routes with gateway are requested
Previously, when multiple routers send RAs with the same preference,
then the kernel merges routes with the same gateway address:
===
default proto ra metric 1024 expires 595sec pref medium
        nexthop via fe80::200:10ff:fe10:1060 dev enp0s9 weight 1
        nexthop via fe80::200:10ff:fe10:1061 dev enp0s9 weight 1
===
This causes IPv6 Conformance Test v6LC.2.2.11 failure, as reported in #33470.

To avoid the coalescing issue, we can use nexthop, as suggested by Ido Schimmel:
https://lore.kernel.org/netdev/ZytjEINNRmtpadr_@shredder/
> BTW, you can avoid the coalescing problem by using the nexthop API.
> # ip nexthop add id 1 via fe80::200:10ff:fe10:1060 dev enp0s9
> # ip -6 route add default nhid 1 expires 600 proto ra
> # ip nexthop add id 2 via fe80::200:10ff:fe10:1061 dev enp0s9
> # ip -6 route append default nhid 2 expires 600 proto ra
> # ip -6 route
> fe80::/64 dev enp0s9 proto kernel metric 256 pref medium
> default nhid 1 via fe80::200:10ff:fe10:1060 dev enp0s9 proto ra metric 1024 expires 563sec pref medium
> default nhid 2 via fe80::200:10ff:fe10:1061 dev enp0s9 proto ra metric 1024 expires 594sec pref medium

Fixes #33470.

Suggested-by: Ido Schimmel <idosch@idosch.org>
2024-11-14 11:59:59 +09:00
Yu Watanabe
bbef21e4e5 test-network: update KeepConfiguration=dhcp -> dynamic 2024-11-14 10:24:27 +09:00
Yu Watanabe
5b73edfa7f test-network: add tests for reloading .netdev files for independent netdevs 2024-11-14 10:17:19 +09:00
Yu Watanabe
d7b323c2dd test-network: several cleanups
- fix verifiers in test_router_preference() to make them actually check
  if unnecessary routes are removed,
- stop radv in test_ndisc_vs_static_route() before checking if the static
  route is preserved even when the router sends a RA with zero lifetime,
- make verifiers in NetworkdIPv6PrefixTests stricter.
2024-11-12 18:08:25 +09:00