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

1320 Commits

Author SHA1 Message Date
Yu Watanabe
6db9b30066
Merge pull request #21175 from tohojo/dhcp-server-expire
sd-dhcp-server: clear out expired leases when finding new address
2021-10-30 04:13:40 +09:00
Toke Høiland-Jørgensen
cb3c06a02e sd-dhcp-server: fix address availability checks
The checks for finding a new available address in the pool were broken in two
ways: not using UINT32_TO_PTR() on hashmap lookups resulted in false negatives,
and the check wasn't skipping the server address if that was part of the pool.

Move the check for available addresses to a small helper function and fix both
issues, and also add a check to the REQUEST code for the server address.
2021-10-29 15:29:05 +02:00
Toke Høiland-Jørgensen
d635a7f9e4 sd-dhcp-server: clear out expired leases when processing requests
The DHCP server configuration supports setting a maximum lease time, but old
leases are never actually cleared out if the client doesn't send a RELEASE.
This causes the pool to run out of addresses on networks where clients just
disappear, which is a fairly common occurrence on wireless networks.

Fix this by cleaning up expired leases before processing client requests, so
addresses can be reused for new clients.
2021-10-29 15:29:05 +02:00
Yu Watanabe
17347053cf libsystemd-network: drop _public_ attribute
No function in libsystemd-network is exposed yet.
2021-10-29 22:13:23 +09:00
Yu Watanabe
41521417ab sd-radv: fix implicit conversion to boolean 2021-10-29 22:10:43 +09:00
Yu Watanabe
9661d2e80c sd-ndisc: drop unused functions
All received information is stored in sd_ndisc_router, and we have
sd_ndisc_router_get_mtu() and sd_ndisc_router_get_hop_limit().
2021-10-29 22:05:27 +09:00
Yu Watanabe
d951507d5d sd-radv: shorten the default lifetime for prefix/route prefix
See draft-ietf-6man-slaac-renum-02 section 4.1.1.
2021-10-27 23:58:35 +09:00
Yu Watanabe
95e104e049 sd-radv: make prefix/route prefix lifetime can be specified with independently with valid_until
Previously, valid_until (or preferred_until for preferred lifetime) was
calculated from lifetime. So, when an upstream interface acquire a
dynamic prefix (e.g. through DHCPv6-PD) with long lifetime, then sd-radv
advertise the same lifetime. It may not be desired for some situations.
2021-10-27 23:58:28 +09:00
Yu Watanabe
eef5ebec97
Merge pull request #21143 from yuwata/sd-radv-router-lifetime
sd-radv: several cleanups for router lifetime
2021-10-27 22:14:35 +09:00
Yu Watanabe
804775577d sd-radv: update how to calculate interval of sending advertisements 2021-10-27 19:27:23 +09:00
Yu Watanabe
0945767012 sd-radv: router lifetime must be 0 or between 4 seconds and 9000 seconds
See RFC 4861 section 6.2.1.
2021-10-27 19:27:07 +09:00
Yu Watanabe
72db0a714b sd-radv: introduce RADV_DEFAULT_ROUTER_LIFETIME_USEC 2021-10-27 19:05:55 +09:00
Yu Watanabe
e786c2e50f sd-radv: add several notes about constants 2021-10-27 19:03:58 +09:00
Yu Watanabe
03ec10fdf4 sd-radv: make several constants not exposed 2021-10-27 19:03:35 +09:00
Yu Watanabe
d6fc0d674f sd-radv: drop SD_ prefix for unexposed constants 2021-10-27 19:03:31 +09:00
Yu Watanabe
68cbac5bd4 sd-radv: use IPv6 specific functions 2021-10-27 16:41:04 +09:00
Yu Watanabe
acbb5500e2 sd-radv: use assert_return() 2021-10-27 16:41:04 +09:00
Yu Watanabe
7003b11487 sd-radv: make sd_radv_set_router_lifetime() take usec_t (uint64_t) 2021-10-27 16:13:09 +09:00
Yu Watanabe
a84171ce6f libsystemd-network: do not warn when log_dhcp_client() or friends with NULL 2021-10-26 08:09:40 +09:00
Yu Watanabe
113e124f9b icmp6: shorten code a bit 2021-10-21 22:40:03 +09:00
Yu Watanabe
ea51deb188 dhcp: shorten BPF code a bit
- replace `A = k` and `X = A` with `X = k`,
- replace `A ^= X` and `A == 0` with `A == X`.
- use UINT32_MAX when accept a packet
2021-10-21 22:39:53 +09:00
Yu Watanabe
155943b259 dhcp: rebreak function arguments 2021-10-21 22:39:43 +09:00
Yu Watanabe
b8319d748f dhcp: fix assertions 2021-10-21 22:39:43 +09:00
Yu Watanabe
d70c78131d dhcp: shorten code a bit 2021-10-21 22:39:43 +09:00
Yu Watanabe
36f1955da8 lldp: shorten code a bit 2021-10-21 22:39:43 +09:00
Yu Watanabe
e2c7c38b74 arp-util: shorten BPF code a bit
- replace `A = k` and `X = A` with `X = k`,
- replace `A ^= X` and `A == 0` with `A == X`.
- use UINT32_MAX when accept a packet
2021-10-21 22:39:25 +09:00
Yu Watanabe
653ddc1d18 sd-dhcp6-client: introduce sd_dhcp6_lease_get_timestamp() 2021-10-20 02:36:20 +09:00
Yu Watanabe
7502812c92 sd-dhcp6-client: max_retransmit_time must be positive
Found by LGTM.com analysis.
2021-10-13 02:49:49 +09:00
Yu Watanabe
fea8c18085 sd-dhcp6-client: introduce dhcp6_option_can_request() 2021-10-13 02:49:49 +09:00
Yu Watanabe
f5e3619b70 sd-dhcp6-client: add missing options 2021-10-12 20:48:19 +09:00
Yu Watanabe
ac94edc857 sd-dhcp6-client: add missing parenthesis 2021-10-12 20:48:19 +09:00
Yu Watanabe
59f1ded834 sd-dhcp6-client: add missing message types
This also changes the prefix: DHCP6_ -> DHCP6_MESSAGE_.
2021-10-12 20:48:19 +09:00
Yu Watanabe
b261b5f416 sd-dhcp6-client: name one more enum 2021-10-12 20:48:19 +09:00
Yu Watanabe
dd5e9378a2 sd-dhcp6-client: typedef several enums
Also introduces _MAX and _INVALID for several enums.
2021-10-12 20:48:19 +09:00
Zbigniew Jędrzejewski-Szmek
78ae9d3100
Merge pull request #20853 from yuwata/network-radv-set-default-timeouts
network: RADV: set default timeouts
2021-10-12 10:49:03 +02:00
Yu Watanabe
f21b863eeb test: use assert_se() instead of assert() 2021-10-12 15:20:28 +09:00
Yu Watanabe
7ebb14313f sd-radv: rename sd_radv_prefix_set_route_prefix() -> sd_radv_route_prefix_set_prefix() 2021-10-12 03:10:30 +09:00
Lennart Poettering
7fbae5b706 tree-wide: use C99 __func__ rather than obsolete __FUNCTION__
We use __func__ almost everywhere, but there are some holdouts. Fix
that.
2021-10-11 14:10:39 +02:00
Lennart Poettering
fe92eb795b network: use official bswap_32() rather than inofficial __bswap_32()
The former is a macro for the latter, but let's use the official API
(the one that has an API).
2021-10-11 14:10:07 +02:00
Yu Watanabe
e210f027e0 sd-dhcp6-client: rename dhcp6_lease_set_dns() -> dhcp6_lease_add_dns()
As it is allowed that multiple DNS server options appear in the message.
2021-09-29 15:29:41 +09:00
Yu Watanabe
e693e96961 sd-dhcp6-client: do not merge NTP and SNTP options
Previously, SNTP option is ignored when it appears after NTP option(s),
but merged later NTP options when it appears first.
This makes split the NTP and SNTP addresses, and use SNTP addresses only
when no NTP option is provided.
2021-09-29 15:29:41 +09:00
Yu Watanabe
9c3d46bf8d sd-dhcp6-client: support multiple NTP server options
Also, it is allowed that the suboption appears multiple times, and each
suboption contains one NTP server.
2021-09-29 15:29:41 +09:00
Yu Watanabe
41b14f0329 sd-dhcp6-client: support multiple domains 2021-09-29 15:29:41 +09:00
Yu Watanabe
5cf67bb407 sd-dhcp6-client: make dhcp6_lease_free() accepts NULL 2021-09-29 15:29:40 +09:00
Yu Watanabe
edeee50b3d sd-dhcp6-client: drop domains_count and ntp_fqdn_count 2021-09-29 15:29:40 +09:00
Yu Watanabe
548c33d712 sd-dhcp6-client: use dhcp6_option_parse() in client_parse_message() 2021-09-29 15:29:40 +09:00
Yu Watanabe
3f8227bf83 sd-dhcp6-client: constify several arguments 2021-09-29 15:29:40 +09:00
Yu Watanabe
b27dcf0813 sd-dhcp6-client: slightly modernize dhcp6_option_parse_domainname()/domainname_list() 2021-09-29 15:29:40 +09:00
Yu Watanabe
ad3c84204c sd-dhcp6-client: fix buffer size calculation in dhcp6_option_parse_ip6addrs()
GREEDY_REALLOC() takes number of elements, not buffer size.

This also rename dhcp6_option_parse_ip6addrs() to
dhcp6_option_parse_addresses().
2021-09-29 15:29:40 +09:00
Yu Watanabe
8a8955507a sd-dhcp6-client: modernize dhcp6_option_parse_ia()
This makes
- the function not update the arguments for storing results on error,
- use dhcp6_option_parse() to parse sub options,
- ignore all errors, except for -ENOMEM, in parsing sub options,
- update log messages.
2021-09-29 15:29:40 +09:00