Commit Graph
1302 Commits
Author SHA1 Message Date
Khem Raj 2a0d07d6a0 networkd: Include linux/netdevice.h header
This header provides definitions for NET_NAME_UNKNOWN ånd NET_NAME_ENUM
Fixes build issue found with non-glibc systems

../git/src/network/networkd-link.c:1203:52: error: 'NET_NAME_UNKNOWN' undeclared (first use in this function)

Signed-off-by: Khem Raj <raj.khem@gmail.com>
2021-07-26 22:48:57 +01:00
Yu Watanabe 54d1fdb244 network: update interface name stored in various network engines 2021-07-14 00:40:47 +01:00
Yu Watanabe 176b8be10f network: check the received interface name is actually new
For some reasons I do not know, on interface renaming, kernel once send
netlink message with old interface name, and then send with new name.
If eth0 is renamed, and then new interface appears as eth0, then the
message with the old name 'eth0' makes the interface enters failed
state.

To ignore such invalid(?) rename event messages, let's confirm the
received interface name.

Fixes #20203.
2021-07-13 19:20:31 +09:00
Yu Watanabe 790736e42e network: fix log message 2021-07-02 20:59:32 +09:00
Yu Watanabe e2bacccd06 network: fix segfault in link_update_hardware_address()
This fixes a bug introduced by fe321d457c.

When we want to update a value (in the case of this commit, it is a hardware
address) which is used as a hashmap key, we need to do the following steps:
1. remove the old hashmap entry,
2. update the value,
3. create a new hashmap entry with the new value.
2021-07-01 16:24:07 +09:00
Yu Watanabe 76a86ffdbe network: ipv4acd: first probe address and then assign it
Previously, if IPv4 ACD is enabled on an address, then we first
assign the address, and start sd-ipv4acd daemon for the address.
This is not only RFC incompliant, but also the address is always
dropped, as the daemon always considers the address is conflicted.

This commit makes networkd first starts sd-ipv4acd daemon to probe
the address, and then the address is configured if no conflict is
detected.

Fixes #17235.
2021-07-01 00:49:03 +09:00
Yu Watanabe a1e35fca46 network: ipv4ll: refuse to configure IPv4LL address on interface where the length of the hardware address is not ETH_ALEN
Currently, sd-ipv4acd assumes hardware address is ETH_ALEN.
2021-07-01 00:49:02 +09:00
Yu Watanabe fe321d457c network: introduce link_get_by_hw_addr() 2021-07-01 00:49:02 +09:00
Yu Watanabe 6eab614db8 network: rename Manager::links -> Manager::links_by_index
This also renames link_get() -> link_get_by_index().
2021-07-01 00:49:02 +09:00
Yu Watanabe 7802194ac0 tree-wide: add missing whitespace at the end of comments 2021-06-15 14:09:29 +09:00
Yu Watanabe 9868493e17 Merge pull request #19913 from yuwata/network-fix-counter
network: add missing increment of Link::set_flags_messages
2021-06-15 10:51:24 +09:00
Yu Watanabe 2502e7befe Merge pull request #19905 from yuwata/network-set-mac-try-again
network: try to bring down interface before setting MAC address
2021-06-15 05:35:45 +09:00
Yu Watanabe 710fa1b3fb network: update wlan information when IFF_LOWER_UP flag is gained
Fixes the issue mentioned at
https://github.com/systemd/systemd/issues/19832#issuecomment-860269320.
2021-06-15 05:14:22 +09:00
Yu Watanabe 7f80fa12c2 network: add brief comment about reconfiguring interfaces
This also renames link_reconfigure_internal() -> link_reconfigure_impl().
2021-06-15 05:12:25 +09:00
Luca Boccassi feaf43158a Merge pull request #19894 from yuwata/network-fix-configure-without-carrier
network: always check dynamic address assignments before entering con…
2021-06-14 14:23:09 +01:00
Luca Boccassi 1340574cf7 Merge pull request #19866 from yuwata/sd-device-new-from-ifindex
sd-device: introduce sd_device_new_from_ifindex()
2021-06-14 14:21:17 +01:00
Yu Watanabe b5d0fd1e7f network: drop misleading debugging logs about MTU
This fixes the following spurious logs on enumerating links:
```
wlan0: Saved original MTU 1500 (min: 256, max: 2304)
wlan0: MTU is changed: 0 → 1500 (min: 256, max: 2304)
```
2021-06-14 14:19:02 +01:00
Yu Watanabe d05c332c8d network: try to bring down before setting MAC address
Most real network devices refuse to set MAC address when its operstate
is not down. So, setting MAC address once failed, then let's bring down
the interface and retry to set.

Closes #6696.
2021-06-14 20:42:54 +09:00
Yu Watanabe 4bcb862548 network: always check dynamic address assignments before entering configured state
Previously (v248 or earlier), even if no static address is configured,
the link did not enter configured state, as e.g. Link::static_addresses_configured
is false until the link gained its carrier.
But, after the commit 1187fc3375, the
situation was changed. Static addresses, routes, and etc are requested even
if the link does not have its carrier, and thus the link enters configured
state when no static address and etc are specified.

