diff options
author | Ilpo Järvinen <ilpo.jarvinen@helsinki.fi> | 2007-05-27 05:04:16 -0400 |
---|---|---|
committer | David S. Miller <davem@sunset.davemloft.net> | 2007-10-10 19:47:54 -0400 |
commit | bdf1ee5d3bd38d0c44bd7baa74e07adcbe4ceab1 (patch) | |
tree | c14e3433624e03b7db6a9f30142581342e848ad6 | |
parent | 539d243fdd7900fa5a544c7c154dc3ddf627e840 (diff) |
[TCP]: Move code from tcp_ecn.h to tcp*.c and tcp.h & remove it
No other users exist for tcp_ecn.h. Very few things remain in
tcp.h, for most TCP ECN functions callers reside within a
single .c file and can be placed there.
Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@helsinki.fi>
Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r-- | include/net/tcp.h | 14 | ||||
-rw-r--r-- | include/net/tcp_ecn.h | 130 | ||||
-rw-r--r-- | net/ipv4/tcp_input.c | 50 | ||||
-rw-r--r-- | net/ipv4/tcp_minisocks.c | 6 | ||||
-rw-r--r-- | net/ipv4/tcp_output.c | 50 |
5 files changed, 118 insertions, 132 deletions
diff --git a/include/net/tcp.h b/include/net/tcp.h index 54053de0bdd7..dde04afbe0a4 100644 --- a/include/net/tcp.h +++ b/include/net/tcp.h | |||
@@ -39,6 +39,7 @@ | |||
39 | #include <net/snmp.h> | 39 | #include <net/snmp.h> |
40 | #include <net/ip.h> | 40 | #include <net/ip.h> |
41 | #include <net/tcp_states.h> | 41 | #include <net/tcp_states.h> |
42 | #include <net/inet_ecn.h> | ||
42 | 43 | ||
43 | #include <linux/seq_file.h> | 44 | #include <linux/seq_file.h> |
44 | 45 | ||
@@ -330,6 +331,17 @@ static inline void tcp_clear_options(struct tcp_options_received *rx_opt) | |||
330 | rx_opt->tstamp_ok = rx_opt->sack_ok = rx_opt->wscale_ok = rx_opt->snd_wscale = 0; | 331 | rx_opt->tstamp_ok = rx_opt->sack_ok = rx_opt->wscale_ok = rx_opt->snd_wscale = 0; |
331 | } | 332 | } |
332 | 333 | ||
334 | #define TCP_ECN_OK 1 | ||
335 | #define TCP_ECN_QUEUE_CWR 2 | ||
336 | #define TCP_ECN_DEMAND_CWR 4 | ||
337 | |||
338 | static __inline__ void | ||
339 | TCP_ECN_create_request(struct request_sock *req, struct tcphdr *th) | ||
340 | { | ||
341 | if (sysctl_tcp_ecn && th->ece && th->cwr) | ||
342 | inet_rsk(req)->ecn_ok = 1; | ||
343 | } | ||
344 | |||
333 | enum tcp_tw_status | 345 | enum tcp_tw_status |
334 | { | 346 | { |
335 | TCP_TW_SUCCESS = 0, | 347 | TCP_TW_SUCCESS = 0, |
@@ -573,8 +585,6 @@ struct tcp_skb_cb { | |||
573 | 585 | ||
574 | #define TCP_SKB_CB(__skb) ((struct tcp_skb_cb *)&((__skb)->cb[0])) | 586 | #define TCP_SKB_CB(__skb) ((struct tcp_skb_cb *)&((__skb)->cb[0])) |
575 | 587 | ||
576 | #include <net/tcp_ecn.h> | ||
577 | |||
578 | /* Due to TSO, an SKB can be composed of multiple actual | 588 | /* Due to TSO, an SKB can be composed of multiple actual |
579 | * packets. To keep these tracked properly, we use this. | 589 | * packets. To keep these tracked properly, we use this. |
580 | */ | 590 | */ |
diff --git a/include/net/tcp_ecn.h b/include/net/tcp_ecn.h deleted file mode 100644 index 89eb3e05116d..000000000000 --- a/include/net/tcp_ecn.h +++ /dev/null | |||
@@ -1,130 +0,0 @@ | |||
1 | #ifndef _NET_TCP_ECN_H_ | ||
2 | #define _NET_TCP_ECN_H_ 1 | ||
3 | |||
4 | #include <net/inet_ecn.h> | ||
5 | #include <net/request_sock.h> | ||
6 | |||
7 | #define TCP_HP_BITS (~(TCP_RESERVED_BITS|TCP_FLAG_PSH)) | ||
8 | |||
9 | #define TCP_ECN_OK 1 | ||
10 | #define TCP_ECN_QUEUE_CWR 2 | ||
11 | #define TCP_ECN_DEMAND_CWR 4 | ||
12 | |||
13 | static inline void TCP_ECN_queue_cwr(struct tcp_sock *tp) | ||
14 | { | ||
15 | if (tp->ecn_flags&TCP_ECN_OK) | ||
16 | tp->ecn_flags |= TCP_ECN_QUEUE_CWR; | ||
17 | } | ||
18 | |||
19 | |||
20 | /* Output functions */ | ||
21 | |||
22 | static inline void TCP_ECN_send_synack(struct tcp_sock *tp, | ||
23 | struct sk_buff *skb) | ||
24 | { | ||
25 | TCP_SKB_CB(skb)->flags &= ~TCPCB_FLAG_CWR; | ||
26 | if (!(tp->ecn_flags&TCP_ECN_OK)) | ||
27 | TCP_SKB_CB(skb)->flags &= ~TCPCB_FLAG_ECE; | ||
28 | } | ||
29 | |||
30 | static inline void TCP_ECN_send_syn(struct sock *sk, struct sk_buff *skb) | ||
31 | { | ||
32 | struct tcp_sock *tp = tcp_sk(sk); | ||
33 | |||
34 | tp->ecn_flags = 0; | ||
35 | if (sysctl_tcp_ecn) { | ||
36 | TCP_SKB_CB(skb)->flags |= TCPCB_FLAG_ECE|TCPCB_FLAG_CWR; | ||
37 | tp->ecn_flags = TCP_ECN_OK; | ||
38 | } | ||
39 | } | ||
40 | |||
41 | static __inline__ void | ||
42 | TCP_ECN_make_synack(struct request_sock *req, struct tcphdr *th) | ||
43 | { | ||
44 | if (inet_rsk(req)->ecn_ok) | ||
45 | th->ece = 1; | ||
46 | } | ||
47 | |||
48 | static inline void TCP_ECN_send(struct sock *sk, struct sk_buff *skb, | ||
49 | int tcp_header_len) | ||
50 | { | ||
51 | struct tcp_sock *tp = tcp_sk(sk); | ||
52 | |||
53 | if (tp->ecn_flags & TCP_ECN_OK) { | ||
54 | /* Not-retransmitted data segment: set ECT and inject CWR. */ | ||
55 | if (skb->len != tcp_header_len && | ||
56 | !before(TCP_SKB_CB(skb)->seq, tp->snd_nxt)) { | ||
57 | INET_ECN_xmit(sk); | ||
58 | if (tp->ecn_flags&TCP_ECN_QUEUE_CWR) { | ||
59 | tp->ecn_flags &= ~TCP_ECN_QUEUE_CWR; | ||
60 | tcp_hdr(skb)->cwr = 1; | ||
61 | skb_shinfo(skb)->gso_type |= SKB_GSO_TCP_ECN; | ||
62 | } | ||
63 | } else { | ||
64 | /* ACK or retransmitted segment: clear ECT|CE */ | ||
65 | INET_ECN_dontxmit(sk); | ||
66 | } | ||
67 | if (tp->ecn_flags & TCP_ECN_DEMAND_CWR) | ||
68 | tcp_hdr(skb)->ece = 1; | ||
69 | } | ||
70 | } | ||
71 | |||
72 | /* Input functions */ | ||
73 | |||
74 | static inline void TCP_ECN_accept_cwr(struct tcp_sock *tp, struct sk_buff *skb) | ||
75 | { | ||
76 | if (tcp_hdr(skb)->cwr) | ||
77 | tp->ecn_flags &= ~TCP_ECN_DEMAND_CWR; | ||
78 | } | ||
79 | |||
80 | static inline void TCP_ECN_withdraw_cwr(struct tcp_sock *tp) | ||
81 | { | ||
82 | tp->ecn_flags &= ~TCP_ECN_DEMAND_CWR; | ||
83 | } | ||
84 | |||
85 | static inline void TCP_ECN_check_ce(struct tcp_sock *tp, struct sk_buff *skb) | ||
86 | { | ||
87 | if (tp->ecn_flags&TCP_ECN_OK) { | ||
88 | if (INET_ECN_is_ce(TCP_SKB_CB(skb)->flags)) | ||
89 | tp->ecn_flags |= TCP_ECN_DEMAND_CWR; | ||
90 | /* Funny extension: if ECT is not set on a segment, | ||
91 | * it is surely retransmit. It is not in ECN RFC, | ||
92 | * but Linux follows this rule. */ | ||
93 | else if (INET_ECN_is_not_ect((TCP_SKB_CB(skb)->flags))) | ||
94 | tcp_enter_quickack_mode((struct sock *)tp); | ||
95 | } | ||
96 | } | ||
97 | |||
98 | static inline void TCP_ECN_rcv_synack(struct tcp_sock *tp, struct tcphdr *th) | ||
99 | { | ||
100 | if ((tp->ecn_flags&TCP_ECN_OK) && (!th->ece || th->cwr)) | ||
101 | tp->ecn_flags &= ~TCP_ECN_OK; | ||
102 | } | ||
103 | |||
104 | static inline void TCP_ECN_rcv_syn(struct tcp_sock *tp, struct tcphdr *th) | ||
105 | { | ||
106 | if ((tp->ecn_flags&TCP_ECN_OK) && (!th->ece || !th->cwr)) | ||
107 | tp->ecn_flags &= ~TCP_ECN_OK; | ||
108 | } | ||
109 | |||
110 | static inline int TCP_ECN_rcv_ecn_echo(struct tcp_sock *tp, struct tcphdr *th) | ||
111 | { | ||
112 | if (th->ece && !th->syn && (tp->ecn_flags&TCP_ECN_OK)) | ||
113 | return 1; | ||
114 | return 0; | ||
115 | } | ||
116 | |||
117 | static inline void TCP_ECN_openreq_child(struct tcp_sock *tp, | ||
118 | struct request_sock *req) | ||
119 | { | ||
120 | tp->ecn_flags = inet_rsk(req)->ecn_ok ? TCP_ECN_OK : 0; | ||
121 | } | ||
122 | |||
123 | static __inline__ void | ||
124 | TCP_ECN_create_request(struct request_sock *req, struct tcphdr *th) | ||
125 | { | ||
126 | if (sysctl_tcp_ecn && th->ece && th->cwr) | ||
127 | inet_rsk(req)->ecn_ok = 1; | ||
128 | } | ||
129 | |||
130 | #endif | ||
diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c index 29999ef73b43..ea690afa592a 100644 --- a/net/ipv4/tcp_input.c +++ b/net/ipv4/tcp_input.c | |||
@@ -118,6 +118,7 @@ int sysctl_tcp_abc __read_mostly; | |||
118 | #define IsSackFrto() (sysctl_tcp_frto == 0x2) | 118 | #define IsSackFrto() (sysctl_tcp_frto == 0x2) |
119 | 119 | ||
120 | #define TCP_REMNANT (TCP_FLAG_FIN|TCP_FLAG_URG|TCP_FLAG_SYN|TCP_FLAG_PSH) | 120 | #define TCP_REMNANT (TCP_FLAG_FIN|TCP_FLAG_URG|TCP_FLAG_SYN|TCP_FLAG_PSH) |
121 | #define TCP_HP_BITS (~(TCP_RESERVED_BITS|TCP_FLAG_PSH)) | ||
121 | 122 | ||
122 | /* Adapt the MSS value used to make delayed ack decision to the | 123 | /* Adapt the MSS value used to make delayed ack decision to the |
123 | * real world. | 124 | * real world. |
@@ -198,6 +199,55 @@ static inline int tcp_in_quickack_mode(const struct sock *sk) | |||
198 | return icsk->icsk_ack.quick && !icsk->icsk_ack.pingpong; | 199 | return icsk->icsk_ack.quick && !icsk->icsk_ack.pingpong; |
199 | } | 200 | } |
200 | 201 | ||
202 | static inline void TCP_ECN_queue_cwr(struct tcp_sock *tp) | ||
203 | { | ||
204 | if (tp->ecn_flags&TCP_ECN_OK) | ||
205 | tp->ecn_flags |= TCP_ECN_QUEUE_CWR; | ||
206 | } | ||
207 | |||
208 | static inline void TCP_ECN_accept_cwr(struct tcp_sock *tp, struct sk_buff *skb) | ||
209 | { | ||
210 | if (tcp_hdr(skb)->cwr) | ||
211 | tp->ecn_flags &= ~TCP_ECN_DEMAND_CWR; | ||
212 | } | ||
213 | |||
214 | static inline void TCP_ECN_withdraw_cwr(struct tcp_sock *tp) | ||
215 | { | ||
216 | tp->ecn_flags &= ~TCP_ECN_DEMAND_CWR; | ||
217 | } | ||
218 | |||
219 | static inline void TCP_ECN_check_ce(struct tcp_sock *tp, struct sk_buff *skb) | ||
220 | { | ||
221 | if (tp->ecn_flags&TCP_ECN_OK) { | ||
222 | if (INET_ECN_is_ce(TCP_SKB_CB(skb)->flags)) | ||
223 | tp->ecn_flags |= TCP_ECN_DEMAND_CWR; | ||
224 | /* Funny extension: if ECT is not set on a segment, | ||
225 | * it is surely retransmit. It is not in ECN RFC, | ||
226 | * but Linux follows this rule. */ | ||
227 | else if (INET_ECN_is_not_ect((TCP_SKB_CB(skb)->flags))) | ||
228 | tcp_enter_quickack_mode((struct sock *)tp); | ||
229 | } | ||
230 | } | ||
231 | |||
232 | static inline void TCP_ECN_rcv_synack(struct tcp_sock *tp, struct tcphdr *th) | ||
233 | { | ||
234 | if ((tp->ecn_flags&TCP_ECN_OK) && (!th->ece || th->cwr)) | ||
235 | tp->ecn_flags &= ~TCP_ECN_OK; | ||
236 | } | ||
237 | |||
238 | static inline void TCP_ECN_rcv_syn(struct tcp_sock *tp, struct tcphdr *th) | ||
239 | { | ||
240 | if ((tp->ecn_flags&TCP_ECN_OK) && (!th->ece || !th->cwr)) | ||
241 | tp->ecn_flags &= ~TCP_ECN_OK; | ||
242 | } | ||
243 | |||
244 | static inline int TCP_ECN_rcv_ecn_echo(struct tcp_sock *tp, struct tcphdr *th) | ||
245 | { | ||
246 | if (th->ece && !th->syn && (tp->ecn_flags&TCP_ECN_OK)) | ||
247 | return 1; | ||
248 | return 0; | ||
249 | } | ||
250 | |||
201 | /* Buffer size and advertised window tuning. | 251 | /* Buffer size and advertised window tuning. |
202 | * | 252 | * |
203 | * 1. Tuning sk->sk_sndbuf, when connection enters established state. | 253 | * 1. Tuning sk->sk_sndbuf, when connection enters established state. |
diff --git a/net/ipv4/tcp_minisocks.c b/net/ipv4/tcp_minisocks.c index a12b08fca5ad..36a8fbd0e64e 100644 --- a/net/ipv4/tcp_minisocks.c +++ b/net/ipv4/tcp_minisocks.c | |||
@@ -368,6 +368,12 @@ void tcp_twsk_destructor(struct sock *sk) | |||
368 | 368 | ||
369 | EXPORT_SYMBOL_GPL(tcp_twsk_destructor); | 369 | EXPORT_SYMBOL_GPL(tcp_twsk_destructor); |
370 | 370 | ||
371 | static inline void TCP_ECN_openreq_child(struct tcp_sock *tp, | ||
372 | struct request_sock *req) | ||
373 | { | ||
374 | tp->ecn_flags = inet_rsk(req)->ecn_ok ? TCP_ECN_OK : 0; | ||
375 | } | ||
376 | |||
371 | /* This is not only more efficient than what we used to do, it eliminates | 377 | /* This is not only more efficient than what we used to do, it eliminates |
372 | * a lot of code duplication between IPv4/IPv6 SYN recv processing. -DaveM | 378 | * a lot of code duplication between IPv4/IPv6 SYN recv processing. -DaveM |
373 | * | 379 | * |
diff --git a/net/ipv4/tcp_output.c b/net/ipv4/tcp_output.c index b11025e8a49e..3abe22e4b576 100644 --- a/net/ipv4/tcp_output.c +++ b/net/ipv4/tcp_output.c | |||
@@ -269,6 +269,56 @@ static u16 tcp_select_window(struct sock *sk) | |||
269 | return new_win; | 269 | return new_win; |
270 | } | 270 | } |
271 | 271 | ||
272 | static inline void TCP_ECN_send_synack(struct tcp_sock *tp, | ||
273 | struct sk_buff *skb) | ||
274 | { | ||
275 | TCP_SKB_CB(skb)->flags &= ~TCPCB_FLAG_CWR; | ||
276 | if (!(tp->ecn_flags&TCP_ECN_OK)) | ||
277 | TCP_SKB_CB(skb)->flags &= ~TCPCB_FLAG_ECE; | ||
278 | } | ||
279 | |||
280 | static inline void TCP_ECN_send_syn(struct sock *sk, struct sk_buff *skb) | ||
281 | { | ||
282 | struct tcp_sock *tp = tcp_sk(sk); | ||
283 | |||
284 | tp->ecn_flags = 0; | ||
285 | if (sysctl_tcp_ecn) { | ||
286 | TCP_SKB_CB(skb)->flags |= TCPCB_FLAG_ECE|TCPCB_FLAG_CWR; | ||
287 | tp->ecn_flags = TCP_ECN_OK; | ||
288 | } | ||
289 | } | ||
290 | |||
291 | static __inline__ void | ||
292 | TCP_ECN_make_synack(struct request_sock *req, struct tcphdr *th) | ||
293 | { | ||
294 | if (inet_rsk(req)->ecn_ok) | ||
295 | th->ece = 1; | ||
296 | } | ||
297 | |||
298 | static inline void TCP_ECN_send(struct sock *sk, struct sk_buff *skb, | ||
299 | int tcp_header_len) | ||
300 | { | ||
301 | struct tcp_sock *tp = tcp_sk(sk); | ||
302 | |||
303 | if (tp->ecn_flags & TCP_ECN_OK) { | ||
304 | /* Not-retransmitted data segment: set ECT and inject CWR. */ | ||
305 | if (skb->len != tcp_header_len && | ||
306 | !before(TCP_SKB_CB(skb)->seq, tp->snd_nxt)) { | ||
307 | INET_ECN_xmit(sk); | ||
308 | if (tp->ecn_flags&TCP_ECN_QUEUE_CWR) { | ||
309 | tp->ecn_flags &= ~TCP_ECN_QUEUE_CWR; | ||
310 | tcp_hdr(skb)->cwr = 1; | ||
311 | skb_shinfo(skb)->gso_type |= SKB_GSO_TCP_ECN; | ||
312 | } | ||
313 | } else { | ||
314 | /* ACK or retransmitted segment: clear ECT|CE */ | ||
315 | INET_ECN_dontxmit(sk); | ||
316 | } | ||
317 | if (tp->ecn_flags & TCP_ECN_DEMAND_CWR) | ||
318 | tcp_hdr(skb)->ece = 1; | ||
319 | } | ||
320 | } | ||
321 | |||
272 | static void tcp_build_and_update_options(__be32 *ptr, struct tcp_sock *tp, | 322 | static void tcp_build_and_update_options(__be32 *ptr, struct tcp_sock *tp, |
273 | __u32 tstamp, __u8 **md5_hash) | 323 | __u32 tstamp, __u8 **md5_hash) |
274 | { | 324 | { |