summaryrefslogtreecommitdiffstats
path: root/src/libsystemd-network/dhcp-identifier.c (follow)
Commit message (Collapse)AuthorAgeFilesLines
* dhcp: use the attached sd_device object when generating IAIDYu Watanabe2022-10-271-35/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Note, previously `use_mac` set with `test_mode`. As `dev`, which is set with `client->dev`, is not set when running test or fuzzer. Hence, the condition ``` if (udev_available() && !use_mac) ``` is effectively equivalent to ``` if (dev) ``` So, this commit mostly does not change behavior. Except for the following corner case. The sd_device object assigned from networkd (that is, Link.dev) never has ID_RENAMING udev property, as sd_device objects which has the property are filtered out at `link_check_initialized()` or `manager_udev_process_link()` in networkd-link.c. However, sd_device object created in `dhcp_identifier_set_iaid()` in the previous code may have it. Such situation may (at least, theoretically) happen when the network interface is renamed after initialized, e.g. by creating the following spurious .link file: ``` [Match] OriginalName=eno1 [Link] Name=lan ``` and then trigger uevent for the network interface while systemd-networkd calling `dhcp_identifier_set_iaid()`.
* dhcp: make dhcp_identifier_set_duid() take struct hw_addr_dataYu Watanabe2022-08-051-18/+28
|
* dhcp: make dhcp_identifier_set_iaid() take struct hw_addr_dataYu Watanabe2022-08-051-3/+6
|
* libsystemd-network: use udev_available()Nick Rosbrook2022-06-091-2/+1
|
* dhcp-identifier: use offsetof()Yu Watanabe2022-02-161-5/+5
| | | | Also use appropriate place to store UUID.
* dhcp-identifier: generate static and constant DUID-EN when the client is ↵Yu Watanabe2022-02-141-9/+16
| | | | | | running in test mode Follow-up for 9216fddc5a8ac2742e6cfa7660f95c20ca4f2193.
* dhcp-identifier: introduce dhcp_identifier_set_duid()Yu Watanabe2022-02-141-34/+63
|
* dhcp-identifier: introduce duid_type_to_string()Yu Watanabe2022-02-141-3/+10
|
* dhcp-identifier: always use a fixed machine-id while fuzzingEvgeny Vereshchagin2022-02-021-7/+5
| | | | | | | | | | | | It's a follow-up to https://github.com/systemd/systemd/pull/10200 where that fuzzer was introduced. At the time it was run regularly on machines where machine-id wasn't present so it was kind of reproducible. Now it's run on CIFuzz and CFLite using GHActions with the public OSS-Fuzz corpora (based on that particular machine-id) so to fully utilize those corpora it's necessary to use it always. Other than that it makes it possible for fuzzers targeting outgoing packets based on incoming packets like https://bugs.launchpad.net/ubuntu/+source/systemd/+bug/1795921 to get past client_parse_message on my machine :-)
* netif-util: rename net_get_name_persistent() -> net_get_persistent_name()Yu Watanabe2021-11-091-1/+1
|
* netif-util: move several functions from network-util.[ch] to ↵Yu Watanabe2021-11-091-1/+1
| | | | | | | shared/netif-util.[ch] These functions are not relevant to sd-network, and only used by networkd, networkctl, and udevd.
* network: use official bswap_32() rather than inofficial __bswap_32()Lennart Poettering2021-10-111-1/+1
| | | | | The former is a macro for the latter, but let's use the official API (the one that has an API).
* sd-dhcp: refuse to set iaid if we cannot find the interfaceYu Watanabe2021-06-111-18/+21
|
* dhcp: do not use ifindex when generating iaid in testsYu Watanabe2021-06-111-1/+2
|
* sd-dhcp: do not use detect_container() to guess udev is running or notYu Watanabe2021-06-111-2/+3
|
* tree-wide: use sd_device_new_from_ifindex/ifname()Yu Watanabe2021-06-111-4/+2
|
* Merge pull request #17478 from yuwata/split-network-internalYu Watanabe2020-11-271-1/+2
|\ | | | | libsystemd-network: split network-internal.c
| * sd-network: move net_get_unique_predictable_data() and net_get_name_persisten()Yu Watanabe2020-10-291-1/+2
| |
* | license: LGPL-2.1+ -> LGPL-2.1-or-laterYu Watanabe2020-11-091-1/+1
|/
* tree-wide: drop if braces around single line expressions as wellFrantisek Sumsal2020-10-091-2/+1
|
* sd-network: DHCPv6 - Add support to send vendor class dataSusant Sahani2020-05-201-1/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | ``` 21.16. Vendor Class Option This option is used by a client to identify the vendor that manufactured the hardware on which the client is running. The information contained in the data area of this option is contained in one or more opaque fields that identify details of the hardware configuration. The format of the Vendor Class option is: 0 1 2 3 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | OPTION_VENDOR_CLASS | option-len | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | enterprise-number | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ . . . vendor-class-data . . . . . . +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ Figure 28: Vendor Class Option Format option-code OPTION_VENDOR_CLASS (16). option-len 4 + length of vendor-class-data field. enterprise-number The vendor's registered Enterprise Number as maintained by IANA [IANA-PEN]. A 4-octet field containing an unsigned integer. vendor-class-data The hardware configuration of the node on which the client is running. A variable-length field (4 octets less than the value in the option-len field). The vendor-class-data field is composed of a series of separate items, each of which describes some characteristic of the client's hardware configuration. Examples of vendor-class-data instances might include the version of the operating system the client is running or the amount of memory installed on the client. Each instance of vendor-class-data is formatted as follows: +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-...-+-+-+-+-+-+-+ | vendor-class-len | opaque-data | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-...-+-+-+-+-+-+-+ Figure 29: Format of vendor-class-data Field The vendor-class-len field is 2 octets long and specifies the length of the opaque vendor-class-data in network byte order. Servers and clients MUST NOT include more than one instance of OPTION_VENDOR_CLASS with the same Enterprise Number. Each instance of OPTION_VENDOR_CLASS can carry multiple vendor-class-data instances. ```
* libsystemd-network: rename net_get_name() to net_get_name_persistent()Zbigniew Jędrzejewski-Szmek2019-06-171-1/+1
| | | | | | | This reflect its role better. (I didn't use …_persistent_name(), because which name is actually used depends on the policy. So it's better not to make this sound like it returns *the* persistent name.)
* dhcp: refuse to configure DHCP IAID if the interface is under renamingYu Watanabe2019-03-051-0/+8
| | | | | | systemd-networkd itself does not start dhcp client, but the code may be used in other projects. So, check that the interface is under renaming or not.
* dhcp/trivial: fix spelling error in commentThomas Haller2019-01-251-1/+1
|
* libsystemd-network: use xsprintf in one more placeZbigniew Jędrzejewski-Szmek2019-01-161-2/+3
| | | | DECIMAL_STR_MAX includes space for NUL, so we don't need 2 here.
* dhcp6: don't enforce DUID content for sd_dhcp6_client_set_duid()Thomas Haller2018-12-201-1/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | There are various functions to set the DUID of a DHCPv6 client. However, none of them allows to set arbitrary data. The closest is sd_dhcp6_client_set_duid(), which would still do validation of the DUID's content via dhcp_validate_duid_len(). Relax the validation and only log a debug message if the DUID does not validate. Note that dhcp_validate_duid_len() already is not very strict. For example with DUID_TYPE_LLT it only ensures that the length is suitable to contain hwtype and time. It does not further check that the length of hwaddr is non-zero or suitable for hwtype. Also, non-well-known DUID types are accepted for extensibility. Why reject certain DUIDs but allowing clearly wrong formats otherwise? The validation and failure should happen earlier, when accepting the unsuitable DUID. At that point, there is more context of what is wrong, and a better failure reason (or warning) can be reported to the user. Rejecting the DUID when setting up the DHCPv6 client seems not optimal, in particular because the DHCPv6 client does not care about actual content of the DUID and treats it as opaque blob. Also, NetworkManager (which uses this code) allows to configure the entire binary DUID in binary. It intentionally does not validate the binary content any further. Hence, it needs to be able to set _invalid_ DUIDs, provided that some basic constraints are satisfied (like the maximum length). sd_dhcp6_client_set_duid() has two callers: both set the DUID obtained from link_get_duid(), which comes from configuration. `man networkd.conf` says: "The configured DHCP DUID should conform to the specification in RFC 3315, RFC 6355.". It does not not state that it MUST conform. Note that dhcp_validate_duid_len() has another caller: DHCPv4's dhcp_client_set_iaid_duid_internal(). In this case, continue with strict validation, as the callers are more controlled. Also, there is already sd_dhcp_client_set_client_id() which can be used to bypass this check and set arbitrary client identifiers.
* dhcp: support endianness independent dhcp_identifier_set_iaid()Thomas Haller2018-11-121-4/+18
| | | | | | | | | | | | | | | | | | | The previous code did htole64() followed by unaligned_write_be32() (the XOR and shift in between is endianness agnostic). That means, on every architeture there is always exactly one byte swap and the iaid is dependent on endianness. Since dhcp_identifier_set_iaid() is part of the DUID generation algorithm, this cannot be fixed without changing the client-id. In particular, as the client-id already depends on the machine-id (and is thus inherrently host-specific), it is better to stick to the current behavior. However, add a parameter to switch between old and new behaviour. Since the new behavior is unused, the only real purpose of this change is to self-document the oddity of the function. Fixes: 933f9caeeb2b3c1b951d330e04beb04226e5a890
* sd-device: make sd_device_get_is_initialized() returns is_initialized by ↵Yu Watanabe2018-10-291-3/+3
| | | | return value
* tests: make fuzz-dhcp6-client work in containers provided by the OSS-Fuzz ↵Evgeny Vereshchagin2018-09-291-1/+6
| | | | | | | | | project The containers come with an empty machine-id, which causes the fuzzer to fail as soon as it starts. See https://github.com/systemd/systemd/pull/9014#discussion_r189594104
* Merge pull request #9406 from yuwata/rfe-9228Zbigniew Jędrzejewski-Szmek2018-08-231-3/+77
|\ | | | | | | Trivial conflict solved in merge and include net/if_arp.h added.
| * sd-dhcp: use MAC address when DUIDType=link-layer-time or link-layer but ↵Yu Watanabe2018-08-081-0/+53
| | | | | | | | DUIDRawData= is not set
| * sd-dhcp: use application specific machine ID when DUIDType=uuid but ↵Yu Watanabe2018-08-081-3/+23
| | | | | | | | DUIDRawData= is not set
* | network: replace udev_device by sd_deviceYu Watanabe2018-08-221-13/+10
|/
* tree-wide: drop copyright headers from frequent contributorsZbigniew Jędrzejewski-Szmek2018-06-201-3/+0
| | | | | | | | Fixes #9320. for p in Shapovalov Chevalier Rozhkov Sievers Mack Herrmann Schmidt Rudenberg Sahani Landden Andersen Watanabe; do git grep -e 'Copyright.*'$p -l|xargs perl -i -0pe 's|/([*][*])?[*]\s+([*#]\s+)?Copyright[^\n]*'$p'[^\n]*\s*[*]([*][*])?/\n*|\n|gms; s|\s+([*#]\s+)?Copyright[^\n]*'$p'[^\n]*\n*|\n|gms' done
* tree-wide: use proper unicode © instead of (C) where we canLennart Poettering2018-06-141-1/+1
| | | | | | Let's use a proper unicode copyright symbol where we can, it's prettier. This important patch is very important.
* tree-wide: drop 'This file is part of systemd' blurbLennart Poettering2018-06-141-2/+0
| | | | | | | | | | | | | | | | This part of the copyright blurb stems from the GPL use recommendations: https://www.gnu.org/licenses/gpl-howto.en.html The concept appears to originate in times where version control was per file, instead of per tree, and was a way to glue the files together. Ultimately, we nowadays don't live in that world anymore, and this information is entirely useless anyway, as people are very welcome to copy these files into any projects they like, and they shouldn't have to change bits that are part of our copyright header for that. hence, let's just get rid of this old cruft, and shorten our codebase a bit.
* tree-wide: drop redundant _cleanup_ macros (#8810)Lennart Poettering2018-04-251-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | This drops a good number of type-specific _cleanup_ macros, and patches all users to just use the generic ones. In most recent code we abstained from defining type-specific macros, and this basically removes all those added already, with the exception of the really low-level ones. Having explicit macros for this is not too useful, as the expression without the extra macro is generally just 2ch wider. We should generally emphesize generic code, unless there are really good reasons for specific code, hence let's follow this in this case too. Note that _cleanup_free_ and similar really low-level, libc'ish, Linux API'ish macros continue to be defined, only the really high-level OO ones are dropped. From now on this should really be the rule: for really low-level stuff, such as memory allocation, fd handling and so one, go ahead and define explicit per-type macros, but for high-level, specific program code, just use the generic _cleanup_() macro directly, in order to keep things simple and as readable as possible for the uninitiated. Note that before this patch some of the APIs (notable libudev ones) were already used with the high-level macros at some places and with the generic _cleanup_ macro at others. With this patch we hence unify on the latter.
* tree-wide: drop license boilerplateZbigniew Jędrzejewski-Szmek2018-04-061-13/+0
| | | | | | | | | | Files which are installed as-is (any .service and other unit files, .conf files, .policy files, etc), are left as is. My assumption is that SPDX identifiers are not yet that well known, so it's better to retain the extended header to avoid any doubt. I also kept any copyright lines. We can probably remove them, but it'd nice to obtain explicit acks from all involved authors before doing that.
* Add SPDX license identifiers to source files under the LGPLZbigniew Jędrzejewski-Szmek2017-11-191-0/+1
| | | | | This follows what the kernel is doing, c.f. https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=5fd54ace4721fc5ce2bb5aef6318fcf17f421460.
* dhcp-identifier: un-inline dhcp_validate_duid_lenZbigniew Jędrzejewski-Szmek2016-05-031-0/+31
| | | | | | | | | | After all it is used in more than one place and is not that short. Also tweak the test a bit: - do not check that duid_len > 0, because we want to allow unknown duid types, and there might be some which are fine with 0 length data, (also assert should not be called from library code), - always check that duid_len <= MAX_DUID_LEN, because we could overwrite available buffer space otherwise.
* DHCP DUID, IAID configuration optionsVinay Kulkarni2016-03-311-1/+1
|
* Revert "DHCP DUID and IAID configurability"Zbigniew Jędrzejewski-Szmek2016-03-211-1/+1
|
* DHCP DUID and IAID configurabilityVinay Kulkarni2016-03-101-1/+1
|
* tree-wide: remove Emacs lines from all filesDaniel Mack2016-02-101-2/+0
| | | | | This should be handled fine now by .dir-locals.el, so need to carry that stuff in every file.
* tree-wide: group include of libudev.h with sd-*Thomas Hindoe Paaboel Andersen2015-11-171-1/+1
|
* Merge pull request #1923 from zonque/siphashLennart Poettering2015-11-171-3/+5
|\ | | | | siphash24: let siphash24_finalize() and siphash24() return the result…
| * siphash24: let siphash24_finalize() and siphash24() return the result directlyDaniel Mack2015-11-161-3/+5
| | | | | | | | | | | | | | | | | | | | Rather than passing a pointer to return the result, return it directly from the function calls. Also, return the result in native endianess, and let the callers care about the conversion. For hash tables and bloom filters, we don't care, but in order to keep MAC addresses and DHCP client IDs stable, we explicitly convert to LE.
* | tree-wide: sort includesThomas Hindoe Paaboel Andersen2015-11-161-1/+1
|/ | | | Sort the includes accoding to the new coding style.
* siphash24: change result argument to uint64_tMartin Pitt2015-11-161-4/+6
| | | | | | | | | | | | Change the "out" parameter from uint8_t[8] to uint64_t. On architectures which enforce pointer alignment this fixes crashes when we previously cast an unaligned array to uint64_t*, and on others this should at least improve performance as the compiler now aligns these properly. This also simplifies the code in most cases by getting rid of typecasts. The only place which we can't change is struct duid's en.id, as that is _packed_ and public API, so we can't enforce alignment of the "id" field and have to use memcpy instead.
* util-lib: split our string related calls from util.[ch] into its own file ↵Lennart Poettering2015-10-241-9/+6
| | | | | | | | | | | | | | string-util.[ch] There are more than enough calls doing string manipulations to deserve its own files, hence do something about it. This patch also sorts the #include blocks of all files that needed to be updated, according to the sorting suggestions from CODING_STYLE. Since pretty much every file needs our string manipulation functions this effectively means that most files have sorted #include blocks now. Also touches a few unrelated include files.