We shouldn't keep using the TTL value of the ICMP echo request,
as we are sending a fresh packet, therefore restore it to the maximum
value.

While at it, also fix the frag_off field: A fragment offset of 0 on its
own doesn't mean that there's no fragmentation, but that this is the
first fragment. Writing 0x4000 there sets the "Don't fragment" bit,
which we are already setting for all other IP communication and should
be setting here as well.

Suggested-by: Jan Lübbe <j.lue...@pengutronix.de>
Signed-off-by: Ahmad Fatoum <a.fat...@pengutronix.de>
---
 net/net.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/net/net.c b/net/net.c
index 6745085635dc..754a764d2a49 100644
--- a/net/net.c
+++ b/net/net.c
@@ -705,7 +705,8 @@ static int ping_reply(struct eth_device *edev, unsigned 
char *pkt, int len)
        icmp->checksum = ~net_checksum((unsigned char *)icmp,
                                       len - sizeof(struct iphdr) - 
ETHER_HDR_SIZE);
        ip->check = 0;
-       ip->frag_off = 0;
+       ip->frag_off = htons(0x4000);
+       ip->ttl = 255;
        net_copy_ip((void *)&ip->daddr, &ip->saddr);
        net_copy_ip((void *)&ip->saddr, &edev->ipaddr);
        ip->check = ~net_checksum((unsigned char *)ip, sizeof(struct iphdr));
-- 
2.39.2


Reply via email to