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

commit 13d1e44fae54109e4574dbe47c4e259cdac77436
Author: Marco Casaroli <[email protected]>
AuthorDate: Thu Nov 26 06:26:09 2026 +0100

    net/ipfilter: Build without the ICMPv6 stack.
    
    ipv6_filter_in() and ipfilter_out() called icmpv6_reply() for a REJECT
    target without a check for the ICMPv6 stack.  A build with
    CONFIG_NET_IPFILTER and CONFIG_NET_IPv6 but without CONFIG_NET_ICMPv6
    failed: icmpv6_reply() has no declaration and no definition.
    
    Call icmpv6_reply() only if NET_ICMPv6_HAVE_STACK is defined, as the
    IPv4 path does for icmp_reply().  Without the ICMP or ICMPv6 stack, a
    REJECT now drops the packet, as DROP does (d_len = 0).  Before, d_len
    kept the length of the packet, and devif_out() sent the packet that the
    filter rejected.
    
    Assisted-by: Claude Code:claude-opus-5-5
    Signed-off-by: Marco Casaroli <[email protected]>
---
 net/ipfilter/ipfilter.c | 17 +++++++++++++++--
 1 file changed, 15 insertions(+), 2 deletions(-)

diff --git a/net/ipfilter/ipfilter.c b/net/ipfilter/ipfilter.c
index 97f05ca86d8..8a557897d09 100644
--- a/net/ipfilter/ipfilter.c
+++ b/net/ipfilter/ipfilter.c
@@ -504,8 +504,11 @@ int ipv4_filter_in(FAR struct net_driver_s *dev)
   if (ret == IPFILTER_TARGET_REJECT)
     {
       /* TODO: Support more --reject-with types later. */
-#if defined(CONFIG_NET_ICMP) && !defined(CONFIG_NET_ICMP_NO_STACK)
+
+#ifdef NET_ICMP_HAVE_STACK
       icmp_reply(dev, ICMP_DEST_UNREACHABLE, ICMP_NET_UNREACH);
+#else
+      dev->d_len = 0;
 #endif
     }
 
@@ -528,7 +531,11 @@ int ipv6_filter_in(FAR struct net_driver_s *dev)
     {
       /* TODO: Support more --reject-with types later. */
 
+#ifdef NET_ICMPv6_HAVE_STACK
       icmpv6_reply(dev, ICMPv6_DEST_UNREACHABLE, ICMPv6_ADDR_UNREACH, 0);
+#else
+      dev->d_len = 0;
+#endif
     }
 
   return ret;
@@ -574,8 +581,10 @@ void ipfilter_out(FAR struct net_driver_s *dev)
 
       if (ret == IPFILTER_TARGET_REJECT)
         {
-#if defined(CONFIG_NET_ICMP) && !defined(CONFIG_NET_ICMP_NO_STACK)
+#ifdef NET_ICMP_HAVE_STACK
           icmp_reply(dev, ICMP_DEST_UNREACHABLE, ICMP_NET_UNREACH);
+#else
+          dev->d_len = 0;
 #endif
         }
     }
@@ -594,7 +603,11 @@ void ipfilter_out(FAR struct net_driver_s *dev)
 
       if (ret == IPFILTER_TARGET_REJECT)
         {
+#ifdef NET_ICMPv6_HAVE_STACK
           icmpv6_reply(dev, ICMPv6_DEST_UNREACHABLE, ICMPv6_ADDR_UNREACH, 0);
+#else
+          dev->d_len = 0;
+#endif
         }
     }
 #endif

Reply via email to