Commit Graph
5902 Commits
Author SHA1 Message Date
Daan De Meyer 7bd76a4456 networkd: expose DHCP server pool size and offset via DBus (#41137) 2026-04-22 15:41:43 +02:00
Lennart Poettering 112f5317d1 resolved: let's generate enum fields properly too
AFAICS none of the enums here uses dashes, hence this should not
actually have any effect except for being more correct.
2026-04-20 09:36:09 +02:00
Lennart Poettering 40ab0df557 networkd: gnerate proper underscored enums in varlink interface
AFAICS none of the states actually user dashes/underscores, but let's
prepare for the future and be fully correct here.
2026-04-20 09:36:09 +02:00
Yu Watanabe 1c8158412f network/json: drop unnecessary return value assignment 2026-04-18 01:35:17 +09:00
Yu Watanabe 7756f0434c network/json: fix error handling 2026-04-18 01:35:17 +09:00
Jonathan Davies f921f13225 networkd: add DHCPServer PoolSize and PoolOffset DBus properties
Closes https://github.com/systemd/systemd/issues/30011
2026-04-15 14:20:32 +00:00
Michael Vogt bd141bd818 many: fix remaining check-pointer-deref issues
The updated parsing_hacks.h file uncovered a bunch of extra
things that the check-pointer-deref coccinelle script flags.

This commit fixes them to make the tree check-pointer-deref clean.
2026-04-12 15:27:15 +02:00
Zbigniew Jędrzejewski-Szmek b8514cff52 libsystemd-network: use DEFINE_POINTER_ARRAY_FREE_FUNC, rename cleanup function 2026-04-10 15:08:02 +02:00
noxiouz 69b6e950e2 networkd-wwan: drop unreachable unknown-bearer fallback path
bearer_get_by_path() only succeeds when both modem and bearer are found.
On failure, trying bearer_new_and_initialize(modem, path) was
unreachable and relied on a modem value that is not returned on that
path.

Treat unknown bearers as no-op and rely on modem_map_bearers() for
association during initialization.

Co-developed-by: Codex (GPT-5) <noreply@openai.com>
2026-04-08 17:28:19 +02:00
noxiouz b5a1ecb8fc networkd-wwan: handle link_get_by_name() errors in modem_simple_connect()
modem_simple_connect() ignored the return value of link_get_by_name()
and then checked link for NULL. Since the helper only sets the output
pointer on success, that could read an indeterminate value.

Check and log the return code directly with log_debug_errno().

Co-developed-by: Codex (GPT-5) <noreply@openai.com>
2026-04-08 13:59:32 +02:00
noxiouz 34649c6f55 networkd: keep static lease section valid on MACAddress= reset
config_parse_dhcp_static_lease_hwaddr() uses a cleanup helper that marks
a lease section invalid unless ownership is taken.

Add TAKE_PTR(lease) on the empty-rvalue reset path so subsequent valid
MACAddress= assignments in the same section are not dropped.

Co-developed-by: Codex (GPT-5) <noreply@openai.com>
2026-04-08 13:57:39 +02:00
Zbigniew Jędrzejewski-Szmek ca745e1914 Convert more programs to the new option and verb parsers (#41458) 2026-04-04 10:21:14 +02:00
Zbigniew Jędrzejewski-Szmek 1008583c91 tree-wide: print error if table_print() fails
We generally want to print an error message if table_print()
fails. Add a helper function for this and use it consistently.
This does one of the three things depending on the call site:
- a no-change reformatting of the code
- change from a custom message to the generic one
- addition of the error message where previously none was printed

In the third case, the actual use impact is very small, since the
table formatting is very unlikely to fail. But if it did, we would
often return an error without any message whatsoever, which we
never want to do.
2026-04-03 13:05:03 +02:00
Zbigniew Jędrzejewski-Szmek 0ce5a8fb4e tree-wide: drop flush&check step after table printing
Almost all callers of table_print() specify stdout or NULL (equivalent
to stdout) as the output stream. Simplify things by not requiring the
the stream to be specified.

In almost all cases, the printing of the table is surrounded by normal
printfs() that don't do explicit flushing and for which we don't check
the output stream status. Let's simplify most callers and skip this
step. The reason is not so much to avoid the extra step itself, but
instead to avoid the _handling_ of the potential failure. We generally
only want to print an error message for ENOMEM and other "internal"
errors, so strictly speaking we should filter out the errors from the
stream. By skipping the flush&check step we implicitly do this.
2026-04-03 13:04:40 +02:00
Yaping Li 39ce1ee990 report: follow up to review comments on #40619
Address review comments on
https://github.com/systemd/systemd/pull/40619#discussion_r2810892362
2026-04-02 21:48:31 -07:00
Lennart Poettering 5f598576b8 network-generator: support BOOTIF= and rd.bootif=0 options (#41028)
The network generator currently supports many of the options described
by dracut.cmdline(7), but not everything.

This commit adds support for the BOOTIF= option (and the related
rd.bootif= option) used in PXE setups.

This is implemented by treating BOOTIF as a special name/placeholder
when used as an interface name, and expecting a MAC address to be set in
the BOOTIF= parameter. The resulting .network file then uses MACAddress=
in the [Match] section, instead of Name=.
2026-04-02 16:17:11 +02:00
Luca Boccassi 34ff7243e1 networkd: fix assert with IPFamily=both in MobileNetwork conf and add minimal mock for test coverage (#41402) 2026-04-02 12:28:04 +01:00
Daan De Meyer 526b8eeb5d More assorted coverity fixes (#41413) 2026-03-30 23:34:44 +02:00
Nick Rosbrook cceddc41fd network-generator: support BOOTIF= and rd.bootif=0 options
The network generator currently supports many of the options described
by dracut.cmdline(7), but not everything.

This commit adds support for the BOOTIF= option (and the related
rd.bootif= option) used in PXE setups.

This is implemented by treating BOOTIF as a special name/placeholder
when used as an interface name, and expecting a MAC address to be set in
the BOOTIF= parameter. The resulting .network file then uses MACAddress=
in the [Match] section, instead of Name=.
2026-03-30 10:48:55 -04:00
Michael Vogt 3e9eaf45f0 network: make check-pointer-deref clean
Add the needed assert changes to make the code clean
for the new check-pointer-deref script.
2026-03-30 13:36:00 +02:00
Luca Boccassi 3fd6774633 networkd-ndisc: add assert for DNSSL allocation overflow safety
Coverity flags ALIGN(sizeof(NDiscDNSSL)) + strlen(*j) + 1 as a
potential overflow. Domain names are protocol-bounded but add an
assert to make this explicit for static analyzers.

CID#1548066

Follow-up for 1e7a0e21c9
2026-03-30 09:37:31 +01: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
Luca Boccassi e0ab84e21b networkd: fix assert with IPFamily=both in MobileNetwork conf
Fixes https://github.com/systemd/systemd/issues/41389

Follow-up for f8a4c3d375
2026-03-28 14:47:34 +00:00
ssahani 1fcb88b234 networkd: Add IPv4SrcValidMark= support
Add support for configuring net.ipv4.conf.<iface>.src_valid_mark
via the [Network] section in .network files.

Co-developed-by: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-27 09:22:06 +05:30
noxiouzandClaude Opus 4.6 7d5ec30862 network: add unmanaged interface checks to Link.Renew and Link.ForceRenew Varlink methods
The D-Bus counterparts (bus_link_method_renew, bus_link_method_force_renew)
reject calls on unmanaged interfaces with BUS_ERROR_UNMANAGED_INTERFACE,
but the Varlink methods silently succeed. Add the same guard to both
Varlink methods, returning io.systemd.Network.Link.InterfaceUnmanaged,
and declare the error in the IDL.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-19 11:50:45 +00:00
noxiouz 1416d3b69c networkctl: drop unused functions
Co-developed-by: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-18 22:55:52 +00:00
noxiouzandYu Watanabe 689e45a6cd networkctl: use io.systemd.Network.Link.Describe() Varlink method
This makes networkctl fetch bit-rate statistics and offered DHCP
leases via Link.Describe() method instead of D-Bus.

Co-authored-by: Yu Watanabe <watanabe.yu+github@gmail.com>

Co-developed-by: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-18 22:55:52 +00:00
noxiouz e90ea94392 network: add io.systemd.Network.Link.Describe() Varlink method
The handler returns the JSON produced by link_build_json().

Co-developed-by: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-18 22:55:52 +00:00
noxiouzandYu Watanabe 54e8ea6552 networkctl: use io.systemd.service.Reload() method
Co-authored-by: Yu Watanabe <watanabe.yu+github@gmail.com>

Co-developed-by: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-18 22:55:52 +00:00
noxiouz 6627dfe425 network: implement io.systemd.service.Reload() in networkd
Bind networkd's reload handler to the generic io.systemd.service.Reload
method.

Co-developed-by: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-18 22:55:52 +00:00
Yu Watanabe dde311ba14 networkctl: use new varlink methods
Co-developed-by: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-18 22:55:52 +00:00
noxiouz 506890fa0d network: add io.systemd.Network.Link.Reconfigure() Varlink method
The handler calls link_reconfigure_full() with UNCONDITIONALLY|CLEANLY
flags and defers the Varlink reply until reconfiguration completes.

Co-developed-by: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-18 22:55:52 +00:00
noxiouz 982a3fa59f network: add io.systemd.Network.Link.ForceRenew() Varlink method
The handler calls sd_dhcp_server_forcerenew() if the server is running
and logs a warning on failure.

Co-developed-by: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-18 22:55:52 +00:00
noxiouz 5e7287c2b5 network: add io.systemd.Network.Link.Renew() Varlink method
The handler calls dhcp4_renew() and logs a warning on failure.

Co-developed-by: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-18 22:55:52 +00:00
noxiouz f8722d4033 network: extend link_reconfigure_full() and manager_reload() for Varlink
Add an sd_varlink* parameter to both functions so Varlink callers can
receive a deferred reply once all async work completes, symmetrically
with the existing sd_bus_message* path.

Co-developed-by: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-18 22:55:52 +00:00
noxiouz 872feaa006 network: add BitRates field to link_build_json() and the Varlink IDL
Expose the speed meter transmit/receive rates as a BitRates struct in
the per-link JSON output and the io.systemd.Network Varlink IDL.

Co-developed-by: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-18 22:55:52 +00:00
noxiouz f9ebd7bb06 network: extract link_get_bit_rates() into networkd-speed-meter.c
Move the bit-rate computation out of property_get_bit_rates() in
networkd-link-bus.c into a standalone link_get_bit_rates() helper in
networkd-speed-meter.c, which already owns the speed meter state.

Co-developed-by: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-18 22:55:52 +00:00
Zbigniew Jędrzejewski-Szmek 31ddd87da0 tree-wide: extend verbs functions with extra per-verb data parameter
We often have a pattern where the same verb function is used for
multiple actions. This leads to an antipattern where we figure out what
action needs to be taken from argv[0] multiple times: often once in
parse_argv() to figure out what options are allowed, then once again
implicitly in dispatch_verb(), and then again in the action verb itself.
Let's allow passing a parameter into the verb to simplify this.

This matches a pattern we have in conf-parser.h, where we have both
void *userdata (more global) and void *data (per-config item). Here,
I opted for uintptr_t userdata. It seems that most of the time we'll
want to just pass an enum value. This works OK with no casts. I also
tried a void* and union. In both cases, much more boilerplate is needed:
either a cast or a macro to help avoid compiler warnings. uintptr_t
seems generic enough to cover foreseeable usecases with no fuss.

This is a noop refactoring. See next commit for an example.
2026-03-18 10:28:47 +00:00
Zbigniew Jędrzejewski-Szmek 26216a7e95 networkctl: call all verb functions verb_* 2026-03-18 10:28:47 +00:00
Yu Watanabe ed54648b47 network: route bound to a link requires the link is up
We checked if the link is up only when configuring (explicit) nexthop,
but we did not checked that when configuring route which has (implicit)
nexthop.

Let's move the checks from nexthop_is_ready_to_configure() to
gateway_is_ready(), which is called for both implicit and explict
nexthops.

Fixes #40106.
2026-03-09 11:46:14 +09:00
Yu Watanabe 43989de642 network: check if gateway is ready only when the nexthop is bound to link
Currently, we support three types of nexthop:
1. simple nexthop, which is bound to link, may have specific gateway
   address,
2. blackhole nexthop, which is global configuration and is not bound to
   any links,
3. group nexthop, which is also global configuration and is not bound to
   any links.

Thus, gateway_is_ready() is only necessary to call for simple nexthop
case. Let's make the logic simpler.
2026-03-09 11:42:45 +09:00
Yu Watanabe ec4f646759 network: introduce link_is_up() helper function 2026-03-09 10:57:06 +09:00
Yu Watanabe 2f32c49a18 network: slightly reword polkit message 2026-03-06 04:43:30 +09:00
Frantisek Sumsal 90f5d2a202 tree-wide: various fixlets suggested by Coccinelle 2026-03-05 10:27:58 +01:00
Mike Yuan 18d1f2dced tree-wide: make private hash ops static 2026-03-04 14:32:15 +01:00
Oleksandr Andrushchenko 899992bc1e network: Rename ModemManager .network section WRT tech, not project...
and use dedicated knobs for every option used in
former SimpleConnectProperties.
New section is [MobileNetwork] with the following configuration options:

APN=
AllowedAuthenticationMechanisms==
User=
Password=
IPFamily=
AllowRoaming=
PIN=
OperatorId=
2026-03-04 12:42:19 +01:00
noxiouz fbf533859f network: fix error aggregation in wwan_check_and_set_configuration()
When removing marked routes, the condition `if (ret)` incorrectly
overwrites any previously accumulated error in `ret` with the latest
return value `r`, even if `r >= 0` (success). This means an earlier
real error can be silently cleared by a subsequent successful
route_remove() call.

The parallel address_remove() block just above uses the correct
`if (r < 0)` pattern. Apply the same fix to the route_remove() block.
2026-03-03 08:59:48 +09:00
Yu Watanabe 4b4eba1666 tree-wide: use _contains() rather than _get()/_find() 2026-03-02 23:10:22 +09:00
Yu Watanabe 2900f04c82 network: do not create state file for removed interface
Fixes #40817.
2026-02-26 08:50:50 +01:00