Commit Graph
5750 Commits
Author SHA1 Message Date
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
Luca Boccassi 555d878749 varlink: say which socket failed to bind in log message
Makes it a lot easier to debug failures
2025-11-15 10:02:10 +09: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
Dr. David Alan Gilbert 72afecf1f6 network: Typo fix configur*a*d
configurad->configured
2025-11-10 10:58:11 +09:00
Anton Tiurin dd2934d44e network: expose Describe Varlink, use for networkctl list & status
Both `list` and `status` with `--json=pretty|short` show the description.
It is fetched via D-Bus by org.freedesktop.network1.Manager.Describe

This change exposes the same data via Varlink API `io.systemd.Network.Describe`
and migrates networkctl list and status commands to use Varlink API.

Update GetStates IDL to use enums for link states.
2025-11-08 00:08:00 +09:00
Nick Rosbrook d49a0bd1da wait-online: ignore unused DNSConfiguration fields when dispatching JSON
The io.systemd.Resolve.Monitor.DNSConfiguration type is being expanded,
but we do not need the extra information for determining online status.

Ignore these fields when dispatching JSON to avoid "Unrecognized object field"
messages adding noise to systemd-networkd-wait-online debug output.
2025-11-06 05:17:59 -05:00
Nick Rosbrook 5e777155d5 wait-online: dispatch DNSConfiguration with SD_JSON_ALLOW_EXTENSIONS
Currently if an unknown field is encountered in the JSON, it is a fatal
error. Dispatch with SD_JSON_ALLOW_EXTENSIONS to avoid this.
2025-11-06 05:17:59 -05:00
Yu Watanabe 5963cdf498 tree-wide: add missing '#pragma once' 2025-11-05 05:16:34 +09:00
Yu Watanabe b1ba55a8a7 network: do not restart DHCPv4 client on stopping/restarting networkd
Follow-up for fc35a9f8d1 (v255).
Fixes #39299.
2025-10-31 17:59:22 +09:00
Yu Watanabe 3f9db926e4 network: propagate error in link_carrier_lost()
Follow-up for 07021ed4f5 (v258).
2025-10-31 17:33:58 +09:00
Yu Watanabe b5d63191ca network/sysctl: logs when per-link IPMasquerade= setting changes the global IPv6Forwarding= setting
All other cases, settings on different interfaces are completely
independent. But IPMasquerade=yes on an interface enables the global
IPv6Forwarding= setting, and hence affects other interfaces.
Let's log about that.

Prompted by https://github.com/systemd/systemd/issues/39304#issuecomment-3430382233.
2025-10-30 14:58:16 +01:00
Yu Watanabe b25fac6776 network/dhcp-server: several cleanups for setting domain to DHCP server
- use dns_name_parent(),
- only ignore errors when the current hostname does not have domain
  part, but make other errors like ENOMEM critical.

Follow-ups for 3eb7b881bd.
2025-10-20 12:21:04 +09:00
Daan De Meyer b8ee7c2206 tree-wide: Various forward header cleanups
- Make sure forward headers have the iwyu pragma to always keep them
- Make sure we always include the daemon specific forward header
  instead of shared-forward.h
- Remove shared-forward.h include where the daemon specific forward
  header is already included
2025-10-17 21:11:23 +09:00
Daan De Meyer f102bc3e5f tree-wide: Introduce sd-forward.h and shared-forward.h headers
Let's not leak details from src/shared and src/libsystemd into
src/basic, even though you can't actually do anything useful with
just forward declarations from src/shared.

The sd-forward.h header is put in src/libsystemd/sd-common as we
don't have a directory for shared internal headers for libsystemd
yet.

