From da6ab79d65239efafb8191a804b216bb42e22c60 Mon Sep 17 00:00:00 2001 From: Zhe Weng Date: Tue, 22 Nov 2022 12:02:55 +0800 Subject: [PATCH] net/ipv4_input: Set IPv4 flag at the same place as ipv6_input Set IPv4 flag before processing ipforward, otherwise the ICMP packet responded by ipforward may sometimes be regarded as IPv6. Signed-off-by: Zhe Weng --- net/devif/ipv4_input.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/net/devif/ipv4_input.c b/net/devif/ipv4_input.c index ae1a04cdc6b..1afec12ad50 100644 --- a/net/devif/ipv4_input.c +++ b/net/devif/ipv4_input.c @@ -184,6 +184,12 @@ int ipv4_input(FAR struct net_driver_s *dev) dev->d_len -= llhdrlen; + /* Make sure that all packet processing logic knows that there is an IPv4 + * packet in the device buffer. + */ + + IFF_SET_IPv4(dev->d_flags); + /* Check the size of the packet. If the size reported to us in d_len is * smaller the size reported in the IP header, we assume that the packet * has been corrupted in transit. If the size of d_len is larger than the @@ -354,12 +360,6 @@ int ipv4_input(FAR struct net_driver_s *dev) goto drop; } - /* Make sure that all packet processing logic knows that there is an IPv4 - * packet in the device buffer. - */ - - IFF_SET_IPv4(dev->d_flags); - /* Now process the incoming packet according to the protocol. */ switch (ipv4->proto)