Commit Graph
1591 Commits
Author SHA1 Message Date
Yu Watanabe b5d39bb3ca tree-wide: also use CMSG_TYPED_DATA() on writing message header 2023-04-16 13:26:58 +09:00
Yu Watanabe 1ebb0953f0 sd-dhcp-server: use CMSG_FIND_DATA() at one more place 2023-04-16 13:26:58 +09:00
Yu Watanabe 789f5c6f70 tree-wide: copy timestamp data from cmsg
On RISCV32, time_t is 64bit and size_t is 32bit, hence the timestamp
data in message header may not be aligned.

Fixes #27241.
2023-04-16 13:26:58 +09:00
Lennart Poettering b1d0219136 tree-wide: port more code over to CMSG_TYPED_DATA() 2023-04-13 10:49:23 +02:00
Frantisek Sumsal 1da3cb8141 tree-wide: simplify x ? x : y to x ?: y where applicable 2023-03-18 14:23:11 +01:00
Jan Janssen 9214828313 meson: Introduce userspace dep
This will help in a later commit to separate userspace from EFI builds.
2023-03-10 11:40:14 +01:00
Yu Watanabe 58fbf167d7 Merge pull request #26528 from keszybz/valgrind-simplification
Drop the -Dvalgrind configuration option
2023-02-22 23:04:12 +09:00
Zbigniew Jędrzejewski-Szmek 50b35193ec meson: merge our two valgrind configuration conditions into one
Most of the support for valgrind was under HAVE_VALGRIND_VALGRIND_H, i.e. we
would enable if the valgrind headers were found. The operations then we be
conditionalized on RUNNING_UNDER_VALGRIND.

But in a few places we had code which was conditionalized on VALGRIND, i.e. the
config option. I noticed because I compiled with -Dvalgrind=true on a machine
that didn't have valgrind.h, and the build failed because
RUNNING_UNDER_VALGRIND was not defined. My first idea was to add a check that
the header is present if the option is set, but it seems better to just remove
the option. The code to support valgrind is trivial, and if we're
!RUNNING_UNDER_VALGRIND, it has negligible cost. And the case of running under
valgrind is always some special testing/debugging mode, so we should just do
those extra steps to make valgrind output cleaner. Removing the option makes
things simpler and we don't have to think if something should be covered by the
one or the other configuration bit.

I had a vague recollection that in some places we used -Dvalgrind=true not
for valgrind support, but to enable additional cleanup under other sanitizers.
But that code would fail to build without the valgrind headers anyway, so
I'm not sure if that was still used. If there are uses like that, we can
extend the condition for cleanup_pools().
2023-02-22 11:39:44 +01:00
Jan Janssen 2ed35b2f3e meson: Use dicts for fuzzer definitions 2023-02-21 15:10:26 +01:00
Jan Janssen 822cd3ff25 meson: Use dicts for test definitions
Although this slightly more verbose it makes it much easier to reason
about. The code that produces the tests heavily benefits from this.

Test lists are also now sorted by test name.
2023-02-21 15:10:26 +01:00
Yu Watanabe 0b75493da0 tree-wide: fix typo and comment style update 2023-02-15 10:08:16 +09:00
Zbigniew Jędrzejewski-Szmek d42add3c17 sd-network: stop using fake flexible array 2023-02-06 10:19:52 +01:00
Yu Watanabe b52031dbbc sd-dhcp-server: allow to send header only message
If we receive a header only message, and the server is running in relay
mode, then the assertion was triggered.

Fixes #26151.
2023-01-28 10:44:30 +00:00
Jan Janssen 4a7ee0a521 meson: Do not include headers in source lists
Meson+ninja+compiler do this for us and are better at it.

