summaryrefslogtreecommitdiffstats
path: root/src/libsystemd-network (follow)
Commit message (Collapse)AuthorAgeFilesLines
* networkd/dhcpserver: Save and expose the client hostname sent when ↵Rene Hollander2023-05-316-47/+71
| | | | | | | | | | 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
* sd-network: use structured initializationFrantisek Sumsal2023-05-301-16/+14
| | | | And squash one unnecessary assignment.
* sd-network: avoid leaking DHCPLeaseFrantisek Sumsal2023-05-263-18/+42
| | | | | | | | | | | | | | | | | | | | | | | | | | | If we fail any allocation prior adding the lease to the server lease hashmap. ==2103==ERROR: LeakSanitizer: detected memory leaks Direct leak of 128 byte(s) in 2 object(s) allocated from: #0 0x4a203e in __interceptor_calloc /src/llvm-project/compiler-rt/lib/asan/asan_malloc_linux.cpp:77:3 #1 0x4f6341 in calloc (/build/fuzz-dhcp-server+0x4f6341) #2 0x4ec818 in add_lease /work/build/../../src/systemd/src/libsystemd-network/fuzz-dhcp-server.c:26:9 #3 0x4ec2bf in LLVMFuzzerTestOneInput /work/build/../../src/systemd/src/libsystemd-network/fuzz-dhcp-server.c:75:9 #4 0x4f68a8 in NaloFuzzerTestOneInput (/build/fuzz-dhcp-server+0x4f68a8) #5 0x5158b3 in fuzzer::Fuzzer::ExecuteCallback(unsigned char const*, unsigned long) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerLoop.cpp:611:15 #6 0x51509a in fuzzer::Fuzzer::RunOne(unsigned char const*, unsigned long, bool, fuzzer::InputInfo*, bool, bool*) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerLoop.cpp:514:3 #7 0x516769 in fuzzer::Fuzzer::MutateAndTestOne() /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerLoop.cpp:757:19 #8 0x517435 in fuzzer::Fuzzer::Loop(std::__Fuzzer::vector<fuzzer::SizedFile, std::__Fuzzer::allocator<fuzzer::SizedFile> >&) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerLoop.cpp:895:5 #9 0x50679f in fuzzer::FuzzerDriver(int*, char***, int (*)(unsigned char const*, unsigned long)) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerDriver.cpp:912:6 #10 0x507068 in LLVMFuzzerRunDriver /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerDriver.cpp:925:10 #11 0x4f6b25 in main (/build/fuzz-dhcp-server+0x4f6b25) #12 0x7f16084e3082 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x24082) (BuildId: 1878e6b475720c7c51969e69ab2d276fae6d1dee) DEDUP_TOKEN: __interceptor_calloc--calloc--add_lease SUMMARY: AddressSanitizer: 128 byte(s) leaked in 2 allocation(s). Found by Nallocufzz.
* tree-wide: use free_and_replace() moreDavid Tardon2023-05-242-8/+4
|
* tree-wide: Fix false positives on newer gccDaan De Meyer2023-05-231-1/+1
| | | | | | Recent gcc versions have started to trigger false positive maybe-uninitialized warnings. Let's make sure we initialize variables annotated with _cleanup_ to avoid these.
* sd-dhcp-server: also send DNS servers or friends on DHCPOFFERYu Watanabe2023-05-131-30/+27
| | | | | | | | | | | | | | | From RFC 2131 section 4.3.1 (https://www.rfc-editor.org/rfc/rfc2131#section-4.3.1): ---- The server MUST return to the client: - Parameters requested by the client, according to the following rules: -- IF the server has been explicitly configured with a default value for the parameter, the server MUST include that value in an appropriate option in the 'option' field, ---- The sentence is not only for ACK, but for all (positive) responses, that is DHCPOFFER and DHCPACK. Fixes #27471.
* sd-dhcp-client: client ID always has non-zero dataYu Watanabe2023-05-091-1/+1
| | | | | Follow-up for f04c991a2fbb3531c3b464ed8e6dd7543e521f7a. Fixes CID#1510978.
* sd-dhcp-client: do not use implicit cast to booleanYu Watanabe2023-05-081-2/+2
|
* sd-dhcp-client: make return arguments for sd_dhcp_client_get_client_id() ↵Yu Watanabe2023-05-081-14/+21
| | | | optional
* sd-dhcp-client: drop redundant conditionYu Watanabe2023-05-081-8/+6
| | | | Closes #27561.
* networkd: fallback to chaddr for static lease lookup when not foundRobert Meijers2023-04-201-1/+37
| | | | | | | | | | | | | | | | DHCP static leases are looked up by the client identifier as send by the client, while configured based on MAC. As RFC 2131 states the client identifier is an opaque key and must not be interpreted by the server this means that DHCP clients can (/will) also use a client identifier which is not a MAC address. One of these clients actually is systemd-networkd which uses an RFC 4361 by default to generate the client identifier. For these kind of DHCP clients static leases thus don't work because of this mismatch between configuring a MAC address but the server matching based on client identifier. This adds a fallback to try to look up a configured static lease based on the "chaddr" of the DHCP message as this will always contain the MAC address of the client. Fixes #21368
* tree-wide: also use CMSG_TYPED_DATA() on writing message headerYu Watanabe2023-04-161-1/+1
|
* sd-dhcp-server: use CMSG_FIND_DATA() at one more placeYu Watanabe2023-04-161-14/+4
|
* tree-wide: copy timestamp data from cmsgYu Watanabe2023-04-162-10/+8
| | | | | | | On RISCV32, time_t is 64bit and size_t is 32bit, hence the timestamp data in message header may not be aligned. Fixes #27241.
* tree-wide: port more code over to CMSG_TYPED_DATA()Lennart Poettering2023-04-133-4/+4
|
* tree-wide: simplify x ? x : y to x ?: y where applicableFrantisek Sumsal2023-03-181-1/+1
|
* meson: Introduce userspace depJan Janssen2023-03-101-0/+1
| | | | This will help in a later commit to separate userspace from EFI builds.
* Merge pull request #26528 from keszybz/valgrind-simplificationYu Watanabe2023-02-221-2/+6
|\ | | | | Drop the -Dvalgrind configuration option
| * meson: merge our two valgrind configuration conditions into oneZbigniew Jędrzejewski-Szmek2023-02-221-2/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Most of the support for valgrind was under HAVE_VALGRIND_VALGRIND_H, i.e. we would enable if the valgrind headers were found. The operations then we be conditionalized on RUNNING_UNDER_VALGRIND. But in a few places we had code which was conditionalized on VALGRIND, i.e. the config option. I noticed because I compiled with -Dvalgrind=true on a machine that didn't have valgrind.h, and the build failed because RUNNING_UNDER_VALGRIND was not defined. My first idea was to add a check that the header is present if the option is set, but it seems better to just remove the option. The code to support valgrind is trivial, and if we're !RUNNING_UNDER_VALGRIND, it has negligible cost. And the case of running under valgrind is always some special testing/debugging mode, so we should just do those extra steps to make valgrind output cleaner. Removing the option makes things simpler and we don't have to think if something should be covered by the one or the other configuration bit. I had a vague recollection that in some places we used -Dvalgrind=true not for valgrind support, but to enable additional cleanup under other sanitizers. But that code would fail to build without the valgrind headers anyway, so I'm not sure if that was still used. If there are uses like that, we can extend the condition for cleanup_pools().
* | meson: Use dicts for fuzzer definitionsJan Janssen2023-02-211-23/+28
| |
* | meson: Use dicts for test definitionsJan Janssen2023-02-211-45/+50
|/ | | | | | | Although this slightly more verbose it makes it much easier to reason about. The code that produces the tests heavily benefits from this. Test lists are also now sorted by test name.
* tree-wide: fix typo and comment style updateYu Watanabe2023-02-151-1/+1
|
* sd-network: stop using fake flexible arrayZbigniew Jędrzejewski-Szmek2023-02-061-1/+1
|
* sd-dhcp-server: allow to send header only messageYu Watanabe2023-01-281-1/+1
| | | | | | | If we receive a header only message, and the server is running in relay mode, then the assertion was triggered. Fixes #26151.
* meson: Do not include headers in source listsJan Janssen2023-01-241-20/+0
| | | | | | Meson+ninja+compiler do this for us and are better at it. https://mesonbuild.com/FAQ.html#do-i-need-to-add-my-headers-to-the-sources-list-like-in-autotools
* string-util: add common implementation of function that converts sized ↵Lennart Poettering2023-01-212-13/+9
| | | | character buffers to NUL terminated C strings
* Merge pull request #26115 from yuwata/test-fix-memleak-fdleakLuca Boccassi2023-01-202-27/+14
|\ | | | | test: fix memleak and fd leak
| * test-ndisc: fix memleak and fd leakYu Watanabe2023-01-202-27/+14
| | | | | | | | Fixes issues reported at #22576.
* | tree-wide: fix typoYu Watanabe2023-01-201-1/+1
|/
* send dhcpv6 release when stoppingchris2023-01-175-16/+152
|
* sd-dhcp-client: gracefully handle invalid ether type client IDYu Watanabe2023-01-161-20/+18
| | | | | | | | Currently, sd-dhcp-server accepts spurious client IDs, then the leases exposed by networkd may be invalid. Let's make networkctl gracefully show such leases. Fixes #25984.
* sd-dhcp6: always append the default status message generated from status codeYu Watanabe2023-01-162-13/+18
| | | | Fixes #25988.
* optionally set socket priority on DHCPv4 raw socketchris2023-01-125-9/+41
|
* 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: use -EBADF moreYu Watanabe2022-12-204-5/+5
|
* tree-wide: introduce PIPE_EBADF macroYu Watanabe2022-12-205-5/+6
|
* fuzz: sort headersYu Watanabe2022-12-201-3/+4
|
* tree-wide: use -EBADF also in pipe initializersZbigniew Jędrzejewski-Szmek2022-12-195-5/+5
| | | | In some places, initialization is dropped when unnecesary.
* tree-wide: use -EBADF for fd initializationZbigniew Jędrzejewski-Szmek2022-12-199-11/+11
| | | | | | | | | | | | | | | | -1 was used everywhere, but -EBADF or -EBADFD started being used in various places. Let's make things consistent in the new style. Note that there are two candidates: EBADF 9 Bad file descriptor EBADFD 77 File descriptor in bad state Since we're initializating the fd, we're just assigning a value that means "no fd yet", so it's just a bad file descriptor, and the first errno fits better. If instead we had a valid file descriptor that became invalid because of some operation or state change, the other errno would fit better. In some places, initialization is dropped if unnecessary.
* all: avoid various "-Wcast-align=strict" warningsThomas Haller2022-12-092-2/+2
|
* basic: rename util.h to logarithm.hZbigniew Jędrzejewski-Szmek2022-11-087-7/+0
| | | | | util.h is now about logarithms only, so we can rename it. Many files included util.h for no apparent reason… Those includes are dropped.
* dhcp: use the attached sd_device object when generating IAIDYu Watanabe2022-10-276-50/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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()`.
* sd-dhcp6-client: introduce sd_dhcp6_client_attach_device()Yu Watanabe2022-10-262-0/+11
| | | | It will be used later.
* sd-dhcp-client: introduce sd_dhcp_client_attach_device()Yu Watanabe2022-10-261-0/+13
| | | | It will be used later.
* 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.
* Merge pull request #24973 from keszybz/simplify-variable-declarationsYu Watanabe2022-10-121-6/+2
|\ | | | | Simplify variable declarations
| * libsystemd-network: trivial simplificationZbigniew Jędrzejewski-Szmek2022-10-121-6/+2
| |
* | Merge pull request #24867 from yuwata/sd-dhcp6-client-large-packetZbigniew Jędrzejewski-Szmek2022-10-124-199/+152
|\| | | | | sd-dhcp6-client: allow to build large packet
| * sd-dhcp6-client: allow to build large packetYu Watanabe2022-10-024-98/+91
| | | | | | | | | | | | | | | | | | | | | | | | | | | | 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: rename buf -> pYu Watanabe2022-10-021-14/+14
| | | | | | | | No functional changes, just preparation for the next commit.