Commit Graph
5902 Commits
Author SHA1 Message Date
Yu Watanabe bc45d9c959 network/routing-policy-rule: fix compare func
Previously, when comparing an existing and requested routing policy
rules, `all` flag was unset, thus the from and to addresses in the two
rules were not compared. Hence, a new request with from and/or to
addresses might be considered as it already exists even the addresses of
existing one were different from the newly requested one.

All existing rules have valid family, i.e. AF_INET or AF_INET6. And,
all requesting rules with from and/or to addresses also have a valid
family. Hence, even `all` flag is unset, the addresses can be and must
be compared in that case.

Fixes a regression caused by fc58350aa4 (v257).
Fixes #35874.
2025-02-05 09:14:54 +09:00
Yu Watanabe 5078e36632 network: allow to configure routing policy rule even if requesting interface is not activated yet
In the kernel, all routing policy rules are not assigned to any interface,
and we can configure them even if the relevant interface is down state.

Fixes a regression caused by 4f8b153d90 (v257).
Fixes #36244.
2025-02-04 12:28:30 +09:00
Nick Rosbrook 5dc89b327f tree-wide: remove some spurious newlines
Specifically, remove double newlines, and newlines before '}'.
2025-01-29 16:17:46 +00:00
Yu Watanabe d90c01d02c network: bridge: add support for configuring locked ports (#36150)
"Recently" (as of 5.18) the Linux kernel gained the ability of locking
bridge ports to restrict network access to authenticated hosts only.

This is implemented by disabling automated learning and dropping
incoming traffic from unknown hosts. User space is then expected to add
fdb entries for authenticated hosts. Once a fdb entry exist, traffic for
that host will be forwarded as expected.

This was later extended with "Mac Authentication Bypass", where the
locking was extended to fdb entries. In this mode the kernel adds fdb
entries again automatically, but they are locked by default.

To properly configure this, add two network options and one netdev
option:

* `LinkLocalLearning=` to prevent the kernel from creating unlocked
entries based on link-local traffic, which would bypass any
authentication. Needed when enabling learning on a locked port.
* `Locked=` to allow setting a bridge port to locked.
* `MACAuthenticationBypass=` to allow enabling Mac Authentication
 Bypass on a port. Requires learning to be enabled on the port as well
 (and consequently `LinkLocalLearning` disabled on the bridge).

An authenticator (e.g. hostapd) is still needed to do the actual
authentication, the kernel only provides the access control.
2025-01-29 04:16:20 +09:00
Nick Rosbrook 359db7e9b9 wait-online: add support for waiting for DNS configuration
Add a new flag to systemd-networkd-wait-online, --dns, to allow waiting
for DNS to be configured.

DNS is considered configured when at least one DNS server is accessible.
If a link has the property DefaultRoute=yes (either by explicit
configuration, or because there are no routing-only domains), or if the
search domain '.' is configured, wait for link-specific DNS to be
configured. Otherwise, global DNS servers may be considered.
2025-01-28 08:49:49 -05:00
Jonas Gorski 08a26ecc47 network: bridge: add support for IFLA_BRPORT_MAB
Since linux commit a35ec8e38cdd1766f29924ca391a01de20163931 ("bridge:
Add MAC Authentication Bypass (MAB) support"), included since v6.2, it
is possible to enable MAC Authentication Bypass for bridge ports. In
this mode the locked port learns again, but the learned fdb entries are
locked, allowing user space to unlock hosts based seen MAC addresses.

This requires learning to be enabled on the port, and link-local
learning disabled for the bridge.

Add support to systemd-network for setting the new attribute for bridge
ports.
2025-01-28 12:22:26 +01:00
Jonas Gorski a434de6056 network: bridge: add support for IFLA_BRPORT_LOCKED
Since linux commit a21d9a670d81103db7f788de1a4a4a6e4b891a0b ("net:
bridge: Add support for bridge port in locked mode"), included since
v5.18,  it is possible to set bridge ports to locked.

Locked ports do not learn automatically, and discard any traffic from
unknown source MACs. To allow traffic, the userspace authenticator is
expected to create fdb entries for authenticated hosts.

Add support to systemd-network for setting the new attribute for bridge
ports.
2025-01-28 10:38:01 +01:00
Jonas Gorski d7de242ce7 network: bridge: add support for NO_LL_LEARN
When using locked ports on a bridge link-local learning needs to be
disabled to prevent the kernel from learning and automatically unlocking
hosts based on link-local traffic.

So add support for enabling NO_LL_LEARN for bridges.
2025-01-28 10:38:01 +01:00
Yu Watanabe 7befabafad network/dhcp4: Gateway=_dhcp4 also assign DHCP address as preferred source
With the following, now preferred source address is set to the DHCP
address.
====
[Route]
Gatewa=_dhcp4
Table=100
====

Before:
====
$ ip route show table 100 default
default via 192.168.0.1 dev eth0 proto dhcp metric 1024
====

After:
====
$ ip route show table 100 default
default via 192.168.0.1 dev eth0 proto dhcp src 192.168.0.100 metric 1024
====

To avoid the assignment, this also introduces PreferredSource=no.
2025-01-27 08:38:24 +09:00
Yu Watanabe 863293dbd3 network/dhcp4: create prefix route and route to gateway in the specified table with Gateway=_dhcp4
Previously, the following setting
====
[Route]
Gateway=_dhcp4
Table=100
====
only configured the route in the specified table. But it was mostly
useless. This makes prefix route and route to the gateway are also
configured in the specified table.

Before:
====
$ ip route show table 100
default via 192.168.0.1 dev eth0 proto dhcp metric 1024
====

After:
====
$ ip route show table 100
default via 192.168.0.1 dev eth0 proto dhcp metric 1024
192.168.0.0/24 dev eth0 proto dhcp src 192.168.0.100 metric 1024
192.168.0.1 dev eth0 proto dhcp scope link src 192.168.0.100 metric 1024
====
2025-01-27 08:38:14 +09:00
Yu Watanabe c7adb64e12 network/dhcp4: rename link_prefixroute() -> prefixroute_by_kernel()
No functional change, just refactoring.
2025-01-27 06:58:09 +09:00
Yu Watanabe c9ee0d2eeb network/dhcp4: make dhcp4_request_route_to_gateway() take Route object
No functional change, preparation for later commits.
2025-01-27 06:29:26 +09:00
Yu Watanabe e92f40c6b0 network/route: adjust configuration source based on Gateway= setting
If Gateway=_dhcp4/_ra, the route will be anyway configured with
NETWORK_CONFIG_SOURCE_DHCP4/_NDISC. See dhcp4_request_route() and
ndisc_route_prepare().

This is mostly for avoiding link_drop_routes(), which drops unnecessary static
and/or foreign routes, unexpectedly filtering an existing route with the
route specified with Gateway=_dhcp4/_ra.
2025-01-27 06:29:26 +09:00
Yu Watanabe ba0266b376 network: fix offset of preference in backward compat option
Fixes a bug introduced by a10d6e0124.

Fixes oss-fuzz#391916479 (https://issues.oss-fuzz.com/issues/391916479).
Fixes #36172.
2025-01-26 11:09:04 +09:00
Yu Watanabe d7306348b2 tree-wide: insert a space at the end of comments 2025-01-25 05:24:23 +09:00
Yu Watanabe 04b7949ecf network: use hash ops with destructor 2025-01-23 18:22:47 +09:00
Yu Watanabe 12006a7233 wait-online: use hash ops with destructor 2025-01-23 18:19:28 +09:00
Yu Watanabe fe9753841f network/radv: add [IPv6RoutePrefix] Preference= setting 2025-01-22 20:48:31 +00:00
Yu Watanabe a10d6e0124 network/radv: modernize config_parse_router_preference() 2025-01-22 20:48:31 +00:00
Lennart Poettering 6d8582ecd6 udev: cleanups around sd_listen_fds() (#36030)
Fixes a bug introduced by 2f0aa9a804.

In the offending commit, `sd_varlink_server_listen_auto()` is used. That
may add file descriptors of netlink socket for uevent and legacy control
socket varlink server. Then, udevd may fail to receive uevents.
2025-01-20 18:06:56 +01:00
Yu Watanabe 901bfcd8c1 tree-wide: rely on sd_varlink_dispatch() for validating zero-argument method calls, too
Follow-ups for a7cc7038ac.
2025-01-20 00:21:31 +09:00
Yu Watanabe 848cdf56dc udev,network: drop unnecessary check for result of sd_listen_fds_with_names() 2025-01-19 23:54:41 +09:00
Lennart Poettering c8127075ae tree-wide: implement generic io.systemd.service Varlink interface in all long-running services
Given we have the generic interface, let's hook it up everywhere.

This doesnt bother with the Reload() call usually, since that's more
involved, but hooks up the other relevant functions where applicable.
2025-01-18 23:24:29 +01:00
Mike Yuan 70923ed358 meson: enable -Wzero-as-null-pointer-constant
Support for C added in gcc 15:
https://github.com/gcc-mirror/gcc/commit/236c0829ee21a179c81b83f0d7f112ca23c47a4d
2025-01-16 02:26:56 +01:00
Mike Yuan 347eb8fbe3 tree-wide: remove unnecessary gcc >= 7 version check
Our baseline is gcc 8.4.
2025-01-16 02:26:56 +01:00
Lennart Poettering 6f84873096 mountfsd,networkd,nsresourced: port over to new fd passing varlink server flags 2025-01-06 10:31:40 +01:00
Daan De Meyer 628a3fc287 network/dhcp: introduce global setting for DHCPv4 client identifier (#35783)
Typically, the same client identifier setting is used for all
interfaces. Hence, better to provide the system-wide setting to specify
the client identifier.
2025-01-03 09:19:55 +01:00
Yu Watanabe 7bbe9ad796 network: introduce system wide default setting for DHCPv4 client ID
Typically, the same client identifier setting is used for all
interfaces. Hence, better to provide the system-wide setting to specify
the client identifier.
2024-12-30 10:27:39 +09:00
Mike Yuan 1e4e557262 tree-wide: replace FLAGS_SET(..., 1 << v) with BIT_SET(..., v) 2024-12-28 15:08:00 +01:00
Mike Yuan cffae6e113 networkd-sysctl: tweak error handling and log level a bit
Follow-up for 6d9ef22acd

- Downgrade log level for bpf not installed or kernel version
  being too old to LOG_DEBUG. Otherwise, on kernels older than 6.12
  the log becomes quite annoying.
- Always propagate the error and ignore only on caller's side.
  The current style is a messy mix.
2024-12-18 16:38:54 +01:00
Mike Yuan 22583a002e networkd-sysctl: rename functions to match our typical prefixes 2024-12-18 16:36:24 +01:00
Lennart Poettering a87a9625f8 tree-wide: drop acquire_data_fd_full() helper
Let's drop support systems lacking memfds, i.e. pre kernel 3.17 systems.
This allows us to drastically simplify the "data fd" concept, so far
that we can remove it entirely.

This replaces acquire_data_fd() with a specialized call to
memfd_new_and_seal(), not that memfds can be the only implementation of
the concept.
2024-12-17 18:26:15 +01:00
Lennart Poettering 0543b02cf8 networkd: show wireguard private key read error number
Noticed while looking at #35641
2024-12-16 18:54:57 +00:00
Ronan Pigott e803e95760 network: don't warn with no NSID assigned
This is nothing interesting to warn about. Also use the symbolic
constant name when testing for this condition.
2024-12-15 09:09:26 +09:00
Yu Watanabe 10a768443a network: introduce MPLSRouting= to enable MPLS routing
Closing #35487.
2024-12-13 15:36:45 +00:00
Luca Boccassi fc35981fda network: several cleanups (#35267) 2024-12-12 12:47:23 +00:00
Yu Watanabe 2dfde4b8f8 network: optionally bring up interface before joining bridge
Closes #34247.
2024-12-11 11:23:48 +09:00
Yu Watanabe 2bb7fe554f network: introduce link_up_now()
This is currently not used. Preparation for later commit.
2024-12-11 11:23:48 +09:00
Yu Watanabe bfe63cb00c network: add missing template to networkd.conf 2024-12-11 11:21:15 +09:00
Yu Watanabe 246b0a4d26 network/nexthop: replace unreachable condition with assertion 2024-12-11 11:21:15 +09:00
Yu Watanabe d49312307e network/nexthop: fix argument name
Fixes copy-and-paste error in b5b42b516e.
2024-12-11 11:21:15 +09:00
Yu Watanabe a4feabd85d network: introduce address_forget() and friends and use it where applicable
No functional change, just refactoring.
2024-12-11 11:21:14 +09:00
Yu Watanabe 290a507f7c network/nexthop: ignore foreign nexthops when ManageForeignNextHops=no 2024-12-11 11:21:14 +09:00
Yu Watanabe 724a296b4f network/nexthop: drop outdated comment and add one debugging log
All NextHop objects are managed by Manager since
352eba2e49.
2024-12-11 11:21:14 +09:00
Yu Watanabe 96fef18ca6 network/ndisc: unref Route objects that depend on the nexthop
No functional change, as when this function is called, the set will be
freed and contained Route objects will be unref()ed anyway soon later
by nexthop_detach() -> nexthop_free().
Even though, when the routes are forgotten from the Manager, then it is
not necessary to keep them by the nexthop. Let's unref earlier.
2024-12-11 11:21:14 +09:00
Yu Watanabe 1168489cd4 network/ndisc: constify several arguments and add several assertions
Follow-up for 0f8afaf94d.

No functional change, just for safety.
2024-12-11 11:21:14 +09:00
Yu Watanabe b5f2d7a1ec network/nexthop: do not share NextHop.nexthops and NextHop.routes with duplicated object
Otherwise, these may be freed twice.
But, fortunately, when this function is called, both are NULL.
So, this should not change any behavior. But for safety.
2024-12-11 11:21:14 +09:00
Yu Watanabe 00b363bb81 network: drop outdated comment
All Route objects are managed by Manager since
8d01e44c1f.
2024-12-11 11:21:14 +09:00
Zbigniew Jędrzejewski-Szmek fd409ff0e0 various: set info on varlink server object
The values that were previously hardcoded in sd-varlink.c are now defined
in new varlink_set_info_systemd() and that function is called everywhere
where we create a server.
2024-12-10 10:51:56 +01:00
Yu Watanabe 1d96f18bd8 network/queue: do not increase reference counter when remove request is not queued
Fixes a bug introduced by ef45f5c8d0.
Fixes #35164.
2024-11-27 19:24:50 +00:00