You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by ac...@apache.org on 2022/12/04 18:59:49 UTC

[nuttx] branch master updated: net/ip: return success if the packet was forwarded.

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

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


The following commit(s) were added to refs/heads/master by this push:
     new 8fc1e524ab net/ip: return success if the packet was forwarded.
8fc1e524ab is described below

commit 8fc1e524ab87d95d4f7a303afc56986e989a1aee
Author: chao an <an...@xiaomi.com>
AuthorDate: Mon Dec 5 00:33:41 2022 +0800

    net/ip: return success if the packet was forwarded.
    
    The incoming packet should not be input to ip layer if the packet has been forwarded
    
    Signed-off-by: chao an <an...@xiaomi.com>
---
 net/devif/ipv4_input.c | 25 +++++++++++++++++++++++--
 net/devif/ipv6_input.c | 10 ++++++++++
 2 files changed, 33 insertions(+), 2 deletions(-)

diff --git a/net/devif/ipv4_input.c b/net/devif/ipv4_input.c
index ee1961f74f..aaf854290b 100644
--- a/net/devif/ipv4_input.c
+++ b/net/devif/ipv4_input.c
@@ -255,8 +255,15 @@ static int ipv4_in(FAR struct net_driver_s *dev)
       /* Forward broadcast packets */
 
       ipv4_forward_broadcast(dev, ipv4);
+
+      /* Process the incoming packet if not forwardable */
+
+      if (dev->d_len > 0)
 #endif
-      ret = udp_ipv4_input(dev);
+        {
+          ret = udp_ipv4_input(dev);
+        }
+
       goto done;
     }
   else
@@ -276,8 +283,15 @@ static int ipv4_in(FAR struct net_driver_s *dev)
       /* Forward broadcast packets */
 
       ipv4_forward_broadcast(dev, ipv4);
+
+      /* Process the incoming packet if not forwardable */
+
+      if (dev->d_len > 0)
 #endif
-      ret = udp_ipv4_input(dev);
+        {
+          ret = udp_ipv4_input(dev);
+        }
+
       goto done;
     }
   else
@@ -298,6 +312,13 @@ static int ipv4_in(FAR struct net_driver_s *dev)
           /* Forward multicast packets */
 
           ipv4_forward_broadcast(dev, ipv4);
+
+          /* Return success if the packet was forwarded. */
+
+          if (dev->d_len == 0)
+            {
+              goto done;
+            }
 #endif
         }
       else
diff --git a/net/devif/ipv6_input.c b/net/devif/ipv6_input.c
index 914ff43872..7b7dfa4067 100644
--- a/net/devif/ipv6_input.c
+++ b/net/devif/ipv6_input.c
@@ -395,6 +395,16 @@ static int ipv6_in(FAR struct net_driver_s *dev)
             }
         }
     }
+
+#ifdef CONFIG_NET_IPFORWARD
+  /* Return success if the packet was forwarded. */
+
+  if (dev->d_len == 0)
+    {
+      goto done;
+    }
+#endif
+
 #ifdef CONFIG_NET_ICMPv6
 
   /* In other cases, the device must be assigned a non-zero IP address