1
1
mirror of https://github.com/systemd/systemd-stable.git synced 2024-12-22 13:33:56 +03:00
Commit Graph

1384 Commits

Author SHA1 Message Date
Yu Watanabe
37d4bf1cd2 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.

(cherry picked from commit b52031dbbc)
(cherry picked from commit 7aeb2a8d4e)
(cherry picked from commit 41fdc8ed32)
2023-02-13 21:10:07 +00:00
Yu Watanabe
fb16404da3 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.

(cherry picked from commit 841dfd3dc0)
(cherry picked from commit a674a398e7)
(cherry picked from commit 088d6c8521)
2023-01-28 00:50:04 +00:00
Cristian Rodríguez
e4ebc60774 libsystemd-network: FTBS in c2x mode
cannot pass false as argument because function wants a pointer to bool
instead, use NULL instead

(cherry picked from commit 2cc697d740)
(cherry picked from commit e78a1489a8)
(cherry picked from commit d857665a54)
2023-01-28 00:50:04 +00:00
Yu Watanabe
950aa1d702 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.

(cherry picked from commit 852bf93826)
(cherry picked from commit d7b83b9986)
2022-11-04 13:09:20 +01:00
Yu Watanabe
887837a5a9 dhcp: fix potential buffer overflow
Fixes a bug introduced by 324f818781.

This also renames several macros for DHCP packet size.

(cherry picked from commit 4473cd7f61)
(cherry picked from commit 037b1a8acc)
2022-11-04 13:02:20 +01:00
Yu Watanabe
3f909ca95a sd-dhcp-client: fix log message
(cherry picked from commit 3857d367f0)
(cherry picked from commit d56649142b)
2022-07-13 13:30:45 +02:00
Matthijs van Duin
0aaceca2d0 Fix placement of TTL TLV in LLDP transmit
The LLDP spec (IEEE 802.1AB) requires the three mandatory TLVs (Chassis
ID, Port ID, and TTL) to be the first three TLVs in the packet, in that
specific order, whereas systemd put the TTL near the end of the packet.

This violation caused the ethernet switch in our office to discard these
packets as malformed, and Wireshark's packet parser also chokes on them.

(cherry picked from commit b0221bb6a4)
2022-05-25 16:33:52 +02:00
Yu Watanabe
5e069e405a sd-lldp: use memcpy_safe() as the buffer size may be zero
(cherry picked from commit 87bd4b79e6)
2022-05-25 16:33:10 +02:00
Yu Watanabe
073eba2319 sd-ndisc: drop unused function
(cherry picked from commit 9a44966e63)
2022-05-25 16:33:10 +02:00
Yu Watanabe
d30d6d8166 libsystemd-network: refuse too large raw_size
Closes #23258.

(cherry picked from commit 4e88a46bfe)
2022-05-25 16:33:10 +02:00
Yu Watanabe
9f689fda54 sd-ipv4acd: actually drop the arp packet from one of the host interface
Fixes a bug in 7f77917c0e.

Fixes #23001.

(cherry picked from commit 239adf0384)
2022-04-28 19:00:24 +02:00
Zbigniew Jędrzejewski-Szmek
7310212021 meson: move files' closing brace to separate line
(cherry picked from commit 2f492a739c)
2022-03-05 21:03:32 +00:00
Zbigniew Jędrzejewski-Szmek
c76aba2b24 meson: do not use split() in file lists
The approach to use '''…'''.split() instead of a list of strings was initially
used when converting from automake because it allowed identical blocks of lines
to be used for both, making the conversion easier.

But over the years we have been using normal lists more and more, especially
when there were just a few filenames listed. This converts the rest.

No functional change.

(cherry picked from commit f1b98127ff)
2022-03-05 21:03:32 +00:00
Yu Watanabe
336711e062 sd-dhcp-server: do not offer server address
The server address may be in the pool.

