Skip to content

Commit 9e6256e

Browse files
rluboscfriedt
authored andcommitted
net: iface: Prevent iface/TCP mutexes deadlock
In rare occasions iface and TCP mutexes could cause a deadlock. As notifying the interface readiness takes place just before the iface mutex is released, it should be not harm to release it just before the TCP is notified about interface going down to avoid the deadlock. Signed-off-by: Robert Lubos <[email protected]>
1 parent ba6387f commit 9e6256e

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

subsys/net/ip/net_if.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5762,7 +5762,6 @@ static void notify_iface_up(struct net_if *iface)
57625762

57635763
static void notify_iface_down(struct net_if *iface)
57645764
{
5765-
net_tcp_close_all_for_iface(iface);
57665765
net_if_flag_clear(iface, NET_IF_RUNNING);
57675766
net_mgmt_event_notify(NET_EVENT_IF_DOWN, iface);
57685767
net_virtual_disable(iface);
@@ -5774,6 +5773,12 @@ static void notify_iface_down(struct net_if *iface)
57745773
clear_joined_ipv4_mcast_groups(iface);
57755774
net_ipv4_autoconf_reset(iface);
57765775
}
5776+
5777+
if (IS_ENABLED(CONFIG_NET_NATIVE_TCP)) {
5778+
net_if_unlock(iface);
5779+
net_tcp_close_all_for_iface(iface);
5780+
net_if_lock(iface);
5781+
}
57775782
}
57785783

57795784
const char *net_if_oper_state2str(enum net_if_oper_state state)

0 commit comments

Comments
 (0)