Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 183496
b: refs/heads/master
c: d218d11
h: refs/heads/master
v: v3
  • Loading branch information
Stephen Hemminger authored and David S. Miller committed Jan 12, 2010
1 parent 26c0e65 commit 3652787
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 3 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: c8e000604bce02a87742240a9b716a0f1b680c0b
refs/heads/master: d218d11133d888f9745802146a50255a4781d37a
2 changes: 2 additions & 0 deletions trunk/include/linux/in.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,8 @@ struct in_addr {
#define IP_ORIGDSTADDR 20
#define IP_RECVORIGDSTADDR IP_ORIGDSTADDR

#define IP_MINTTL 21

/* IP_MTU_DISCOVER values */
#define IP_PMTUDISC_DONT 0 /* Never send DF frames */
#define IP_PMTUDISC_WANT 1 /* Use per route hints */
Expand Down
4 changes: 3 additions & 1 deletion trunk/include/net/inet_sock.h
Original file line number Diff line number Diff line change
Expand Up @@ -122,10 +122,12 @@ struct inet_sock {
__be32 inet_saddr;
__s16 uc_ttl;
__u16 cmsg_flags;
struct ip_options *opt;
__be16 inet_sport;
__u16 inet_id;

struct ip_options *opt;
__u8 tos;
__u8 min_ttl;
__u8 mc_ttl;
__u8 pmtudisc;
__u8 recverr:1,
Expand Down
14 changes: 13 additions & 1 deletion trunk/net/ipv4/ip_sockglue.c
Original file line number Diff line number Diff line change
Expand Up @@ -451,7 +451,8 @@ static int do_ip_setsockopt(struct sock *sk, int level,
(1<<IP_TTL) | (1<<IP_HDRINCL) |
(1<<IP_MTU_DISCOVER) | (1<<IP_RECVERR) |
(1<<IP_ROUTER_ALERT) | (1<<IP_FREEBIND) |
(1<<IP_PASSSEC) | (1<<IP_TRANSPARENT))) ||
(1<<IP_PASSSEC) | (1<<IP_TRANSPARENT) |
(1<<IP_MINTTL))) ||
optname == IP_MULTICAST_TTL ||
optname == IP_MULTICAST_ALL ||
optname == IP_MULTICAST_LOOP ||
Expand Down Expand Up @@ -936,6 +937,14 @@ static int do_ip_setsockopt(struct sock *sk, int level,
inet->transparent = !!val;
break;

case IP_MINTTL:
if (optlen < 1)
goto e_inval;
if (val < 0 || val > 255)
goto e_inval;
inet->min_ttl = val;
break;

default:
err = -ENOPROTOOPT;
break;
Expand Down Expand Up @@ -1198,6 +1207,9 @@ static int do_ip_getsockopt(struct sock *sk, int level, int optname,
case IP_TRANSPARENT:
val = inet->transparent;
break;
case IP_MINTTL:
val = inet->min_ttl;
break;
default:
release_sock(sk);
return -ENOPROTOOPT;
Expand Down
3 changes: 3 additions & 0 deletions trunk/net/ipv4/tcp_ipv4.c
Original file line number Diff line number Diff line change
Expand Up @@ -1649,6 +1649,9 @@ int tcp_v4_rcv(struct sk_buff *skb)
if (!sk)
goto no_tcp_socket;

if (iph->ttl < inet_sk(sk)->min_ttl)
goto discard_and_relse;

process:
if (sk->sk_state == TCP_TIME_WAIT)
goto do_time_wait;
Expand Down

0 comments on commit 3652787

Please sign in to comment.