Commit Graph

1562 Commits

Author SHA1 Message Date
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
Yu Watanabe
ee3455cf11 fd-util: rename CLOSE_AND_REPLACE() -> close_and_replace()
We have free_and_replace() and friends, they are all named with lower
letters, even they are macros, not functions.
For consistency, let's rename CLOSE_AND_REPLACE() with lower letters.

This also mekes the macro used more places.
2022-09-17 09:54:41 +02:00
David Tardon
995340074e tree-wide: use ASSERT_PTR more 2022-09-13 08:13:27 +02:00
Jan Janssen
5570a09702 tree-wide: Fix format specifier warnings for %x
Unfortunately, hex output can only be produced with unsigned types. Some
cases can be fixed by producing the correct type, but a few simply have
to be cast. At least casting makes it explicit.
2022-08-30 12:03:33 +02:00
Jan Janssen
c0f86d66f3 tree-wide: Use correct format specifiers
gcc will complain about all these with -Wformat-signedness.
2022-08-30 12:03:28 +02:00