Commit Graph
100 Commits
Author SHA1 Message Date
Zbigniew Jędrzejewski-Szmek f6c8c89ff7 networkd: downgrade error for non-system users/groups to a warning
This reverts (in spirit) "network/tuntap: deny from owning Tun/Tap interfaces",
commit 940441b44c.

Justification similar as in the previous commit. The check is only
partially connected to the intended purpose and breaks backwards compat
without a sufficient reason.

Alternative fix for #37279.
2026-02-11 11:24:37 +01:00
Daan De Meyer aec52c1e6e string-table: Introduce DECLARE_STRING_TABLE_LOOKUP() and friends
Let's introduce these for the following two reasons:
- Using them makes sure the parameter names match between declaration
  and definition (if both use the corresponding macros).
- They make sure developers can't forget the _const_ and _pure_
  attributes for the declarations.

This commit also includes some include sorting fixes
2026-01-02 04:05:45 +09:00
Daan De Meyer daff8ea8bb tree-wide: Introduce DECLARE_TRIVIAL_REF_UNREF_FUNC() and friends 2026-01-02 04:04:19 +09:00
Daan De Meyer 6a9f0641cd tree-wide: Fix declaration/definition parameter name mismatches 2025-11-26 19:02:31 +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 5d5eb76557 network: Remove circular header dependencies in network/netdev 2025-04-23 10:33:37 +02:00
Yu Watanabe 67bdb6bee0 network/netdev: remove support of netdevsim
netdevsim device creation by networkd was deprecated by
59a9ef1022 (v246), and it does not work
since kernel v5.2:
https://github.com/torvalds/linux/commit/e05b2d141fef22cfac1928cf0eb6890e5dae4216