(cherry picked from commit 9e0cb8b61f)
2022-02-22 21:47:38 +00:00
Yu Watanabe
995086918c sd-dhcp-server: do not assign address reserved for static leases to non-matching clients
This fix the root cause of the issue #22253.

(cherry picked from commit bd1a3eb65b)
2022-02-22 21:47:38 +00:00
Yu Watanabe
0478298bf9 sd-dhcp-server: explicitly refuse when conflicting address is requested
(cherry picked from commit 7e98fe05a0)
2022-02-22 21:47:38 +00:00
Yu Watanabe
71d05ec458 sd-dhcp-server: do not assign an address from pool when a static lease for the client ID exists
(cherry picked from commit e2ba408084)
2022-02-22 21:47:38 +00:00
Yu Watanabe
316f6bdb39 sd-dhcp-server: rename get_pool_offset() -> address_is_in_pool()
As, the value of pool_offset is not used.

(cherry picked from commit 5cc8be890d)
2022-02-22 21:47:38 +00:00
Yu Watanabe
7f36fb25d5 sd-dhcp-server: rename server_send_nak() -> server_send_nak_or_ignore()
And logs error in the function.

(cherry picked from commit eb5bff9c9d)
2022-02-22 21:47:38 +00:00
Yu Watanabe
1dcd82a7bf sd-dhcp-server: set DHCPLease::server before hashmap_put()
Otherwise, if the second push is failed, then the first hashmap contains
dirty entry.

Also, this makes hashmap_remove_value() used when removing leases to
make not wrong lease is removed from the hashmap.

Note, this just hide the root cause of the issue #22253, which will be
fixed in later commit.

Fixes #22253.

(cherry picked from commit 8a7d048d1d)
2022-02-22 21:47:38 +00:00
Thomas Haller
74dfb51f70 sd-dhcp6-client: fix sending prefix delegation request during rebind
Fixes an assertion failure "pd->type == SD_DHCP6_OPTION_IA_PD" in dhcp6_option_append_pd().

