summaryrefslogtreecommitdiffstats
path: root/src/network/networkd-dhcp-server.c (follow)
Commit message (Collapse)AuthorAgeFilesLines
* network: introduce link_get_use_ntp()Yu Watanabe2024-04-191-1/+2
| | | | No functional change, just refactoring.
* network: introduce link_get_use_dns()Yu Watanabe2024-04-191-1/+1
| | | | No functional change, just refactoring.
* networkd: report error if lease file cannot be loaded and ignoreZbigniew Jędrzejewski-Szmek2024-04-081-1/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | On my system, networkd would report that interface ve-rawhide is "Failed" without anything in the logs: systemd-networkd[651095]: ve-rawhide: Trying to reconfigure the interface. systemd-networkd[651095]: ve-rawhide: Gained IPv6LL systemd-networkd[651095]: ve-rawhide: Link DOWN systemd-networkd[651095]: ve-rawhide: Lost carrier systemd-networkd[651095]: ve-rawhide: Configuring with /usr/lib/systemd/network/80-container-ve.network. systemd-networkd[651095]: ve-rawhide: Link UP systemd-networkd[651095]: ve-rawhide: Gained carrier systemd-networkd[651095]: ve-rawhide: Failed At debug level: systemd-networkd[799993]: dhcp-server-lease/ve-rawhide:1:1: Missing object field 'Address'. $ jq </var/lib/systemd/network/dhcp-server-lease/ve-rawhide { "BootID": "5d86b34b98894322bfd4ae8443ce59b3", "Leases": [ { "ClientId": [ ... ], "Address": [ 192, 168, 120, 179 ], "Hostname": "rawhide", "ExpirationUSec": 966046821158, "ExpirationRealtimeUSec": 1711203197266940 } ] } I'm not sure why "Address" is missing, but anyway, in this case, we should ignore the lease file rather than refusing to configure the interface. Also, warn at the point where we know what the filename is.
* network/dhcp-server: introduce PersistLeases= settingYu Watanabe2024-03-271-2/+19
| | | | Requested at https://github.com/systemd/systemd/pull/31772#issuecomment-2000053357.
* network/address: acquire address from DHCP server lease fileYu Watanabe2024-03-181-0/+46
| | | | | | | | | | | | If the DHCP server on an interface is configured with its server address is null, then let's reuse the previous server address if possible. Otherwise, if networkd is restarted or the host is rebooted, then possibly new subnet is picked, and clients that already have addresses in the previous subnet cannot access the server. Prompted by https://github.com/systemd/systemd/pull/30021#discussion_r1518478633.
* network/dhcp-server: use the pinned fd of persistent storgeYu Watanabe2024-03-151-19/+27
|
* network: pin file descriptor of persistent storageYu Watanabe2024-03-151-1/+1
| | | | | | This also drop the support of /run/systemd/netif/persistent-storage-ready, as the file is anyway removed when networkd is stopped. Let's use $SYSTEMD_NETWORK_PERSISTENT_STORAGE_READY=1 instead on testing.
* sd-dhcp-server: make sd_dhcp_server_set_lease_file() optionally take ↵Yu Watanabe2024-03-141-1/+1
| | | | | | | directory fd Currently, though, no valid directory fd is passed to the function call. Preparation for later commits.
* network: use link_start_dhcp4_server() at one more placeYu Watanabe2024-03-141-1/+1
| | | | | | | Otherwise, even if the persistent storage is not ready, the DHCP server may be started e.g. by unplugging and plugging cable. Follow-up for 5582b36c384fc522c23ef1ac032001882d033aff.
* network/dhcp-server: save leases in state directoryYu Watanabe2024-03-111-2/+61
| | | | | | | | | | | | Then, we can read the lease file on restart, and the DHCP server will be able to manage previously assigned addresses. To save leases in the state directory /var/lib/systemd/network/, this adds systemd-networkd-dhcp-server.service, and by default systemd-networkd does not start the DHCP server without the heler service started. Closes #29991.
* network/address: introduce ref/unref functions for Address objectYu Watanabe2024-01-031-1/+1
| | | | | Then, Address object can live if it is detached from the owner (Link or Network object).
* tree-wide: drop space between variable and an increment/decrementYu Watanabe2023-12-241-1/+1
|
* network: add [DHCPServer] RapidCommit= settingYu Watanabe2023-11-071-0/+5
|
* tree-wide: port various parsers over to read_stripped_line()Lennart Poettering2023-10-171-5/+3
|
* network/dhcp-server: allow to configure IPv6 only preferred optionSusant Sahani2023-10-111-0/+48
| | | | Co-authored-by: Yu Watanabe <watanabe.yu+github@gmail.com>
* sd-dhcp-server: store lifetime and friends in usec_tYu Watanabe2023-09-191-4/+2
|
* Merge pull request #29119 from ↵Luca Boccassi2023-09-171-75/+70
|\ | | | | | | | | yuwata/network-dhcp-server-allow-null-server-address network/dhcp-server: allow null server address
| * network: allow to set null address for [DHCPServer] ServerAddress=Yu Watanabe2023-09-081-2/+2
| | | | | | | | | | | | | | And refuse a link-local address. With the previous commit, now ServerAddress= can take a null address, but the config parser refused that. Let's allow that now.
| * network: find DHCP server address only on loading .network fileYu Watanabe2023-09-081-71/+67
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Previously, we periodically search suitable address for DHCP server, 1. when .network file is loaded, 2. when checking if we can configure sd_dhcp_server object, 3. when configuring sd_dhcp_server. Especially, the step 2 may be triggered several times. This makes, when .network file is loaded, find a corresponding Address object, add a new Address object if not found, then save the found or added Address object. So, it is not necessary to find address again on configuring sd_dhcp_server object.
| * network: call network_adjust_dhcp_server() from network_drop_invalid_addresses()Yu Watanabe2023-09-081-2/+1
| | | | | | | | | | | | | | | | | | We need to find a suitable static address for the DHCP server. So, all static addresses must be verified before network_adjust_dhcp_server() is called. For safety, let's call it from network_drop_invalid_addresses(). No functional change, just refactoring and preparation for later commits.
* | Revert "tree-wide: Mount file descriptors via /proc/<pid>/fd"Lennart Poettering2023-09-081-3/+2
|/
* network: drop duplicated address_set_broadcast()Yu Watanabe2023-09-071-1/+0
| | | | It will be called later in link_request_address().
* tree-wide: Always include <net/if.h> before related linux headersDaan De Meyer2023-08-141-2/+3
| | | | | Otherwise, we get redefinition errors if <net/if.h> is included later on by another header.
* network/address: introduce address_get_harder() and use it where appropriateYu Watanabe2023-07-301-2/+2
| | | | | | With the previous change, now Address objects under requesting are not owned by Link object, hence we need to also search corresponding Address object in the request queue.
* network/address: free Address object by caller that passed to ↵Yu Watanabe2023-07-291-1/+1
| | | | | | | | | link_request_address() Follow-up for 9684a8ded083dd427f843b0c40aa0292e6c7ae06. Now, the input Address object is always copied, hence it is not necessary to free it in link_request_address().
* tree-wide: use ASSERT_PTR moreDavid Tardon2022-09-131-2/+1
|
* network: drop an unused variableFrantisek Sumsal2022-08-201-3/+1
|
* network: check link state with link_is_ready_to_configure() before ↵Yu Watanabe2022-08-051-7/+1
| | | | | | | configuring DHCP client or friends Otherwise, DHCP client or friends may started before link-layer properties, e.g. MAC address, being configured or the link being activated.
* strv: make iterator in STRV_FOREACH() declaread in the loopYu Watanabe2022-03-191-2/+0
| | | | This also avoids multiple evaluations in STRV_FOREACH_BACKWARDS()
* Merge pull request #22631 from yuwata/network-redesign-request-queueLuca Boccassi2022-03-111-6/+3
|\ | | | | network: re-design request queue
| * network: re-design request queueYu Watanabe2022-03-111-2/+2
| | | | | | | | | | | | | | | | This makes Request object takes hash, compare, free, and process functions. With this change, the logic in networkd-queue.c can be mostly independent of the type of the request or the object (e.g. Address) assigned to the request, and it becomes simpler.
| * network: make request_process_address() and friends take Link and ↵Yu Watanabe2022-03-111-5/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | corresponding object This also renames e.g. request_process_address() -> address_process_request(). Also, this drops type checks such as `assert(req->type == REQUEST_TYPE_ADDRESS)`, as in the later commits, the function of processing request, e.g. `address_process_request()`, will be assigned to the Request object when it is created. And the request type will be used to distinguish and to avoid deduplicating requests which do not have any assigned objects, like REQUEST_TYPE_DHCP4_CLIENT. Hence, the type checks in process functions are mostly not necessary and redundant. This is mostly cleanups and preparation for later commits, and should not change any behavior.
* | network: dhcp: rename NextServer= and Filename= settingsYu Watanabe2022-03-111-5/+9
|/ | | | | | | And make the settings configures DHCP option 66 and 67. Follow-ups for #22615. Fixes #22661.
* network: dhcp-server: add two more log messagesYu Watanabe2022-02-251-6/+18
|
* network: move functionsYu Watanabe2022-02-251-13/+13
| | | | No functional change. Preparation for later commits.
* network: add NextServer= and Filename= setting to [DHCPServer] sectionYu Watanabe2022-02-241-0/+8
| | | | Closes #4403.
* network: set broadcast address on requestYu Watanabe2022-02-231-1/+1
| | | | | | | | | | | Previously, the broadcast address was set to a Address object in address_section_verify() (or address_acquire()). But, for wireguard interfaces, we do not use the broadcast address. The .network file may be assigned to multiple interfaces, hence, we cannot determine if we should set the broadcast address in address_section_verify(). This makes the broadcast address set in link_request_address(). Then, we set the broadcast address only when we need it.
* network: dhcp-server: make empty string to DNS= or friends clear previously ↵Yu Watanabe2022-02-021-0/+6
| | | | specified servers
* Merge pull request #22332 from yuwata/network-dhcp-server-dns-server-addressYu Watanabe2022-02-011-14/+16
|\ | | | | network: dhcp-server: allow to specify server address for DNS= or friends
| * network: dhcp-server: introduce special value DNS=_server_addressYu Watanabe2022-02-011-5/+15
| | | | | | | | Closes #15026.
| * network: use GREEDY_REALLOC() at one more placeYu Watanabe2022-02-011-3/+1
| |
| * network: drop outdated TODO commentYu Watanabe2022-02-011-6/+0
| | | | | | | | Follow-up for 59aa622013277cfe6349d0789a7a00ad2b884902.
* | network: dhcp-server: also refuse link local address to use as the server ↵Yu Watanabe2022-02-011-6/+17
|/ | | | address
* network: split networkd-route.[ch]Yu Watanabe2021-11-141-1/+1
|
* network: dhcp-server: introduce Router= setting to specify router addressYu Watanabe2021-11-021-3/+5
| | | | Closes #21202.
* network: use NetworkConfigSource/State to manage addresses and routesYu Watanabe2021-09-241-10/+50
| | | | This also fixes #20146.
* network: introduce UplinkInterface= in [IPv6SendRA]Yu Watanabe2021-08-041-53/+1
|
* Drop the text argument from assert_not_reached()Zbigniew Jędrzejewski-Szmek2021-08-031-1/+1
| | | | | | | | | | | | | | | | | In general we almost never hit those asserts in production code, so users see them very rarely, if ever. But either way, we just need something that users can pass to the developers. We have quite a few of those asserts, and some have fairly nice messages, but many are like "WTF?" or "???" or "unexpected something". The error that is printed includes the file location, and function name. In almost all functions there's at most one assert, so the function name alone is enough to identify the failure for a developer. So we don't get much extra from the message, and we might just as well drop them. Dropping them makes our code a tiny bit smaller, and most importantly, improves development experience by making it easy to insert such an assert in the code without thinking how to phrase the argument.
* network: rename Manager::links -> Manager::links_by_indexYu Watanabe2021-06-301-1/+1
| | | | This also renames link_get() -> link_get_by_index().
* network: do not process requests which conditionalized with link flags while ↵Yu Watanabe2021-06-081-0/+3
| | | | | | | | the flags are updating E.g. nexthop requires IFF_UP flag, but the currently stored flag may be outdated if we called link_down(). This makes such requests pending if at least one of the flags are updating.