summaryrefslogtreecommitdiffstats
path: root/src/network/networkd-address.c (follow)
Commit message (Collapse)AuthorAgeFilesLines
* network/address: rename address_kernel_{compare,hash}_func() -> ↵Yu Watanabe2023-07-311-18/+18
| | | | | | | address_{compare,hash}_func() Previously, we had two compare/hash functions. But we do not have one of them anymore. Let's rename them.
* network/address: drop unused functionsYu Watanabe2023-07-311-49/+0
|
* network/address: check if existing addresses can be updated in more detailYu Watanabe2023-07-311-11/+78
| | | | | | | Some properties of address can be updated, but some cannot. On reconfiguring an interface or restarting networkd, let's keep an assigned address only when it can be updated later with the requested setting, and otherwise drop it.
* network/address: always set IFA_ADDRESS attribute for IPv6 address on configureYu Watanabe2023-07-311-1/+1
| | | | | | | | | IPv6 address can update the peer address without removing the address. If an address have a peer, but now we want to drop the peer, we need to specify a null address in IFA_ADDRESS attribute. IPv4 address cannot update the peer address, so let's specify peer address only when necessary.
* network/address: make Label= accept an empty stringYu Watanabe2023-07-311-0/+6
| | | | We usually reset setting when an emptry string is specified.
* network/address: add missing space in log messageYu Watanabe2023-07-311-1/+1
|
* network/address: do not set configuring flag when a request is canceledYu Watanabe2023-07-311-1/+1
| | | | | Fixes copy-and-paste error. Follow-up for 0a0c2672dbd22dc85d660e5baa7e1bef701beb88.
* network/address: also save/update priority of prefix routeYu Watanabe2023-07-301-0/+4
| | | | | Strictly speaking, this is not necessary, but let's make the managed Address objects more consistent with the kernel's addresses.
* network/address: introduce address_get_harder() and use it where appropriateYu Watanabe2023-07-301-0/+20
| | | | | | 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: do not add Address object to Link on requestingYu Watanabe2023-07-301-70/+98
| | | | | | | | | Then, all addresses managed by a link really exist (unless the kernel silently removes addresses). By this change, now Address objects managed by Link and owned by Request are decoupled, and always requested settings will be applied. Fixes #25843.
* network/address: make Address object more consistent with assigned addressYu Watanabe2023-07-301-79/+67
| | | | | | | | | | | This makes `manager_rtnl_process_address()` - first read minimal information to get managed Address object, - then update the managed Address object directly. Previously, we updated the Address object managed by Link partially, e.g. peer address did not updated. This makes the managed Address object more consistent with the assigned address.
* Merge pull request #28575 from yuwata/network-address-next-part3Yu Watanabe2023-07-301-1/+53
|\ | | | | network: check specified address settings in more detail
| * network/address: ignore address settings with unsupported flagsYu Watanabe2023-07-301-0/+46
| |
| * network/address: drop IPv6 settings when the kernel does not support IPv6Yu Watanabe2023-07-301-1/+7
| |
* | Merge pull request #28572 from yuwata/network-ipv4acdYu Watanabe2023-07-301-6/+6
|\ \ | | | | | | network: split-out sd_ipv4acd object management from Address object
| * | network/ipv4acd: split out sd_ipv4acd management from Address to LinkYu Watanabe2023-07-301-6/+6
| |/ | | | | | | | | | | | | | | Then, we can start IPv4ACD without adding corresponding Address object to Link. Hopefully, no functional change, just refactoring and preparation for later commits.
* | network/address: merge address_needs_to_set_broadcast() with ↵Yu Watanabe2023-07-301-19/+33
| | | | | | | | | | | | address_get_broadcast() No functional change, preparation for later commits.
* | network/address: split-out address_match_null()Yu Watanabe2023-07-291-11/+22
| | | | | | | | No functional change, preparation for later commits.
* | network: drop unnecessary conditionsYu Watanabe2023-07-291-2/+2
| | | | | | | | When link_get_by_index() succeeds, the result is always non-NULL.
* | network/address: free Address object by caller that passed to ↵Yu Watanabe2023-07-291-9/+4
|/ | | | | | | | | 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().
* Merge pull request #28359 from keszybz/ret-gatherDaan De Meyer2023-07-281-10/+4
|\ | | | | Add RET_GATHER macro to make continue-but-remember-first-error functions easier
| * network: use RET_GATHERZbigniew Jędrzejewski-Szmek2023-07-131-10/+4
| | | | | | | | No functional change intended.
* | Merge pull request #28430 from keszybz/cleanupsLuca Boccassi2023-07-281-1/+1
|\ \ | | | | | | Various small cleanups
| * | network: warning message fixletZbigniew Jędrzejewski-Szmek2023-07-171-1/+1
| | | | | | | | | | | | | | | "Address 1.2.3.4" works as a proper noun, so the article is not appropriate.
* | | Revert "network: delay to configure address until it is removed on reconfigure"Yu Watanabe2023-07-231-3/+0
|/ / | | | | | | | | | | | | | | This reverts commit 6e8477edd3a988357ad5f5fa6610904d44ec402c. The commit intended to fix a race reported at #28009. However, unfortunately, it does not fix the root of the race, and reveals the race in more simple setups. See reports in #28358.
* / network: check lifetime of address and route before configureYu Watanabe2023-07-141-2/+10
|/ | | | | | | | Otherwise, we may configure a route that depends on the existence of an address or another route, and may fail when lifetime of one of them are already zero. Hopefully fixes #28358.
* network: make address_get() work for null addressYu Watanabe2023-07-071-13/+76
| | | | | | | | | | | | | | | When a static null address is requested, e.g. Address=0.0.0.0/24, then the corresponding Address object owned by Network object has null address, and previously it did not match any addresses already assigne to the interface. Let's search matching Address object when originally it is requested as the null address. Then, the address configured with requested as a null address will be kept on reconfigure. Fixes #26113.
* network: always copy input address for link_request_address()Yu Watanabe2023-07-071-52/+25
| | | | | | | Then, the code becomes much simpler. This also adds several missing log messages. No functional change, just refactoring.
* network: also use address_kernel_{hash,compare}_func() for managing address ↵Yu Watanabe2023-07-071-28/+8
| | | | | | | | requests Request may refer Address object owned by Link, but its broadcast address or label may be updated by address_equalify(), hence these fields cannot be used in the hash and compare functions.
* network: log broadcast address and address labelYu Watanabe2023-07-071-2/+8
|
* network: ignore Broadcast= setting when the address is nullYu Watanabe2023-07-071-0/+4
| | | | | | When an address is requested with null address, then broadcast should be determined after an address aquired that will be assigned to the interface.
* network: split-out address_section_adjust_broadcast()Yu Watanabe2023-07-071-10/+27
| | | | No functional change, just refactoring.
* network: delay to configure address until it is removed on reconfigureYu Watanabe2023-07-031-0/+3
| | | | | | | | | When we request an address that already exists and is under removing, we need to wait for the address being removed. Otherwise, configuration of a route whose preferred source is the address will fail. Fixes #28009. Replaces #28088.
* network: rewrite dynamic addressing protocol checkers in link_check_ready()Yu Watanabe2023-05-301-0/+23
| | | | | | | | Notable change is, - UseAddress=no in [DHCPv6], - Assign=no in [DHCPPrefixDelegation], and - UseAutonomousPrefix=no in [IPv6AcceptRA] are gracefully handled now.
* network: assume prefix length is full address sizeYu Watanabe2023-01-191-6/+5
| | | | | | | | | | | The commit 0f707207b9fc04d45ad176930cfefc77c0068545 enables strong warning about missing prefix length in Address= setting. The change was done in v241, and was about 4 years ago. Let's drop the legacy assumption and make the parser consistent with 'ip address' command. C.f. #11307. Closes #26102.
* network: fix memleakYu Watanabe2023-01-161-1/+5
| | | | | | Fixes a bug introduced by af2aea8bb64b0dc42ecbe5549216eb567681a803. Fixes #25883 and #25891.
* network: manage addresses in the way the kernel doesYu Watanabe2022-12-071-22/+71
| | | | | | | | | | | | | This effectively reverts 5d0030310c134a016321ad8cf0b4ede8b1800d84. With the commit 5d0030310c134a016321ad8cf0b4ede8b1800d84, networkd manages addresses with the detailed hash and compare functions. But that causes networkd cannot detect address update by the kernel or an external tool. See issue https://github.com/systemd/systemd/issues/481#issuecomment-1328132401. With this commit, networkd (again) manages addresses in the way that the kernel does. Hence, we can correctly detect address update.
* network: address: use ASSERT_PTR()Yu Watanabe2022-11-301-15/+5
|
* network: address: always update link state when an address is removedYu Watanabe2022-11-301-7/+2
| | | | The removed address might be in the tentative state.
* basic: rename util.h to logarithm.hZbigniew Jędrzejewski-Szmek2022-11-081-0/+1
| | | | | 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.
* network: ndisc: drop addresses and friends when RA with zero lifetime is ↵Yu Watanabe2022-10-031-2/+8
| | | | | | | | | | | | 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: introduce {address,route}_remove_and_drop()Yu Watanabe2022-10-031-0/+12
| | | | Preparation for later commits.
* network: don't forget old RAs when a new one arrivesThomas Hebb2022-10-031-5/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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")
* network: NetLabel integrationTopi Miettinen2022-08-291-0/+52
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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" ... ```
* Merge pull request #24356 from keszybz/sd-netlink-apiYu Watanabe2022-08-201-1/+1
|\ | | | | Small improvements to the sd-netlink api
| * sd-netlink: rename sd_netlink_message_request_dump to ↵Zbigniew Jędrzejewski-Szmek2022-08-191-1/+1
| | | | | | | | sd_netlink_message_set_request_dump
* | 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-181-4/+4
|/ | | | | | | | | | 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: make link_may_have_ipv6ll() optionally check Multicast= settingYu Watanabe2022-08-011-1/+1
| | | | Fixes the IPv6LL issue in #23197.
* network: refuse to configure address or route with 0 valid lifetimeYu Watanabe2022-07-141-7/+15
| | | | Fixes #23625.