This makes the link does not enter configured state before it gains its
carrier when at least one of dynamic address assignment protocols (e.g.
DHCP) except for NDISC is enabled.

Note that, unfortunately, netplan always enables ConfigureWithoutCarrier=
for all virtual devices, e.g. bridge. See,
https://github.com/canonical/netplan/commit/978e20f902f6b92a46dc6e0050e2172e834e4617
So, we need to support e.g. the following strange config:
```
[Netowkr]
ConfigureWithoutCarrier=yes
DHCP=yes
```

Fixes #19855.
2021-06-12 08:51:16 +09:00
Yu Watanabe 0ac655a63b tree-wide: use sd_device_new_from_ifindex/ifname() 2021-06-12 03:19:08 +09:00
Yu Watanabe f929f18c59 network: use hw_addr_equal() or friends 2021-06-10 00:29:59 +09:00
Yu Watanabe ca2b7cd813 ether-addr-util: drop redundant "addr" from struct hw_addr_data
Also, this makes always specifiy "struct" for hw_addr_data.
2021-06-10 00:19:50 +09:00
Yu Watanabe baa95d2274 network: do not process requests which conditionalized with link flags while the flags are updating
E.g. nexthop requires IFF_UP flag, but the currently stored flag may be
outdated if we called link_down(). This makes such requests pending if
at least one of the flags are updating.
2021-06-09 04:59:23 +09:00
Yu Watanabe 712fd5d25a network: use request queue to handle always-up or -down activation policy 2021-06-09 04:59:23 +09:00
Yu Watanabe 68f5206349 network: use request queue to handle bound_to list 2021-06-09 04:59:23 +09:00
Yu Watanabe aa9117c0c4 network: handle bound_by list even if IgnoreCarrierLoss=yes 2021-06-09 04:59:23 +09:00
Yu Watanabe ad82f0c32b network: add brief comments about bound_to and bound_by list 2021-06-09 04:59:23 +09:00
Yu Watanabe 899b0e5eec network: apply activation policy only when it is once activated
Otherwise, e.g., if activation policy is always-up is set for bond
slave, then setting bond configuration may fail.
2021-06-09 04:59:23 +09:00
Yu Watanabe da4929eeb9 network: do not drop requests on carrier lost
On carrier lost, then all requests which require carrier will not be
processed. And they will be processed when the interface gained its
carrier again. So, it is not necessary to drop requests here.
2021-06-09 04:59:23 +09:00
Yu Watanabe 717ba5fc90 network: read the minimum and maximum MTU of the interface, and adjust requested MTU based on these values 2021-06-09 04:59:23 +09:00
Yu Watanabe 7558f9e717 network: use request queue to configure CAN interfaces
This also makes SR-IOV configurations are ignored for CAN interfaces,
as CAN interfaces seem not to support SR-IOV features.
2021-06-09 04:59:23 +09:00
Yu Watanabe a7f07cbe34 network: wait for all set-link requests are processed 2021-06-08 06:39:48 +09:00
Yu Watanabe 29836c166d network: drop trivial aliases of link_set_state() 2021-06-08 06:39:48 +09:00
Yu Watanabe 1187fc3375 network: use link_request_to_set_master() or friends 2021-06-08 06:39:48 +09:00
Yu Watanabe 112a0972a2 network: introduce link_request_to_activate()
The request will be processed after all setlink requests are processed.
The function will be used in later commits.
2021-06-08 06:39:48 +09:00
Yu Watanabe 0e397560cc network: it is not necessary to call RTM_GETLINK when carrier is gained 2021-06-08 06:39:48 +09:00
Yu Watanabe 5a1860f761 network: use link_call_getlink() where applicable 2021-06-08 06:39:48 +09:00
Yu Watanabe 79c6e11456 network: introduce link_call_getlink() 2021-06-08 06:39:48 +09:00
Yu Watanabe 0d411b7f8f network: split link_update() into small pieces 2021-06-08 06:39:26 +09:00
Yu Watanabe 852a391605 network: shorten code a bit, and reduce indentation 2021-06-08 06:35:49 +09:00
Yu Watanabe b156a95d4a network: update operational state or friends on reconfigure 2021-06-08 06:35:49 +09:00
Yu Watanabe 4b9a8c2b51 network: make link enter failed state when link_initialized() is failed 2021-06-08 06:35:49 +09:00
Yu Watanabe 0c9ee5d5e8 network: move functions
This changes no behavior. Preparation for later commits.
2021-06-08 06:35:49 +09:00
Yu Watanabe 813572853e network: introduce link_get_master() and use it where applicable 2021-06-08 06:35:49 +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 8e00e24cc9 network: use request queue to set IPv6LL address generation mode 2021-06-08 06:33:27 +09:00
Yu Watanabe cc4c8fb136 network: use request queue to set interface group 2021-06-08 06:33:27 +09:00
Yu Watanabe a8e5e27c9f network: use request queue to set MAC address 2021-06-08 06:33:27 +09:00
Yu Watanabe 93fabc10fa network: use request queue to set link flags 2021-06-08 06:33:27 +09:00
Yu Watanabe 0fa8ee6c77 network: use request queue to set MTU 2021-06-08 06:33:27 +09:00