Commit Graph

975 Commits

Author SHA1 Message Date
Luca Boccassi
9e4248fbbf test: also check if networkd built with BTF support before BPF test
SUSE does not provide a vmlinux.h so the package is not built with
CO-RE support, hence the test fails. This was previously masked
by the fact that python3-packaging was never installed, so the
test always skipped everywhere as it could not detect the kernel
version.

Follow-up for c310106c15
2026-05-25 18:13:51 +01:00
Daan De Meyer
e64337ee10 sd-dhcp-relay: reimplement DHCP relay agent and drop legacy DHCP relay mode from sd-dhcp-server (#42130) 2026-05-21 16:23:44 +02:00
Luca Boccassi
d46dae085f network: several fixlets for NDisc (#42218)
Unfortunately, previously the path to test-ndisc-send has been wrong, so
some test cases have not been checked in our mkosi CIs. And two test
cases have been broken.

The test case `test_ndisc_redirect` was not updated when the logic in
networkd was changed by 9142bd5a8e. The
change itself should be OK. So, the test case is updated.

The test case `test_ndisc_mtu` was broken when the commit
32417c1723 is merged. The commit is not
correct, as we cannot set IPv6 MTU larger than interface MTU. So, the
offending commit is reverted.
2026-05-21 12:05:34 +01:00
Yu Watanabe
cb2bba6b04 network: drop use of legacy DHCP relay agent in sd-dhcp-server
Then, this deprecates
- BindToInterface=
- RelayTarget=
- RelayAgentCircuitId=
- RelayAgentRemoteId=
settings in [DHCPServer] section.
These are gracefully translated as new settings.
2026-05-21 16:55:59 +09:00
Yu Watanabe
08b3ebf5f1 test-network: add test case for DHCP relay 2026-05-21 16:55:59 +09:00
Yu Watanabe
dece52443c test-network: fix path to test-ndisc-send
Follow-up for 9dcdf16b25.

Previously, test cases that use test-ndisc-send executable did not
tested in our mkosi CIs...
2026-05-21 07:53:18 +09:00
Yu Watanabe
d9b7fdf06a test-network: fix test case for Neighbor Announcement message handling
After 9142bd5a8e, when NA without router
flag is received, the corresponding redirect route and the default route
is removed, but the other routes are kept.

The corresponding test case was not updated by the commit, and the test
case has been unfortunately skipped...

This fixes the test case, and added more checks.
2026-05-21 07:53:12 +09:00
Yu Watanabe
0080566c92 test-network: add test cases for 'networkctl dhcp-lease' command
Addresses the request:
https://github.com/systemd/systemd/pull/42137#pullrequestreview-4305664376
2026-05-21 07:51:16 +09:00
Yu Watanabe
18f2e9bcfa test-network: try to stop test-modem-manager-mock.service only when necessary
Otherwise, all test cases that does not create/start the service emits
the following error:
```
Failed to stop test-modem-manager-mock.service: Unit test-modem-manager-mock.service not loaded.
```

Moreover, without this change, extra 'systemctl daemon-reload' is triggered after
all test cases. That's super heavy, especially when the test is running on
sanitizers.

Follow-up for abe3d570f8.
2026-05-21 07:10:50 +09:00
Yu Watanabe
52421acf17 test-network: use networkctl_status() helper function at one more place 2026-05-21 07:06:32 +09:00
Jörg Behrmann
b54d167934 test-network: make masq a proper function 2026-05-18 09:43:36 +09:00
Jörg Behrmann
9ea0b5f688 test-network: factor out common functions 2026-05-18 09:42:34 +09:00
Jörg Behrmann
475fb5e44f test-network: factor out common enum 2026-05-18 09:41:23 +09:00
Jörg Behrmann
7cf552e481 test-network: remove unused variable 2026-05-18 09:41:22 +09:00
Yu Watanabe
1b94d7d7ec test-network: apply "ruff format" and "ruff check --fix" 2026-05-18 02:44:46 +09:00
Yu Watanabe
59199ec3bd test-network: drop old ip command support 2026-05-18 02:44:46 +09:00
Yu Watanabe
9c0c203db4 test-network: assume the test is running with newer udevd 2026-05-18 02:44:46 +09:00
Yu Watanabe
cbc2990335 test-network: drop old kernel support and workaround for fixed kernel bug
- l3mdev in fib rules is supported since
96c63fa739 (v4.8).
- uid range in fib rules is supported since
622ec2c9d5 (v4.10).
- port range and ip proto in fib rules is supported since
bfff486265 (v4.17).
- interface alternative name is supported since
36fbf1e52b (v5.5).
- SRIOV on netdevsim is supported since
7957922056 (4.16).
- nexthop is supported since
65ee00a940 (v5.3).
- bridge MDB entries on bridge master is supported since
1bc844ee0f (v5.4).
2026-05-18 02:44:46 +09:00
Luca Boccassi
446b0393ff test-network: retry networkctl status in wait_operstate()
networkctl status may transiently fail right after start_networkd() because networkd has not yet picked up the freshly-created link from the kernel. The retry loop in wait_operstate() did not catch the resulting subprocess.CalledProcessError, so the test aborted on the first attempt instead of retrying for the configured timeout.

Observed in TEST-85-NETWORK-NetworkdBridgeTests, subtest test_bridge_configure_without_carrier[no-slave]:

  [   19.600156] systemd-networkd-tests.py[526]: Failed to issue io.systemd.Network.Link.Describe() varlink call: Invalid argument
  [   53.124982] systemd[1]: systemd-networkd.service: Changed start -> running
  [   53.336167] systemd-networkd-tests.py[526]: ERROR: test_bridge_configure_without_carrier (__main__.NetworkdBridgeTests.test_bridge_configure_without_carrier) (test='no-slave')
  [   53.336167] systemd-networkd-tests.py[526]:     self.wait_operstate('bridge99', operstate=r'(no-carrier|routable)', setup_state=None, setup_timeout=30)
  [   53.336167] systemd-networkd-tests.py[526]: subprocess.CalledProcessError: Command '['/usr/bin/networkctl', '-n', '0', 'status', 'bridge99']' returned non-zero exit status 1.

Co-developed-by: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-16 05:08:35 +09:00
Diego Viola
5d17215c7e treewide: fix typos in the entire codebase
Signed-off-by: Diego Viola <diego.viola@gmail.com>
2026-05-05 17:22:26 +02:00
Daan De Meyer
b5f219d834 networkd: Add IPv4SrcValidMark= support (#41364)
Closes https://github.com/systemd/systemd/issues/40643
2026-04-22 15:48:50 +02:00
Jonathan Davies
c87ab483e7 test-network: verify DHCP server PoolSize and PoolOffset DBus properties
Add integration test coverage for the PoolSize and PoolOffset properties
exposed on the org.freedesktop.network1.DHCPServer DBus interface.
2026-04-15 14:20:40 +00:00
ssahani
2f69c8e712 networkd: Add docs and tests for IPv4SrcValidMark=
Document the new setting in systemd.network(5) man page
and add coverage in the networkd integration tests.

Co-developed-by: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-30 06:25:00 +05:30
Luca Boccassi
abe3d570f8 test: add a mock ModemManager for basic coverage of sd-networkd's integration
Just the minimal setup and test case required to cover
https://github.com/systemd/systemd/issues/41389 for now, can be
expanded in the future

Boring boilerplate is bot-made, don't @ me

Co-developed-by: Claude Opus 4.6 noreply@anthropic.com
2026-03-28 15:19:21 +00:00
Zbigniew Jędrzejewski-Szmek
9e8658b887 various: fix typos 2026-03-25 02:03:56 +01:00
Zbigniew Jędrzejewski-Szmek
e799263ff4 test-network: handle the case where dnsmasq is slow to start better
> read_dnsmasq_log_file() will raise FileNotFoundError if dnsmasq hasn’t created the
> log file yet (or if the file was just removed by stop_dnsmasq() before the restart).
> This would error the test instead of retrying.

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
2026-03-13 12:02:07 +01:00
Yu Watanabe
8e764acf1e test-network: also check if DHCPRELEASE is sent on stopping networkd 2026-03-13 04:53:24 +09:00
Yu Watanabe
bd061abd87 test-network: improve reliability of test case of DHCPRELEASE message 2026-03-13 04:53:20 +09:00
Yu Watanabe
67957b1464 test-network: drop duplicated definition of networkd_pid() 2026-03-13 04:44:12 +09:00
Yu Watanabe
5188882fbf test-network: add test case for sending DHCPv4 RELEASE message 2026-03-11 08:45:28 +09:00
Yu Watanabe
f47d180b85 test-network: add test case for issue #40106 2026-03-09 12:31:41 +09:00
Yaping Li
23c639be6d metrics: add networkd related metrics 2026-02-18 17:58:33 +09:00
Yu Watanabe
6109cf8b61 meson,test: sort unit files 2026-02-18 17:57:17 +09:00
Yu Watanabe
cb9d854207 network: Support interface-bound ECMP routes in MultiPathRoute= (#39742)
MultiPathRoute= can now specify device-only nexthops without a gateway
address, e.g. MultiPathRoute=@wg0. This enables ECMP configurations over
interfaces that don't use gateway addresses, such as WireGuard tunnels.

The syntax is extended from "address[@device] [weight]" to
"[address]@device [weight]". The address is now optional, but at least
one of gateway or device must be specified. The @ symbol must still be
present for device-only routes, making the syntax unambiguous: @wg0
specifies a device, while a bare IP address specifies a gateway.

Device-only nexthops are only available for IPv4 routes. Device-only
multipath routes for IPv6 are not supported by the kernel's netlink
interface and will be rejected with a warning.

This change is fully backwards compatible. All existing configurations
continue to work unchanged, as they always included a gateway address.

Closes #39699.
2026-01-02 09:25:43 +09:00
Yu Watanabe
72711b76e0 TEST-85-NETWORK: enable NetworkdSysctlTest
Note, each test case must be prefixed with 'test_'.

This also adds one more log check for issue #40051.

Follow-up for c78bcda461.
2025-12-11 14:37:04 +09:00
Luca Boccassi
afcc0ca509 test-network: drop unused variable
Follow-up for e2fbcee030
2025-12-09 03:30:57 +09:00
Yu Watanabe
80cfe9abf2 test: several fixlets/workarounds for supporting postmarketOS (#39905) 2025-12-07 10:16:58 +09:00
Luca Boccassi
e2fbcee030 test-network: fix invalid captive portal URL with dnsmasq 2.92 (#40011)
dnsmasq 2.92 started converting binary content to ascii so the previous
invalid URL is no longer invalid as it's escaped.

So the test started failing: https://bugs.debian.org/1122015

Use a '|' character instead, which is not a valid URL character but it's
also not escaped by dnsmasq.

Follow-up for 1219391c9f
2025-12-07 09:43:47 +09:00
Yu Watanabe
8374085f22 test-network: IPv4-mapped-IPv6 addresses may be shown as pure IPv6 address
It seems ip command built with musl always shows IPv6 addresses in the same way.
2025-12-07 09:09:03 +09:00
Yu Watanabe
193626bd8b test-network: also stop nftables.service
It is a firewall service used in postmarketOS.
When it is active, then e.g. DHCP packets are filtered, and many
tests will be failed.
2025-12-07 09:09:03 +09:00
Chris Down
23d02f6327 test: Add comprehensive tests for MultiPathRoute device-only syntax
Add unit tests for config_parse_multipath_route() covering the new
device-only nexthop syntax (@device). Tests verify basic parsing of
device-only routes, gateway with device routes, gateway-only routes,
interface index handling, etc. Also some checks on new hash/duplicate
semantics.

Also add an integration test to verify device-only multipath routes are
correctly installed in the kernel routing table.
2025-11-28 19:09:15 +08:00
Quentin Deslandes
5b0e262f45 network: clear existing routes if Gateway= is empty in [Network]
Add support for an empty Gateway= in [Network] to clear the existing
routes. This change will allow users to remove the default route from a
drop-in file.
2025-11-20 07:16:26 +09:00
Yu Watanabe
d7cf08b735 test-network: drop two overly verbose outputs
Follow-up for 7f9c0c31d2.
2025-11-16 22:15:44 +09:00
Yu Watanabe
3632d7322f test-network: set TimeoutStopFailureMode=abort when running with sanitizers
Hopefully this provides useful data for issue #39631.
2025-11-16 22:15:43 +09:00
Yu Watanabe
c43585bc30 Revert "test-network: disable several more sandbox features when running with sanitizers"
This reverts commit 454ce42305.

Unfortunately, it does not work.
2025-11-16 22:15:43 +09:00
Lennart Poettering
a7fa29b1b5 networkd: add support for resolved hook for DHCP server
Let's synthesize DNS RRs for leases handed out by our DHCP server. This
way local VMs can have resolvable hostnames locally.

This does not implement reverse look ups for now. We can add this
later in similar fashion.
2025-11-15 07:52:42 +01:00
Chris Down
7f9c0c31d2 sd-dhcp-server: Add Hostname= option to static leases
This adds a new `Hostname=` option to the [DHCPServerStaticLease]
section in .network files, allowing an administrator to assign a
specific hostname to a client receiving a static lease.

We automatically select the correct DHCP option to use based on the
format of the provided string:

- Single DNS labels are sent as Option 12.
- Names with multiple DNS labels are sent as Option 81 in wire format.

Fixes: #39634
2025-11-14 07:50:13 +09:00
Yu Watanabe
454ce42305 test-network: disable several more sandbox features when running with sanitizers
These settings also imply seccomp.
Hopefully fixes #39567.
2025-11-06 00:50:11 +09:00
Yu Watanabe
da665b708a test-network: read default values from environment variables
Nowadays, the test script is run as a service, and no argument about
sanitizers are passed. Let's read them from the environment variables.
2025-11-06 00:22:17 +09:00
Yu Watanabe
df75dd34f6 test-network: also save the current state of socket units for resolved and stop them
Silence the following waring:
```
Stopping 'systemd-resolved.service', but its triggering units are still active:
systemd-resolved-varlink.socket, systemd-resolved-monitor.socket
```

Follow-up for 0fa188307b.
2025-08-08 19:38:27 +09:00