Commit Graph

1965 Commits

Author SHA1 Message Date
Daan De Meyer
9adb4685df tree-wide: Remove unused includes 2025-09-19 14:46:55 +02:00
ssoss
1e55da38aa network: add new DHCPv6 message types and options
Gives enum definitions for the DHCPv6 options from RFC9527 and RFC 9686
and the new message types defined in RFC 9686.
2025-07-31 05:41:53 +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
Yu Watanabe
3eb5402b5c networkd/dhcp6: Add support for IPv6 SIP servers (#38269)
This pull-request adds support for IPv6 SIP servers, which can be
obtained from DHCPv6 options.

[RFC3319](https://www.rfc-editor.org/rfc/rfc3319.html) defines two
options for this: option 21 (SIP Servers Domain Name List) and option 22
(SIP Servers IPv6 Address List).

systemd-networkd currently only supports IPv4 SIP servers, but ISPs like
NTT EAST provide IPv6 SIP servers. Exposing this in the D-Bus API would
allow other programs, such as downstream DHCPv6 servers, to utilize it.

Usage:

```
[DHCPv6]
UseSIP=yes
```

Partial output of `run0 systemd-networkd-tests.py
NetworkdDHCPClientTests.test_dhcp_client_use_sip`:

```console
> networkctl status veth99
● 17: veth99
                 NetDev File: /run/systemd/network/25-veth.netdev
                   Link File: /usr/lib/systemd/network/99-default.link
                Network File: /run/systemd/network/25-dhcp-client.network
                              └─/run/systemd/network/25-dhcp-client.network.d/override.conf
                       State: routable (configured)
                Online state: online
                        Type: ether
                        Kind: veth
                      Driver: veth
            Hardware Address: 12:34:56:78:9a:bc
                         MTU: 1500 (min: 68, max: 65535)
                       QDisc: noqueue
IPv6 Address Generation Mode: eui64
    Number of Queues (Tx/Rx): 2/2
            Auto negotiation: no
                       Speed: 10Gbps
                      Duplex: full
                        Port: tp
                     Address: 192.168.5.181 (DHCPv4 via 192.168.5.1)
                              2600::15
                              fe80::1034:56ff:fe78:9abc
                     Gateway: 192.168.5.1
                              fe80::1034:56ff:fe78:9abd
                         SIP: 192.168.5.1
                              2600::1
                              foo.example.com
           Activation Policy: up
         Required For Online: yes
            DHCPv4 Client ID: IAID:0x7ec6b6c/DUID
          DHCPv6 Client IAID: 0x7ec6b6c
          DHCPv6 Client DUID: DUID-EN/Vendor:0000ab11617740de1342c3a2
```
2025-07-23 08:09:06 +09:00
haxibami
d2191515ba sd-dhcp6-client: add SIP server domain support 2025-07-22 16:54:08 +09:00
haxibami
551bfe7738 sd-dhcp6-client: add SIP server address support 2025-07-22 16:31:52 +09:00
Yu Watanabe
7f6086d530 tree-wide: do not use %m with SYNTHETIC_ERRNO() 2025-07-22 03:05:54 +09:00
Beniamino Galvani
8f5eaeb143 sd-dhcp6-lease: fix calculation of t2
sd_dhcp6_lease_get_t2() was returning t1, and so the client was going directly
to the rebind state skipping the lease renewal.

Reported-by: Jaime Caamano <jcaamano@redhat.com>
Fixes: 394fac52d0 ("sd-dhcp6-client: introduce sd_dhcp6_lease_get_t1() and friends")
2025-07-22 02:15:43 +09: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
Yu Watanabe
92b64168f6 sd-lldp: replace ETHERTYPE_LLDP with ETH_P_LLDP
ETH_P_LLDP is defined in linux/if_ether.h.
2025-06-19 19:08:45 +09:00
Yu Watanabe
b6f96f635f sd-lldp-tx: introduce sd_lldp_tx_describe() to dump current settings 2025-06-18 01:51:16 +09:00
Yu Watanabe
4c45437b60 sd-lldp-rx: also dump received MUD URL 2025-06-18 00:53:24 +09:00
Yu Watanabe
898513783e sd-lldp-tx: allow to emit VLAN ID 2025-06-18 00:53:24 +09:00
Yu Watanabe
0597109ddf sd-lldp-tx: append capabilities before MUD URL
No functional change, but let's append vendor specific informations
after others to sort the TLVs with their type.
2025-06-18 00:53:24 +09:00
Yu Watanabe
27546b769c sd-lldp-tx: do not expose machine ID by default
Previously, systemd-networkd sent machine ID as chassis ID.
Let's use application specific machine ID.

This is a kind of backward compat breaking. Hence, this also introduces
the support of $SD_LLDP_SEND_MACHINE_ID environment variable.

Closes #37613.
2025-06-18 00:53:20 +09:00
Yu Watanabe
98b02dd7e7 sd-dhcp-server: reopen fd only when it is valid
Fixes a bug in 11b88419ae.
2025-06-14 02:53:31 +09:00
Colin Foster
2871f967cc test-dhcp-client: add test for bootp clients
Verify that BOOTP replies are successfully handled by the sd-dhcp-client
when configured for BOOTP.

Co-authored-by: Avram Dorfman <dorfman@est.org>
2025-06-13 14:15:04 +09:00
Colin Foster
4ad29bad7b sd-dhcp-client: add ability to support bootp
BOOTP can be used to sign a static IP to clients. Instead of using the
four message exchange, and Option 53 (DHCP Message Type) there is only a
two message exchange. This adds the support for this exchange.

Co-authored-by: Avram Dorfman <dorfman@est.org>
Co-authored-by: Yu Watanabe <watanabe.yu+github@gmail.com>
2025-06-13 14:14:33 +09:00
Yu Watanabe
98a9b0f92a sd-dhcp-client: move comment to relevant place 2025-06-13 13:35:21 +09:00
Yu Watanabe
556f641fb5 dhcp: several coding style cleanups
- rename arguments for storing results,
- reorder arguments to move ret_xyz at the end,
- add several missing assertions.
2025-06-13 13:35:21 +09:00
Colin Foster
be40a31f5c dhcp: relocate type field
The type field is a DHCP-specific parameter. Relocate the parameter so
there is a clearer separation between DHCP and BOOTP parameters.
2025-06-13 13:35:21 +09:00
Yu Watanabe
6c2558a2fc tree-wide: allow building with -Wgnu-variable-sized-type-not-at-end option for clang (#37499)
Follow-up for #36993.
Closes #37497.
2025-06-07 01:02:38 +09:00
Lorenzo Arena
6b78f13b7e network: test-lldp-rx: set more variable as static const 2025-06-06 09:35:11 +02:00
Lorenzo Arena
496b21ab8e sd-lldp-rx: add VLAN ID parsing
Closes #28354.
2025-06-06 09:35:11 +02:00
Yu Watanabe
fda47cd92b sd-dhcp: explicitly set buffer size of each type 2025-06-04 13:13:14 +09:00
Daan De Meyer
5cdf13c70c libsystemd: Clean up includes
For libsystemd's headers, the changes made depend on whether the
header is installed or not. For installed headers, the only change
made is that commonly included headers were moved to _sd-common.h.
For these headers, there should be no noticeable change in behavior
when including them. For non-installed headers, includes were replaced
with forward declarations where possible as usual.

Split out of #37344.
2025-05-25 03:40:24 +09:00
Daan De Meyer
1e35e81b2c tree-wide: Clean up includes
Preparation for cleaning up includes in src/shared.
2025-05-22 21:10:15 +02:00
Daan De Meyer
e97cd0ca9f icmp6-packet: Fix typo 2025-05-21 10:37:18 +02:00
Daan De Meyer
d86fead481 meson: Rework clang-tidy integration to be done via unit tests
Instead of using run-clang-tidy.py with its own scheduling, let's
just gather a list of source files ourselves and then use that to
add a unit test for each source file that runs clang-tidy on the
source file.

We also add a bit of logic to run clang-tidy on most header files
as well for extra coverage. This uncovered various header files that
were not standalone so this commit also includes fixes to make sure
the clang-tidy tests are all green.

We can also use this in a later commit to run clang-include-cleaner
on each source file in the same way.
2025-05-20 10:29:59 +02:00
Daan De Meyer
a583b34416 meson: Extract more objects instead of compiling multiple times
Also, let's deflatten the lists of sources in preparation for the
next commit at the same time.

In systemctl, we split out systemctl-main.c to make sure the definition
of main() is in a separate object which allows us to extract the systemctl.c
object and link it in the fuzzer target without getting a multiple definition
error when linking.
2025-05-20 10:29:58 +02:00
Jelle van der Waa
346c62f9ca treewide: correct argument comments 2025-05-15 15:39:20 +02:00
Daan De Meyer
30d20907bd meson: Remove unneeded include directories
meson by default adds the current source and build directory as include
directories. Because we structure our meson code by gathering a giant dict
of everything we want to do and then doing all the actual target generation
in the top level meson.build, this behavior does not make sense at all because
we end up adding the top level repository directory as an include directory
which is never what we want.

At the same time, let's also make sure the top level directory of the build
directory is not an include directory, by moving the version.h generation
into the src/version subdirectory and then adding the src/version subdirectory
of the build directory as an include directory instead of the top level
repository directory.

Making this change means that language servers such as clangd can't get
confused when they automatically insert an #include line and insert
"#include "src/basic/fs-util.h" instead of "#include "fs-util.h".
2025-05-12 13:35:50 +02:00
Yu Watanabe
f9550d1182 prioq: make prioq_ensure_put() type safe 2025-05-08 05:58:33 +09:00
Daan De Meyer
decad4826d static-destruct: Reduce transitive includes 2025-05-07 22:04:46 +09:00
Daan De Meyer
e53d4f343d iovec-util: Reduce transitive includes 2025-05-07 22:04:46 +09:00
Daan De Meyer
6553db6063 strv: Reduce transitive includes 2025-05-07 22:04:46 +09:00
Jelle van der Waa
70201ae720 libsystemd-network: correct argument comment 2025-05-06 16:26:47 +02:00
Jelle van der Waa
5cdec544c7 libsystemd-network: fix typo in argument comment 2025-05-05 19:38:18 +02:00
Daan De Meyer
a0233fcd86 socket-util: Replace sockaddr length macros with functions
There's no need for these to be macros, let's just make them regular
functions instead.
2025-05-02 09:41:41 +02:00
Daan De Meyer
a40f6dd4d8 sd-id128: Use static instead of _SD_ARRAY_STATIC in source files
When compiling the source files, we know static is going to be available
so there's no need to use the macro from _sd-common.h and we can just use
static instead.
2025-05-01 14:02:17 +02:00
Daan De Meyer
1cf40697e3 tree-wide: Sort includes
This was done by running a locally built clang-format with
https://github.com/llvm/llvm-project/pull/137617 and
https://github.com/llvm/llvm-project/pull/137840 applied on all .c
and .h files.
2025-04-30 09:30:51 +02:00
Daan De Meyer
d559f46384 basic: Add our own <netinet/in.h> and <net/if.h> headers
These glibc headers conflicts with the corresponding linux headers
(<linux/in.h> and <linux/if.h>) and impose an include order (the glibc one
has to be included before any linux header is included). This makes sorting
includes a royal pain so let's define our own versions of these headers using
various linux headers to do all the work and filling in the missing bits
ourselves.
2025-04-30 07:50:03 +02:00
Zbigniew Jędrzejewski-Szmek
7dcbb48e46 various: do not use assert_se as a workaround in non-test code
This partially reverts 5332be60d3. I expect that
there is no practical difference, but it seems philosophically wrong to use
assert_se(), i.e. for the generation of the code in non-debug builds, just to
suppress a warning. We have _unused_ for that, use it.

I verified that we don't get warnings with clang and -DNDEBUG=1 with this patch.
2025-04-29 21:59:32 +09:00
Beniamino Galvani
2451cd2512 networkd: reduce the IPv4 DAD timeout to 200ms
The original timeout of 7 seconds is very long for today's networks. Reduce it
to 200ms. Note that this change also affects IPv4 link-local addressing.
2025-04-26 14:44:52 +09:00
Beniamino Galvani
c2691d8e7c networkd: make the ACD timeout configurable
RFC 5227 specifies randomized intervals to avoid that a large number of hosts
powered up at the same time send their message simultaneously. Performing the
conflict detection takes a variable time between 4 and 7 seconds from the
beginning to the first announcement, as shown by the following diagram where P
indicates a probe and A an announcement:

 time(s)     0   1   2   3   4   5   6   7   8   9
             +---+---+---+---+---+---+---+---+---+
 SHORTEST    P   P   P       A       A
 LONGEST         P       P       P       A       A

The host can't use the address until the first announcement is sent. 7 seconds
is a very long time on modern computers especially considering the fact that
the round-trip time on current LAN technologies is at most few milliseconds.
Section 2.2 of the RFC addresses this matter and hints that a future standard
will adjust those timeouts; however that standard doesn't exist yet.

Make the timeout configurable via a new IPv4DuplicateAddressDetectionTimeoutSec=
option. The intervals defined in the RFC are then scaled proportionally so that
the duration of the conflict detection takes at most the given value. Interval
happening after the first announcement are not scaled, as recommended by the
RFC.
2025-04-26 14:44:31 +09:00
Daan De Meyer
bcf716ca01 tree-wide: Remove dead code
This code seems to not be used anywhere at all, so let's drop it.

Follow up for ba8d00e859
Follow up for 85686b37b0
Follow up for aff853f8ea
Follow up for 36dad381a2
2025-04-24 10:15:19 +09:00
Daan De Meyer
5332be60d3 tree-wide: Use assert_se() instead of assert() in various places
assert() is compiled away if NDEBUG is set which causes an unused
variable warning in various places when the next commit is applied
so let's use assert_se() to avoid these warnings.
2025-04-23 13:48:16 +02:00
Daan De Meyer
93a1f7921a basic: Stop including log.h in macro.h
Now that the necessary functions from log.h have been moved to macro.h,
we can stop including log.h in macro.h. This requires modifying source
files all over the tree to include log.h instead.
2025-04-18 14:19:15 +02:00
Daan De Meyer
69ebfef1a1 basic: Remove stdio-util.h include from log.h 2025-04-18 13:59:06 +02:00
Daan De Meyer
b14f74f9ab basic: Move trivial cleanup/ref/unref macros from macro.h to memory-util.h
Let's keep macro.h for the extremely generic macros that don't fit anywhere
else. Since CLEANUP_ARRAY() is already in memory-util-fundamental.h, we can
make a good case for moving the other cleanup macros in there as well.
2025-04-18 13:59:04 +02:00