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 <wengzhe@xiaomi.com>
This commit is contained in:
Zhe Weng 2022-11-22 12:02:55 +08:00 committed by Xiang Xiao
parent c1c17794f9
commit da6ab79d65

View File

@ -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)