You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by ar...@apache.org on 2026/03/24 05:49:18 UTC

(nuttx) branch master updated (07058280247 -> ef67e946136)

This is an automated email from the ASF dual-hosted git repository.

archer pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git


    from 07058280247 boards/nrf53/thingy53: add sensor scope example
     new db572d860b6 net/nat: g_nat_lock can be used recursively
     new ef67e946136 net/nat: fix missed nat_unlock

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 net/nat/nat.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)


(nuttx) 01/02: net/nat: g_nat_lock can be used recursively

Posted by ar...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

archer pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git

commit db572d860b68eb67bcb22923bad96b79af241b68
Author: shichunma <ma...@gmail.com>
AuthorDate: Sat Mar 21 15:42:16 2026 +0800

    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 <sh...@bestechnic.com>
---
 net/nat/nat.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/net/nat/nat.c b/net/nat/nat.c
index 4ccc2d9700b..426a04cd848 100644
--- a/net/nat/nat.c
+++ b/net/nat/nat.c
@@ -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 */


(nuttx) 02/02: net/nat: fix missed nat_unlock

Posted by ar...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

archer pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git

commit ef67e946136b03abebd30c94dda3a24bd973c179
Author: shichunma <ma...@gmail.com>
AuthorDate: Mon Mar 23 21:36:09 2026 +0800

    net/nat: fix missed nat_unlock
    
    If call nat_enable twice, there will be a miss "nat_unlock".
    
    Signed-off-by: Jerry Ma <sh...@bestechnic.com>
---
 net/nat/nat.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/net/nat/nat.c b/net/nat/nat.c
index 426a04cd848..d8cf542b667 100644
--- a/net/nat/nat.c
+++ b/net/nat/nat.c
@@ -118,6 +118,7 @@ int nat_enable(FAR struct net_driver_s *dev)
   if (IFF_IS_NAT(dev->d_flags))
     {
       nwarn("WARNING: NAT was already enabled for %s!\n", dev->d_ifname);
+      nat_unlock();
       return -EEXIST;
     }