Commit Graph
1244 Commits
Author SHA1 Message Date
Alvin Šipraga 8e664ab6ec network: print Ethernet Link-Layer DHCP client ID with leading 0's
This is a small cosmetic change.

Before:

   Offered DHCP leases: 192.168.0.183 (to 0:9:a7:36:bc:89)

After:

   Offered DHCP leases: 192.168.0.183 (to 00:09:a7:36:bc:89)
2021-09-01 00:04:04 +09:00
Yu Watanabe 9365e296fe socket-util: introduce CMSG_SPACE_TIMEVAL/TIMESPEC macro to support additional 64bit timeval or timespec
Fixes #20482 and #20564.
2021-08-30 19:56:41 +09:00
Yu Watanabe 6da22a2fa5 icmp6: drop unnecessary assertion
Follow-up for 3691bcf3c5.
2021-08-20 08:44:31 +09:00
Yu Watanabe b713a99b1a sd-dhcp-server: support static lease outside of address pool
Closes #20341.
2021-08-11 16:43:26 +09:00
Yu Watanabe 3dc8fb0eb8 sd-dhcp-server: fix possible double-free or use-after-free 2021-08-11 16:43:25 +09:00
Yu Watanabe cedf6a8da5 sd-dhcp-server: use hashmap_ensure_put() 2021-08-11 16:43:25 +09:00
Yu Watanabe 0eec7f5ffa sd-dhcp6-client: use SYNTHETIC_ERRNO() 2021-08-10 21:57:42 +09:00
Yu Watanabe de949e911e sd-dhcp6-client: cirtainly adjust T1 and T2
This fixes a bug introduced by 99f1d3fc50.
Note that in the information requesting mode, the lease has neither
addresses nor PD prefixes.
2021-08-10 21:39:30 +09:00
Yu Watanabe 0c42b61348 sd-dhcp6-client: fix copy-and-paste mistake
Fix bug introduced by b47fb949b3.
2021-08-10 21:36:07 +09:00
Yu Watanabe d7799877a0 sd-dhcp6-client: do not ignore errors in client_receive_advertise()
This also adds several debug log messages.
2021-08-05 11:14:23 +01:00
Zbigniew Jędrzejewski-Szmek 04499a70fb Drop the text argument from assert_not_reached()
In general we almost never hit those asserts in production code, so users see
them very rarely, if ever. But either way, we just need something that users
can pass to the developers.

We have quite a few of those asserts, and some have fairly nice messages, but
many are like "WTF?" or "???" or "unexpected something". The error that is
printed includes the file location, and function name. In almost all functions
there's at most one assert, so the function name alone is enough to identify
the failure for a developer. So we don't get much extra from the message, and
we might just as well drop them.

Dropping them makes our code a tiny bit smaller, and most importantly, improves
development experience by making it easy to insert such an assert in the code
without thinking how to phrase the argument.
2021-08-03 10:05:10 +02:00
Yu Watanabe e18f21e349 Merge pull request #20109 from keszybz/timestamp-macros
Add macros that define scratch buffer internally for timestamp/timespan formatting
2021-07-14 16:14:08 +09:00
Frantisek Sumsal 2f0927626a tree-wide: coccinelle fixes
Yet another batch of Coccinelle fixes.
2021-07-09 20:54:22 +01:00
Zbigniew Jędrzejewski-Szmek 5291f26d4a tree-wide: add FORMAT_TIMESPAN() 2021-07-09 11:03:36 +02:00
Zbigniew Jędrzejewski-Szmek 04f5c018ce tree-wide: use FORMAT_TIMESTAMP() 2021-07-09 11:03:35 +02:00
Yu Watanabe 1e59122d45 sd-ipv4ll: introduce sd_ipv4ll_set_check_mac_callback() 2021-07-01 00:49:02 +09:00
Yu Watanabe 9e5aa34fc8 sd-ipv4ll: allow to set MAC address without stopping sd-ipv4ll engine 2021-07-01 00:49:02 +09:00
Yu Watanabe 7f77917c0e sd-ipv4acd: update condition of address conflict
See RFC 5227 section 2.1.1.

This introduces a callback which intend to a library user, e.g.
networkd, checks whether the sender hardware address is a MAC address of
the host's intrerface or not.
2021-07-01 00:49:02 +09:00
Yu Watanabe 5c35c13a4d sd-ipv4acd: allow to change requesting address without restarting sd-ipv4acd 2021-07-01 00:49:02 +09:00
Yu Watanabe 3d817902c4 sd-ipv4acd: set defend window in timeout event and state is IPV4ACD_STATE_STARTED 2021-07-01 00:49:02 +09:00
Yu Watanabe fcb7345950 sd-ipv4acd: allow to change MAC address without restarting sd-ipv4acd
This also makes sd_ipv4acd_set_mac() refuses null MAC address.
2021-07-01 00:49:02 +09:00
Yu Watanabe d17ed573aa arp-util: split out logic of setting BPF code into a function 2021-07-01 00:49:02 +09:00
Yu Watanabe ecad63f850 arp-util: use struct in_addr 2021-07-01 00:49:02 +09:00
Yu Watanabe e1a3915b41 arp-util: make arp_send_{probe,announcement}() inline 2021-07-01 00:49:02 +09:00
Yu Watanabe 28ba416c99 arp-util: shorten code a bit 2021-07-01 00:49:02 +09:00
Yu Watanabe 504bf2b54a arp-util: check ifindex and mac address 2021-07-01 00:49:02 +09:00
Yu Watanabe f6720fe62e arp-util: check sent message size 2021-07-01 00:49:02 +09:00
Yu Watanabe 51d113512f arp-util: align elements 2021-07-01 00:49:02 +09:00
Yu Watanabe 265b6d4e0c sd-ipv4acd: include announced address in log message 2021-07-01 00:49:02 +09:00
Yu Watanabe 9be2ba5e12 sd-ipv4acd: use struct in_addr instead of be32_t 2021-07-01 00:49:02 +09:00
Yu Watanabe 38e980a6a5 sd-dhcp-client: tentatively ignore FORCERENEW command
This makes DHCP client ignore FORCERENEW requests, as unauthenticated
FORCERENEW requests causes a security issue (TALOS-2020-1142, CVE-2020-13529).

