summaryrefslogtreecommitdiffstats
path: root/src/network (follow)
Commit message (Collapse)AuthorAgeFilesLines
* network/netdev: enter ready state only when it is created by usYu Watanabe2024-11-141-18/+19
| | | | | | | | | | | | | | | | Follow-up for PR #34909. This fixes an issue that network interfaces cannot join a master netdev, like bond or bridge, when the corresponding .netdev is reloaded. With PR #34909, networkd supports reloading .netdev files. However, When a .netdev file is modified and reloaded, ifindex is copied from the old NetDev object to the new one. Thus, even if the interface is successfully updated, netdev_set_ifindex_impl() will return 0 and netdev_enter_ready() will never called. If the netdev is a kind of master netdev, then port interfaces cannot join the master netdev, as REQUEST_TYPE_SET_LINK_MASTER requires that the master netdev is in the ready state.
* network/netdev: do not update MAC address if netdev is already runningYu Watanabe2024-11-148-7/+74
| | | | | | | | | | | Follow-up for 17c5337f7b2993619d84acc2088b2ba1789e6477. Older kernels (older than v6.5) refuse RTM_NEWLINK messages with IFLA_ADDRESS attribute when the netdev already exists and is running, even if the MAC address is unchanged. So, let's not set IFLA_ADDRESS or IFLA_MTU if they are unchanged, and set the attributes only when we can update them.
* network/netdev: set interface name only when creating a new netdevYu Watanabe2024-11-141-3/+8
| | | | Otherwise, the kernel older than v6.2 will refuse the netlink message.
* network/ndisc: restore the original preference and priority before checking ↵Yu Watanabe2024-11-121-0/+9
| | | | | | | | | | if existing route can be updated Follow-up for 972f1d17ab461a51142a142609dd3ec50bae8440. This fixes the logic of removing unnecessary routes configured by the previously received RAs. Previously, we wrongly handled existing routes could be updated, and unexpected routes would be kept.
* network/ndisc: introduce ndisc_route_prepare() and ndisc_router_route_prepare()Yu Watanabe2024-11-121-16/+46
| | | | | | These applies common parameters to the route to be requested or removed. No functional change, just refactoring and preparation for later commits.
* network/ndisc: several cleanups for ndisc_remove_route()Yu Watanabe2024-11-121-10/+4
| | | | | | - drop unnecessary call of ndisc_set_route_priority() at the beginning, as it is called later in the loop below, - use RET_GATHER() and remove all possible routes even if failed.
* network/ndisc: introduce route_is_bound_to_link() helper function and use it ↵Yu Watanabe2024-11-123-4/+17
| | | | | | where applicable No functional change, and preparation for later commits.
* network/nexthop: also forget IPv4 nexthops when an interface went downYu Watanabe2024-11-113-0/+57
| | | | Similar to the previous commit, but for nexthop.
* network/route: forget IPv4 non-local routes when an interface went downYu Watanabe2024-11-113-0/+35
| | | | | | | When an interface went down, IPv4 non-local routes are removed by the kernel without any notifications. Let's forget the routes in that case. Fixes #35047.
* network/nexthop: forget dependent routes without trying to removeYu Watanabe2024-11-113-12/+16
| | | | | | When a nexthop is removed, routes depend on the removed nexthop are already removed. It is not necessary to remove them, as already commented. Let's forget them without trying to remove.
* network/nexthop: do not remove depending nexthops when a nexthop is removedYu Watanabe2024-11-111-13/+3
| | | | | Previously, when a nexthop is removed, depending nexthops were removed, but that's not necessary, as the kernel keeps them, at least with v6.11.
* network/route: update reference of the route from nexthopYu Watanabe2024-11-111-0/+2
| | | | | | Follow-up for 6f09031e4d04727cc72164fefcbc763e37556493. The function has been introduced by the commit, but it has never been used...
* network: make 'networkctl reconfigure' work safely even when ↵Yu Watanabe2024-11-117-57/+99
| | | | | | | | | | | | KeepConfiguration=dhcp or yes Previously, even if KeepConfiguration=dhcp or yes is specified in the new .network file, dynamic configurations like DHCP address and routes were dropped when 'networkctl reconfigure INTERFACE' is invoked. If the setting is specified, let's gracefully handle the dynamic configurations. Then, 'networkctl reconfigure' can be also used for an interface that has critical connections.
* network: drop static configs laterYu Watanabe2024-11-111-7/+0
| | | | | | | | | Follow-up for dd6d53a8dc58c5e6e310b09ba7f7a22600a87ba9. Unnecessary static configs will be anyway dropped later in link_configure() -> link_drop_unmanaged_config(). Hence, even if we are reconfiguring an interface cleanly, it is not necessary to drop static configs here.
* network/dhcp-pd: do not remove unreachable route when reconfiguring ↵Yu Watanabe2024-11-114-23/+62
| | | | | | | | | | | | non-upstream interface Unreachable routes are not owned by any interfaces, and its ifindex is zero. Previously, if a non-upstream interface is reconfigured, all routes including unreachable routes configured by the upstream interface are removed. This makes unreachable routes are always handled by the upstream interface, and only removed when the delegated prefixes are changed or lost.
* network: reorder dropping dynamic configurationYu Watanabe2024-11-111-2/+2
| | | | Follow-up for 451c2baf30f50b95d73e648058c7c2348dbf0c31.
* network: reset 'configured' flags even if we keep DHCP lease and friends on ↵Yu Watanabe2024-11-111-0/+9
| | | | | | | | | | | | | | | | | reconfigure Follow-up for 451c2baf30f50b95d73e648058c7c2348dbf0c31. With the commits, reloading .network files does not release previously acquired DHCP lease and friends if possible. If previously a DHCP client was configured as not requesting DNS servers or so, then the previously acquired lease might not contain any DNS servers. In that case, if the new .network file enables UseDNS=, then the interface should enter the configured state after a new lease is acquired. To achieve that, we need to reset the flags. With this change, the workaround applied to the test by the commit 451c2baf30f50b95d73e648058c7c2348dbf0c31 can be dropped.
* network: drop unnecessary size specifierYu Watanabe2024-11-111-1/+1
| | | | It does not save any memory usage but increase code complexity.
* netwrok: call link_drop_unmanaged_config() earlier in link_configure()Yu Watanabe2024-11-111-4/+4
| | | | | | | | | Otherwise, even if a link enters the configuring state at the beginning of link_configure(), link_check_ready() may be called before link_drop_unmanaged_config() is called, and the link may enter the configured state. Fixes #35092.
* networkd: add possibility to specify MulticastIGMPVersionMichele Dionisio2024-11-065-0/+44
|
* network: reconfigure interface more gracefully (#35035)Yu Watanabe2024-11-0627-395/+507
|\ | | | | split-out of #34989.
| * network: introduce LINK_RECONFIGURE_CLEANLY flagYu Watanabe2024-11-053-3/+4
| | | | | | | | | | | | And use it when explicit reconfiguration is requested by Reconfigure() DBus method or networkd certainly detects that connected network is changed. Otherwise do not use the flag especially when we come back from sleep mode.
| * network: keep dynamic configurations as possible as we can on reconfigureYu Watanabe2024-11-0513-42/+275
| | | | | | | | | | | | | | | | | | | | E.g. when a .network file is updated, but DHCP setting is unchanged, it is not necessary to drop acquired DHCP lease. So, let's not stop DHCP client and friends in link_reconfigure_impl(), but stop them later when we know they are not necessary anymore. Still DHCP clients and friends are stopped and leases are dropped when the explicit reconfiguration is requested
| * network: merge link_foreignize_config() and link_drop_foreign_config()Yu Watanabe2024-11-0511-221/+115
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When a reconfiguration of an interface is triggered, previously we call link_foreignize_config(), which sets all static configurations as foreign, then later call link_drop_foreign_config(), which drops unnecessary foreign configurations. This commit merges these two steps into one, link_drop_unmanaged_config(), which drops unnecessary static and foreign configurations. Also, this renames link_drop_managed_configs() to link_drop_static_config(), as it only drops static configurations. Note that dynamically aquired configurations are dropped by link_stop_engines().
| * network: several cleanups for link_reconfigure()Yu Watanabe2024-11-055-111/+81
| | | | | | | | | | | | | | | | | | | | | | | | Effectively no functional changes, just refactoring and preparation for later changes. - convert boolean flag 'force' to LinkReconfigurationFlag enum, - merge link_reconfigure() and reconfigure_handler_on_bus_method_reload() as link_reconfigure_full(), - Rename ReconfigureData -> LinkReconfigurationData, - make Reconfigure() DBus message wait for reconfiguration being started before sending reply.
| * network: split out link_enter_unmanaged() from link_reconfigure_impl()Yu Watanabe2024-11-051-29/+43
| | | | | | | | No functional change, just refactoring.
* | mount-util: introduce path_is_network_fs_harder() and use it in networkd ↵Zbigniew Jędrzejewski-Szmek2024-11-061-4/+6
|\ \ | | | | | | | | | | | | (#35040) Closes #32426.
| * | network: use path_is_network_fs_harder()Yu Watanabe2024-11-051-4/+6
| | | | | | | | | | | | Closes #32426.
* | | network: handle ENODATA better with DNRRonan Pigott2024-11-052-38/+38
|/ / | | | | | | | | | | | | | | It is normal for DHCP leases not to have DNR options. We need to be less verbose and more forgiving in these cases. Also, if either DHCP does not have DNR options, make sure to still consider any DHCPv6/RA options. Fixes: c7c9e3c7c016 (network: adjust log message about DNR)
* / tree-wide: time-out → timeoutZbigniew Jędrzejewski-Szmek2024-11-051-1/+1
|/ | | | For justification, see 3f9a0a522f2029e9295ea5e9984259022be88413.
* network: limit the total number of Encrypted DNS options processedRonan Pigott2024-11-051-0/+6
| | | | | | | We need a sensible limit on the number of Encrypted DNS options allowed so that the set of resolvers per link does not grow without bound. Fixes: 0c90d1d2f243 ("ndisc: Parse RFC9463 encrypted DNS (DNR) option")
* network/dhcp4: keep DHCP address and routes on stop even when SendDecline=yesYu Watanabe2024-11-041-5/+5
| | | | | KeepConfiguration=dhcp or dhcp-on-stop already violate RFC. It is not necessary to honor the RFC about sending decline message on stop.
* network: expose log_route_debug() and log_address_debug()Yu Watanabe2024-11-044-2/+6
| | | | They will be used in another file in a later commit.
* network: add more debugging logsYu Watanabe2024-11-042-8/+21
| | | | | This also fixes the position of the logging "Enumeration completed.", and downgrade its log level.
* network: check if interface is initialized after enumeration completedYu Watanabe2024-11-043-1/+22
| | | | | | | | We enumerate interfaces at first, then enumerate other configurations like addresses and so on. If we are running on a container, previously we started to configure the enumerated interfaces before enumerating other configurations. Let's configure interfaces after all configurations are enumerated.
* network: check earlier if we are running in test modeYu Watanabe2024-11-041-13/+20
|
* network: introduce network_config_source_from_string()Yu Watanabe2024-11-042-1/+2
| | | | | It is currently unused, but will be used later. Preparation for later commits.
* network/json: add missing entries for route propertiesYu Watanabe2024-11-041-0/+2
|
* network: remove unexpected netlink socket from service managerYu Watanabe2024-11-041-2/+2
|
* network/address: slightly optimize link_address_is_dynamic()Yu Watanabe2024-11-041-1/+5
|
* network: realign string tableYu Watanabe2024-11-041-5/+5
|
* json: add json_dispatch_ifindex() helper (#34982)Lennart Poettering2024-11-042-6/+6
|\ | | | | Inspired by: #34640
| * tree-wide: port things over to new json_dispatch_ifindex()Lennart Poettering2024-11-042-6/+6
| |
* | network: refuse new requests on stop (#35004)Luca Boccassi2024-11-047-5/+28
|\ \ | | | | | | split-out of #34989..
| * | network: free DHCP client and friends in link_free()Yu Watanabe2024-11-033-5/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | No functional change, at least now. Preparation for later commits. But we are planning to extend KeepConfiguration= and also keep addresses and so on assigned by other dynamic configuration protocol like DHCPv6 or NDisc. However, when link_free_engines() is called here, acquired addresses so on by NDisc will be removed, even if link_stop_engines() handles restarting networkd or KeepConfiguration= gracefully. So, let's not free engines here, but free them later in link_free(). It is not necessary to be called here anyway.
| * | network: refuse further requests when manager is in MANAGER_STOPPEDYu Watanabe2024-11-034-0/+26
| |/ | | | | | | | | In that case, requests will never be processed anyway. But further more, we cannot call link_ref() at that stage. Otherwise, we trigger assertion.
* | network/ipv4ll: not necessary to set initial address on each startYu Watanabe2024-11-022-13/+16
| |
* | network/dhcp4: do not restart IPv4LL client when KeepConfiguration=dhcpYu Watanabe2024-11-021-5/+5
|/ | | | | When KeepConfiguration=dhcp, we do not remove acquired address, hence not necessary to restart IPv4LL client.
* network: update tunnel or vxlan interface if the local address is changedYu Watanabe2024-10-3110-2/+75
| | | | | | | If a tunnel or vxlan is configured with Local=dhcp4 or so, then the local address needs to be changed when it is changed. Fixes #24854.
* network/netdev: replace old NetDev object with newer one on reloadYu Watanabe2024-10-303-2/+80
| | | | | | | | | | | | | | | | | | | Then, when a .netdev file of a stacked netdev is modified, the netdev can be reconfigured with the updated setting by something like the following way: ``` ip link del vlan99 networkctl reload ``` Note, removing the vlan interface in the above example may not be necessary, e.g. when only VLAN flags, egress mapping, or ingress mapping are updated. But, it is necessary when VLAN ID is updated. Closes #9627. Closes #27177. Closes #34907. Replaces #22557.