Something similar was done in commit 26a63b8132 ('sd-dhcp6-client: Fix
sending prefix delegation request (#17136)'). The justification is
probably the same.

(cherry picked from commit 58da18251f)
2022-02-14 22:00:56 +00:00
Yu Watanabe
ae95ca27be sd-dhcp-lease: fix memleak
Fixes https://github.com/systemd/systemd/pull/22294#issuecomment-1024840811.

(cherry picked from commit 06cf04dff4)
2022-02-14 21:58:27 +00:00
Yu Watanabe
2b04d3b3fc sd-dhcp-lease: fix reading unaligned memory
The destination address was read twice, one is for prefixlen, and
other is for destination address itself. And for prefixlen, the address
might be read from unaligned buffer.

This also modernizes the code.

(cherry picked from commit 7b86854307)
2022-02-14 21:58:27 +00:00
Evgeny Vereshchagin
7dc0f80588 sd-dhcp-lease: fix a memory leak in dhcp_lease_parse_search_domains
=================================================================
==81071==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 16 byte(s) in 1 object(s) allocated from:
    #0 0x51245c in __interceptor_reallocarray (/home/vagrant/systemd/build/fuzz-dhcp-client+0x51245c)
    #1 0x7f01440c67e6 in strv_push /home/vagrant/systemd/build/../src/basic/strv.c:435:13
    #2 0x7f01440ca9e1 in strv_consume /home/vagrant/systemd/build/../src/basic/strv.c:506:13
    #3 0x7f01440ca9e1 in strv_extend /home/vagrant/systemd/build/../src/basic/strv.c:558:16
    #4 0x5806e3 in dhcp_lease_parse_search_domains /home/vagrant/systemd/build/../src/libsystemd-network/sd-dhcp-lease.c:900:21
    #5 0x57c1be in dhcp_lease_parse_options /home/vagrant/systemd/build/../src/libsystemd-network/sd-dhcp-lease.c:727:21
    #6 0x572450 in parse_options /home/vagrant/systemd/build/../src/libsystemd-network/dhcp-option.c:348:33
    #7 0x571c6a in dhcp_option_parse /home/vagrant/systemd/build/../src/libsystemd-network/dhcp-option.c:376:13
    #8 0x559a01 in client_handle_offer /home/vagrant/systemd/build/../src/libsystemd-network/sd-dhcp-client.c:1543:13
    #9 0x5592bd in LLVMFuzzerTestOneInput /home/vagrant/systemd/build/../src/libsystemd-network/fuzz-dhcp-client.c:74:16
    #10 0x44a379 in fuzzer::Fuzzer::ExecuteCallback(unsigned char const*, unsigned long) (/home/vagrant/systemd/build/fuzz-dhcp-client+0x44a379)
    #11 0x42ae1f in fuzzer::RunOneTest(fuzzer::Fuzzer*, char const*, unsigned long) (/home/vagrant/systemd/build/fuzz-dhcp-client+0x42ae1f)
    #12 0x432ade in fuzzer::FuzzerDriver(int*, char***, int (*)(unsigned char const*, unsigned long)) (/home/vagrant/systemd/build/fuzz-dhcp-client+0x432ade)
    #13 0x421f86 in main (/home/vagrant/systemd/build/fuzz-dhcp-client+0x421f86)
    #14 0x7f0142fff55f in __libc_start_call_main (/lib64/libc.so.6+0x2d55f)

(cherry picked from commit 9591c0a8b3)
2022-02-14 21:56:48 +00:00
Evgeny Vereshchagin
426807c54b sd-dhcp-lease: fix an infinite loop found by the fuzzer
(cherry picked from commit 86b06c666b)
2022-02-14 21:56:48 +00:00
Yu Watanabe
530a18d493 sd-dhcp-server: refuse too large packet to send
Fixes https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=44134.

(cherry picked from commit 71df50a973)
2022-02-14 21:56:48 +00:00
Yu Watanabe
d44050a015 test: add testcase for broken NTP server option
For issue #22099.

(cherry picked from commit 95c514e9a5)
2022-01-18 12:11:58 +01:00
Yu Watanabe
2a7279f226 test: voidify test functions
This also drops unnecessary arguments, and unbreak several lines.

(cherry picked from commit 37408dd264)
2022-01-18 12:11:57 +01:00
Yu Watanabe
ab73799568 sd-dhcp6-client: expose client_parse_message()
To introduce tests for the function in later commits.

(cherry picked from commit 16de849fd8)
2022-01-18 12:11:49 +01:00
Yu Watanabe
bc56b640f6 sd-dhcp6-client: ignore broken non-critical options
The commit b89a3758e9 made the validity
check of the received message stricter. E.g. if the client received a
message with broken NTP server option, then the entire message is
dropped.

This relaxes the check. If some non-critical options are broken, then
ignore the options, but the message itself is still accepted.

Fixes #22099.

(cherry picked from commit 0ac9daa4a1)
2022-01-18 12:11:35 +01:00
Yu Watanabe
b9f27a0567 sd-radv: do not use goto for non-error-handling cases
Follow-up for 059d7b6eae.

The comment https://github.com/systemd/systemd/pull/21814#discussion_r771842132
suggests to introduce new helper, but it is used only one place.
Let's not add such, but simply replace the goto with a flag.
2021-12-19 12:23:14 +00:00
Yu Watanabe
897f720602 sd-dhcp-client: add log message when a message is received 2021-12-18 10:09:07 +09:00
Yu Watanabe
059d7b6eae sd-radv: send RA when prefix is updated 2021-12-18 10:09:07 +09:00
Zbigniew Jędrzejewski-Szmek
03f7ddf0bf meson: stop building out convenience libraries by default
The meson default for static_library() are:
build_by_default=true, install=false. We never interact with the
static libraries, and we only care about them as a stepping-stone towards
the installable executables or libraries. Thus let's only build them if
they are a dependency of something else we are building.

While at it, let's drop install:false, since this appears to be the default.

This change would have fixed the issue with lib_import_common failing
to build too: we wouldn't attempt to build it.

In practice this changes very little, because we generally only declare static
libraries where there's something in the default target that will make use of
them. But it seems to be a better pattern to set build_by_default to false.
2021-12-16 11:01:08 +01:00
Yu Watanabe
ab8a8a4e77 libsystemd-network: ignore -ENETDOWN or friends in recv()
And this makes most errors in io events ignored.
2021-12-09 09:10:51 +01:00
Zbigniew Jędrzejewski-Szmek
874e525de4 test-dhcp-option: inline iterator variable declarations 2021-12-08 10:13:50 +01:00
Zbigniew Jędrzejewski-Szmek
74e2e54896 test-dhcp-option: rename variable to avoid global/local name conflict
CodeQL was complaining that the local variable obscurs the global
one. It is indeed a bit confusing when reading this… Let's rename
the variable to avoid confusing the reader.
2021-12-08 10:13:44 +01:00
Yu Watanabe
990d0aa980 dhcp: fix assertion failure
Fixes #21671.
2021-12-08 08:52:33 +09:00
Yu Watanabe
dbdcaca3ab sd-dhcp-client: support 6rd option 2021-12-07 20:32:02 +09:00
Yu Watanabe
d262928879 dhcp6: drop unnecessary space 2021-12-06 19:15:41 +09:00
Yu Watanabe
8add30a03c tree-wide: use ERRNO_IS_TRANSIENT() 2021-11-30 23:06:43 +09:00
Yu Watanabe
97e80ee4a8 sd-dhcp6-client: fix error handling 2021-11-30 22:37:21 +09:00
Zbigniew Jędrzejewski-Szmek
8e560cd090
Merge pull request #21532 from yuwata/network-json-more
network: add more json entries
2021-11-29 21:26:56 +01:00
Nacho Barrientos
081f44859a Byte order to host before using the lifetime
I've seen this in `NetworkManager-1.34.0-0.3.el8.x86_64` (latest in CentOS
Stream 8 at the time of writing this message) which does not use the latest
Systemd but probably the code base is the same (see
51f93e00a2).

Before the patch:

```
libsystemd: eth0: DHCPv6 client: T1 expires in 34y 3w 6d 45min 31s
libsystemd: eth0: DHCPv6 client: T2 expires in 54y 5month 3w 3d 23h 20min 35s
```

After the patch:

```
libsystemd: eth0: DHCPv6 client: T1 expires in 3d 7h 58min 3s
libsystemd: eth0: DHCPv6 client: T2 expires in 5d 2h 26min 50s
```

same box (x86_64 system) and same DHCPv6 server.

This regression has likely been introduced by 8a8955507a.
2021-11-30 03:05:02 +09:00
Yu Watanabe
5656ff9dd1 dhcp6: make sd_dhcp6_lease_get_dns() and friends accepts NULL 2021-11-26 20:20:05 +09:00
Yu Watanabe
ee5b48341e dhcp: make sd_dhcp_lease_get_servers() accepts NULL 2021-11-26 20:20:05 +09:00
Zbigniew Jędrzejewski-Szmek
ed8ba68f3b
Merge pull request #21272 from yuwata/netif-util-split
netif-util: move several functions from network-util.c to netif-util.c
2021-11-09 10:01:07 +01:00
Yu Watanabe
b01895bf70 arp-util: drop redundant line
The client's IP address is already loaded to X.
(The comment of the dropped line is wrong, X instead of A.)
2021-11-09 09:32:09 +01:00
Yu Watanabe
043b193f6e netif-util: rename net_get_name_persistent() -> net_get_persistent_name() 2021-11-09 08:24:10 +09:00
Yu Watanabe
b5cc5591fa netif-util: move several functions from network-util.[ch] to shared/netif-util.[ch]
These functions are not relevant to sd-network, and only used by
networkd, networkctl, and udevd.
2021-11-09 08:24:10 +09:00