Commit Graph
1551 Commits
Author SHA1 Message Date
Zbigniew Jędrzejewski-Szmek 59818f4381 libsystemd-network: trivial simplification 2022-10-12 09:18:24 +02: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
Yu Watanabe 4c275f362f dhcp6: do not append ORO option when no option requested
Fixes #24292.
2022-08-14 02:44:52 +09:00
Yu Watanabe 1929c1fcb2 dhcp6: gracefully handle NoBinding error
When we receive NoBinding status code, the requesting binding (address or
any other information) does not exist anymore in the server. Hence,
resending the request is meaningless. Let's restart the transaction from
the beginning in that case.
2022-08-13 05:26:22 +09:00
Yu Watanabe 113522868a dhcp: add assertions about client state 2022-08-08 20:19:46 +09:00
Yu Watanabe 4473cd7f61 dhcp: fix potential buffer overflow
Fixes a bug introduced by 324f818781.

This also renames several macros for DHCP packet size.
2022-08-06 13:06:32 +09:00
Yu Watanabe 073a1daaba dhcp: make dhcp_network_bind_raw_socket() take struct hw_addr_data 2022-08-06 04:57:27 +09:00
Yu Watanabe 8cad358e4a dhcp: make dhcp_identifier_set_duid() take struct hw_addr_data 2022-08-06 04:53:36 +09:00
Yu Watanabe 3b75435db6 dhcp: make dhcp_identifier_set_iaid() take struct hw_addr_data 2022-08-06 04:53:36 +09:00
Yu Watanabe e0ead13088 sd-dhcp6-client: use hw_addr_set() 2022-08-06 04:53:36 +09:00
Yu Watanabe 7e5c25b244 sd-dhcp-client: use struct hw_addr_data to store MAC and broadcast address 2022-08-06 04:53:36 +09:00
Yu Watanabe 7fddb9704f dhcp4: stop client before updating MAC address 2022-08-06 04:53:36 +09:00
Yu Watanabe 8547260579 tree-wide: drop unnecessary inclusion of netlink-util.h 2022-07-23 23:31:23 +09:00
Yu Watanabe 4397967f8c sd-dhcp6-client: introduce sd_dhcp6_client_set_rapid_commit() 2022-07-22 21:26:44 +09:00
Yu Watanabe d3efcd2def network: refuse 169.254.0.0/24 and 169.254.255.0/24 for IPv4LLStartAddress=
Follow-up for #23927.
2022-07-15 03:37:09 +09:00
Yu Watanabe c1dd250f18 Merge pull request #23927 from AndreKalb/feature/ipv4-link-local-start-address
network: Feature IPv4 link-local start address
2022-07-15 03:21:26 +09:00
Andre Kalb 59c272316c sd-ipv4ll/networkd: Try to select an IPv4 link-local start address 2022-07-14 14:35:42 +02:00
Yu Watanabe 68870a46b3 sd-dhcp6-client: fix off-by-one error in parsing dhcp6 options
This fixes error in parsing message when the rapid commit option is
located at the end of the message.

Fixes an issure reported in #24002.
2022-07-14 10:49:18 +09:00
Yu Watanabe d81b5a191e sd-dhcp6-client: allow NULL option value when length is zero 2022-07-14 10:49:14 +09:00
Yu Watanabe 50309ff785 sd-dhcp6-client: add more debugging logs on parsing message 2022-07-14 09:31:04 +09:00
Yu Watanabe 3857d367f0 sd-dhcp-client: fix log message 2022-07-09 11:44:25 +09:00
Yu Watanabe 377157e6bd Merge pull request #23616 from keszybz/in-addr-to-string-formatting
Add macros that allocate a fixed buffer for in_addr_to_string(), in_addr_prefix+to_string()
2022-06-09 15:21:57 +09:00
Nick Rosbrook bfe2e67f25 libsystemd-network: use udev_available() 2022-06-08 18:32:37 -04:00
Zbigniew Jędrzejewski-Szmek 071e522eec tree-wide: convert inet_ntop() calls to anonymous-buffer macros 2022-06-06 09:52:52 +02:00
Zbigniew Jędrzejewski-Szmek c71384a9ee basic/in-addr-util: add IN_ADDR_PREFIX_TO_STRING 2022-06-06 09:52:52 +02:00
Zbigniew Jędrzejewski-Szmek dd6d433a4f libsystemd-network: minor simplification 2022-06-06 09:52:52 +02:00
Zbigniew Jędrzejewski-Szmek 84dbb3fd83 basic/in-addr-util: add IN_ADDR_TO_STRING
Since we don't need the error value, and the buffer is allocated with a fixed
size, the whole logic provided by in_addr_to_string() becomes unnecessary, so
it's enough to wrap inet_ntop() directly.

