Commit Graph
29 Commits
Author SHA1 Message Date
Yu Watanabe ed54648b47 network: route bound to a link requires the link is up
We checked if the link is up only when configuring (explicit) nexthop,
but we did not checked that when configuring route which has (implicit)
nexthop.

Let's move the checks from nexthop_is_ready_to_configure() to
gateway_is_ready(), which is called for both implicit and explict
nexthops.

Fixes #40106.
2026-03-09 11:46:14 +09:00
Yu Watanabe 93378148d4 tree-wide: normalize comment style 2025-12-15 08:50:13 +09:00
Daan De Meyer baa3fadfb7 network: Clean up includes
Split out of #37344.
2025-05-22 02:15:43 +09:00
Daan De Meyer 1cf40697e3 tree-wide: Sort includes
This was done by running a locally built clang-format with
https://github.com/llvm/llvm-project/pull/137617 and
https://github.com/llvm/llvm-project/pull/137840 applied on all .c
and .h files.
2025-04-30 09:30:51 +02:00
Yu Watanabe e75372958d missing_threads.h: threads.h exists since glibc-2.28 2025-03-04 02:24:49 +09:00
Mike Yuan 1e4e557262 tree-wide: replace FLAGS_SET(..., 1 << v) with BIT_SET(..., v) 2024-12-28 15:08:00 +01:00
Yu Watanabe ea684ccb6d network/route: use sysctl_read_ip_property_int() for reading route/max_size 2024-10-15 06:52:19 +09:00
Yu Watanabe 0c7bb54238 network: split out core logic route_type_is_reject()
Preparation for later change.
2024-08-05 09:15:15 +09:00
Yu Watanabe 56f91e2d0b network: make link_get_address() provide matching address with peer
As all callers do not care if the address has peer address.
This also drops prefixlen argument as it is always zero.

Fixes a bug introduced by 42f8b6a808.
Fixes #31950.
2024-07-31 05:36:14 +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 054b8c2817 network/route: also use RouteNextHop for managing gateway
No functional change, just refactoring.
2024-01-15 10:28:25 +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
Yu Watanabe e091ed4053 network/route: fix reachability check when peer address is specified
When an address with peer address is specified, the kernel by default
adds the prefix route for the peer address. When ManageForeignRoute=no
is set, then we also needs to check the prefix for the peer address.

Fixes #30403.
2023-12-10 14:01:33 +09:00
Yu WatanabeandSusant Sahani fc35a9f8d1 network/dhcp4: support IPv6 only mode (RFC 8925)
Co-authored-by: Susant Sahani <ssahani@gmail.com>
2023-10-11 21:42:13 +09:00
Luca Boccassi ef32125c65 Merge pull request #28387 from yuwata/network-route-table-name
network: cleanups for route table name
2023-07-14 22:57:31 +01:00
Yu Watanabe e8e91a81ee network: refuse to override predefined route table name 2023-07-15 02:56:25 +09:00
Yu Watanabe f4defbdc5d network: do not append table number in TableString field in json output
The json output already contains table number, hence, it is not
necessary to include number in the string.
2023-07-15 02:56:20 +09:00
Yu Watanabe dc32de3924 network: check lifetime of address and route before configure
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.
2023-07-14 10:01:20 +02:00
Cristian RodríguezandYu Watanabe 5545f336fd Include <threads.h> if possible to get thread_local definition
IN C23, thread_local is a reserved keyword and we shall therefore
do nothing to redefine it. glibc has it defined for older standard
version with the right conditions.

v2 by Yu Watanabe:
Move the definition to missing_threads.h like the way we define e.g.
missing syscalls or missing definitions, and include it by the users.

Co-authored-by: Yu Watanabe <watanabe.yu+github@gmail.com>
2023-03-06 10:04:39 +09:00
Zbigniew Jędrzejewski-Szmek 3ae6b3bf72 basic: rename util.h to logarithm.h
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.
2022-11-08 18:21:10 +01:00
Yu Watanabe 513bed294e network: allow 0 for table number
Fixes #25089.
2022-10-28 11:33:22 +09:00
David Tardon 995340074e tree-wide: use ASSERT_PTR more 2022-09-13 08:13:27 +02:00
Yu Watanabe 8b7615f9b9 network: introduce {manager,link}_address_is_reachable() 2022-02-27 09:36:48 +09:00
Yu Watanabe c45cbc2394 network: merge gateway_is_ready() and link_address_is_reachable()
As link_address_is_reachable() is used only by gateway_is_ready().
2022-02-27 09:36:48 +09:00
Yu Watanabe d2d602f4b4 network: refuse empty or numeric route table names 2021-12-09 09:06:41 +01:00
Yu Watanabe cf477495d6 network: route: handle null address with non-zero prefixlen correctly
Previously, even if a link has a route to e.g. ::/96, default gateway
via ::1.2.3.4 cannot be configured.
2021-12-06 19:16:17 +09:00
Zbigniew Jędrzejewski-Szmek 8a7da94082 networkd: replace a table with log2 fields by a list 2021-11-29 11:16:15 +01:00
Yu Watanabe 18b23bd493 network: introduce route_flags_to_string_alloc() 2021-11-14 14:41:37 +09:00
Yu Watanabe 344b3cff36 network: split networkd-route.[ch] 2021-11-14 14:41:37 +09:00