net/udp: correct icmp(v6) response from udp_input

Ensure that the correct icmp(v6) response is generated from udb_input.

Signed-off-by: Laczen JMS <laczenjms@gmail.com>
This commit is contained in:
Laczen JMS
2025-03-12 10:06:05 +01:00
committed by Alin Jerpelea
parent 24221b611f
commit e83d31bee9

View File

@@ -348,28 +348,35 @@ static int udp_input(FAR struct net_driver_s *dev, unsigned int iplen)
* unless destination address was broadcast/multicast. * unless destination address was broadcast/multicast.
*/ */
#if defined(CONFIG_NET_ICMP) || defined(CONFIG_NET_ICMPv6) #if !defined(CONFIG_NET_ICMP) && !defined(CONFIG_NET_ICMPv6)
# ifdef CONFIG_NET_ICMPv6 dev->d_len = 0;
# ifdef CONFIG_NET_ICMP #else
if (IFF_IS_IPv6(dev->d_flags)) # ifdef CONFIG_NET_IPv4
# ifdef CONFIG_NET_IPv6
if (IFF_IS_IPv4(dev->d_flags))
# endif # endif
{ {
icmpv6_reply(dev, ICMPv6_DEST_UNREACHABLE,
ICMPv6_PORT_UNREACH, 0);
}
# endif /* CONFIG_NET_ICMPv6 */
# ifdef CONFIG_NET_ICMP # ifdef CONFIG_NET_ICMP
# ifdef CONFIG_NET_ICMPv6 icmp_reply(dev, ICMP_DEST_UNREACHABLE, ICMP_PORT_UNREACH);
# else
dev->d_len = 0;
# endif /* CONFIG_NET_ICMP */
}
# endif /* CONFIG_NET_IPv4 */
# ifdef CONFIG_NET_IPv6
# ifdef CONFIG_NET_IPv4
else else
# endif # endif
{ {
icmp_reply(dev, ICMP_DEST_UNREACHABLE, ICMP_PORT_UNREACH); # ifdef CONFIG_NET_ICMPv6
} icmpv6_reply(dev, ICMPv6_DEST_UNREACHABLE,
# endif /* CONFIG_NET_ICMP */ ICMPv6_PORT_UNREACH, 0);
#else # else
dev->d_len = 0; dev->d_len = 0;
#endif /* CONFIG_NET_ICMP || CONFIG_NET_ICMPv6 */ # endif /* CONFIG_NET_ICMPv6 */
}
# endif /* CONFIG_NET_IPv6*/
#endif
} }
} }