diff options
author | Florian Westphal <fw@strlen.de> | 2010-06-02 20:43:57 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2010-06-05 05:23:15 -0400 |
commit | 5918e2fb9035b35164002c3a268feaf70b7c04d5 (patch) | |
tree | 3a785e4b13971d9b9e9098a339ad005364949852 /net | |
parent | af9b4738574b46025de7ccbe75c7b24fd8914379 (diff) |
syncookies: update mss tables
- ipv6 msstab: account for ipv6 header size
- ipv4 msstab: add mss for Jumbograms.
Signed-off-by: Florian Westphal <fw@strlen.de>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net')
-rw-r--r-- | net/ipv4/syncookies.c | 38 | ||||
-rw-r--r-- | net/ipv6/syncookies.c | 39 |
2 files changed, 34 insertions, 43 deletions
diff --git a/net/ipv4/syncookies.c b/net/ipv4/syncookies.c index c9dac8615958..a7cbcc4b726b 100644 --- a/net/ipv4/syncookies.c +++ b/net/ipv4/syncookies.c | |||
@@ -138,23 +138,23 @@ static __u32 check_tcp_syn_cookie(__u32 cookie, __be32 saddr, __be32 daddr, | |||
138 | } | 138 | } |
139 | 139 | ||
140 | /* | 140 | /* |
141 | * This table has to be sorted and terminated with (__u16)-1. | 141 | * MSS Values are taken from the 2009 paper |
142 | * XXX generate a better table. | 142 | * 'Measuring TCP Maximum Segment Size' by S. Alcock and R. Nelson: |
143 | * Unresolved Issues: HIPPI with a 64k MSS is not well supported. | 143 | * - values 1440 to 1460 accounted for 80% of observed mss values |
144 | * - values outside the 536-1460 range are rare (<0.2%). | ||
145 | * | ||
146 | * Table must be sorted. | ||
144 | */ | 147 | */ |
145 | static __u16 const msstab[] = { | 148 | static __u16 const msstab[] = { |
146 | 64 - 1, | 149 | 64, |
147 | 256 - 1, | 150 | 512, |
148 | 512 - 1, | 151 | 536, |
149 | 536 - 1, | 152 | 1024, |
150 | 1024 - 1, | 153 | 1440, |
151 | 1440 - 1, | 154 | 1460, |
152 | 1460 - 1, | 155 | 4312, |
153 | 4312 - 1, | 156 | 8960, |
154 | (__u16)-1 | ||
155 | }; | 157 | }; |
156 | /* The number doesn't include the -1 terminator */ | ||
157 | #define NUM_MSS (ARRAY_SIZE(msstab) - 1) | ||
158 | 158 | ||
159 | /* | 159 | /* |
160 | * Generate a syncookie. mssp points to the mss, which is returned | 160 | * Generate a syncookie. mssp points to the mss, which is returned |
@@ -169,10 +169,10 @@ __u32 cookie_v4_init_sequence(struct sock *sk, struct sk_buff *skb, __u16 *mssp) | |||
169 | 169 | ||
170 | tcp_synq_overflow(sk); | 170 | tcp_synq_overflow(sk); |
171 | 171 | ||
172 | /* XXX sort msstab[] by probability? Binary search? */ | 172 | for (mssind = ARRAY_SIZE(msstab) - 1; mssind ; mssind--) |
173 | for (mssind = 0; mss > msstab[mssind + 1]; mssind++) | 173 | if (mss >= msstab[mssind]) |
174 | ; | 174 | break; |
175 | *mssp = msstab[mssind] + 1; | 175 | *mssp = msstab[mssind]; |
176 | 176 | ||
177 | NET_INC_STATS_BH(sock_net(sk), LINUX_MIB_SYNCOOKIESSENT); | 177 | NET_INC_STATS_BH(sock_net(sk), LINUX_MIB_SYNCOOKIESSENT); |
178 | 178 | ||
@@ -202,7 +202,7 @@ static inline int cookie_check(struct sk_buff *skb, __u32 cookie) | |||
202 | jiffies / (HZ * 60), | 202 | jiffies / (HZ * 60), |
203 | COUNTER_TRIES); | 203 | COUNTER_TRIES); |
204 | 204 | ||
205 | return mssind < NUM_MSS ? msstab[mssind] + 1 : 0; | 205 | return mssind < ARRAY_SIZE(msstab) ? msstab[mssind] : 0; |
206 | } | 206 | } |
207 | 207 | ||
208 | static inline struct sock *get_cookie_sock(struct sock *sk, struct sk_buff *skb, | 208 | static inline struct sock *get_cookie_sock(struct sock *sk, struct sk_buff *skb, |
diff --git a/net/ipv6/syncookies.c b/net/ipv6/syncookies.c index 9fcb3ec7c838..70d330f8c990 100644 --- a/net/ipv6/syncookies.c +++ b/net/ipv6/syncookies.c | |||
@@ -27,28 +27,17 @@ extern __u32 syncookie_secret[2][16-4+SHA_DIGEST_WORDS]; | |||
27 | #define COOKIEBITS 24 /* Upper bits store count */ | 27 | #define COOKIEBITS 24 /* Upper bits store count */ |
28 | #define COOKIEMASK (((__u32)1 << COOKIEBITS) - 1) | 28 | #define COOKIEMASK (((__u32)1 << COOKIEBITS) - 1) |
29 | 29 | ||
30 | /* | 30 | /* Table must be sorted. */ |
31 | * This table has to be sorted and terminated with (__u16)-1. | ||
32 | * XXX generate a better table. | ||
33 | * Unresolved Issues: HIPPI with a 64k MSS is not well supported. | ||
34 | * | ||
35 | * Taken directly from ipv4 implementation. | ||
36 | * Should this list be modified for ipv6 use or is it close enough? | ||
37 | * rfc 2460 8.3 suggests mss values 20 bytes less than ipv4 counterpart | ||
38 | */ | ||
39 | static __u16 const msstab[] = { | 31 | static __u16 const msstab[] = { |
40 | 64 - 1, | 32 | 64, |
41 | 256 - 1, | 33 | 512, |
42 | 512 - 1, | 34 | 536, |
43 | 536 - 1, | 35 | 1280 - 60, |
44 | 1024 - 1, | 36 | 1480 - 60, |
45 | 1440 - 1, | 37 | 1500 - 60, |
46 | 1460 - 1, | 38 | 4460 - 60, |
47 | 4312 - 1, | 39 | 9000 - 60, |
48 | (__u16)-1 | ||
49 | }; | 40 | }; |
50 | /* The number doesn't include the -1 terminator */ | ||
51 | #define NUM_MSS (ARRAY_SIZE(msstab) - 1) | ||
52 | 41 | ||
53 | /* | 42 | /* |
54 | * This (misnamed) value is the age of syncookie which is permitted. | 43 | * This (misnamed) value is the age of syncookie which is permitted. |
@@ -134,9 +123,11 @@ __u32 cookie_v6_init_sequence(struct sock *sk, struct sk_buff *skb, __u16 *mssp) | |||
134 | 123 | ||
135 | tcp_synq_overflow(sk); | 124 | tcp_synq_overflow(sk); |
136 | 125 | ||
137 | for (mssind = 0; mss > msstab[mssind + 1]; mssind++) | 126 | for (mssind = ARRAY_SIZE(msstab) - 1; mssind ; mssind--) |
138 | ; | 127 | if (mss >= msstab[mssind]) |
139 | *mssp = msstab[mssind] + 1; | 128 | break; |
129 | |||
130 | *mssp = msstab[mssind]; | ||
140 | 131 | ||
141 | NET_INC_STATS_BH(sock_net(sk), LINUX_MIB_SYNCOOKIESSENT); | 132 | NET_INC_STATS_BH(sock_net(sk), LINUX_MIB_SYNCOOKIESSENT); |
142 | 133 | ||
@@ -154,7 +145,7 @@ static inline int cookie_check(struct sk_buff *skb, __u32 cookie) | |||
154 | th->source, th->dest, seq, | 145 | th->source, th->dest, seq, |
155 | jiffies / (HZ * 60), COUNTER_TRIES); | 146 | jiffies / (HZ * 60), COUNTER_TRIES); |
156 | 147 | ||
157 | return mssind < NUM_MSS ? msstab[mssind] + 1 : 0; | 148 | return mssind < ARRAY_SIZE(msstab) ? msstab[mssind] : 0; |
158 | } | 149 | } |
159 | 150 | ||
160 | struct sock *cookie_v6_check(struct sock *sk, struct sk_buff *skb) | 151 | struct sock *cookie_v6_check(struct sock *sk, struct sk_buff *skb) |