summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFelix Fietkau2023-12-19 21:32:56 +0000
committerFelix Fietkau2024-01-04 12:35:43 +0000
commit2703f740a23ecc8d5cd7a7ebc11a970c1364d215 (patch)
tree3efba28c7e5d4546b1d3708f05d2f876b4221607
parent2bbe49c36224efa2fd7379e259bb25b06aa520c0 (diff)
downloadnetifd-2703f740a23ecc8d5cd7a7ebc11a970c1364d215.tar.gz
Revert "system-linux: set pending to 0 on ifindex found or error for if_get_master"
This reverts commit 66a7652176a7580b55076a0975b77c2bfb5bf7ce. Users reported that netifd hangs after this commit. I suspect that the added optimization which sets data->pending to false early might be the cause. It might leave unprocessed netlink messages in the socket, which could mess up the next netlink call. Signed-off-by: Felix Fietkau <nbd@nbd.name>
-rw-r--r--system-linux.c20
1 files changed, 7 insertions, 13 deletions
diff --git a/system-linux.c b/system-linux.c
index e6160d5..f4dbc18 100644
--- a/system-linux.c
+++ b/system-linux.c
@@ -1719,7 +1719,7 @@ int system_vlandev_del(struct device *vlandev)
struct if_get_master_data {
int ifindex;
int master_ifindex;
- bool pending;
+ int pending;
};
static void if_get_master_dsa_linkinfo_attr(struct if_get_master_data *data,
@@ -1733,7 +1733,6 @@ static void if_get_master_dsa_linkinfo_attr(struct if_get_master_data *data,
continue;
data->master_ifindex = *(__u32 *)RTA_DATA(cur);
- return;
}
}
@@ -1748,7 +1747,7 @@ static void if_get_master_linkinfo_attr(struct if_get_master_data *data,
continue;
if (cur->rta_type == IFLA_INFO_KIND && strcmp("dsa", (char *)RTA_DATA(cur)))
- return;
+ break;
if (cur->rta_type == IFLA_INFO_DATA)
if_get_master_dsa_linkinfo_attr(data, cur);
@@ -1776,11 +1775,8 @@ static int cb_if_get_master_valid(struct nl_msg *msg, void *arg)
rem = nh->nlmsg_len - NLMSG_LENGTH(sizeof(*ifi));
while (RTA_OK(attr, rem)) {
- if (attr->rta_type == IFLA_LINKINFO) {
+ if (attr->rta_type == IFLA_LINKINFO)
if_get_master_linkinfo_attr(data, attr);
- data->pending = false;
- break;
- }
attr = RTA_NEXT(attr, rem);
}
@@ -1791,16 +1787,14 @@ static int cb_if_get_master_valid(struct nl_msg *msg, void *arg)
static int cb_if_get_master_ack(struct nl_msg *msg, void *arg)
{
struct if_get_master_data *data = (struct if_get_master_data *)arg;
- data->pending = false;
-
+ data->pending = 0;
return NL_STOP;
}
static int cb_if_get_master_error(struct sockaddr_nl *nla, struct nlmsgerr *err, void *arg)
{
struct if_get_master_data *data = (struct if_get_master_data *)arg;
- data->pending = false;
-
+ data->pending = 0;
return NL_STOP;
}
@@ -1815,7 +1809,7 @@ static int system_if_get_master_ifindex(struct device *dev)
struct if_get_master_data data = {
.ifindex = if_nametoindex(dev->ifname),
.master_ifindex = -1,
- .pending = true,
+ .pending = 1,
};
int ret = -1;
@@ -1838,7 +1832,7 @@ static int system_if_get_master_ifindex(struct device *dev)
if (ret < 0)
goto free;
- while (data.pending)
+ while (data.pending > 0)
nl_recvmsgs(sock_rtnl, cb);
if (data.master_ifindex >= 0)