[PATCH 04/10] net: icmp: properly set IP TTL and fragement fields

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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.luebbe@xxxxxxxxxxxxxx>
Signed-off-by: Ahmad Fatoum <a.fatoum@xxxxxxxxxxxxxx>
---
 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





[Index of Archives]     [Linux Embedded]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux