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

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

commit 18e383360b7e850f16959a546631c1a4306b0792
Author: zhanghongyu <[email protected]>
AuthorDate: Tue Nov 18 10:09:09 2025 +0800

    tun.c: fix tcpdump can not capture the tun reply packet
    
    The TUN driver did not loop the reply packet back to the read path,
    so tcpdump running on the tun interface could not capture the packets
    the stack sent in reply.  Feed the reply back so it is visible to the
    packet socket used by tcpdump.
    
    Signed-off-by: zhanghongyu <[email protected]>
---
 drivers/net/tun.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/drivers/net/tun.c b/drivers/net/tun.c
index 4c7a0068b03..1bf547fae04 100644
--- a/drivers/net/tun.c
+++ b/drivers/net/tun.c
@@ -517,6 +517,11 @@ static void tun_net_receive_tap(FAR struct tun_device_s 
*priv)
 
   if (priv->dev.d_len > 0)
     {
+#ifdef CONFIG_NET_PKT
+      /* When packet sockets are enabled, feed the frame into the tap */
+
+      pkt_input(dev);
+#endif
       /* And send the packet */
 
       DEBUGASSERT(priv->write_buf == NULL);
@@ -599,6 +604,13 @@ static void tun_net_receive_tun(FAR struct tun_device_s 
*priv)
 
   if (dev->d_len > 0)
     {
+#ifdef CONFIG_NET_PKT
+      /* When packet sockets are enabled, feed the frame into the tap */
+
+      pkt_input(dev);
+#endif
+      /* And send the packet */
+
       DEBUGASSERT(priv->write_buf == NULL);
       priv->write_d_len = dev->d_len;
       priv->write_buf   = dev->d_iob;

Reply via email to