https://mesonbuild.com/FAQ.html#do-i-need-to-add-my-headers-to-the-sources-list-like-in-autotools
2023-01-24 22:04:03 +01:00
Lennart Poettering 7153213e40 string-util: add common implementation of function that converts sized character buffers to NUL terminated C strings 2023-01-21 10:45:25 +01:00
Luca Boccassi a6a9ee4b36 Merge pull request #26115 from yuwata/test-fix-memleak-fdleak
test: fix memleak and fd leak
2023-01-20 11:00:53 +00:00
Yu Watanabe d09df6b94e tree-wide: fix typo 2023-01-20 15:32:16 +09:00
Yu Watanabe 86d82cb888 test-ndisc: fix memleak and fd leak
Fixes issues reported at #22576.
2023-01-20 14:54:53 +09:00
chris b895aa5ff5 send dhcpv6 release when stopping 2023-01-17 21:26:18 +09:00
Yu Watanabe 841dfd3dc0 sd-dhcp-client: gracefully handle invalid ether type client ID
Currently, sd-dhcp-server accepts spurious client IDs, then the leases
exposed by networkd may be invalid. Let's make networkctl gracefully
show such leases.

Fixes #25984.
2023-01-16 20:00:08 +00:00
Yu Watanabe ea9dbf51c6 sd-dhcp6: always append the default status message generated from status code
Fixes #25988.
2023-01-16 19:46:05 +00:00
chris ea57796854 optionally set socket priority on DHCPv4 raw socket 2023-01-12 13:26:47 +09:00
Cristian Rodríguez 2cc697d740 libsystemd-network: FTBS in c2x mode
cannot pass false as argument because function wants a pointer to bool
instead, use NULL instead
2023-01-03 15:58:55 +01:00
Yu Watanabe 5bb1d7fbab tree-wide: use -EBADF more 2022-12-21 01:50:33 +09:00
Yu Watanabe 19ee48a6c2 tree-wide: introduce PIPE_EBADF macro 2022-12-20 11:12:58 +09:00
Yu Watanabe f26c38edfa fuzz: sort headers 2022-12-20 11:12:58 +09:00
Zbigniew Jędrzejewski-Szmek 3401477982 tree-wide: use -EBADF also in pipe initializers
In some places, initialization is dropped when unnecesary.
2022-12-19 15:00:59 +01:00
Zbigniew Jędrzejewski-Szmek 254d1313ae tree-wide: use -EBADF for fd initialization
-1 was used everywhere, but -EBADF or -EBADFD started being used in various
places. Let's make things consistent in the new style.

Note that there are two candidates:
EBADF 9 Bad file descriptor
EBADFD 77 File descriptor in bad state

Since we're initializating the fd, we're just assigning a value that means
"no fd yet", so it's just a bad file descriptor, and the first errno fits
better. If instead we had a valid file descriptor that became invalid because
of some operation or state change, the other errno would fit better.

In some places, initialization is dropped if unnecessary.
2022-12-19 15:00:57 +01:00
Thomas Haller 6759b62720 all: avoid various "-Wcast-align=strict" warnings 2022-12-09 08:58:07 +01:00
Zbigniew Jędrzejewski-Szmek 3ae6b3bf72 basic: rename util.h to logarithm.h
util.h is now about logarithms only, so we can rename it. Many files included
util.h for no apparent reason… Those includes are dropped.
2022-11-08 18:21:10 +01:00
Yu Watanabe 14805b1468 dhcp: use the attached sd_device object when generating IAID
Note, previously `use_mac` set with `test_mode`. As `dev`, which is set with
`client->dev`, is not set when running test or fuzzer. Hence, the condition
```
if (udev_available() && !use_mac)
```
is effectively equivalent to
```
if (dev)
```
So, this commit mostly does not change behavior. Except for the following
corner case.

The sd_device object assigned from networkd (that is, Link.dev) never
has ID_RENAMING udev property, as sd_device objects which has the property
are filtered out at `link_check_initialized()` or `manager_udev_process_link()`
in networkd-link.c.

