Subject: Re: [PATCH] ipv4/ipv6: check hop limit field on input

From: Eric Dumazet <[email-masked]>
Date: Tue, 02 Jun 2009 07:31:12 +0200

David Miller a écrit :
> From: Nicolas Dichtel <[email-masked]>
> Date: Mon, 01 Jun 2009 17:13:43 +0200
> 
>> RFC indicates that a router must drop the packet if this field is 0.
> 
> It only must do this when executing the forwarding function.  It's an
> egress check, not an ingress one.
> 
> I'm not applying this patch, it can even break some applications
> out there that use a TTL of zero intentionally to keep traffic
> only on a local subnet.

I wonder if we then should allow setting ttl to zero. I had to patch
my kernel to allow ping to do this...

I'll check RFC when time permits.

diff --git a/net/ipv4/ip_sockglue.c b/net/ipv4/ip_sockglue.c
index e2d1f87..efe2797 100644
--- a/net/ipv4/ip_sockglue.c
+++ b/net/ipv4/ip_sockglue.c
@@ -558,7 +558,7 @@ static int do_ip_setsockopt(struct sock *sk, int level,
 	case IP_TTL:
 		if (optlen<1)
 			goto e_inval;
-		if (val != -1 && (val < 1 || val>255))
+		if (val != -1 && (val < 0 || val>255))
 			goto e_inval;
 		inet->uc_ttl = val;
 		break;