Commit Graph
1535 Commits
Author SHA1 Message Date
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
Yu Watanabe 822883b3e7 sd-dhcp6-client: request several options
Even though these options are not currently used by sd-dhcp6-client,
RFC 8415 states these options MUST be requested.
2022-04-04 01:22:02 +09:00
Yu Watanabe 612caa2626 network: dhcp6: request DNS servers or friends only when they will be used 2022-04-03 19:55:25 +09:00
Yu Watanabe f697ab358a dhcp: make option names singular 2022-04-03 19:50:02 +09:00
Yu Watanabe 0e0c4daea6 sd-dhcp6-client: sort requesting options 2022-04-03 19:23:03 +09:00
Yu Watanabe 2f53b311c3 sd-dhcp6-client: rename req_opts_len -> n_req_opts
As 'len' is confusing and we may misunderstand it as the size of
the buffer instead of the number of options.
2022-04-03 19:23:03 +09:00
Yu Watanabe 798931160e tree-wide: add a space after if, switch, for, and while 2022-04-01 22:48:42 +09:00
Lennart Poettering ba4e0427e9 time-util: assume CLOCK_BOOTTIME always exists
Let's raise our supported baseline a bit: CLOCK_BOOTTIME started to work
with timerfd in kernel 3.15 (i.e. back in 2014), let's require support
for it now.

This will raise our baseline only modestly from 3.13 → 3.15.
2022-03-28 16:55:41 +02:00
Zbigniew Jędrzejewski-Szmek 8e1fc5d939 fuzz: rename fuzz-dhcp-server-relay-message to fuzz-dhcp-server-relay
We can only relay messages, so we can make the name shorter without
losing informational value. This makes meson test output look better.
2022-03-21 11:43:47 +01:00
Yu Watanabe de010b0b2e strv: make iterator in STRV_FOREACH() declaread in the loop
This also avoids multiple evaluations in STRV_FOREACH_BACKWARDS()
2022-03-19 08:33:33 +09:00
Yu Watanabe 80a226b26b list: make LIST_FOREACH() and LIST_FOREACH_BACKWARDS() safer 2022-03-19 08:10:29 +09:00
Yu Watanabe 03677889f0 list: declare iterator of LIST_FOREACH() in the loop 2022-03-19 08:10:29 +09:00
Yu Watanabe faaf3d66ce sd-radv: fix indentation 2022-03-17 14:34:58 +09:00
Yu Watanabe 56aa51432e sd-radv: do not use iterater outside of the loop 2022-03-17 14:34:58 +09:00
Yu Watanabe 95931532aa sd-radv: voidify sd_radv_remove_prefix()
If the prefix is only referenced by sd_radv, then the returned pointer
is already freed.

networkd does not uses the returned value. Let's voidify the function.
2022-03-17 14:34:58 +09:00
Jan Janssen 68da8adf54 test: Use TEST macros in more places 2022-03-16 14:50:12 +01:00
Yu Watanabe 6278e42878 network: dhcp: rename NextServer= and Filename= settings
And make the settings configures DHCP option 66 and 67.

Follow-ups for #22615.
Fixes #22661.
2022-03-11 10:14:57 +09:00