However, sd_device object created in `dhcp_identifier_set_iaid()` in the
previous code may have it. Such situation may (at least, theoretically)
happen when the network interface is renamed after initialized, e.g. by
creating the following spurious .link file:
```
[Match]
OriginalName=eno1
[Link]
Name=lan
```
and then trigger uevent for the network interface while systemd-networkd
calling `dhcp_identifier_set_iaid()`.
2022-10-27 09:12:47 +09:00
Yu Watanabe 793178b987 sd-dhcp6-client: introduce sd_dhcp6_client_attach_device()
It will be used later.
2022-10-26 08:08:35 +09:00
Yu Watanabe be615f7c14 sd-dhcp-client: introduce sd_dhcp_client_attach_device()
It will be used later.
2022-10-26 08:08:35 +09:00
Zbigniew Jędrzejewski-Szmek 0923b4253c tree-wide: replace "plural(s)" by "plurals"
(s) is just ugly with a vibe of DOS. In most cases just using the normal plural
form is more natural and gramatically correct.

There are some log_debug() statements left, and texts in foreign licenses or
headers. Those are not touched on purpose.
2022-10-17 15:10:53 +02:00
Yu Watanabe 6c65a9e1d6 Merge pull request #24973 from keszybz/simplify-variable-declarations
Simplify variable declarations
2022-10-12 19:36:47 +09:00
Zbigniew Jędrzejewski-Szmek 59818f4381 libsystemd-network: trivial simplification 2022-10-12 09:18:24 +02:00
Zbigniew Jędrzejewski-Szmek 1d3fae91f7 Merge pull request #24867 from yuwata/sd-dhcp6-client-large-packet
sd-dhcp6-client: allow to build large packet
2022-10-12 09:18:07 +02:00
Luca Boccassi dd4212105e Merge pull request #24957 from yuwata/network-ignore-failure-in-sending-solicitation
network: ignore failure in sending solicitation
2022-10-11 21:58:26 +02:00
Zbigniew Jędrzejewski-Szmek 0b6a47957b tree-wide: drop () around the first argument of a ternary op
https://github.com/systemd/systemd/pull/24933#discussion_r991242789
2022-10-11 16:59:00 +02:00
Yu Watanabe abb977a61a sd-radv: mention that failures in sending RA are ignored 2022-10-11 16:22:35 +09:00
Yu Watanabe 852bf93826 sd-ndisc: ignore failure in sending solicitation
Even if a bonding master interface has carrier, the underlying slave
interfaces may not. In such a case, sending solicitation fails with
-ENOBUS. Here, let's unconditionally ignore errors, as anyway we will
send a solicitation later.

Fixes #24717.
2022-10-11 16:19:16 +09:00
Yu Watanabe 9d2d346aae sd-dhcp6-client: allow to build large packet
Previously, the maximum packet size was hardcoded with 512 + size of
the DHCP header. This makes the packet size increased when necessary.
See option_append_hdr().

Previously, all functions which append DHCP options took the head of the
unused area of the packet, and the size of the free area.
However, with this change, the buffer for the whole packet may be
reallocated, hence now they take the head of the packet and the offset
to the free area.

Fixes #24851.
2022-10-02 23:05:05 +09:00
Yu Watanabe 0454223840 sd-dhcp6-client: rename buf -> p
No functional changes, just preparation for the next commit.
2022-10-02 23:05:05 +09:00
Yu Watanabe cb9c303d70 sd-dhcp6-client: use GREEDY_REALLOC() in dhcp6_option_append_vendor_class() 2022-10-02 23:05:05 +09:00
Yu Watanabe 60cbf2ea82 sd-dhcp6-client: use GREEDY_REALLOC()
And merge 'total' and 'offset' -> 'n'
2022-10-02 23:05:05 +09:00
Yu Watanabe 451daa394e sd-dhcp6-client: slightly shorten dhcp6_option_append_fqdn() 2022-10-02 23:05:05 +09:00
Yu Watanabe 6f8c3de6b7 sd-dhcp6-client: simplify dhcp6_option_append_ia() 2022-10-02 23:05:05 +09:00
Yu Watanabe 4ec5b5c778 sd-dhcp6-client: make dhcp6_option_append_fqdn() or friends handle zero length value gracefully 2022-10-02 23:05:05 +09:00
Yu Watanabe 93ed1c0eb9 sd-dhcp6-client: use assert() in non-public functions 2022-10-02 23:05:05 +09:00
Yu Watanabe 4124b03b8c sd-dhcp6-client: do not use implicit cast from integer to boolean 2022-10-02 23:05:05 +09:00