1
1
mirror of https://github.com/systemd/systemd-stable.git synced 2025-01-10 01:17:44 +03:00
Commit Graph

1215 Commits

Author SHA1 Message Date
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
Yu Watanabe
22bbba8444 sd-dhcp-client: introduce sd_dhcp_client_is_running() 2021-04-14 22:31:28 +02:00
Zbigniew Jędrzejewski-Szmek
2d359acda5 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-14 16:19:54 +02:00
Luca Boccassi
c2b2df604b tree-wide: avoid uninitialized warning on _cleanup_ variables
With some versions of the compiler, the _cleanup_ attr makes it think
the variable might be freed/closed when uninitialized, even though it
cannot happen. The added cost is small enough to be worth the benefit,
and optimized builds will help reduce it even further.
2021-04-14 12:25:06 +01:00
Yegor Alexeyev
21b6b87eb3 dhcp: Implemented BindToInterface= configuration option 2021-04-14 07:30:40 +09:00
Yu Watanabe
9bafb8d504 sd-dhcp-client: constify argument in sd_dhcp_lease_get_xxx() 2021-04-12 09:55:26 +02:00
Yu Watanabe
080e5c2fde sd-dhcp6-client: do not use IN_SET() macro when only one target value 2021-04-10 13:24:56 +01:00
Zbigniew Jędrzejewski-Szmek
82a335db83
Merge pull request #18777 from yuwata/network-set-ifname-to-engines
network: set ifname to dhcp4 client or friends
2021-03-31 10:25:23 +02:00
Luca Boccassi
a9dd1010f0 test-dhcp6-client: add one more assert on memory mapping
Same as 7489d0640a, one more case
that was missed.

Coverity CID #1394277
2021-03-26 20:17:35 +01:00
Luca Boccassi
7489d0640a test-dhcp6-client: add one more assert on memory mapping
Static analyzers need a hint that optval is not pointing
off the end of the msg_advertise array, since pos can go
up to the full length of it. The array is manually
constructed so we know this won't happen, but adding one
more assert should be enough to avoid false positives.

Coverity CID #1394277
2021-03-25 12:02:43 +00:00
Yu Watanabe
fa92d38428 dhcp6: fix wrong length for IA_PD dhcp6 option
Fixes an issue introduced by 73b49d433c.

When PrefixDelegationHint= is not set, dhcp6_option_append_pd() sets
wrong length for IA_PD option, as `r` is `-EINVAL`.

Fixes #19021.
2021-03-16 21:29:49 +01:00
Zbigniew Jędrzejewski-Szmek
63dc82d378
Merge pull request #18852 from yuwata/tree-wide-use-UINT64_MAX
tree-wide: use UINT64_MAX or friends
2021-03-05 17:51:34 +01:00
Yu Watanabe
986c0edfcb dhcp-server: also append specified additional options and vendor specific option on DHCP_OFFER
Fixes #15780.
2021-03-05 11:34:32 +09:00
Yu Watanabe
f5fbe71d95 tree-wide: use UINT64_MAX or friends 2021-03-05 07:10:13 +09:00
Yu Watanabe
a7d757ec29 dhcp6: tighten T1 and T2 value check
Only when T1 and T2 are both 0, they are adjusted later based on
address or prefix T1 and T2. So the first check must be changed.
2021-03-04 05:51:56 +09:00
Yu Watanabe
353887831b libsystemd-network: make log_dhcp_client() or friends include interface name 2021-03-04 05:51:28 +09:00
Yu Watanabe
61a9fa8f0c libsystemd-network: introduce sd_xxx_{set,get}_ifname() 2021-03-04 05:24:54 +09:00
Yu Watanabe
ab7153b3f4 dhcp: use unlink_and_freep() in dhcp_lease_save() 2021-03-03 16:26:32 +09:00
Zbigniew Jędrzejewski-Szmek
d9a65c5976
Merge pull request #18730 from yuwata/dhcp6-client-do-not-set-t1-t2-18090
dhcp6: do not set T1 and T2 in IA_PD option or friends
2021-02-24 09:53:37 +01:00
Lennart Poettering
d9a650bbe8 icmp6-util: add missing variable initialization
Coverity 1446712
2021-02-23 15:45:15 +01:00
Yu Watanabe
73b49d433c dhcp6: do not set T1 and T2 by dhcp6_option_append_pd() in client
Fixes #18090.
2021-02-23 19:36:37 +09:00
Yu Watanabe
e7613578b4 dhcp6: do not set T1 and T2 by dhcp6_option_append_ia() in client 2021-02-23 19:36:37 +09:00
Yu Watanabe
1e84213a43 dhcp6: make dhcp6_option_parse_{address,pdprefix}() return -EINVAL when received address or prefix is refused
And then the caller ignores the error.
Otherwise, `ret_liftime_valid` is not set even if they succeeds.
2021-02-23 19:36:23 +09:00
Yu Watanabe
cf6c33bd6b dhcp6: do not use input value before checking 2021-02-23 18:49:11 +09:00
Lennart Poettering
2324fd3a39 network: suffix types with _t in public headers
Apparently, in our current public headers (i.e. those called sd-*.h) we
suffixed typedefs that we use as values with _t, but we didn't do this
for enum typedefs. Fix that while this stuff is not actually public yet.

With this scheme "value typedefs" now end systematically in _t, and
"object typedefs" (i.e. structures that are typically passed around via
pointers and not values) do not.

No code changes, just some renaming.
2021-02-18 18:17:16 +01:00
Yu Watanabe
c633628daf tree-wide: constify variables if possible 2021-02-18 03:48:07 +09:00
Yu Watanabe
5380707aba network: use in_addr_prefix_to_string() 2021-02-18 03:48:07 +09:00
Yu Watanabe
94876904bb tree-wide: use in_addr_is_set() or friends 2021-02-18 03:48:07 +09:00
Benjamin Robin
0979e4adb5 libsystemd-network: use -EINVAL for _DUID_TYPE_INVALID
Follow-up of #11484
2021-02-16 23:40:30 +01:00
Zbigniew Jędrzejewski-Szmek
75db809ae5 tree-wide: return NULL from freeing functions
I started working on this because I wanted to change how
DEFINE_TRIVIAL_CLEANUP_FUNC is defined. Even independently of that change, it's
nice to make make things more consistent and predictable.
2021-02-16 17:15:10 +01:00