Skip to content

Commit

Permalink
net: shell: Prevent deadlock with net arp command
Browse files Browse the repository at this point in the history
In case one of the networking shell backends is enabled, net arp command
could potentially trigger a deadlock, as it locks the ARP mutex before
TCP connection mutex, while TCP stack could do this in reverse order
(for instance when sending ACK or retransmission).

Mitigate this, by forcing a separate TX thread in such case, so that ARP
mutex is no longer accessed with TCP mutex locked.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
  • Loading branch information
rlubos authored and fabiobaltieri committed Dec 15, 2023
1 parent 37e1a11 commit 0c09589
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions subsys/net/ip/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -184,13 +184,23 @@ config NET_SHELL_DYN_CMD_COMPLETION
length) by default. Other dynamic completion commands in
net-shell require also some smaller amount of memory.

config NET_SHELL_REQUIRE_TX_THREAD
bool
depends on NET_SHELL && (SHELL_BACKEND_TELNET || SHELL_BACKEND_MQTT)
default y if NET_ARP
help
Hidden symbol indicating that network shell requires separate TX
thread due to possible deadlocks during shell/net stack operations.

config NET_TC_TX_COUNT
int "How many Tx traffic classes to have for each network device"
default 1 if USERSPACE || USB_DEVICE_NETWORK
default 1 if USERSPACE || USB_DEVICE_NETWORK || \
NET_SHELL_REQUIRE_TX_THREAD
default 0
range 1 NET_TC_NUM_PRIORITIES if NET_TC_NUM_PRIORITIES<=8 && USERSPACE
range 1 NET_TC_NUM_PRIORITIES if NET_TC_NUM_PRIORITIES<=8 && \
(USERSPACE || NET_SHELL_REQUIRE_TX_THREAD)
range 0 NET_TC_NUM_PRIORITIES if NET_TC_NUM_PRIORITIES<=8
range 1 8 if USERSPACE
range 1 8 if USERSPACE || NET_SHELL_REQUIRE_TX_THREAD
range 0 8
help
Define how many Tx traffic classes (queues) the system should have
Expand Down

0 comments on commit 0c09589

Please sign in to comment.