Commit Graph
418 Commits
Author SHA1 Message Date
Yu Watanabe 134fe8d274 network: introduce link_requeue_request() 2024-03-15 02:28:48 +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 972f1d17ab network/ndisc: remove conflicting routes on configuring routes based on newly received RA
The linux kernel does not update several parameters, e.g. RTA_PREF.
Hence, when we configure routes based on a RA, we need to remove
existing conflicting routes.

Fixes #28426 and #28439.
2024-02-15 00:43:12 +09:00
Yu Watanabe 7027cdbd79 network/route: remove existing route if some property conflict with requested ones
Fixes #28853.
2024-02-15 00:43:12 +09:00
Yu Watanabe fe0acbf7e0 network: set 'removing' flag to remembered object
Previously, if address_remove() or friends called with a temporary
object, the removing flag is assigned to the temporary object, and is
not set to the remembered object. Hence, e.g.
route_is_ready_to_configure() wrongly judge a required address for a
route is (still) ready, hence networkd fails to configure the route.

Fixes #28009.
2024-02-07 10:25:19 +00:00
Yu Watanabe 6f09031e4d network/route: introduce reverse map for route with nexthop ID
It is not used in this commit, but will be used later.
Preparation for later commits.

This is the one for routes of 531c724682.
2024-01-25 16:43:44 +09:00
Yu Watanabe d529b12a01 network/route: drop Route object even if we fail to remove the route
If we could not remove a route, then previously the corresponding
Route object was never removed, as it was freed only when we receive
remove notification from the kernel. So, we might confused that the
route still exists and being removed, and might block reconfiguring
the route.

With this change, even if we fail to remove a route, the corresponding
Route object will be freed.

This is the one for routes of 56a995fe8e.
2024-01-25 16:43:44 +09:00
Yu Watanabe 74c301b9ee network/route: introduce ref/unref functions for Route object
Then, Route object can live if it is detached from the owner (Manager,
Network, or Wireguard object).

This is the one for routes of ebd9690647.
2024-01-25 16:43:44 +09:00
Yu Watanabe 3caed9ea08 network/route: introduce route_remove_and_cancel()
Then, replace route_remove_and_drop() with it.

If a route is requested, and the request is already called,
we may not received its reply and notification from the kernel, and
the corresponding Route object may not be remembered. Even in such
case, we need to remove the route, otherwise the route will come
later after the function called.

This is the version for route of f22b586a21.
2024-01-25 16:43:44 +09:00
Yu Watanabe 8d01e44c1f network/route: manage all routes by Manager object
Previously, a Route object is owned by a Link object corresponding to the
outgoing interface of the route, and a Route object that does not have
outgoing interface is owned by the Manager object.

However, there were several issues:
- if a route has a nexthop ID, then the corresponding nexthop may be
  changed to use another interface, hence the outgoing interface of the
  route may be changed.
- if a route requested with MultiPathRoute=, then the link who requests
  the route is different from the outgoing interface of the configured
  route. So, we need to find routes on other interfaces on reconfiguring
  or so.

By this change, the limit of the number of routes per-interface is
tentatively dropped. Let's re-introduce the limit later in a nicer way.
2024-01-24 21:52:33 +09:00
Yu Watanabe 1c62c4fe0b network/route: update MTU of IPv6 route even if the kernel returns -EEXIST 2024-01-20 22:17:26 +09:00
Yu Watanabe 10b08b6790 network/route-nexthop: drop unnecessary link arguments
These arguments are unused now.
2024-01-19 19:20:29 +09:00
Yu Watanabe 5a18697d61 network/route: convert route before requesting
Previously,
1. use the passed Route object as is when a route is requested,
2. when the route becomes ready to configure, convert the Route object
   if necessary, to resolve outgoing interface name, and split multipath
   routes, and save them to the associated interfaces,
3. configure the route with the passed Route object.

However, there are several inconsistencies with what kernel does:
- The kernel does not merge nor split IPv4 multipath routes. However, we
  unconditionally split multipath routes to manage.
- The kernel does not set gateway or so to a route if it has nexthop ID.

Fortunately, I do not find any issues caused by the inconsistencies. But
for safety, let's manage routes in a consistent way with the kernel.

This makes,
1. when a route is requested, split IPv6 multipath routes, but keep IPv4
   multipath routes as is, and queue (possibly multiple) requests for
   the route.
