net/nat: g_nat_lock can be used recursively

case: when rndis receive a packet and this packet is going to be forwarded.
1. first lock happen when ipv4_dev_forward call ipv4_nat_outbound;
2. next lock is: ipv4_nat_outbound_entry_find --> nat_port_select --> tcp_selectport
   --> nat_port_inuse

Signed-off-by: Jerry Ma <shichunma@bestechnic.com>
This commit is contained in:
shichunma 2026-03-21 15:42:16 +08:00 committed by archer
parent 0705828024
commit db572d860b

View file

@ -42,7 +42,7 @@
* Private Data
****************************************************************************/
static mutex_t g_nat_lock = NXMUTEX_INITIALIZER;
static rmutex_t g_nat_lock = NXRMUTEX_INITIALIZER;
/****************************************************************************
* Private Functions
@ -418,7 +418,7 @@ uint32_t nat_expire_time(uint8_t protocol)
void nat_lock(void)
{
nxmutex_lock(&g_nat_lock);
nxrmutex_lock(&g_nat_lock);
}
/****************************************************************************
@ -431,7 +431,7 @@ void nat_lock(void)
void nat_unlock(void)
{
nxmutex_unlock(&g_nat_lock);
nxrmutex_unlock(&g_nat_lock);
}
#endif /* CONFIG_NET_NAT */