Let's re-enable this after RFC3118 (Authentication for DHCP Messages)
and/or RFC6704 (Forcerenew Nonce Authentication) are implemented.

Fixes #16774.
2021-06-24 11:25:26 +09:00
Yu Watanabe 551ad0b7de sd-dhcp-client: logs when dhcp client unexpectedly gains a new lease
Previously, such situation is handled silently.
2021-06-24 11:25:26 +09:00
Yu Watanabe d57b62be0d sd-dhcp-client: shorten code a bit 2021-06-24 11:25:26 +09:00
Yu Watanabe 67d8cd8193 sd-dhcp-client: check error earlier and reduce indentation 2021-06-24 11:25:26 +09:00
Yu Watanabe af7b405dff sd-dhcp: refuse to set iaid if we cannot find the interface 2021-06-12 03:19:08 +09:00
Yu Watanabe 8d71f2b3a6 dhcp: do not use ifindex when generating iaid in tests 2021-06-12 03:19:08 +09:00
Yu Watanabe 0299deab53 sd-dhcp: do not use detect_container() to guess udev is running or not 2021-06-12 03:19:08 +09:00
Yu Watanabe 0ac655a63b tree-wide: use sd_device_new_from_ifindex/ifname() 2021-06-12 03:19:08 +09:00
Yu Watanabe b27e5d53f3 sd-dhcp-server: make sd_dhcp_server_start() no-op if it is already running 2021-06-08 06:33:27 +09:00
borna-blazevic 65a0ef2341 sd-dhcp-server: support static address to DHCPv4 offer 2021-05-27 15:15:27 +09:00
Lennart Poettering 319a4f4bc4 alloc-util: simplify GREEDY_REALLOC() logic by relying on malloc_usable_size()
We recently started making more use of malloc_usable_size() and rely on
it (see the string_erase() story). Given that we don't really support
sytems where malloc_usable_size() cannot be trusted beyond statistics
anyway, let's go fully in and rework GREEDY_REALLOC() on top of it:
instead of passing around and maintaining the currenly allocated size
everywhere, let's just derive it automatically from
malloc_usable_size().

I am mostly after this for the simplicity this brings. It also brings
minor efficiency improvements I guess, but things become so much nicer
to look at if we can avoid these allocation size variables everywhere.

Note that the malloc_usable_size() man page says relying on it wasn't
"good programming practice", but I think it does this for reasons that
don't apply here: the greedy realloc logic specifically doesn't rely on
the returned extra size, beyond the fact that it is equal or larger than
what was requested.

(This commit was supposed to be a quick patch btw, but apparently we use
the greedy realloc stuff quite a bit across the codebase, so this ends
up touching *a*lot* of code.)
2021-05-19 16:42:37 +02:00
Lennart Poettering 041ea9f9bb netlink,network: drop "const" from opaque object parameters in supposed-to-be-public APIs
This drops the "const" specifier from the opaque object parameters to
various functions in our API.

This effectively reverts #19292 and more.

Why drop this? Our public APIs should not leak too much information
about how stuff is implemented internally. In our public APIs we
shouldn't give too many guarantees we don#t want to necessarily keep.
Specifically: in many cases it makes sense that getters actually
generate/parse/allocate data on the fly, storing/caching the result
internally, to speed things up, do things lazily or to track memory
allocations so that they can be freed later. Doing this means we need to
change the objects, even though the getters are semantically a read
operation.

We want to retain the freedom that we can change things around
internally. By exposing the objects as "const" we remove a good chunk of
that, for little gain.

See sd_bus_creds_get_description() for a real example of a getter that
implicitly caches and thus modifies the relevant object.

This removes the "const" decorators from sd-dhcp and sd-netlink, two
APIs that we intend to make public eventually even though they still are
not, leaving us the chance to still fix this before it becomes set in
stone.
2021-05-12 16:19:58 +09:00
Yu Watanabe 19cc6d5e54 tree-wide: fix typo 2021-05-09 14:36:19 +09:00
Yegor Alexeyev 11c38d3e51 rfc3046 implementation 2021-05-08 15:59:29 +09:00
Yegor Alexeyev c95df5879e relay role implementation 2021-04-20 15:11:53 +02:00
Luca Boccassi 2d8c8549ab Merge pull request #19317 from keszybz/check-return-values-from-log_errno-functions
Check return values from log_errno functions
2021-04-15 20:33:54 +01:00
Zbigniew Jędrzejewski-Szmek 828b603a79 libsystemd-network: fix dhcp option buffer confusion
We were writing to the wrong buffer with a wrong offset :(
Bug present since the original introduction of the code in
04b28be1a3.
2021-04-15 13:46:48 +09:00
Zbigniew Jędrzejewski-Szmek 00dd6d7770 libsystemd-network: check that errno==0 is not passed to log functions 2021-04-14 23:32:10 +02:00
Zbigniew Jędrzejewski-Szmek a0c2541b6b libsystemd-network: use macro for definitions of log_{lldp,dhcp,…}_errno
No functional change.
2021-04-14 23:32:07 +02:00
Zbigniew Jędrzejewski-Szmek f407219cd1 Check that errno passed log_{interface,link}_*_errno() is non-zero 2021-04-14 22:53:49 +02:00