Commit Graph
5114 Commits
Author SHA1 Message Date
Mike Yuan b377a7cce9 daemon-util: introduce notify_reloading helper
Prompted by #31951
2024-03-26 12:52:33 +00:00
Yu Watanabe 0ffcf398e5 Merge pull request #31899 from yuwata/sd-journal-add-match
sd-journal: introduce two helpers for adding journal filter
2024-03-26 02:56:58 +09:00
Luca Boccassi 650421fb8e Merge pull request #31730 from yuwata/network-dhcp-server-lease-file-follow-ups
network: several follow-ups for DHCP server lease file
2024-03-25 14:32:05 +00:00
Yu Watanabe 077f63264f networkctl: use journal_add_matchf() and journal_add_match_pair() 2024-03-25 21:39:37 +09:00
Yu Watanabe 2858d92914 network: set varlink description 2024-03-21 19:52:31 +09:00
Yu Watanabe 7742d03e8d networkctl: use varlink_flush_close_unrefp() 2024-03-21 19:45:03 +09:00
Zbigniew Jędrzejewski-Szmek 6a705f1234 Replace strdup_or_null() by strdup_to()
I didn't know that this helper existed… It is very similar to strdup_to_full(),
but all callers can actually be replaced by strdup_to(), which has more fitting
semantics.
2024-03-20 15:18:21 +01:00
Yu Watanabe bfd8f70cb8 network/varlink: pass file descriptor of state directory with SetPersistentStorage method
The state directory is owned by systemd-networkd-persistent-storage.service,
at least technically. Let's not directly access the storage through the path,
but through the fd.

Addresses https://github.com/systemd/systemd/pull/31746#issuecomment-1993556966.

Suggested-by: Mike Yuan <me@yhndnzj.com>
2024-03-19 15:15:32 +09:00
Yu Watanabe 7a89aeb138 network/address: acquire address from DHCP server lease file
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.
2024-03-18 22:33:14 +09:00
Yu Watanabe 7eafdbeb00 network/dhcp-server: use the pinned fd of persistent storge 2024-03-16 01:12:05 +09:00
Yu Watanabe e1254d0616 network/varlink: return earlier from SetPersistentStorage method if nothing changed 2024-03-16 01:12:05 +09:00
Yu Watanabe 013359ac65 network: pin file descriptor of persistent storage
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.
2024-03-16 01:12:05 +09:00
Luca Boccassi 681b1645b4 Merge pull request #31791 from yuwata/sd-dhcp-server-several-preparations
sd-dhcp-server: several cleanups and extension
2024-03-15 15:04:04 +00:00
Yu Watanabe dbf66cd1ab network/address: acquire address in address_process_request()
Previously, if an [Address] section is configured with a null address,
e.g. Address=0.0.0.0/24, then we acquired a free address in
link_request_address().

With this commit, we queue a request with the null address as is, and
acquire a free address later in address_process_request(). Similary,
now IPv4ACD daemon is configured in address_process_request().

With this change, we can make the address acquisition depend on other
conditions, e.g. if the persistent storage is ready or not.
2024-03-15 14:54:49 +00:00
Yu Watanabe 11b88419ae sd-dhcp-server: make sd_dhcp_server_set_lease_file() optionally take directory fd
Currently, though, no valid directory fd is passed to the function call.
Preparation for later commits.
2024-03-15 04:15:10 +09:00
Yu Watanabe 134fe8d274 network: introduce link_requeue_request() 2024-03-15 02:28:48 +09:00
Yu Watanabe c91f8f90ba network: use link_start_dhcp4_server() at one more place
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 5582b36c38.
2024-03-15 02:28:38 +09:00
Luca Boccassi 8e35076101 Merge pull request #31584 from yuwata/sd-ndisc-option-parser-cleanups
sd-ndisc: rewrite option parser
2024-03-13 23:06:50 +00:00
Yu Watanabe cac8e820d6 network/varlink: return StorageReadOnly error
Addresses https://github.com/systemd/systemd/pull/30021#discussion_r1521595855.
2024-03-13 21:49:12 +09:00
AKHIL KUMAR 8cbc701ded networkctl.c : call 'assert_not_reached' where appropriate
networkctl.c : call 'assert_not_reached' where appropriate
2024-03-13 21:46:05 +09:00
Mike Yuan 9c16c8a177 networkd-manager: drop spurious return
Follow-up for f90eb08627
2024-03-13 21:44:33 +09:00
Yu Watanabe 9ca04752cb sd-ndisc-router: adjust function names and type of returned value
- prefix length and preference should be fit in uint8_t, and actually
  the kernel and networkd uses uint8_t to store them.
