From 9dd135ff076611a65db2bb6a953c099030bbf583 Mon Sep 17 00:00:00 2001 From: "chao.an" Date: Fri, 29 Jan 2021 15:01:41 +0800 Subject: [PATCH] net/ip: do not drop the udp packet from IP layer N/A this change to support receive the udp data from the specified port without obtaining the address. e.g: disable the Bootstrap flag on dhcpc handshake Reference: RFC1542: Clarifications and Extensions for the Bootstrap Protocol. Change-Id: I9e2c4d8223e3be62e1722d51bf5b2f8258bee307 Signed-off-by: chao.an --- net/devif/ipv6_input.c | 29 +++++++++++++---------------- 1 file changed, 13 insertions(+), 16 deletions(-) diff --git a/net/devif/ipv6_input.c b/net/devif/ipv6_input.c index 95d75ccfc30..5d56d832486 100644 --- a/net/devif/ipv6_input.c +++ b/net/devif/ipv6_input.c @@ -409,22 +409,6 @@ int ipv6_input(FAR struct net_driver_s *dev) * address by its IPv6 nexthdr field. */ } - - /* In other cases, the device must be assigned a non-zero IP address - * (the all zero address is the "unspecified" address. - */ - - else -#endif -#ifdef CONFIG_NET_ICMPv6 - if (net_ipv6addr_cmp(dev->d_ipv6addr, g_ipv6_unspecaddr)) - { - nwarn("WARNING: No IP address assigned\n"); - goto drop; - } - - /* Check if the packet is destined for out IP address */ - else #endif { @@ -449,6 +433,7 @@ int ipv6_input(FAR struct net_driver_s *dev) } else #endif + if (nxthdr != IP_PROTO_UDP) { /* Not destined for us and not forwardable... drop the packet. */ @@ -457,6 +442,18 @@ int ipv6_input(FAR struct net_driver_s *dev) } } } +#ifdef CONFIG_NET_ICMPv6 + + /* In other cases, the device must be assigned a non-zero IP address + * (the all zero address is the "unspecified" address. + */ + + if (net_ipv6addr_cmp(dev->d_ipv6addr, g_ipv6_unspecaddr)) + { + nwarn("WARNING: No IP address assigned\n"); + goto drop; + } +#endif /* Now process the incoming packet according to the protocol specified in * the next header IPv6 field.