2. when the route becomes ready to configure, resolve nexthop and interface
   name, and requeue request if necessary.
3. configure the (possibly split) route.

By using the logic,
- Now we manage routes in a mostly consistent way with the kernel.
- We can drop ConvertedRoutes object.
- Hopefully the code becomes much simpler.
2024-01-19 19:20:29 +09:00
Yu Watanabe 3babbdf632 network/route: introduce route_get_request()
No functional change, just refactoring and preparation for later
commits.
2024-01-19 10:23:14 +09:00
Yu Watanabe 413ea20ab3 network/route-nexthop: introduce route_nexthops_copy()
This also introduce an extra argument for route_dup(), but it is
currently unused, will be used later.

No functional change, just preparation for later commits.
2024-01-19 10:21:55 +09:00
Luca Boccassi aa3ee22592 Merge pull request #30955 from yuwata/network-queue-request_detach
network/queue: cleanups for detaching request
2024-01-16 21:17:32 +00:00
Luca Boccassi eda07d7fcf Merge pull request #30949 from yuwata/network-route-cosmetic-cleanups
network/route: several cosmetic cleanups
2024-01-16 21:16:09 +00:00
Yu Watanabe 47420573a7 network/route: find/distinguish routes in the same way that the kernel uses
The kernel uses different logics to find or distinguish IPv4 and IPv6 routes.
Let's follow the same way that the kernel uses.
See comments in the code for more details.
2024-01-16 16:13:53 +00:00
Yu Watanabe b9b5096edb network/queue: detach request from the queue only when the request is actually queued
No effective functionality is changed in this commit.
Refactoring and preparation for later commits.
2024-01-16 23:25:32 +09:00
Yu Watanabe 3518ff4a42 network/route: introduce route_get_link() and use it in log_route_debug()
No functional change, just refactoring and preparation for later
commits.
2024-01-16 12:35:58 +00:00
Yu Watanabe 0a94e19c72 network/route: trivial cosmetic changes
- downgrade log level,
- add short comment for boolean argument.
2024-01-16 11:45:14 +09:00
Yu Watanabe 0013863972 network/route: reorder getters in manager_rtnl_process_route()
No functional change, just refactoring and preparation for later
commits.
2024-01-16 11:02:55 +09:00
Yu Watanabe 31b26dee4f network/route: reorder setter called in route_set_netlink_message()
Also, this renames 'req' -> 'm', and makes the function unconditionally
set route type and route metric, and override type later if necessary.