- captive portal is now stored as a NUL-terminated string. Hence, it
  is not necessary to also provide its length.
2024-03-13 12:32:52 +09:00
Yu Watanabe 5582b36c38 network/dhcp-server: save leases in state directory
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.
2024-03-12 01:57:17 +09:00
Yu Watanabe b923ada838 sd-dhcp-server-lease: move functions to build json format
No functional change, just preparation for later commits.
2024-03-12 01:57:17 +09:00
Yu Watanabe 91676b6458 networkctl: introduce "persistent-storage" command
Then, this introduces systemd-networkd-persistent-storage.service.

systemd-networkd.service is an early starting service. So, at the time
it is started, the persistent storage for the service may not be ready,
and we cannot use StateDirectory=systemd/network in
systemd-networkd.service.

The newly added systemd-networkd-persistent-storage.service creates the
state directory for networkd, and notify systemd-networkd that the
directory is usable.
2024-03-12 01:57:16 +09:00
Yu Watanabe f90eb08627 network/varlink: introduce io.systemd.Network.SetPersistentStorage method
And make the networkd use state directory.

Currently, the state directory and the method are not used, but will be used later.
2024-03-12 01:57:11 +09:00
Zbigniew Jędrzejewski-Szmek ec596fe34e Merge pull request #30480 from keszybz/kernel-install-more-paths
Read kernel-install config from /run/kernel too
2024-03-08 08:25:07 +01:00
Zbigniew Jędrzejewski-Szmek 6378f257e7 various: use new config loader instead of config_parse_config_file()
This means the main config file is loaded also from /run and /usr.

We should load the main config file from all the places where we load drop-ins.

I realize I had a giant blind spot: I always assumed that we load config files
from /etc, /run, /usr/local/lib, /usr/lib. But it turns out that we only used
those paths for drop-ins. For the main config file, we only looked in /etc. The
docs actually partially described this behaviour, i.e. most SYNOPSIS sections
and some parts of the text, but not others.

This is strange, because 6495361c7d was completely
bogus with the behaviour before this patch. We had a huge discussion before it
was merged, and clearly nobody noticed this. Similarly, in the previous version
of the current pull request, we had a long discussion about the appropriate
order of directories, and apparently nobody noticed that there was no order,
because only looked in one directory. So the blind spot seems to have been
shared.

Also, systemd-analyze cat-config behaved incorrectly, i.e. its behaviour matches
the new behaviour.

Possibly, in the future it'll make it easier to add support for --root.
2024-03-07 19:14:36 +01:00
Zbigniew Jędrzejewski-Szmek e5abff372d shared/conf-parser: collapse pkgdir and conf_file args into one
This essentially reverts 5656cdfeea. I find it
much easier to understand what is going on when the
path-relative-to-the-search-path is passed in full, instead of being constructed
from two parts, with one of the parts being implicit in some places.

Also, we call 'systemd-analyze cat-config <path>' with <path> with the same
meaning, so this makes the internal and external APIs more consistent.
2024-03-07 18:49:44 +01:00
Mike Yuan 4f49512695 extract-word: modernize extract_many_words 2024-03-03 19:01:00 +08:00
Yu Watanabe d5e6df24bd Merge pull request #31498 from ssahani/bond
netdev: bond - add support for peer_notif_delay
2024-03-01 12:45:52 +09:00
Yu Watanabe 5a0f6adbb2 network/lldp: do not save LLDP neighbors under /run/systemd
Now LLDP neighbors are exposed through varlink. Hence, it is not
necessary to save to a file.
2024-03-01 09:40:26 +09:00
Yu WatanabeandTomáš Pecka 14a5c07afa networkctl: use varlink method to dump LLDP neighbors
`networkctl lldp` and `networkctl status INTERFACE` now use varlink
call to the networkd to query LLDP neighbors.

Then, this allows to dump LLDP neighbors in JSON format.

Co-authored-by: Tomáš Pecka <tomas.pecka@cesnet.cz>
2024-03-01 09:40:26 +09:00
Yu Watanabe 1dbd2cc72a networkctl: rename check_netns_match() -> varlink_connect_networkd()
Then optionally return the varlink connection to the caller.
2024-03-01 09:40:26 +09:00
Yu WatanabeandTomáš Pecka c48ca17aa8 network/varlink: add varlink method to get LLDP neighbors
The method provides the list of LLDP neighbors.

