summaryrefslogtreecommitdiffstats
path: root/src/network
diff options
context:
space:
mode:
authorYu Watanabe <watanabe.yu+github@gmail.com>2022-05-13 13:48:18 +0200
committerYu Watanabe <watanabe.yu+github@gmail.com>2022-08-05 14:49:27 +0200
commit4b482e8bf4763320d05aeb4b4e31b21b433b1123 (patch)
tree05b8ea4a86855c544b6e1f9cf7e3a7df28f69da8 /src/network
parentnetwork: drop carrier check for unmanaged interface from link_is_ready_to_con... (diff)
downloadsystemd-4b482e8bf4763320d05aeb4b4e31b21b433b1123.tar.xz
systemd-4b482e8bf4763320d05aeb4b4e31b21b433b1123.zip
network: check link state with link_is_ready_to_configure() before configuring DHCP client or friends
Otherwise, DHCP client or friends may started before link-layer properties, e.g. MAC address, being configured or the link being activated.
Diffstat (limited to 'src/network')
-rw-r--r--src/network/netdev/l2tp-tunnel.c4
-rw-r--r--src/network/netdev/netdev-util.c2
-rw-r--r--src/network/networkd-dhcp-server.c8
-rw-r--r--src/network/networkd-dhcp4.c2
-rw-r--r--src/network/networkd-dhcp6.c2
-rw-r--r--src/network/networkd-ndisc.c2
-rw-r--r--src/network/networkd-radv.c2
7 files changed, 8 insertions, 14 deletions
diff --git a/src/network/netdev/l2tp-tunnel.c b/src/network/netdev/l2tp-tunnel.c
index c38b9dc312..7e7d167928 100644
--- a/src/network/netdev/l2tp-tunnel.c
+++ b/src/network/netdev/l2tp-tunnel.c
@@ -292,7 +292,7 @@ static int l2tp_get_local_address(NetDev *netdev, union in_addr_union *ret) {
if (r < 0)
return r;
- if (!IN_SET(link->state, LINK_STATE_CONFIGURING, LINK_STATE_CONFIGURED))
+ if (!link_is_ready_to_configure(link, /* allow_unmanaged = */ false))
return -EBUSY;
}
@@ -346,7 +346,7 @@ static int l2tp_get_local_address(NetDev *netdev, union in_addr_union *ret) {
return link_get_l2tp_local_address(link, t, ret);
HASHMAP_FOREACH(link, netdev->manager->links_by_index) {
- if (!IN_SET(link->state, LINK_STATE_CONFIGURING, LINK_STATE_CONFIGURED))
+ if (!link_is_ready_to_configure(link, /* allow_unmanaged = */ false))
continue;
if (link_get_l2tp_local_address(link, t, ret) >= 0)
diff --git a/src/network/netdev/netdev-util.c b/src/network/netdev/netdev-util.c
index 06028855a8..23506246ce 100644
--- a/src/network/netdev/netdev-util.c
+++ b/src/network/netdev/netdev-util.c
@@ -51,7 +51,7 @@ int link_get_local_address(
assert_not_reached();
}
- if (!IN_SET(link->state, LINK_STATE_CONFIGURING, LINK_STATE_CONFIGURED))
+ if (!link_is_ready_to_configure(link, /* allow_unmanaged = */ false))
return -EBUSY;
SET_FOREACH(a, link->addresses) {
diff --git a/src/network/networkd-dhcp-server.c b/src/network/networkd-dhcp-server.c
index 5861ecb922..076779dc0e 100644
--- a/src/network/networkd-dhcp-server.c
+++ b/src/network/networkd-dhcp-server.c
@@ -539,13 +539,7 @@ static bool dhcp_server_is_ready_to_configure(Link *link) {
assert(link);
- if (!link->network)
- return false;
-
- if (!IN_SET(link->state, LINK_STATE_CONFIGURING, LINK_STATE_CONFIGURED))
- return false;
-
- if (link->set_flags_messages > 0)
+ if (!link_is_ready_to_configure(link, /* allow_unmanaged = */ false))
return false;
if (!link_has_carrier(link))
diff --git a/src/network/networkd-dhcp4.c b/src/network/networkd-dhcp4.c
index c6cbadc08b..3795fb32f3 100644
--- a/src/network/networkd-dhcp4.c
+++ b/src/network/networkd-dhcp4.c
@@ -1557,7 +1557,7 @@ static int dhcp4_process_request(Request *req, Link *link, void *userdata) {
assert(link);
- if (!IN_SET(link->state, LINK_STATE_CONFIGURING, LINK_STATE_CONFIGURED))
+ if (!link_is_ready_to_configure(link, /* allow_unmanaged = */ false))
return 0;
r = dhcp4_configure_duid(link);
diff --git a/src/network/networkd-dhcp6.c b/src/network/networkd-dhcp6.c
index 7f9f4e12b9..4293eb6242 100644
--- a/src/network/networkd-dhcp6.c
+++ b/src/network/networkd-dhcp6.c
@@ -741,7 +741,7 @@ static int dhcp6_process_request(Request *req, Link *link, void *userdata) {
assert(link);
- if (!IN_SET(link->state, LINK_STATE_CONFIGURING, LINK_STATE_CONFIGURED))
+ if (!link_is_ready_to_configure(link, /* allow_unmanaged = */ false))
return 0;
r = dhcp_configure_duid(link, link_get_dhcp6_duid(link));
diff --git a/src/network/networkd-ndisc.c b/src/network/networkd-ndisc.c
index dfbb7043bf..579282136f 100644
--- a/src/network/networkd-ndisc.c
+++ b/src/network/networkd-ndisc.c
@@ -1099,7 +1099,7 @@ static int ndisc_process_request(Request *req, Link *link, void *userdata) {
assert(link);
- if (!IN_SET(link->state, LINK_STATE_CONFIGURING, LINK_STATE_CONFIGURED))
+ if (!link_is_ready_to_configure(link, /* allow_unmanaged = */ false))
return 0;
r = ndisc_configure(link);
diff --git a/src/network/networkd-radv.c b/src/network/networkd-radv.c
index c59ae82694..a0ce162532 100644
--- a/src/network/networkd-radv.c
+++ b/src/network/networkd-radv.c
@@ -549,7 +549,7 @@ static int radv_is_ready_to_configure(Link *link) {
assert(link);
assert(link->network);
- if (!IN_SET(link->state, LINK_STATE_CONFIGURING, LINK_STATE_CONFIGURED))
+ if (!link_is_ready_to_configure(link, /* allow_unmanaged = */ false))
return false;
if (in6_addr_is_null(&link->ipv6ll_address))