Should not change any effective behavior. Just refactoring.
2024-01-16 11:02:55 +09:00
Yu Watanabe 1bcd7cd0e7 network/route: relocate route_new() and friends
No functional change, preparation for later commits.
2024-01-16 11:02:55 +09:00
Yu Watanabe 13efe0ab11 network/route: do not read RTA_OIF twice
It is also read in route_nexthops_read_netlink_message(), and already
stored in the Route object. Let's use it.
2024-01-15 10:28:25 +09:00
Yu Watanabe 054b8c2817 network/route: also use RouteNextHop for managing gateway
No functional change, just refactoring.
2024-01-15 10:28:25 +09:00
Yu Watanabe fea879cd04 network/route-nexthop: introduce struct RouteNextHop and replace MultipathRoute with it
It is mostly equivalent to MultipathRoute. So, no functional change,
just refactoring and preparation for later commits.
2024-01-15 10:28:25 +09:00
Yu Watanabe a0ab69d062 network/route-nexthop: make multipath_route_get_link() take fallback link
No functional change, just refactoring.
2024-01-14 06:04:46 +09:00
Yu Watanabe c23f957eb1 network/route-nexthop: split out route_nexthops_is_ready_to_configure()
No effective functionality changed, just refactoring and preparation for
later commits.
2024-01-14 06:04:46 +09:00
Yu Watanabe f47d38c6fc network/route-nexthop: split out route_nexthops_to_string()
And reorder elements shown in the debugging log.
No effective functionality changed, just refactoring.
2024-01-14 06:04:46 +09:00
Yu Watanabe 54f9fba5e6 network/route-nexthop: split out netlink message handling for route nexthops
No functional change, just refactoring and preparation for later
commits.
2024-01-14 06:04:23 +09:00
Yu Watanabe 4db8ccbb59 wireguard: verify routes configured in .netdev file
Then, scope and friends are correctly adjusted, and the behavior should
be matched when the same route is configured in .network file.
2024-01-13 10:10:32 +09:00
Yu Watanabe 0db96961b4 network/route: split out route_section_verify_nexthops()
No effective functional change, just refactoring and preparation for
later commits.
2024-01-13 10:10:32 +09:00
Yu Watanabe b9f29e9f52 network/route: relocate route_type_is_reject() and friends
No functional change, preparation for later commits.
2024-01-13 10:10:32 +09:00
Luca Boccassi f60c964535 Merge pull request #30897 from yuwata/network-route-expiration
network: several cleanups for route expiration handling
2024-01-12 23:32:12 +00:00
Yu Watanabe 2c0b49baab network/route: update expiration timer only when we know the route exists 2024-01-12 09:46:09 +09:00
Yu Watanabe 14436bf523 network/route: save if the route expiration is managed by the kernel
Otherwise, our own expiration timer will be setup on updating a route.
See comment in link_request_route().
2024-01-12 09:46:09 +09:00
Yu Watanabe f86575ca06 network/route: unconditionally call route_setup_timer() for managed routes
For foreign routes, we do not set lifetime, as it is foreign.
So, this should not change any behavior. Preparation for later commits.
2024-01-12 09:46:09 +09:00
Yu Watanabe a5a0a4eb56 network/route: use specified error message
Previously, specified error message was not used.
2024-01-12 09:46:09 +09:00
Yu Watanabe 4444c2baf5 network/route: move two more conf parsers to networkd-route-nexthop.[ch]
Let's manage nexthop (gateway) handling in networkd-route-nexthop.[ch].
2024-01-12 09:44:03 +09:00
Yu Watanabe ebf4fa1e82 network/route-metric: manage uint32_t RTAX_XYZ attributes in the same way
Except for RTAX_CC_ALGO, all RTAX_XYZ attributes take uint32_t and
the kernel's default value is zero. So, let's unify handling of the
attributes.

This should not change any effective behavior. Just refactoring.
2024-01-07 14:04:00 +09:00
Yu Watanabe d32a520b09 network/route-metric: introduce RouteMetric
Then, split out route metric handling from networkd-route.c to
networkd-route-metric.c.

No functional change, just refactoring and preparation for later
commits.
2024-01-07 14:04:00 +09:00
Yu Watanabe df8767fc8d network/route: move several conf parsers to networkd-route-metric.c and networkd-route-nexthop.c
This also split config_parse_route_boolean() into two:
for GatewayOnline= and boolean route metrics.

No functional change, just refactoring and preparation for later commits.
2024-01-07 01:39:58 +09:00
Yu Watanabe f48e52bda8 network/route: rename n -> route in conf parsers 2024-01-07 01:39:58 +09:00
Yu Watanabe d2bec2426f network/route: do not invalidate [Route] section when an empty string is assigned to MultiPathRoute= 2024-01-07 01:39:58 +09:00
Yu Watanabe b87ffa9b5a network/route: use nexthop_is_ready() 2024-01-05 05:33:49 +09:00
Yu Watanabe 18c4c5d84f network/route: make the route section invalid when an invalid MTUBytes= is specified
We usually set the invalid flag for a section if a setting in the section has
an invalid value. Let's also do the same thing for MTUBytes= in [Route].
2024-01-04 23:18:28 +09:00
Yu Watanabe cb0a3b8c14 network/route: drop TTL propagate support for MPLS routes
This effectively reverts 9b88f20aba.

We do not support MPLS routes, only IPv4 or IPv6 routes are supported.
2024-01-03 08:41:53 +09:00
Yu Watanabe 1a4b0459f6 network/address: unconditionally check if address is ready
Previously, we checked if the address is ready only when it is an IPv6
address. But, IPv4 address never enter tentative state, hence the check
for an IPv4 address is effectively equivalent to the one for IPv6.
So, let's unify the check. This does not change any effective behavior.
2023-12-28 07:08:37 +09:00
Yu Watanabe fe3fcb9492 Merge pull request #30633 from mrc0mmand/cocci-shenanigans
coccinelle: rework how we run the Coccinelle transformations
2023-12-26 05:45:58 +09:00