summaryrefslogtreecommitdiff
path: root/src/network
Commit message (Collapse)AuthorAgeFilesLines
* Merge pull request #24933 from keszybz/erradicate-strerrorLuca Boccassi2022-10-111-1/+1
|\ | | | | Erradicate strerror
| * tree-wide: drop () around the first argument of a ternary opZbigniew Jędrzejewski-Szmek2022-10-111-1/+1
| | | | | | | | https://github.com/systemd/systemd/pull/24933#discussion_r991242789
* | network: free timer event source for NDisc when link is freedYu Watanabe2022-10-071-2/+6
| | | | | | | | | | Though, it should be already freed already freed in link_stop_engines() -> ndisc_stop(). Just for safety.
* | network: drop unnecessary call of ndisc_vacuum()Yu Watanabe2022-10-073-25/+0
| | | | | | | | | | | | | | | | | | | | | | | | After the commit 773024685b37170395a11716f8e4ad99d3580455, DNS servers or domains are dropped when their lifefime become zero. Hence, it is not necessary to try to them when writing state file. Of course, because of the accuracy of the timer event source or priority of event sources, a possibility is introduced that a DNS server or domain with zero lifetime is stored in the state file. However, such entry will be dropped soon when the timer event source is triggered. Hence, that should not cause any real issues.
* | network: ndisc: do not accept too many DNS servers or domainsYu Watanabe2022-10-041-13/+16
| | | | | | | | | | If there exists multiple routers, then the previous logic may introduce too many DNS servers or domains.
* | network: ndisc: drop addresses and friends when RA with zero lifetime is ↵Yu Watanabe2022-10-043-24/+30
| | | | | | | | | | | | | | | | | | | | | | | | received Routers may send options with zero lifetime if previously announced information is outdated. Hence, if we receive such messages, then we need to drop relevant addresses or friends. See e.g. https://www.rfc-editor.org/rfc/rfc4861#section-12. Follow-up for 2ccada8dc4a3571468a335808fd6fe49b8c6c6dd.
* | network: make sec_to_usec() map 0sec -> 0usecYu Watanabe2022-10-041-4/+7
| | | | | | | | | | | | | | | | | | | | Zero lifetime in RA is special, and we should not assign possibly very short lifetime addresses or friends. This should not change anything at least now, preparation for later commits. Note, DHCPv4 and v6 code also uses it, but sd-dhcp-client and sd-dhcp6-client already filtered messages with zero lifetime. Hence, the change should not affect DHCP code.
* | network: ndisc: also introduce timer event source to drop outdated settingsYu Watanabe2022-10-044-1/+80
| | | | | | | | | | Otherwise, settings based on previously received RA messages will never removed without receiving a new RA message.
* | network: ndisc: drop outdated settings before processing RA messageYu Watanabe2022-10-041-12/+71
| | | | | | | | | | | | | | Otherwise, e.g. if a router is replaced, then the previously received settings may never dropped. Follow-up for 2ccada8dc4a3571468a335808fd6fe49b8c6c6dd.
* | network: ndisc: address_get() returns 0 on successYu Watanabe2022-10-041-1/+1
| | | | | | | | | | After the commit 3b6a3bdebfb555754fdc6ee507e3f6964de7b61c, address_get() does not return 1.
* | network: introduce {address,route}_remove_and_drop()Yu Watanabe2022-10-044-0/+29
| | | | | | | | Preparation for later commits.
* | network: ndisc: ignore prefix option with link-local prefixYu Watanabe2022-10-041-0/+8
| | | | | | | | See https://www.rfc-editor.org/rfc/rfc4861#section-4.6.2.
* | network: ndisc: read prefix earlierYu Watanabe2022-10-041-4/+6
|/ | | | No functional changes.
* network: fix use-after-freeYu Watanabe2022-10-031-0/+2
| | | | | | | | If the lifetime of the route is already expired, do not try to configure it. Fixes a use-after-free, as the Request object is already freed, thus, we cannot use Route or Link stored in Request object.
* network: don't forget old RAs when a new one arrivesThomas Hebb2022-10-039-130/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | IPv6 Neighbor Discovery lets us autoconfigure a link's IPv6 addresses, routes, DNS servers, and DNS search domains by listening for Router Advertisement (RA) packets broadcast by one or more routers on the link. Each RA can contain zero or more "options," each describing one piece of configuration (e.g. a single route). Currently, when we receive an RA from a router, we delete any addresses, routes, etc. that originated from that router's previous RAs unless they're also present as options in the new RA. That behavior is a violation of RFC 4861[1]. In Section 9, the RFC states that Senders MAY send a subset of options in different packets. ... Thus, a receiver MUST NOT associate any action with the absence of an option in a particular packet. This protocol specifies that receivers should only act on the expiration of timers and on the information that is received in the packets. Several other passages in the RFC reiterate this. Section 6.2.3: A router MAY choose not to include some or all options when sending unsolicited Router Advertisements. Section 6.3.4: Hosts accept the union of all received information; the receipt of a Router Advertisement MUST NOT invalidate all information received in a previous advertisement or from another source. At least one consumer router in production today, the Google Nest Wifi, often sends RAs that omit its global IPv6 prefix. When current versions of systemd-networkd receive those RAs, they immediately delete the interface's global IPv6 address, which breaks IPv6 connectivity. Fix the issue by removing the invalidation logic entirely. It's not needed at all, since we already invalidate addresses, routes, and DNS configuration when the interface goes down or their lifetimes expire. This fix does have the side effect of preventing changes to the .network file (e.g. denylisted prefixes, whether to add routes from RAs) from taking effect as soon as a new RA arrives. Instead, a full interface reconfiguration is needed. But triggering those changes on RA receipt was already rather arbitrary and out of the administrator's control, so I think this change is fine. commit 69203fba700e ("network: ndisc: remove old addresses and routes after at least one SLAAC address becomes ready") introduced this behavior. commit 50550722e3ba fixed it partially, by preventing one router's RAs from invalidating another router's configuration. [1] https://www.rfc-editor.org/rfc/rfc4861 Fixes: 69203fba700e ("network: ndisc: remove old addresses and routes after at least one SLAAC address becomes ready")
* Merge pull request #24805 from yuwata/sd-networkLennart Poettering2022-09-272-27/+16
|\ | | | | sd-network: several cleanups
| * sd-network: drop fallback valuesYu Watanabe2022-09-271-5/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This drops spurious lines in `networkctl status` for unmanaged interfaces. Before: ``` $ networkctl status --lines 0 lo ● 1: lo Link File: n/a Network File: n/a Type: loopback State: carrier (unmanaged) Online state: unknown HW Address: 00:00:00:00:00:00 MTU: 65536 QDisc: noqueue IPv6 Address Generation Mode: eui64 Queue Length (Tx/Rx): 1/1 Address: 127.0.0.1 ::1 Activation Policy: up Required For Online: yes ``` After: ``` $ networkctl status --lines 0 lo ● 1: lo Link File: n/a Network File: n/a State: carrier (unmanaged) Online state: unknown Type: loopback Hardware Address: 00:00:00:00:00:00 MTU: 65536 QDisc: noqueue IPv6 Address Generation Mode: eui64 Number of Queues (Tx/Rx): 1/1 Address: 127.0.0.1 ::1 ``` That is, the lines for Activation Policy and Required For Online are dropped.
| * networkctl: use table_add_string_line() at one more placeYu Watanabe2022-09-271-14/+7
| |
| * networkctl: handle all errors in sd_network_link_get_setup_state() as ↵Yu Watanabe2022-09-271-8/+4
| | | | | | | | | | | | "unmanaged" We have already ignored all errors in other fields.
* | Merge pull request #24757 from yuwata/sd-device-get-child-firstLennart Poettering2022-09-261-22/+9
|\ \ | |/ |/| sd-device: introduce sd_device_get_child_first() and _next()
| * network: use FOREACH_DEVICE_CHILD_WITH_SUFFIX() macroYu Watanabe2022-09-231-22/+8
| |
| * network: fix assertion triggered by passing wrong ifindexYu Watanabe2022-09-231-1/+2
| |
* | networkctl: re-order entries in status commandYu Watanabe2022-09-231-69/+71
| | | | | | | | Also fixes "Speed:" field, which may show empty value.
* | networkctl: use "-" for empty LLDP entriesYu Watanabe2022-09-231-5/+6
|/
* shared/format-table: use enum instead of Table.empty_stringZbigniew Jędrzejewski-Szmek2022-09-221-2/+1
| | | | | | | | | | | | All users were setting this to some static string (usually "-"), so let's simplify things by not doing strdup, but instead limiting callers to a fixed set of values. In preparation for the next commit, the function is renamed from "empty" to "replacement", because it'll be used for more than empty fields. I didn't do the whole string-table setup, because it's all used internally in one file and this way we can immediately assert if an invalid value is passed in. Some callers were (void)ing the error, others were ignoring it, and others propagating. It's nicer to remove the boilerplate.
* networkctl: use "-" for empty fieldsZbigniew Jędrzejewski-Szmek2022-09-211-1/+1
| | | | | This looks nicer. Some fields were already using "-" as fallback, e.g. Speed, so this makes things more consistent too.
* meson: add libatomic dependencyHeinrich Schuchardt2022-09-151-2/+2
| | | | | | | | | | | | | | | Building with GCC 12.2 and binutils 2.39 fails on riscv64 Ubuntu Kinetic with: FAILED: systemd-oomd /usr/bin/ld: systemd-oomd.p/src_oom_oomd-util.c.o: in function `oomd_cgroup_context_acquire': build/../src/oom/oomd-util.c:415: undefined reference to `__atomic_exchange_1' We have to link with -latomic. Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
* tree-wide: use ASSERT_PTR moreDavid Tardon2022-09-1360-346/+167
|
* tree-wide: Mark some constants as unsignedJan Janssen2022-08-302-3/+3
| | | | | All these are really unsigned and used as such. This silences some -Wformat-signedness warnings with gcc.
* tree-wide: Use correct format specifiersJan Janssen2022-08-307-13/+13
| | | | gcc will complain about all these with -Wformat-signedness.
* network: NetLabel integrationTopi Miettinen2022-08-2912-1/+219
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | New directive `NetLabel=` provides a method for integrating static and dynamic network configuration into Linux NetLabel subsystem rules, used by Linux Security Modules (LSMs) for network access control. The label, with suitable LSM rules, can be used to control connectivity of (for example) a service with peers in the local network. At least with SELinux, only the ingress can be controlled but not egress. The benefit of using this setting is that it may be possible to apply interface independent part of NetLabel configuration at very early stage of system boot sequence, at the time when the network interfaces are not available yet, with netlabelctl(8), and the per-interface configuration with systemd-networkd once the interfaces appear later. Currently this feature is only implemented for SELinux. The option expects a single NetLabel label. The label must conform to lexical restrictions of LSM labels. When an interface is configured with IP addresses, the addresses and subnetwork masks will be appended to the NetLabel Fallback Peer Labeling rules. They will be removed when the interface is deconfigured. Failures to manage the labels will be ignored. Example: ``` [DHCPv4] NetLabel=system_u:object_r:localnet_peer_t:s0 ``` With the above rules for interface `eth0`, when the interface is configured with an IPv4 address of 10.0.0.123/8, `systemd-networkd` performs the equivalent of `netlabelctl` operation ``` $ sudo netlabelctl unlbl add interface eth0 address:10.0.0.0/8 label:system_u:object_r:localnet_peer_t:s0 ``` Result: ``` $ sudo netlabelctl -p unlbl list ... interface: eth0 address: 10.0.0.0/8 label: "system_u:object_r:localnet_peer_t:s0" ... ```
* network: drop unused timestampYu Watanabe2022-08-283-12/+0
|
* network: introduce TCPCongestionControlAlgorithm=Yu Watanabe2022-08-263-0/+57
| | | | Closes #24432.
* network: drop an unused variableFrantisek Sumsal2022-08-201-3/+1
|
* Merge pull request #24356 from keszybz/sd-netlink-apiYu Watanabe2022-08-205-7/+7
|\ | | | | Small improvements to the sd-netlink api
| * sd-netlink: rename sd_netlink_message_request_dump to ↵Zbigniew Jędrzejewski-Szmek2022-08-195-7/+7
| | | | | | | | sd_netlink_message_set_request_dump
* | network: unref existing sd_ipv4acd object when not necessaryYu Watanabe2022-08-181-10/+24
| | | | | | | | | | | | On reconfiguring an interface, the new setting may not enable IPv4ACD for an existing address anymore. Hence, we need to unref it. Otherwise, newly requested addresses may never be ready for (re-)configuring.
* | network: update setting for IPv4ACD or IPv6DAD in existing Address objectsYu Watanabe2022-08-181-0/+1
| | | | | | | | | | Otherwise, if the setting is changed on reconfigure, the new setting is not applied to the existing addresses.
* | network: fix DHCPv4 address renewal with IPv4ACDYu Watanabe2022-08-186-44/+46
|/ | | | | | | | | | Previously, when a DHCP address is renewed and if the IPv4ACD for the address is enabled, the address will never drop the probing flag, thus the lifetime of the address will never be updated. This drops NETWORK_CONFIG_STATE_PROBING, and the IPv4ACD status is managed another bit, Address.acd_bound. And, the flag is updated only when the IPv4ACD announced the address or detects conflict.
* network/tuntap: save tun or tap file descriptor in fd storeYu Watanabe2022-08-167-15/+152
|
* network/tuntap: introduce KeepCarrier= settingYu Watanabe2022-08-163-0/+20
| | | | Closes #24267.
* network/tuntap: code cleanupsYu Watanabe2022-08-161-62/+39
| | | | | | | - merge unnecessarily split functions, - drop unnecessary initializations, - tighten variable scopes, - introduce TUNTAP() helper function.
* network/bridge: fix UseBPDU= and AllowPortToBeRoot=Yu Watanabe2022-08-141-2/+2
| | | | | | Fixes bugs caused by 7f9915f0de67f3a10a4b22810d119da65af8c84a. Fixes #24268.
* network: replace usage of sd_bus_call_method_async() to ↵williamsumendap2022-08-132-8/+5
| | | | bus_call_method_async() (#24290)
* config-parser: Add list of drop-in files as return argument of config_parse_manyRichard Phibel2022-08-122-2/+4
| | | | This will be used to save the list of drop-in files for each partition
* tree-wide: fix typoYu Watanabe2022-08-101-1/+1
|
* network/teql: wait for corresponding teql interface to be availableYu Watanabe2022-08-091-0/+16
|
* network/qdisc: introduce is_ready() in qdisc vtableYu Watanabe2022-08-092-3/+11
| | | | Preparation for next commit.
* tree-wide: use bus locator (#24252)gtwang012022-08-091-4/+3
| | | This modifies some sd_bus calls to equivalent bus calls.
* dhcp4: stop client before updating MAC addressYu Watanabe2022-08-061-2/+20
|