inet_ntop() can only fail with ENOSPC. But we specify a buffer that is supposed
to be large enough, so this should never fail. A bunch of tests of this are added.
This allows all the wrappers like strna(), strnull(), strempty() to be dropped.

The guard of 'if (DEBUG_LOGGING)' can be dropped from around log_debug(),
because log_debug() implements the check outside of the function call. But
log_link_debug() does not, so it we need it to avoid unnecessary evaluation of
the formatting.
2022-06-06 09:52:52 +02:00
Zbigniew Jędrzejewski-Szmek c4f883b78e fuzzers: ignore size limits when compiled standalone
This way we can still call fuzzers on old samples, but oss-fuzz will not waste
its and our time finding overly large inputs.
2022-05-12 14:57:07 +02:00
Zbigniew Jędrzejewski-Szmek 96974ea4a8 fuzz-dhcp-server: remove limit on input size
It was added originally back in 2bd37c5be2,
but there doesn't seem to by any particular reason for it.
2022-05-12 13:30:44 +02:00
Zbigniew Jędrzejewski-Szmek c9c3b81f12 libsystemd-network: constify casts
It is better to not drop the const-ness from the argument.
2022-05-08 22:47:50 +02:00
Alex Henrie 0bcc6557fb network: clarify the relationship between RA flags and DHCPv6 modes
In the documentation, using the term "managed" for both the RA flag and
the DHCPv6 mode is confusing because the mode is referred to as
"solicit" both in the official DHCPv6 documentation (see RFC 8415) and
in the WithoutRA option.

Furthermore, calling the other RA flag "other information" or "other
address configuration" is confusing because its official name is simply
"other configuration" (see RFC 4861 and RFC 5175) and it isn't used to
assign IP addresses.

Rewrite the documentation for DHCPv6Client and WithoutRA to make it
clear that getting the "managed" RA flag triggers the same kind of DHCP
request as WithoutRA=solicit, whereas getting the "other configuration"
RA flag triggers the same kind of DHCP request as
WithoutRA=information-request.
2022-05-06 14:01:53 -06:00
Matthijs van Duin b0221bb6a4 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.
2022-05-05 01:19:02 +09:00
Yu Watanabe 87bd4b79e6 sd-lldp: use memcpy_safe() as the buffer size may be zero 2022-05-04 16:05:04 +09:00
Yu Watanabe 9a44966e63 sd-ndisc: drop unused function 2022-05-04 16:03:57 +09:00
Yu Watanabe 4e88a46bfe libsystemd-network: refuse too large raw_size
Closes #23258.
2022-05-04 15:46:19 +09:00
Zbigniew Jędrzejewski-Szmek 6f1b4574b4 libsystemd-network: add assert about packet length
We reject too-short packets in client_receive_message_raw(), so
the packets that dhcp_packet_verify_headers() gets are of sufficient size.
But let's add an assert to clarify this for the reader.

Closes #23223.
2022-04-29 15:56:53 +02:00
Zbigniew Jędrzejewski-Szmek 9a94baa6c7 libsystemd-network: do not split messages in half
This makes grepping for the messages unnecessarily painful.
2022-04-29 15:56:53 +02:00
Yu Watanabe 239adf0384 sd-ipv4acd: actually drop the arp packet from one of the host interface
Fixes a bug in 7f77917c0e.

Fixes #23001.
2022-04-07 15:02:21 +09:00