Co-authored-by: Tomáš Pecka <tomas.pecka@cesnet.cz>
2024-03-01 09:40:26 +09:00
Yu Watanabe 1e18e1aa11 Merge pull request #31492 from yuwata/icmp6-packet
sd-ndisc: introduce ICMP6Packet and relevant functions, and use them
2024-03-01 09:18:52 +09:00
Lennart Poettering 78266a54f1 tree-wide: use "_" rather than "-" as separator in kernel cmdline options
Most of our kernel cmdline options use underscores as word separators in
kernel cmdline options, but there were some exceptions. Let's fix those,
and also use underscores.

Since our /proc/cmdline parsers don't distinguish between the two
characters anyway this should not break anything, but makes sure our own
codebase (and in particular docs and log messages) are internally
consistent.
2024-02-28 15:33:51 +01:00
Susant Sahani 00386d5b3f netdev: bond - add support for peer_notif_delay
Specify the delay, in milliseconds, between each peer
notification (gratuitous ARP and unsolicited IPv6
Neighbor Advertisement) when they are issued after
a failover event. This delay should be a multiple of
the MII link monitor interval (miimon).

 The valid range is 0 - 300s. The default value is 0,
which means to match the value of the MII link monitor interval.
2024-02-28 17:31:02 +05:30
Yu Watanabe 39af486a7f network/ndisc: drop redundant sd_ndisc_router_get_icmp6_ratelimit()
This effectively reverts 9175002864.

The retrans time field in RA message is for neighbor solicitation,
and the commit d4c8de21a0 makes the value
assigned to the correct sysctl property.

Let's deprecate the option, and drop the redundant functions.
2024-02-28 11:05:00 +00:00
Yu Watanabe 25413fbfc7 sd-ndisc: ignore Router Advertisement messages sent by the same interface 2024-02-28 11:40:50 +09:00
Yu Watanabe 7036d472d0 network: fix use-after-free in {address,route}_remove_and_cancel()
Fixes #31485.
2024-02-26 11:02:13 +00:00
Yu Watanabe 52672db3f8 network/ndisc: rename Network.ipv6_accept_ra -> Network.ndisc
These settings are leated to sd-ndisc and Neighbor Discovery protocol.
Let's use more suitable name.
2024-02-26 11:38:57 +01:00
Yu Watanabe a569c2c5fd network/varlink: downgrade log level about failure in getting netns ID 2024-02-26 13:42:37 +09:00
Yu Watanabe 28eef15898 sd-ndisc: make callback takes arbitrary type of message
No functional change. Preparation for supporting Neighbor Advertisement
message.
2024-02-25 11:38:58 +00:00
Yu Watanabe c75d119658 network/ndisc: drop all configurations without lifetime on stop
As we call ndisc_drop_outdated() with USEC_INFINITY on stop.
2024-02-25 11:38:08 +00:00
Yu Watanabe f2e5a28bdd network: use FOREACH_STRING() 2024-02-24 21:04:14 +09:00
Lennart Poettering db7136ec73 signal-util: imply sentinel -1 in sigprocmask_many() + sigset_add_many() args list 2024-02-23 09:35:12 -08:00
Yu Watanabe 3976c43092 network: introduce per-interface IP forwarding settings
This deprecates IPForward= setting, which unconditionally controled
the global setting, even though it is a setting in .network file.

Instead, this introduces new IPv4Forwarding= and IPv6Forwarding=
settings both in .network and networkd.conf.
If these settings are specified in a .network file, then the
per-interface forwarding setting will be configured.
If specified in networkd.conf, then the global IP forwarding setting will
be configured.

Closes #30648.
2024-02-22 19:24:12 +00:00
Susant Sahani 9adafeddac netdev/macvlan: allow to set the broadcast queueing threshold
Allow to set the broadcast queueing threshold
on macvlan devices. This controls which multicast packets will be
processed in a workqueue instead of inline.
2024-02-22 09:36:19 +09:00
Yu Watanabe 6e2343c714 network/json: use DUID obtained by sd_dhcp6_client_get_duid()
Follow-up for e5aa8c193d.
2024-02-22 05:58:59 +09:00