Let's also rename forward.h to basic-forward.h to keep things
self-explanatory.
2025-10-16 17:00:29 +02:00
Govind Venugopal 3eb7b881bd network: add DHCP server domain name option support (#39260)
Implements DHCP option 15 (Domain Name) for systemd-networkd's DHCP
server, allowing administrators to configure the DNS default domain that
clients should use.

This addresses the feature request in issue #37077, where users needed
to manually configure domain names using
SendOption=15:string:example.com as a workaround.

This adds two new configuration options to the [DHCPServer] section:
- EmitDomain= (boolean): whether to send domain name to clients
- Domain= (string): the domain name to send (e.g., "example.com")

Example configuration:
  [DHCPServer] EmitDomain=yes Domain=example.com

This eliminates the need for manual workarounds using
SendOption=15:string:...

Fixes #37077
2025-10-15 11:20:41 +02:00
Sebastian Gross 582a1e1877 network-generator: ip: do not fail on ntp value
linux https://www.kernel.org/doc/html/latest/admin-guide/nfs/nfsroot.html
states `ntp0-ip` as parameter to `ip=` command line.

Until now systemd-network-generator would fail if ntp was provided with
-EINVAL due to trailing arguments.

Stay in line with kernel doc and handle ntp value properly.
2025-09-26 21:11:11 +09:00
Anton Tiurin 59d946ee6b networkd: fia xRequiredOperationalStateForOnline serializtion
In integration tests (for example TEST-85-NETWORK-NetworkctlTests)

LINK_OPERSTATE_RANGE_INVALID and required_for_online == -1 are serialized as
```
"RequiredForOnline": "true",
"RequiredOperationalStateForOnline": [null, null]
```
Such link should be reported as required_for_online=False and not
serialize nulls.
2025-09-26 14:55:50 +09:00
Anton Tiurin 9893859beb networkctl: change bitrate format from 'bps' to 'Bps' 2025-09-26 14:41:20 +09:00
Lennart Poettering b7f6bdbbd3 service-util: add generic parser for runtime scope 2025-09-25 22:43:59 +02:00
Daan De Meyer 8796164189 tree-wide: Remove unused includes (#39023) 2025-09-19 16:07:04 +02:00
Daan De Meyer 9adb4685df tree-wide: Remove unused includes 2025-09-19 14:46:55 +02:00
Yu Watanabe 7184f8366f firewall-util: drop FirewallContext
After iptables support is dropped, FirewallContext is a trivial
wrapper of sd_netlink. Let's drop it and directly use sd_netlink.
2025-09-19 15:33:17 +09:00
Yu Watanabe 6fdaa3d22c network/netdev: realign gperf table 2025-09-17 22:07:27 +09:00
Yu Watanabe f7dffbf835 network: shorten conf parser names and realign gperf table 2025-09-17 22:07:27 +09:00
Anton Tiurin 505deaff01 networkctl: list drop unused dbus connection
Do not acquire dbus connection as it is unused in list_links
2025-09-17 14:39:34 +02:00
Yu Watanabe 13852e1914 network: remove unnecessary fd saved in fd-store
Fixes the following warning:
```
[  130.968170] H systemd-networkd[4288]: Restart operation initiated.
[  130.968265] H systemd-networkd[4288]: Serializing...
[  130.968274] H systemd-networkd[4288]: There is nothing to serialize.
(snip)
[  130.978756] H systemd[1]: Stopped systemd-networkd.service.
(snip)
[  130.991407] H systemd[1]: Starting systemd-networkd.service...
(snip)
[  131.077440] H systemd-networkd[4318]: Enumeration completed.
[  131.077471] H systemd-networkd[4318]: Deserializing...
[  131.077491] H systemd-networkd[4318]: Failed to parse json (line=0, column=0): No data available
[  131.077524] H systemd-networkd[4318]: Failed to deserialize the previous invocation, ignoring: No data available
```
2025-09-04 19:50:28 +09:00
Yu Watanabe 570210eb28 network/bridge-vlan: fix segfault
Fixes a bug introduced by 78738adf88.
Fixes #38515.
2025-08-08 19:39:31 +09:00
Kevin P. Fleming 2fe2ee9adb logging: Improve logging messages related to NFTSet.
The 'NFTSet' directive in various units adds and removes entries in nftables
sets, it does not add or remove entire sets. The logging messages should
indicate that an entry was added or removed, not that a set was added or
removed.
2025-08-07 08:10:02 +09:00
Luca Boccassi 7108a882b3 network: fix build with libbpf < 0.7
bpf_loop() and bpf_strncmp(), used by sysctl-monitor, were introduced
in libbpf 0.7, so skip the module if using an older version

Follow-up for 6d9ef22acd
2025-08-06 13:33:21 +01:00
Yu Watanabe 7292d676d0 test: skip verification for racy test cases
FORMAT_LIFETIME() internally calls now(), hence we cannot provide any
reliable verifications for finite lifetime.
2025-07-28 03:37:31 +09:00
Yu Watanabe 5bd37b352c network/state-file: coding style fixlet
Follow-up for 168ad243cc.
2025-07-23 22:24:19 +09:00
Yu Watanabe 5489a9c409 network/state-file: ignore any errors in sd_dhcp6_lease_get_dnr()
Follow-up for 168ad243cc.

For consistency with other places.
2025-07-23 22:24:19 +09:00
Yu Watanabe 2924a6c927 network/json: ignore -ENODATA and any failures from sd_dhcp_lease_get_sip()
Addresses https://github.com/systemd/systemd/pull/38269#discussion_r2225375899.

Follow-up for 238c427aa9.
2025-07-23 22:24:19 +09:00
Mike Yuan a6da6c9050 networkctl-config-file: validate args are valid filenames
... as opposed to full paths

Fixes #38288
2025-07-23 22:11:42 +09:00
Zbigniew Jędrzejewski-Szmek dcccbe049c tree-wide: several fixlets for log message and comment (#38263) 2025-07-23 10:17:33 +02:00
haxibami 238c427aa9 network/dhcp6: add SIP server support 2025-07-22 17:05:13 +09:00
Yu Watanabe 7f6086d530 tree-wide: do not use %m with SYNTHETIC_ERRNO() 2025-07-22 03:05:54 +09:00
Yu Watanabe 5918ba9c69 tree-wide: fix log messages: "Failed VERB" -> "Failed to VERB" 2025-07-22 03:05:33 +09:00
Linus Heckemann 94e5d8b0e0 netdev-util: allow finding addresses from dhcp-pd 2025-07-16 16:17:19 +02:00
Linus Heckemann 4d6c0a55e1 netdev-util: don't repeat AF check for each address type 2025-07-14 13:56:28 +02:00
DaanDeMeyer f4df5902d8 bpf: Use hyphens in directory names instead of underscores 2025-07-13 12:45:37 +02:00
DaanDeMeyer 47f761fda6 basic: Use hyphens in missing header names instead of underscores 2025-07-13 12:41:14 +02:00
Yu Watanabe 52d6032b4a network/radv: allow to send Router Advertisement from e.g. Tun interface
Sending router advertisement requires an IPv6LL address and
IFF_MULTICAST flag. The length of the hardware address is irrelevant.

Closes #38170.
2025-07-11 20:53:04 +09:00
Yu Watanabe 291b6feedd network: split link_may_have_ipv6ll() into two
This renames and splits link_may_have_ipv6ll() into
link_ipv6ll_enabled_harder() and link_multicast_enabled(),
as they are completely irrelevant to each other.

Also, this makes link_ipv6ll_enabled_harder() work non-Wireguard
interfaces.
2025-07-11 20:53:04 +09:00
Yu Watanabe 78738adf88 network/bridge-vlan: allow to configure bridge vlan on stacked bridge master interface
Fixes #38157.
2025-07-11 08:59:28 +02:00
Daan De Meyer b0ea79c5b5 network: Add varlink socket unit 2025-07-03 11:22:34 +02:00
Yu Watanabe 4f18ff2e29 tree-wide: include unistd.h where necessary
We use symbols provided by unistd.h without including it. E.g.
open(), close(), read(), write(), access(), symlink(), unlink(), rmdir(),
fsync(), syncfs(), lseek(), ftruncate(), fchown(), dup2(), pipe2(),
getuid(), getgid(), gettid(), getppid(), pipe2(), execv(), _exit(),
environ, STDIN_FILENO, STDOUT_FILENO, STDERR_FILENO, F_OK, and their
friends and variants, so on.

Currently, unistd.h is indirectly included mainly in the following two paths:
- through missing_syscall.h, which is planned to covert to .c file.
- through signal.h -> bits/sigstksz.h, which is new since glibc-2.34.
  Note, signal.h is included by sd-eevent.h. So, many source files
  indirectly include unistd.h if newer glibc is used.

Currently, our baseline on glibc is 2.31. We need to support glibc older
than 2.34, but unfortunately, we do not have any CI environments with
such old glibc. CIFuzz uses glibc-2.31, but it builds only fuzzers, and
many files are even not compiled.
2025-06-30 09:19:15 +02:00
Zbigniew Jędrzejewski-Szmek 7d247d3cb8 meson: drop explicit custom_target names
[1] says:
> Since 0.60.0 the name argument is optional and defaults to the basename of
> the first output
We specify >= 0.62 as the supported version, so drop the duplicate name in all cases
where it is the same as outputs[0], i.e. almost all cases.

[1] https://mesonbuild.com/Reference-manual_functions.html#custom_target
2025-06-28 17:14:50 +02:00
Lennart Poettering 5584632f40 cpu-set-util: fix null pointer dereference and several cleanups (#37900)
Fixes CID#1611618.
2025-06-27 14:59:25 +02:00
Lennart Poettering 51cc3825d1 tree-wide: use sd_bus_message_send() instead of sd_bus_send() wherever possible
Also, add a coccinelle script that patches this automatically.
2025-06-24 23:23:40 +09:00