summaryrefslogtreecommitdiff
path: root/src/libsystemd-network/dhcp6-option.c
Commit message (Collapse)AuthorAgeFilesLines
* sd-dhcp6: always append the default status message generated from status codeYu Watanabe2023-01-161-9/+16
| | | | Fixes #25988.
* libsystemd-network: trivial simplificationZbigniew Jędrzejewski-Szmek2022-10-121-6/+2
|
* sd-dhcp6-client: allow to build large packetYu Watanabe2022-10-021-38/+44
| | | | | | | | | | | | | | 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.
* sd-dhcp6-client: use GREEDY_REALLOC() in dhcp6_option_append_vendor_class()Yu Watanabe2022-10-021-19/+10
|
* sd-dhcp6-client: use GREEDY_REALLOC()Yu Watanabe2022-10-021-13/+8
| | | | And merge 'total' and 'offset' -> 'n'
* sd-dhcp6-client: slightly shorten dhcp6_option_append_fqdn()Yu Watanabe2022-10-021-4/+2
|
* sd-dhcp6-client: simplify dhcp6_option_append_ia()Yu Watanabe2022-10-021-38/+9
|
* sd-dhcp6-client: make dhcp6_option_append_fqdn() or friends handle zero ↵Yu Watanabe2022-10-021-4/+9
| | | | length value gracefully
* sd-dhcp6-client: use assert() in non-public functionsYu Watanabe2022-10-021-11/+19
|
* sd-dhcp6-client: fix off-by-one error in parsing dhcp6 optionsYu Watanabe2022-07-141-2/+2
| | | | | | | 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.
* sd-dhcp6-client: allow NULL option value when length is zeroYu Watanabe2022-07-141-5/+5
|
* sd-dhcp6-client: request several optionsYu Watanabe2022-04-041-2/+4
| | | | | Even though these options are not currently used by sd-dhcp6-client, RFC 8415 states these options MUST be requested.
* dhcp: make option names singularYu Watanabe2022-04-031-5/+5
|
* tree-wide: add a space after if, switch, for, and whileYu Watanabe2022-04-011-2/+2
|
* strv: make iterator in STRV_FOREACH() declaread in the loopYu Watanabe2022-03-191-2/+0
| | | | This also avoids multiple evaluations in STRV_FOREACH_BACKWARDS()
* list: declare iterator of LIST_FOREACH() in the loopYu Watanabe2022-03-191-1/+0
|
* sd-dhcp6-client: rename timezone optionsYu Watanabe2022-03-101-2/+2
| | | | To make them follow corresponding DHCPv4 options.
* sd-dhcp6-client: use mempcpy() or mempcpy_safe()Yu Watanabe2022-02-161-12/+5
|
* sd-dhcp6-client: split dhcp6-internal.h into twoYu Watanabe2022-02-141-3/+1
| | | | Also, this moves string tables to dhcp6-protocol.c.
* sd-dhcp6-client: use OrderedSet for vendor optionYu Watanabe2022-02-141-2/+2
| | | | This also fixes memleak.
* sd-dhcp6-client: fix possible unaligned read or writeYu Watanabe2022-02-141-12/+6
|
* sd-dhcp6-lease: unify lease lifetime calculationYu Watanabe2022-02-141-25/+3
|
* sd-dhcp6-client: unify dhcp6_option_append_{ia,pd}()Yu Watanabe2022-02-141-80/+56
|
* sd-dhcp6-client: store PD prefix hint in ia_pdYu Watanabe2022-02-141-9/+1
| | | | And allows to specify multiple hints.
* sd-dhcp6-client: introduce dhcp6_ia_free()Yu Watanabe2022-02-141-16/+21
|
* sd-dhcp6-client: unify IA option headerYu Watanabe2022-02-141-143/+97
| | | | This also fixes possible unaligned read of message.
* sd-dhcp6-client: trigger assertion whn invalid IA type is providedYu Watanabe2022-02-141-1/+1
| | | | | If the condition hits, then it is an error in coding, instead of a user misconfiguration or invalid receivd message.
* Byte order to host before using the lifetimeNacho Barrientos2021-11-301-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | I've seen this in `NetworkManager-1.34.0-0.3.el8.x86_64` (latest in CentOS Stream 8 at the time of writing this message) which does not use the latest Systemd but probably the code base is the same (see https://github.com/NetworkManager/NetworkManager/commit/51f93e00a23fbd09f5ad96da6290bf4ca737d46a). Before the patch: ``` libsystemd: eth0: DHCPv6 client: T1 expires in 34y 3w 6d 45min 31s libsystemd: eth0: DHCPv6 client: T2 expires in 54y 5month 3w 3d 23h 20min 35s ``` After the patch: ``` libsystemd: eth0: DHCPv6 client: T1 expires in 3d 7h 58min 3s libsystemd: eth0: DHCPv6 client: T2 expires in 5d 2h 26min 50s ``` same box (x86_64 system) and same DHCPv6 server. This regression has likely been introduced by 8a8955507af363c31297bbc5df79852db4ad39d6.
* sd-dhcp6-client: introduce dhcp6_option_can_request()Yu Watanabe2021-10-131-0/+187
|
* sd-dhcp6-client: add missing optionsYu Watanabe2021-10-121-1/+1
|
* sd-dhcp6-client: drop domains_count and ntp_fqdn_countYu Watanabe2021-09-291-4/+2
|
* sd-dhcp6-client: slightly modernize ↵Yu Watanabe2021-09-291-29/+38
| | | | dhcp6_option_parse_domainname()/domainname_list()
* sd-dhcp6-client: fix buffer size calculation in dhcp6_option_parse_ip6addrs()Yu Watanabe2021-09-291-8/+14
| | | | | | | GREEDY_REALLOC() takes number of elements, not buffer size. This also rename dhcp6_option_parse_ip6addrs() to dhcp6_option_parse_addresses().
* sd-dhcp6-client: modernize dhcp6_option_parse_ia()Yu Watanabe2021-09-291-190/+173
| | | | | | | | 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.
* sd-dhcp6-client: make dhcp6_option_parse_status() also parse error messageYu Watanabe2021-09-291-36/+75
| | | | | | | This also introduce dhcp6_option_parse_ia_options(). Currently, it is assumed that each IA address or PD prefix may contain a status sub-option. But it is not prohibited that other sub-options or multiple status options are contained.
* sd-dhcp6-client: modernize dhcp6_option_parse()Yu Watanabe2021-09-291-34/+26
| | | | | | | - merge dhcp6_option_parse() with option_parse_hdr(). - do not assign/update any values on error. - use assert() instead of assert_return(), as the assertions cannot be triggered by a library user.
* sd-dhcp6-client: constify one argumentYu Watanabe2021-09-291-1/+1
|
* sd-dhcp6-client: ignore IAs whose IAID do not match client's IAIDYu Watanabe2021-09-221-3/+33
| | | | | | But do not refuse whole message. Fixes #20803.
* alloc-util: simplify GREEDY_REALLOC() logic by relying on malloc_usable_size()Lennart Poettering2021-05-191-7/+5
| | | | | | | | | | | | | | | | | | | | | | | | 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.)
* sd-dhcp6-client: do not use IN_SET() macro when only one target valueYu Watanabe2021-04-101-1/+1
|
* Merge pull request #18777 from yuwata/network-set-ifname-to-enginesZbigniew Jędrzejewski-Szmek2021-03-311-47/+39
|\ | | | | network: set ifname to dhcp4 client or friends
| * dhcp6: tighten T1 and T2 value checkYu Watanabe2021-03-041-4/+4
| | | | | | | | | | 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.
| * libsystemd-network: make log_dhcp_client() or friends include interface nameYu Watanabe2021-03-041-45/+37
| |
* | dhcp6: fix wrong length for IA_PD dhcp6 optionYu Watanabe2021-03-161-2/+2
|/ | | | | | | | | Fixes an issue introduced by 73b49d433c2c8e6304c8b82538bd4231d070fce4. When PrefixDelegationHint= is not set, dhcp6_option_append_pd() sets wrong length for IA_PD option, as `r` is `-EINVAL`. Fixes #19021.
* dhcp6: do not set T1 and T2 by dhcp6_option_append_pd() in clientYu Watanabe2021-02-231-45/+84
| | | | Fixes #18090.
* dhcp6: do not set T1 and T2 by dhcp6_option_append_ia() in clientYu Watanabe2021-02-231-17/+27
|
* dhcp6: make dhcp6_option_parse_{address,pdprefix}() return -EINVAL when ↵Yu Watanabe2021-02-231-30/+36
| | | | | | | received address or prefix is refused And then the caller ignores the error. Otherwise, `ret_liftime_valid` is not set even if they succeeds.
* dhcp6: do not use input value before checkingYu Watanabe2021-02-231-3/+4
|
* dhcp6: refuse zero length vendor classYu Watanabe2021-01-131-3/+6
| | | | | Also, fixes the maximum length of the vendor class to UINT16_MAX. Moreover, a memory leak in sd_dhcp6_client_set_request_vendor_class().
* dhcp6: refuse zero length dhcp user classYu Watanabe2021-01-131-5/+8
| | | | | This also fixes a memory leak when sd_dhcp6_client_set_request_user_class() is called multiple times.