Commit Graph
463 Commits
Author SHA1 Message Date
Yu Watanabe 5984b92726 network: l2tp: refuse null address 2022-04-17 09:31:35 +09:00
Yu Watanabe 96d96ec4e7 network: tunnel: handle null address as "any"
Fixes oss-fuzz#44881 (https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=44881).

Fixes #23098.
2022-04-17 09:31:30 +09:00
Zbigniew Jędrzejewski-Szmek c3eaba2d3d Move path_simplify_and_warn() to new shared/parse-helpers.c
This is a high-level function, and it belongs in libsystemd-shared. This way we
don't end up linking a separate copy into various binaries. It would even end
up in libsystemd, where it is not needed. (Maybe it'd be removed in some
optimization phase, but it's better to not rely on that.)

$ grep -l -r -a 'path is not absolute%s' build/
build/libnss_systemd.so.2
build/pam_systemd_home.so
build/test-dlopen
build/src/basic/libbasic.a.p/path-util.c.o
build/src/basic/libbasic.a
build/src/shared/libsystemd-shared-249.so
build/test-bus-error
build/libnss_mymachines.so.2
build/pam_systemd.so
build/libnss_resolve.so.2
build/libnss_myhostname.so.2
build/libsystemd.so.0.32.0
build/libudev.so.1.7.2

$ grep -l -r -a 'path is not absolute%s' build/
build/src/shared/libsystemd-shared-251.a.p/parse-helpers.c.o
build/src/shared/libsystemd-shared-251.a
build/src/shared/libsystemd-shared-251.so

No functional change.
2022-04-07 18:25:55 +02:00
Yu Watanabe 61ec7beaf5 network: always log error in network_load_one() and netdev_load_one() 2022-04-05 02:02:42 +09:00
Lennart Poettering ba4e0427e9 time-util: assume CLOCK_BOOTTIME always exists
Let's raise our supported baseline a bit: CLOCK_BOOTTIME started to work
with timerfd in kernel 3.15 (i.e. back in 2014), let's require support
for it now.

This will raise our baseline only modestly from 3.13 → 3.15.
2022-03-28 16:55:41 +02:00
Yu Watanabe ec4954d934 network: rename netdev kind virtual-wlan -> wlan
The Kind= setting in [Match] section of .network files takes "wlan".
This makes the same setting in .netdev files matches the one in .network
files.
2022-03-28 23:53:12 +09:00
Yu Watanabe de010b0b2e strv: make iterator in STRV_FOREACH() declaread in the loop
This also avoids multiple evaluations in STRV_FOREACH_BACKWARDS()
2022-03-19 08:33:33 +09:00
Yu Watanabe 80a226b26b list: make LIST_FOREACH() and LIST_FOREACH_BACKWARDS() safer 2022-03-19 08:10:29 +09:00
Yu Watanabe 03677889f0 list: declare iterator of LIST_FOREACH() in the loop 2022-03-19 08:10:29 +09:00
Luca Boccassi 1bd29614ff Merge pull request #22631 from yuwata/network-redesign-request-queue
network: re-design request queue
2022-03-11 10:48:45 +00:00
Yu Watanabe 09d09207de network: re-design request queue
This makes Request object takes hash, compare, free, and process functions.

With this change, the logic in networkd-queue.c can be mostly
independent of the type of the request or the object (e.g. Address) assigned
to the request, and it becomes simpler.
2022-03-11 14:20:31 +09:00
Yu Watanabe 80d62d4f1a network: introduce request_call_netlink_async()
In most netlink handlers, we do the following,
1. decrease the message counter,
2. check the link state,
3. error handling,
4. update link state via e.g. link_check_ready().

The first two steps are mostly common, hence let's extract it.

Moreover, this is not only extracting the common logic, but provide a
strong advantage; `request_call_netlink_async()` assigns the relevant
Request object to the userdata of the netlink slot, and the request object
has full information about the message we sent. Hence, in the future,
netlink handler can print more detailed error message. E.g. when
an address is failed to configure, then currently we only show an
address is failed to configure, but with this commit, potentially we can
show which address is failed explicitly.

This does not change such error handling yet. But let's do that later.
2022-03-11 14:20:31 +09:00
Yu Watanabe ff51134c93 network: make request_process_address() and friends take Link and corresponding object
This also renames e.g. request_process_address() -> address_process_request().

Also, this drops type checks such as `assert(req->type == REQUEST_TYPE_ADDRESS)`,
as in the later commits, the function of processing request, e.g.
`address_process_request()`, will be assigned to the Request object when
it is created. And the request type will be used to distinguish and to
avoid deduplicating requests which do not have any assigned objects,
like REQUEST_TYPE_DHCP4_CLIENT. Hence, the type checks in process functions
are mostly not necessary and redundant.

This is mostly cleanups and preparation for later commits, and should
not change any behavior.
2022-03-11 14:16:41 +09:00
Yu Watanabe 54ff39f7ae network: make address_configure() and friends take Request object
This should not change any behavior.
Just a preparation for a later commit which introduces
request_call_netlink_async().
2022-03-11 10:40:59 +09:00
Yu Watanabe 3f87eaa5d8 conf-parser: merge config_parse_string() and config_parse_safe_string()
This also makes unsafe strings escaped when logged. Otherwise,
journalctl may not show the log message unless '--all' is specified.
2022-03-10 14:43:43 +09:00
Yu Watanabe 3d24b0ddd8 network: netdev: drop unused creation type NETDEV_CREATE_AFTER_CONFIGURED 2022-02-27 09:36:48 +09:00
Yu Watanabe 0c91c7a241 network: l2tp: change create type to independent
L2TP tunnel does not have underlying interface. Let's change its type to
independent.
2022-02-27 09:36:48 +09:00
Yu Watanabe 8b49ee2dcd network: l2tp: make Local= optionally take interface name 2022-02-27 09:36:48 +09:00
Yu Watanabe 97b2bc3506 network: netdev: drop NETDEV_CREATE_MASTER
As there is no deference between NETDEV_CREATE_MASTER and
NETDEV_CREATE_INDEPENDENT.
2022-02-26 15:01:50 +09:00
Yu Watanabe eae0d010f7 network: netdev: use netdev_is_stacked() at one more place 2022-02-26 15:01:50 +09:00
Yu Watanabe 490c00a369 network: netdev: make link_get_local_address() refuse non-ready links and addresses 2022-02-26 14:59:56 +09:00
Yu Watanabe b93ce59e51 network: drop unused flag and counter 2022-02-26 05:49:52 +09:00
Yu Watanabe b4d6ae63ba network: split netdev_create() into two 2022-02-26 05:49:52 +09:00
Yu Watanabe 9aa2585e2f network: assign corresponding NetDev object to Link 2022-02-26 05:49:52 +09:00
Yu Watanabe c2b19b8f70 network/netdev: drop unused argument 2022-02-26 05:49:52 +09:00
Yu Watanabe fef805b9fa network/netdev: do not assign value on failure 2022-02-26 05:49:52 +09:00
Yu Watanabe 047b9991a4 network: create stacked netdevs after the underlying link is activated
Otherwise, the activation policy for the netdevs are ignored.

Fixes #22593.
2022-02-24 08:37:26 +09:00
Yu Watanabe dedf2d0054 network: add support to create wlan virtual interface
Closes #18977.
2022-02-15 23:24:55 +09:00
Yu Watanabe 1d4312d5f9 network: netdev: add flag to skip kind check
It will be used in later commit.
2022-02-15 16:06:43 +09:00
Yu Watanabe 5d4a925af0 network: netdev: use request queue to create independent netdevs 2022-02-15 16:06:37 +09:00
Yu Watanabe efa7b8adde network: netdev: increment reference counter on request
Otherwise, it may be freed on reload.
2022-02-15 15:54:02 +09:00
Yu Watanabe d708bc6e4f network: netdev: make netdev_is_ready_to_create() return negative errno on fatal error 2022-02-15 15:54:02 +09:00
Yu Watanabe 709055dabb network: rename REQUEST_TYPE_STACKED_NETDEV -> REQUEST_TYPE_NETDEV_STACKED 2022-02-15 15:54:02 +09:00
Yu Watanabe 6eb35be8e0 network: bridge: fix endian of vlan protocol
Fixes #22469.
2022-02-10 17:47:17 +09:00
Luca Boccassi 0b0ad494a0 Merge pull request #22458 from poettering/parse-safe-string
some safety tweaks to conf-parser.[ch]
2022-02-09 16:59:14 +00:00
Lennart Poettering a99a85242c tree-wide: use config_parse_safe_string() at various places 2022-02-09 10:17:33 +01:00
Yu Watanabe 89346ac6f6 network: coding style fixes 2022-02-09 14:35:25 +09:00
Yu Watanabe 1ae308abb5 network: tunnel: support external mode
Closes #22352.
2022-02-03 11:12:01 +09:00
Yu Watanabe acd8abb7f9 network: tunnel: reorder setting ip6tnl attributes
Just for improving readability.
2022-02-03 11:10:15 +09:00
Yu Watanabe a07e07cd9c network: tunnel: reduce indentation in config_parse_encap_limit() 2022-02-03 11:10:15 +09:00
Yu Watanabe 59c8bef008 network: tunnel: reduce indentation in config_parse_ipv6_flowlabel() 2022-02-03 11:10:15 +09:00
Yu Watanabe 396dfe0a14 network: tunnel: use "data" field to assign result 2022-02-03 11:10:15 +09:00
Yu Watanabe fd11005951 network: xfrm: refuse zero interface ID
Since kernel 5.17-rc1, 5.16.3, and 5.15.17 (more specifically,
https://github.com/torvalds/linux/commit/8dce43919566f06e865f7e8949f5c10d8c2493f5)
the kernel refuses to create an xfrm interface with zero ID.
2022-02-01 13:15:11 +09:00
Yu Watanabe 307fe3cdf2 network: rename NetworkConfigSection -> ConfigSection
And move it and relevant functions to conf-parser.[ch].
2022-01-19 14:57:59 +09:00
Yu Watanabe e135559d80 network: wireguard: also accept negative boolean values to disable adding routes
RouteTable=off was introduced to provide consistency with wg-quick
command. This makes the RouteTable= settings accepts other negative
boolean values.
2022-01-16 19:25:28 +09:00
Yu Watanabe cfe1237f38 network: wireguard: do not add routes to AllowedIPs= by default
As setting such routes may break existing setups.

Closes #21964.
2022-01-16 19:18:23 +09:00
Zbigniew Jędrzejewski-Szmek f2b78e0e91 network: split out dhcp4_pd_create_6rd_tunnel_message(), simplify logging 2022-01-05 11:45:16 +01:00
Zbigniew Jędrzejewski-Szmek 51762897c6 network: adjust log message about MACsec associations 2022-01-05 11:45:11 +01:00
Zbigniew Jędrzejewski-Szmek 9e369704a8 network: simplify logging in macsec netdev code 2022-01-05 11:43:36 +01:00
Zbigniew Jędrzejewski-Szmek b471fc9456 network: simplify logging in l2tp_create_session() and l2tp_create_tunnel()
All the detailed logging is replaced by a simple "Failed to create netlink message",
which should be enough for the user in the unlikely case that this ever fails.
2022-01-05 11:43:36 +01:00