Now our baseline for the kernel is v5.4. Let's completely kill the
feature.
2025-04-12 09:23:27 +09:00
Yu Watanabe f5b09f02ac network/netdev: fix typo
Follow-up for 540eb5f037.
2025-04-07 16:44:21 +09:00
Beniamino Galvani f7996e2a33 network: add support for HSR netdev
Add support for creating HSR/PRP interfaces. HSR (High-availability Seamless
Redundancy) and PRP (Parallel Redundancy Protocol) are two protocols that
provide seamless failover against failure of any single network component. They
are both implemented by the "hsr" kernel driver.
2025-04-05 05:23:53 +09:00
Yu Watanabe 422b7c857c network/netdev: do not try to update if not supported
Some netdevs cannot update there properties after created.
Let's skip requests in that case.
2024-11-14 10:17:19 +09:00
Yu Watanabe b8b0c1a065 network: update tunnel or vxlan interface if the local address is changed
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.
2024-10-31 18:41:44 +09:00
Yu Watanabe b3ae4e8622 network/netdev: replace old NetDev object with newer one on reload
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.
2024-10-31 05:30:40 +09:00
Yu Watanabe 933d88f756 network/netdev: move calls of netdev_attach() and netdev_request_to_create() to netdev_load()
No functional change, preparation for later commits.
2024-10-31 05:30:40 +09:00
Yu Watanabe 5251cb8254 network/netdev: do not try to update several parameters if the interface already exists (#34937)
split-out of #34909.
2024-10-31 04:04:33 +09:00
Yu Watanabe 17c5337f7b network/netdev: introduce netdev_can_set_mac/mtu() helper functions
Several netdevs cannot set IFLA_ADDRESS or IFLA_MTU attribute on update.
Currently, the vtable field is unused, as we do not support updating
existing netdevs. Preparation for later commits.
2024-10-31 01:06:25 +09:00
Yu Watanabe 173c9f639b network: drop no-op cleanup
- network_load() is always called with an empty OrderedHashmap, renamed the output
  parameter to 'ret'.
- When netdev_load() is called on startup, the hashmap is NULL. When it is
  called on reloading, the hashmap is not cleaned up.

Hence, then these cleanups are always no-op. Let's drop them.
2024-10-31 00:58:42 +09:00
Yu Watanabe 525c53a95a network: swap asterisk and space 2024-10-31 00:51:50 +09:00
Yu Watanabe c60cd572bd network/netdev: add attach(), detach(), set_ifindex(), and get_ifindex() to netdev vtable
Currently no vtable sets these functions, but will be used later.
2024-09-10 19:30:17 +09:00
Yu Watanabe 5dc20e1acd network/netdev: split out netdev_set_ifindex_internal() and _impl()
No functional change, just refactoring and preparation for later
commits.
2024-09-10 19:30:13 +09:00
Yu Watanabe bfacb8fe1d network/netdev: split out netdev_attach() and netdev_attach_name() from netdev_load_one()
No functional change, just refactoring and preparation for later
commits.
2024-09-10 19:29:05 +09:00
Yu Watanabe 0dc71b9584 network/netdev: use hashmap_remove_value() on detaching NetDev from manager
Then, it is not necessary to free NetDev.ifname when a conflicting
.netdev file is already loaded.

This also split out netdev_detach_name() and netdev_detach_impl().

No functional change, just refactoring.
2024-09-10 19:29:05 +09:00
Yu Watanabe 1788c34628 network/netdev: also check ifindex, iftype, and kind when assigning NetDev to Link
Even when a NetDev object with the same name found, its iftype or kind
may be different. For safety, let's also check them.
2024-09-10 16:38:06 +09:00
Mike Yuan 2cf9b1a0ee network: store netdev drop-in paths and dump into state file 2024-09-09 23:20:41 +02:00
Zbigniew Jędrzejewski-Szmek bfd5a0687f various: move const ptr indicator to return value 2024-06-19 16:28:28 +02:00
Zbigniew Jędrzejewski-Szmek 117843fe95 network: make DEFINE_NETDEV_CAST() assert on input and output
The macro used to return NULL if input was NULL or had the wrong type. Now
it asserts that input is nonnull and it has the expected type.

There are a few places where a missing or mismatched type was OK, but in a
majority of places, we would do both of the asserts. In various places we'd
only do one, but that was by ommission/mistake. So moving the asserts into the
macro allows us to save some lines.
2023-09-22 08:17:42 +02:00
Yu Watanabe af7a86b8a6 network/tuntap: save tun or tap file descriptor in fd store 2022-08-16 21:57:35 +09: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 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 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 3d24b0ddd8 network: netdev: drop unused creation type NETDEV_CREATE_AFTER_CONFIGURED 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 b4d6ae63ba network: split netdev_create() into two 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 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 562729d744 network/netdev: introduce .is_ready_to_create() entry in netdev vtable 2021-12-12 13:41:39 +09:00
Yu Watanabe b90d0f83b2 network/netdev: add support to create IPoIB subinterface 2021-12-04 15:06:58 +09:00
Yu Watanabe a8ee2b8e1f network/netdev: generate persistent MAC address when creating netdev interface
Preparation for later commits.
2021-12-04 15:05:32 +09:00
Yu Watanabe aaa5ca57ae network/netdev: make MACAddress= take 'none' to suppress generating persistent hardware address
This is mostly equivalent to .link file's MACAddressPolicy=none.
2021-11-28 12:04:55 +09:00
Yu Watanabe 007899f43e network/netdev: verify specified MAC address
Drop multicast bit and set local bit of the specified MAC address.

This also makes failure in generating persistent MAC address
non-critical.
2021-11-27 06:39:04 +09:00
Yu Watanabe 5e20e1e3e3 network/netdev: use "struct hw_addr_data" to store MAC address 2021-11-27 06:39:04 +09:00
Yu Watanabe 9f0cf80dd0 network/netdev: introduce .iftype to netdev vtable
And disable .generate_mac flag for non-ether interfaces.
2021-11-27 06:38:26 +09:00
Yu Watanabe bc945c2b42 network/netdev: sort netdev kinds 2021-11-09 16:00:49 +09:00
Yu Watanabe 7f0ed7d1c9 network/netdev: update comment 2021-11-09 16:00:49 +09:00
Yu Watanabe b14686ff3a network: adjust log messages, function names, etc. 2021-08-12 14:39:39 +09:00
Yu Watanabe 8f65304c5d network: use netdev_enter_failed() instead of netdev_drop() on error
Preparation for later commits to support reconfiguring netdevs.
2021-08-12 14:23:57 +09:00
Yu Watanabe 1187fc3375 network: use link_request_to_set_master() or friends 2021-06-08 06:39:48 +09:00
Yu Watanabe 71a754f70f network: introduce link_request_to_create_stacked_netdev()
This will be used in later commits.
2021-06-08 06:33:27 +09:00
Yu Watanabe 6064344894 network: make log_netdev_xxx_errno() refuse zero errno 2021-04-16 09:17:28 +09:00