summaryrefslogtreecommitdiffstats
path: root/src/libsystemd-network/sd-dhcp-lease.c (follow)
Commit message (Collapse)AuthorAgeFilesLines
* networkd/dhcpserver: Save and expose the client hostname sent when ↵Rene Hollander2023-05-311-28/+4
| | | | | | | | | | requesting a DHCP lease. DHCP clients often send their own hostname in option 12. It can be useful to store it with the lease so it can be shown to a human to easily identify which lease belongs to which device. RFC: https://www.rfc-editor.org/rfc/rfc2132#section-3.14
* tree-wide: use free_and_replace() moreDavid Tardon2023-05-241-6/+3
|
* string-util: add common implementation of function that converts sized ↵Lennart Poettering2023-01-211-6/+5
| | | | character buffers to NUL terminated C strings
* libsystemd-network: FTBS in c2x modeCristian Rodríguez2023-01-031-4/+4
| | | | | cannot pass false as argument because function wants a pointer to bool instead, use NULL instead
* tree-wide: replace "plural(s)" by "plurals"Zbigniew Jędrzejewski-Szmek2022-10-171-1/+1
| | | | | | | | (s) is just ugly with a vibe of DOS. In most cases just using the normal plural form is more natural and gramatically correct. There are some log_debug() statements left, and texts in foreign licenses or headers. Those are not touched on purpose.
* tree-wide: use ASSERT_PTR moreDavid Tardon2022-09-131-3/+1
|
* dhcp: fix potential buffer overflowYu Watanabe2022-08-061-3/+3
| | | | | | Fixes a bug introduced by 324f818781a250b60f2fcfa74ff1c9101d2d1315. This also renames several macros for DHCP packet size.
* sd-dhcp-client: fix log messageYu Watanabe2022-07-091-1/+1
|
* tree-wide: convert inet_ntop() calls to anonymous-buffer macrosZbigniew Jędrzejewski-Szmek2022-06-061-6/+5
|
* tree-wide: add a space after if, switch, for, and whileYu Watanabe2022-04-011-1/+1
|
* list: declare iterator of LIST_FOREACH() in the loopYu Watanabe2022-03-191-4/+5
|
* dhcp: list all known DHCP optionsYu Watanabe2022-03-101-5/+5
|
* sd-dhcp-lease: store static routes and classless static routes in different ↵Yu Watanabe2022-02-021-75/+83
| | | | | | | | | | | arrays When classless static routes option is provided, then static routes option should not be used. Hence, let's not mix and store them in one storage. This introduce sd_dhcp_lease_get_static_routes() and sd_dhcp_lease_get_classless_routes().
* sd-dhcp-lease: fix memleakYu Watanabe2022-02-011-2/+18
| | | | Fixes https://github.com/systemd/systemd/pull/22294#issuecomment-1024840811.
* sd-dhcp-lease: fix reading unaligned memoryYu Watanabe2022-02-011-19/+26
| | | | | | | | The destination address was read twice, one is for prefixlen, and other is for destination address itself. And for prefixlen, the address might be read from unaligned buffer. This also modernizes the code.
* sd-dhcp-lease: fix a memory leak in dhcp_lease_parse_search_domainsEvgeny Vereshchagin2022-01-291-1/+1
| | | | | | | | | | | | | | | | | | | | | | ================================================================= ==81071==ERROR: LeakSanitizer: detected memory leaks Direct leak of 16 byte(s) in 1 object(s) allocated from: #0 0x51245c in __interceptor_reallocarray (/home/vagrant/systemd/build/fuzz-dhcp-client+0x51245c) #1 0x7f01440c67e6 in strv_push /home/vagrant/systemd/build/../src/basic/strv.c:435:13 #2 0x7f01440ca9e1 in strv_consume /home/vagrant/systemd/build/../src/basic/strv.c:506:13 #3 0x7f01440ca9e1 in strv_extend /home/vagrant/systemd/build/../src/basic/strv.c:558:16 #4 0x5806e3 in dhcp_lease_parse_search_domains /home/vagrant/systemd/build/../src/libsystemd-network/sd-dhcp-lease.c:900:21 #5 0x57c1be in dhcp_lease_parse_options /home/vagrant/systemd/build/../src/libsystemd-network/sd-dhcp-lease.c:727:21 #6 0x572450 in parse_options /home/vagrant/systemd/build/../src/libsystemd-network/dhcp-option.c:348:33 #7 0x571c6a in dhcp_option_parse /home/vagrant/systemd/build/../src/libsystemd-network/dhcp-option.c:376:13 #8 0x559a01 in client_handle_offer /home/vagrant/systemd/build/../src/libsystemd-network/sd-dhcp-client.c:1543:13 #9 0x5592bd in LLVMFuzzerTestOneInput /home/vagrant/systemd/build/../src/libsystemd-network/fuzz-dhcp-client.c:74:16 #10 0x44a379 in fuzzer::Fuzzer::ExecuteCallback(unsigned char const*, unsigned long) (/home/vagrant/systemd/build/fuzz-dhcp-client+0x44a379) #11 0x42ae1f in fuzzer::RunOneTest(fuzzer::Fuzzer*, char const*, unsigned long) (/home/vagrant/systemd/build/fuzz-dhcp-client+0x42ae1f) #12 0x432ade in fuzzer::FuzzerDriver(int*, char***, int (*)(unsigned char const*, unsigned long)) (/home/vagrant/systemd/build/fuzz-dhcp-client+0x432ade) #13 0x421f86 in main (/home/vagrant/systemd/build/fuzz-dhcp-client+0x421f86) #14 0x7f0142fff55f in __libc_start_call_main (/lib64/libc.so.6+0x2d55f)
* sd-dhcp-lease: fix an infinite loop found by the fuzzerEvgeny Vereshchagin2022-01-291-4/+2
|
* dhcp: fix assertion failureYu Watanabe2021-12-081-1/+1
| | | | Fixes #21671.
* sd-dhcp-client: support 6rd optionYu Watanabe2021-12-071-0/+89
|
* dhcp: make sd_dhcp_lease_get_servers() accepts NULLYu Watanabe2021-11-261-2/+3
|
* alloc-util: simplify GREEDY_REALLOC() logic by relying on malloc_usable_size()Lennart Poettering2021-05-191-13/+9
| | | | | | | | | | | | | | | | | | | | | | | | 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.)
* netlink,network: drop "const" from opaque object parameters in ↵Lennart Poettering2021-05-121-30/+30
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* sd-dhcp-client: constify argument in sd_dhcp_lease_get_xxx()Yu Watanabe2021-04-121-30/+30
|
* tree-wide: use UINT64_MAX or friendsYu Watanabe2021-03-041-3/+3
|
* dhcp: use unlink_and_freep() in dhcp_lease_save()Yu Watanabe2021-03-031-20/+11
|
* network: suffix types with _t in public headersLennart Poettering2021-02-181-2/+2
| | | | | | | | | | | | 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.
* dhcp: use conservative_rename()Yu Watanabe2021-01-221-3/+3
|
* 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
|
* tree-wide: assorted coccinelle fixesFrantisek Sumsal2020-10-091-2/+1
|
* tree-wide: coccinelle fixesFrantisek Sumsal2020-10-041-1/+1
|
* dhcp: fix entry name in parsing lease fileYu Watanabe2020-06-231-1/+1
|
* sd-dhcp: clean-up of DHCP lease server codeLennart Poettering2020-05-301-114/+62
| | | | | | | | | | | | | | | | | | This is an attempt to clean-up the DHCP lease server type code a bit. We now strictly use the same enum everywhere, and store server info in an array. Moreover, we use the same nomenclature everywhere. This only makes the changes in the sd-dhcp code. The networkd code is untouched so far (but should be fixed up like this too. But it's more complicated since this would then touch actual settings in .network files). Note that this also changes some field names in serialized lease files. But given that these field names have not been part of a released version of systemd yet, such a change should be ok. This is pure renaming/refactoring, shouldn't actually change any behaviour.
* Merge pull request #15472 from keszybz/dbus-api-docsLennart Poettering2020-04-231-1/+1
|\ | | | | A few more dbus api documentation updates
| * tree-wide: use "hostname" spelling everywhereZbigniew Jędrzejewski-Szmek2020-04-211-1/+1
| | | | | | | | | | | | | | | | It's not that I think that "hostname" is vastly superior to "host name". Quite the opposite — the difference is small, and in some context the two-word version does fit better. But in the tree, there are ~200 occurrences of the first, and >1600 of the other, and consistent spelling is more important than any particular spelling choice.
* | Merge pull request #15530 from ssahani/lpr-dhcpv4-option-9Zbigniew Jędrzejewski-Szmek2020-04-231-0/+28
|\ \ | | | | | | network: add support to DHCPv4 server/client option 9 LPR
| * | sd-network: DHCPv4 Add support to send and receive LPR servers.Susant Sahani2020-04-221-0/+28
| |/
* | tree-wide: fix spelling errorsFrantisek Sumsal2020-04-211-1/+1
| | | | | | | | | | | | Based on a report from Fossies.org using Codespell. Followup to #15436
* | tree-wide: formatting tweaks reported by CoccinelleFrantisek Sumsal2020-04-211-2/+2
|/
* sd-dhcp-lease: add a meta-getter to simplify querying of server listsZbigniew Jędrzejewski-Szmek2020-04-101-37/+48
|
* sd-dhcp: Add support to emit and retrieve SMTP serverSusant Sahani2020-03-281-0/+28
|
* libsystemd-network: DHCP add support to emit and retrive DHCP POP3 serverSusant Sahani2020-03-281-0/+28
|
* network: DHCP lease load SIP copy paste errorSusant Sahani2020-03-211-1/+1
|
* tree-wide: drop stdio.h when stdio-util.h is includedYu Watanabe2019-11-031-1/+0
|
* tree-wide: drop string.h when string-util.h or friends are includedYu Watanabe2019-11-031-1/+0
|
* dhcp: Log SIP server information correctlyChris Down2019-09-201-1/+1
|
* network: DHCP server Add support to transmit SIP serverSusant Sahani2019-09-201-0/+65
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 1. DHCP server trasmit 2. Client parses and saves in leases Implements http://www.rfc-editor.org/rfc/rfc3361.txt ``` Frame 134: 348 bytes on wire (2784 bits), 348 bytes captured (2784 bits) on interface 0 Ethernet II, Src: 42:65:85:d6:4e:32 (42:65:85:d6:4e:32), Dst: 1e:04:f8:b8:2f:d4 (1e:04:f8:b8:2f:d4) Internet Protocol Version 4, Src: 192.168.5.1, Dst: 192.168.5.11 User Datagram Protocol, Src Port: 67, Dst Port: 68 Dynamic Host Configuration Protocol (ACK) Message type: Boot Reply (2) Hardware type: Ethernet (0x01) Hardware address length: 6 Hops: 0 Transaction ID: 0x7cc87cb4 Seconds elapsed: 0 Bootp flags: 0x0000 (Unicast) Client IP address: 0.0.0.0 Your (client) IP address: 192.168.5.11 Next server IP address: 0.0.0.0 Relay agent IP address: 0.0.0.0 Client MAC address: 1e:04:f8:b8:2f:d4 (1e:04:f8:b8:2f:d4) Client hardware address padding: 00000000000000000000 Server host name not given Boot file name not given Magic cookie: DHCP Option: (53) DHCP Message Type (ACK) Length: 1 DHCP: ACK (5) Option: (51) IP Address Lease Time Length: 4 IP Address Lease Time: (3600s) 1 hour Option: (1) Subnet Mask (255.255.255.0) Length: 4 Subnet Mask: 255.255.255.0 Option: (3) Router Length: 4 Router: 192.168.5.1 Option: (6) Domain Name Server Length: 4 Domain Name Server: 192.168.5.1 Option: (42) Network Time Protocol Servers Length: 4 Network Time Protocol Server: 192.168.1.1 Option: (120) SIP Servers <=====here Length: 9 SIP Server Encoding: IPv4 Address (1) SIP Server Address: 192.168.1.1 SIP Server Address: 192.168.5.2 Option: (101) TCode Length: 13 TZ TCode: Europe/Berlin Option: (54) DHCP Server Identifier (192.168.5.1) Length: 4 DHCP Server Identifier: 192.168.5.1 Option: (255) End Option End: 255 ``` ``` cat /run/systemd/netif/state  ✔  ⚡  3148  16:40:51 OPER_STATE=routable CARRIER_STATE=carrier ADDRESS_STATE=routable DNS=192.168.94.2 192.168.5.1 NTP=192.168.5.1 SIP=192.168.1.1 192.168.5.2 ``` aa
* dhcp4: use memdup_suffix0() instead of strndup() for binary dataYu Watanabe2019-05-301-1/+1
| | | | | | C.f. ac0a94f7438b49a0890d9806db1fa211a5bca10a. Fixes #12693.
* Make fopen_temporary and fopen_temporary_label unlockedZbigniew Jędrzejewski-Szmek2019-04-121-2/+0
| | | | | | | | This is partially a refactoring, but also makes many more places use unlocked operations implicitly, i.e. all users of fopen_temporary(). AFAICT, the uses are always for short-lived files which are not shared externally, and are just used within the same context. Locking is not necessary.
* headers: remove unneeded includes from util.hZbigniew Jędrzejewski-Szmek2019-03-271-0/+3
| | | | | This means we need to include many more headers in various files that simply included util.h before, but it seems cleaner to do it this way.