aboutsummaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
Diffstat (limited to 'net')
-rw-r--r--net/dccp/ccid.h18
-rw-r--r--net/dccp/dccp.h56
-rw-r--r--net/dccp/input.c100
-rw-r--r--net/dccp/ipv4.c114
-rw-r--r--net/dccp/minisocks.c37
-rw-r--r--net/dccp/options.c215
-rw-r--r--net/dccp/output.c44
-rw-r--r--net/dccp/packet_history.c11
-rw-r--r--net/dccp/packet_history.h6
-rw-r--r--net/dccp/proto.c51
-rw-r--r--net/dccp/timer.c36
11 files changed, 430 insertions, 258 deletions
diff --git a/net/dccp/ccid.h b/net/dccp/ccid.h
index 469f9a14b463..95eb47d85517 100644
--- a/net/dccp/ccid.h
+++ b/net/dccp/ccid.h
@@ -30,21 +30,26 @@ struct ccid {
30 int (*ccid_hc_tx_init)(struct sock *sk); 30 int (*ccid_hc_tx_init)(struct sock *sk);
31 void (*ccid_hc_rx_exit)(struct sock *sk); 31 void (*ccid_hc_rx_exit)(struct sock *sk);
32 void (*ccid_hc_tx_exit)(struct sock *sk); 32 void (*ccid_hc_tx_exit)(struct sock *sk);
33 void (*ccid_hc_rx_packet_recv)(struct sock *sk, struct sk_buff *skb); 33 void (*ccid_hc_rx_packet_recv)(struct sock *sk,
34 struct sk_buff *skb);
34 int (*ccid_hc_rx_parse_options)(struct sock *sk, 35 int (*ccid_hc_rx_parse_options)(struct sock *sk,
35 unsigned char option, 36 unsigned char option,
36 unsigned char len, u16 idx, 37 unsigned char len, u16 idx,
37 unsigned char* value); 38 unsigned char* value);
38 void (*ccid_hc_rx_insert_options)(struct sock *sk, struct sk_buff *skb); 39 void (*ccid_hc_rx_insert_options)(struct sock *sk,
39 void (*ccid_hc_tx_insert_options)(struct sock *sk, struct sk_buff *skb); 40 struct sk_buff *skb);
40 void (*ccid_hc_tx_packet_recv)(struct sock *sk, struct sk_buff *skb); 41 void (*ccid_hc_tx_insert_options)(struct sock *sk,
42 struct sk_buff *skb);
43 void (*ccid_hc_tx_packet_recv)(struct sock *sk,
44 struct sk_buff *skb);
41 int (*ccid_hc_tx_parse_options)(struct sock *sk, 45 int (*ccid_hc_tx_parse_options)(struct sock *sk,
42 unsigned char option, 46 unsigned char option,
43 unsigned char len, u16 idx, 47 unsigned char len, u16 idx,
44 unsigned char* value); 48 unsigned char* value);
45 int (*ccid_hc_tx_send_packet)(struct sock *sk, 49 int (*ccid_hc_tx_send_packet)(struct sock *sk,
46 struct sk_buff *skb, int len); 50 struct sk_buff *skb, int len);
47 void (*ccid_hc_tx_packet_sent)(struct sock *sk, int more, int len); 51 void (*ccid_hc_tx_packet_sent)(struct sock *sk, int more,
52 int len);
48}; 53};
49 54
50extern int ccid_register(struct ccid *ccid); 55extern int ccid_register(struct ccid *ccid);
@@ -123,7 +128,8 @@ static inline int ccid_hc_tx_parse_options(struct ccid *ccid, struct sock *sk,
123{ 128{
124 int rc = 0; 129 int rc = 0;
125 if (ccid->ccid_hc_tx_parse_options != NULL) 130 if (ccid->ccid_hc_tx_parse_options != NULL)
126 rc = ccid->ccid_hc_tx_parse_options(sk, option, len, idx, value); 131 rc = ccid->ccid_hc_tx_parse_options(sk, option, len, idx,
132 value);
127 return rc; 133 return rc;
128} 134}
129 135
diff --git a/net/dccp/dccp.h b/net/dccp/dccp.h
index 8a0d7af649e4..62e735f1807d 100644
--- a/net/dccp/dccp.h
+++ b/net/dccp/dccp.h
@@ -25,7 +25,8 @@ extern int dccp_debug;
25 do { if (dccp_debug) \ 25 do { if (dccp_debug) \
26 printk(KERN_DEBUG "%s: " format, __FUNCTION__ , ##a); \ 26 printk(KERN_DEBUG "%s: " format, __FUNCTION__ , ##a); \
27 } while (0) 27 } while (0)
28#define dccp_pr_debug_cat(format, a...) do { if (dccp_debug) printk(format, ##a); } while (0) 28#define dccp_pr_debug_cat(format, a...) do { if (dccp_debug) \
29 printk(format, ##a); } while (0)
29#else 30#else
30#define dccp_pr_debug(format, a...) 31#define dccp_pr_debug(format, a...)
31#define dccp_pr_debug_cat(format, a...) 32#define dccp_pr_debug_cat(format, a...)
@@ -72,7 +73,8 @@ static inline const int after48(const u64 seq1, const u64 seq2)
72} 73}
73 74
74/* is seq2 <= seq1 <= seq3 ? */ 75/* is seq2 <= seq1 <= seq3 ? */
75static inline const int between48(const u64 seq1, const u64 seq2, const u64 seq3) 76static inline const int between48(const u64 seq1, const u64 seq2,
77 const u64 seq3)
76{ 78{
77 return (seq3 << 16) - (seq2 << 16) >= (seq1 << 16) - (seq2 << 16); 79 return (seq3 << 16) - (seq2 << 16) >= (seq1 << 16) - (seq2 << 16);
78} 80}
@@ -107,12 +109,14 @@ struct dccp_mib {
107} __SNMP_MIB_ALIGN__; 109} __SNMP_MIB_ALIGN__;
108 110
109DECLARE_SNMP_STAT(struct dccp_mib, dccp_statistics); 111DECLARE_SNMP_STAT(struct dccp_mib, dccp_statistics);
110#define DCCP_INC_STATS(field) SNMP_INC_STATS(dccp_statistics, field) 112#define DCCP_INC_STATS(field) SNMP_INC_STATS(dccp_statistics, field)
111#define DCCP_INC_STATS_BH(field) SNMP_INC_STATS_BH(dccp_statistics, field) 113#define DCCP_INC_STATS_BH(field) SNMP_INC_STATS_BH(dccp_statistics, field)
112#define DCCP_INC_STATS_USER(field) SNMP_INC_STATS_USER(dccp_statistics, field) 114#define DCCP_INC_STATS_USER(field) SNMP_INC_STATS_USER(dccp_statistics, field)
113#define DCCP_DEC_STATS(field) SNMP_DEC_STATS(dccp_statistics, field) 115#define DCCP_DEC_STATS(field) SNMP_DEC_STATS(dccp_statistics, field)
114#define DCCP_ADD_STATS_BH(field, val) SNMP_ADD_STATS_BH(dccp_statistics, field, val) 116#define DCCP_ADD_STATS_BH(field, val) \
115#define DCCP_ADD_STATS_USER(field, val) SNMP_ADD_STATS_USER(dccp_statistics, field, val) 117 SNMP_ADD_STATS_BH(dccp_statistics, field, val)
118#define DCCP_ADD_STATS_USER(field, val) \
119 SNMP_ADD_STATS_USER(dccp_statistics, field, val)
116 120
117extern int dccp_transmit_skb(struct sock *sk, struct sk_buff *skb); 121extern int dccp_transmit_skb(struct sock *sk, struct sk_buff *skb);
118extern int dccp_retransmit_skb(struct sock *sk, struct sk_buff *skb); 122extern int dccp_retransmit_skb(struct sock *sk, struct sk_buff *skb);
@@ -234,8 +238,8 @@ extern int dccp_disconnect(struct sock *sk, int flags);
234extern int dccp_getsockopt(struct sock *sk, int level, int optname, 238extern int dccp_getsockopt(struct sock *sk, int level, int optname,
235 char *optval, int *optlen); 239 char *optval, int *optlen);
236extern int dccp_ioctl(struct sock *sk, int cmd, unsigned long arg); 240extern int dccp_ioctl(struct sock *sk, int cmd, unsigned long arg);
237extern int dccp_sendmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg, 241extern int dccp_sendmsg(struct kiocb *iocb, struct sock *sk,
238 size_t size); 242 struct msghdr *msg, size_t size);
239extern int dccp_recvmsg(struct kiocb *iocb, struct sock *sk, 243extern int dccp_recvmsg(struct kiocb *iocb, struct sock *sk,
240 struct msghdr *msg, size_t len, int nonblock, 244 struct msghdr *msg, size_t len, int nonblock,
241 int flags, int *addr_len); 245 int flags, int *addr_len);
@@ -246,7 +250,8 @@ extern void dccp_shutdown(struct sock *sk, int how);
246extern int dccp_v4_checksum(const struct sk_buff *skb, 250extern int dccp_v4_checksum(const struct sk_buff *skb,
247 const u32 saddr, const u32 daddr); 251 const u32 saddr, const u32 daddr);
248 252
249extern int dccp_v4_send_reset(struct sock *sk, enum dccp_reset_codes code); 253extern int dccp_v4_send_reset(struct sock *sk,
254 enum dccp_reset_codes code);
250extern void dccp_send_close(struct sock *sk); 255extern void dccp_send_close(struct sock *sk);
251 256
252struct dccp_skb_cb { 257struct dccp_skb_cb {
@@ -303,7 +308,8 @@ static inline void dccp_inc_seqno(u64 *seqno)
303 308
304static inline void dccp_hdr_set_seq(struct dccp_hdr *dh, const u64 gss) 309static inline void dccp_hdr_set_seq(struct dccp_hdr *dh, const u64 gss)
305{ 310{
306 struct dccp_hdr_ext *dhx = (struct dccp_hdr_ext *)((void *)dh + sizeof(*dh)); 311 struct dccp_hdr_ext *dhx = (struct dccp_hdr_ext *)((void *)dh +
312 sizeof(*dh));
307 313
308#if defined(__LITTLE_ENDIAN_BITFIELD) 314#if defined(__LITTLE_ENDIAN_BITFIELD)
309 dh->dccph_seq = htonl((gss >> 32)) >> 8; 315 dh->dccph_seq = htonl((gss >> 32)) >> 8;
@@ -315,7 +321,8 @@ static inline void dccp_hdr_set_seq(struct dccp_hdr *dh, const u64 gss)
315 dhx->dccph_seq_low = htonl(gss & 0xffffffff); 321 dhx->dccph_seq_low = htonl(gss & 0xffffffff);
316} 322}
317 323
318static inline void dccp_hdr_set_ack(struct dccp_hdr_ack_bits *dhack, const u64 gsr) 324static inline void dccp_hdr_set_ack(struct dccp_hdr_ack_bits *dhack,
325 const u64 gsr)
319{ 326{
320#if defined(__LITTLE_ENDIAN_BITFIELD) 327#if defined(__LITTLE_ENDIAN_BITFIELD)
321 dhack->dccph_ack_nr_high = htonl((gsr >> 32)) >> 8; 328 dhack->dccph_ack_nr_high = htonl((gsr >> 32)) >> 8;
@@ -332,11 +339,14 @@ static inline void dccp_update_gsr(struct sock *sk, u64 seq)
332 struct dccp_sock *dp = dccp_sk(sk); 339 struct dccp_sock *dp = dccp_sk(sk);
333 u64 tmp_gsr; 340 u64 tmp_gsr;
334 341
335 dccp_set_seqno(&tmp_gsr, dp->dccps_gsr + 1 - (dp->dccps_options.dccpo_sequence_window / 4)); 342 dccp_set_seqno(&tmp_gsr,
343 (dp->dccps_gsr + 1 -
344 (dp->dccps_options.dccpo_sequence_window / 4)));
336 dp->dccps_gsr = seq; 345 dp->dccps_gsr = seq;
337 dccp_set_seqno(&dp->dccps_swl, max48(tmp_gsr, dp->dccps_isr)); 346 dccp_set_seqno(&dp->dccps_swl, max48(tmp_gsr, dp->dccps_isr));
338 dccp_set_seqno(&dp->dccps_swh, 347 dccp_set_seqno(&dp->dccps_swh,
339 dp->dccps_gsr + (3 * dp->dccps_options.dccpo_sequence_window) / 4); 348 (dp->dccps_gsr +
349 (3 * dp->dccps_options.dccpo_sequence_window) / 4));
340} 350}
341 351
342static inline void dccp_update_gss(struct sock *sk, u64 seq) 352static inline void dccp_update_gss(struct sock *sk, u64 seq)
@@ -344,7 +354,9 @@ static inline void dccp_update_gss(struct sock *sk, u64 seq)
344 struct dccp_sock *dp = dccp_sk(sk); 354 struct dccp_sock *dp = dccp_sk(sk);
345 u64 tmp_gss; 355 u64 tmp_gss;
346 356
347 dccp_set_seqno(&tmp_gss, dp->dccps_gss - dp->dccps_options.dccpo_sequence_window + 1); 357 dccp_set_seqno(&tmp_gss,
358 (dp->dccps_gss -
359 dp->dccps_options.dccpo_sequence_window + 1));
348 dp->dccps_awl = max48(tmp_gss, dp->dccps_iss); 360 dp->dccps_awl = max48(tmp_gss, dp->dccps_iss);
349 dp->dccps_awh = dp->dccps_gss = seq; 361 dp->dccps_awh = dp->dccps_gss = seq;
350} 362}
@@ -373,16 +385,20 @@ extern struct socket *dccp_ctl_socket;
373 * 385 *
374 * @dccpap_buf_head - circular buffer head 386 * @dccpap_buf_head - circular buffer head
375 * @dccpap_buf_tail - circular buffer tail 387 * @dccpap_buf_tail - circular buffer tail
376 * @dccpap_buf_ackno - ack # of the most recent packet acknoldgeable in the buffer (i.e. %dccpap_buf_head) 388 * @dccpap_buf_ackno - ack # of the most recent packet acknowledgeable in the
377 * @dccpap_buf_nonce - the one-bit sum of the ECN Nonces on all packets acked by the buffer with State 0 389 * buffer (i.e. %dccpap_buf_head)
390 * @dccpap_buf_nonce - the one-bit sum of the ECN Nonces on all packets acked
391 * by the buffer with State 0
378 * 392 *
379 * Additionally, the HC-Receiver must keep some information about the 393 * Additionally, the HC-Receiver must keep some information about the
380 * Ack Vectors it has recently sent. For each packet sent carrying an 394 * Ack Vectors it has recently sent. For each packet sent carrying an
381 * Ack Vector, it remembers four variables: 395 * Ack Vector, it remembers four variables:
382 * 396 *
383 * @dccpap_ack_seqno - the Sequence Number used for the packet (HC-Receiver seqno) 397 * @dccpap_ack_seqno - the Sequence Number used for the packet
398 * (HC-Receiver seqno)
384 * @dccpap_ack_ptr - the value of buf_head at the time of acknowledgement. 399 * @dccpap_ack_ptr - the value of buf_head at the time of acknowledgement.
385 * @dccpap_ack_ackno - the Acknowledgement Number used for the packet (HC-Sender seqno) 400 * @dccpap_ack_ackno - the Acknowledgement Number used for the packet
401 * (HC-Sender seqno)
386 * @dccpap_ack_nonce - the one-bit sum of the ECN Nonces for all State 0. 402 * @dccpap_ack_nonce - the one-bit sum of the ECN Nonces for all State 0.
387 * 403 *
388 * @dccpap_buf_len - circular buffer length 404 * @dccpap_buf_len - circular buffer length
diff --git a/net/dccp/input.c b/net/dccp/input.c
index bdaecde0bde1..4b8638f153a5 100644
--- a/net/dccp/input.c
+++ b/net/dccp/input.c
@@ -93,7 +93,8 @@ static int dccp_check_seqno(struct sock *sk, struct sk_buff *skb)
93 */ 93 */
94 if (dh->dccph_type == DCCP_PKT_SYNC || 94 if (dh->dccph_type == DCCP_PKT_SYNC ||
95 dh->dccph_type == DCCP_PKT_SYNCACK) { 95 dh->dccph_type == DCCP_PKT_SYNCACK) {
96 if (between48(DCCP_SKB_CB(skb)->dccpd_ack_seq, dp->dccps_awl, dp->dccps_awh) && 96 if (between48(DCCP_SKB_CB(skb)->dccpd_ack_seq,
97 dp->dccps_awl, dp->dccps_awh) &&
97 !before48(DCCP_SKB_CB(skb)->dccpd_seq, dp->dccps_swl)) 98 !before48(DCCP_SKB_CB(skb)->dccpd_seq, dp->dccps_swl))
98 dccp_update_gsr(sk, DCCP_SKB_CB(skb)->dccpd_seq); 99 dccp_update_gsr(sk, DCCP_SKB_CB(skb)->dccpd_seq);
99 else 100 else
@@ -122,11 +123,13 @@ static int dccp_check_seqno(struct sock *sk, struct sk_buff *skb)
122 123
123 if (between48(DCCP_SKB_CB(skb)->dccpd_seq, lswl, dp->dccps_swh) && 124 if (between48(DCCP_SKB_CB(skb)->dccpd_seq, lswl, dp->dccps_swh) &&
124 (DCCP_SKB_CB(skb)->dccpd_ack_seq == DCCP_PKT_WITHOUT_ACK_SEQ || 125 (DCCP_SKB_CB(skb)->dccpd_ack_seq == DCCP_PKT_WITHOUT_ACK_SEQ ||
125 between48(DCCP_SKB_CB(skb)->dccpd_ack_seq, lawl, dp->dccps_awh))) { 126 between48(DCCP_SKB_CB(skb)->dccpd_ack_seq,
127 lawl, dp->dccps_awh))) {
126 dccp_update_gsr(sk, DCCP_SKB_CB(skb)->dccpd_seq); 128 dccp_update_gsr(sk, DCCP_SKB_CB(skb)->dccpd_seq);
127 129
128 if (dh->dccph_type != DCCP_PKT_SYNC && 130 if (dh->dccph_type != DCCP_PKT_SYNC &&
129 DCCP_SKB_CB(skb)->dccpd_ack_seq != DCCP_PKT_WITHOUT_ACK_SEQ) 131 (DCCP_SKB_CB(skb)->dccpd_ack_seq !=
132 DCCP_PKT_WITHOUT_ACK_SEQ))
130 dp->dccps_gar = DCCP_SKB_CB(skb)->dccpd_ack_seq; 133 dp->dccps_gar = DCCP_SKB_CB(skb)->dccpd_ack_seq;
131 } else { 134 } else {
132 dccp_pr_debug("Step 6 failed, sending SYNC...\n"); 135 dccp_pr_debug("Step 6 failed, sending SYNC...\n");
@@ -161,10 +164,13 @@ int dccp_rcv_established(struct sock *sk, struct sk_buff *skb,
161 if (dccp_ackpkts_add(dp->dccps_hc_rx_ackpkts, 164 if (dccp_ackpkts_add(dp->dccps_hc_rx_ackpkts,
162 DCCP_SKB_CB(skb)->dccpd_seq, 165 DCCP_SKB_CB(skb)->dccpd_seq,
163 DCCP_ACKPKTS_STATE_RECEIVED)) { 166 DCCP_ACKPKTS_STATE_RECEIVED)) {
164 LIMIT_NETDEBUG(KERN_INFO "DCCP: acknowledgeable packets buffer full!\n"); 167 LIMIT_NETDEBUG(KERN_INFO "DCCP: acknowledgeable "
168 "packets buffer full!\n");
165 ap->dccpap_ack_seqno = DCCP_MAX_SEQNO + 1; 169 ap->dccpap_ack_seqno = DCCP_MAX_SEQNO + 1;
166 inet_csk_schedule_ack(sk); 170 inet_csk_schedule_ack(sk);
167 inet_csk_reset_xmit_timer(sk, ICSK_TIME_DACK, TCP_DELACK_MIN, TCP_RTO_MAX); 171 inet_csk_reset_xmit_timer(sk, ICSK_TIME_DACK,
172 TCP_DELACK_MIN,
173 DCCP_RTO_MAX);
168 goto discard; 174 goto discard;
169 } 175 }
170 176
@@ -175,7 +181,8 @@ int dccp_rcv_established(struct sock *sk, struct sk_buff *skb,
175 */ 181 */
176 if (!inet_csk_ack_scheduled(sk)) { 182 if (!inet_csk_ack_scheduled(sk)) {
177 inet_csk_schedule_ack(sk); 183 inet_csk_schedule_ack(sk);
178 inet_csk_reset_xmit_timer(sk, ICSK_TIME_DACK, 5 * HZ, TCP_RTO_MAX); 184 inet_csk_reset_xmit_timer(sk, ICSK_TIME_DACK, 5 * HZ,
185 DCCP_RTO_MAX);
179 } 186 }
180 } 187 }
181 188
@@ -186,8 +193,8 @@ int dccp_rcv_established(struct sock *sk, struct sk_buff *skb,
186 case DCCP_PKT_DATAACK: 193 case DCCP_PKT_DATAACK:
187 case DCCP_PKT_DATA: 194 case DCCP_PKT_DATA:
188 /* 195 /*
189 * FIXME: check if sk_receive_queue is full, schedule DATA_DROPPED option 196 * FIXME: check if sk_receive_queue is full, schedule DATA_DROPPED
190 * if it is. 197 * option if it is.
191 */ 198 */
192 __skb_pull(skb, dh->dccph_doff * 4); 199 __skb_pull(skb, dh->dccph_doff * 4);
193 __skb_queue_tail(&sk->sk_receive_queue, skb); 200 __skb_queue_tail(&sk->sk_receive_queue, skb);
@@ -272,11 +279,13 @@ static int dccp_rcv_request_sent_state_process(struct sock *sk,
272 __kfree_skb(sk->sk_send_head); 279 __kfree_skb(sk->sk_send_head);
273 sk->sk_send_head = NULL; 280 sk->sk_send_head = NULL;
274 281
275 if (!between48(DCCP_SKB_CB(skb)->dccpd_ack_seq, dp->dccps_awl, dp->dccps_awh)) { 282 if (!between48(DCCP_SKB_CB(skb)->dccpd_ack_seq,
276 dccp_pr_debug("invalid ackno: S.AWL=%llu, P.ackno=%llu, S.AWH=%llu \n", 283 dp->dccps_awl, dp->dccps_awh)) {
277 (unsigned long long) dp->dccps_awl, 284 dccp_pr_debug("invalid ackno: S.AWL=%llu, "
278 (unsigned long long) DCCP_SKB_CB(skb)->dccpd_ack_seq, 285 "P.ackno=%llu, S.AWH=%llu \n",
279 (unsigned long long) dp->dccps_awh); 286 (unsigned long long)dp->dccps_awl,
287 (unsigned long long)DCCP_SKB_CB(skb)->dccpd_ack_seq,
288 (unsigned long long)dp->dccps_awh);
280 goto out_invalid_packet; 289 goto out_invalid_packet;
281 } 290 }
282 291
@@ -296,16 +305,17 @@ static int dccp_rcv_request_sent_state_process(struct sock *sk,
296 /* 305 /*
297 * Step 10: Process REQUEST state (second part) 306 * Step 10: Process REQUEST state (second part)
298 * If S.state == REQUEST, 307 * If S.state == REQUEST,
299 * / * If we get here, P is a valid Response from the server (see 308 * / * If we get here, P is a valid Response from the
300 * Step 4), and we should move to PARTOPEN state. PARTOPEN 309 * server (see Step 4), and we should move to
301 * means send an Ack, don't send Data packets, retransmit 310 * PARTOPEN state. PARTOPEN means send an Ack,
302 * Acks periodically, and always include any Init Cookie from 311 * don't send Data packets, retransmit Acks
303 * the Response * / 312 * periodically, and always include any Init Cookie
313 * from the Response * /
304 * S.state := PARTOPEN 314 * S.state := PARTOPEN
305 * Set PARTOPEN timer 315 * Set PARTOPEN timer
306 * Continue with S.state == PARTOPEN 316 * Continue with S.state == PARTOPEN
307 * / * Step 12 will send the Ack completing the three-way 317 * / * Step 12 will send the Ack completing the
308 * handshake * / 318 * three-way handshake * /
309 */ 319 */
310 dccp_set_state(sk, DCCP_PARTOPEN); 320 dccp_set_state(sk, DCCP_PARTOPEN);
311 321
@@ -341,7 +351,8 @@ static int dccp_rcv_request_sent_state_process(struct sock *sk,
341 351
342out_invalid_packet: 352out_invalid_packet:
343 return 1; /* dccp_v4_do_rcv will send a reset, but... 353 return 1; /* dccp_v4_do_rcv will send a reset, but...
344 FIXME: the reset code should be DCCP_RESET_CODE_PACKET_ERROR */ 354 FIXME: the reset code should be
355 DCCP_RESET_CODE_PACKET_ERROR */
345} 356}
346 357
347static int dccp_rcv_respond_partopen_state_process(struct sock *sk, 358static int dccp_rcv_respond_partopen_state_process(struct sock *sk,
@@ -358,11 +369,12 @@ static int dccp_rcv_respond_partopen_state_process(struct sock *sk,
358 case DCCP_PKT_DATAACK: 369 case DCCP_PKT_DATAACK:
359 case DCCP_PKT_ACK: 370 case DCCP_PKT_ACK:
360 /* 371 /*
361 * FIXME: we should be reseting the PARTOPEN (DELACK) timer here, 372 * FIXME: we should be reseting the PARTOPEN (DELACK) timer
362 * but only if we haven't used the DELACK timer for something else, 373 * here but only if we haven't used the DELACK timer for
363 * like sending a delayed ack for a TIMESTAMP echo, etc, for now 374 * something else, like sending a delayed ack for a TIMESTAMP
364 * were not clearing it, sending an extra ACK when there is nothing 375 * echo, etc, for now were not clearing it, sending an extra
365 * else to do in DELACK is not a big deal after all. 376 * ACK when there is nothing else to do in DELACK is not a big
377 * deal after all.
366 */ 378 */
367 379
368 /* Stop the PARTOPEN timer */ 380 /* Stop the PARTOPEN timer */
@@ -374,7 +386,8 @@ static int dccp_rcv_respond_partopen_state_process(struct sock *sk,
374 386
375 if (dh->dccph_type == DCCP_PKT_DATAACK) { 387 if (dh->dccph_type == DCCP_PKT_DATAACK) {
376 dccp_rcv_established(sk, skb, dh, len); 388 dccp_rcv_established(sk, skb, dh, len);
377 queued = 1; /* packet was queued (by dccp_rcv_established) */ 389 queued = 1; /* packet was queued
390 (by dccp_rcv_established) */
378 } 391 }
379 break; 392 break;
380 } 393 }
@@ -399,7 +412,8 @@ int dccp_rcv_state_process(struct sock *sk, struct sk_buff *skb,
399 if (dccp_parse_options(sk, skb)) 412 if (dccp_parse_options(sk, skb))
400 goto discard; 413 goto discard;
401 414
402 if (DCCP_SKB_CB(skb)->dccpd_ack_seq != DCCP_PKT_WITHOUT_ACK_SEQ) 415 if (DCCP_SKB_CB(skb)->dccpd_ack_seq !=
416 DCCP_PKT_WITHOUT_ACK_SEQ)
403 dccp_event_ack_recv(sk, skb); 417 dccp_event_ack_recv(sk, skb);
404 418
405 ccid_hc_rx_packet_recv(dp->dccps_hc_rx_ccid, sk, skb); 419 ccid_hc_rx_packet_recv(dp->dccps_hc_rx_ccid, sk, skb);
@@ -415,14 +429,17 @@ int dccp_rcv_state_process(struct sock *sk, struct sk_buff *skb,
415 DCCP_ACKPKTS_STATE_RECEIVED)) 429 DCCP_ACKPKTS_STATE_RECEIVED))
416 goto discard; 430 goto discard;
417 /* 431 /*
418 * FIXME: this activation is probably wrong, have to study more 432 * FIXME: this activation is probably wrong, have to
419 * TCP delack machinery and how it fits into DCCP draft, but 433 * study more TCP delack machinery and how it fits into
420 * for now it kinda "works" 8) 434 * DCCP draft, but for now it kinda "works" 8)
421 */ 435 */
422 if (dp->dccps_hc_rx_ackpkts->dccpap_ack_seqno == DCCP_MAX_SEQNO + 1 && 436 if ((dp->dccps_hc_rx_ackpkts->dccpap_ack_seqno ==
437 DCCP_MAX_SEQNO + 1) &&
423 !inet_csk_ack_scheduled(sk)) { 438 !inet_csk_ack_scheduled(sk)) {
424 inet_csk_schedule_ack(sk); 439 inet_csk_schedule_ack(sk);
425 inet_csk_reset_xmit_timer(sk, ICSK_TIME_DACK, TCP_DELACK_MIN, TCP_RTO_MAX); 440 inet_csk_reset_xmit_timer(sk, ICSK_TIME_DACK,
441 TCP_DELACK_MIN,
442 DCCP_RTO_MAX);
426 } 443 }
427 } 444 }
428 } 445 }
@@ -436,7 +453,10 @@ int dccp_rcv_state_process(struct sock *sk, struct sk_buff *skb,
436 * Drop packet and return 453 * Drop packet and return
437 */ 454 */
438 if (dh->dccph_type == DCCP_PKT_RESET) { 455 if (dh->dccph_type == DCCP_PKT_RESET) {
439 /* Queue the equivalent of TCP fin so that dccp_recvmsg exits the loop */ 456 /*
457 * Queue the equivalent of TCP fin so that dccp_recvmsg
458 * exits the loop
459 */
440 dccp_fin(sk, skb); 460 dccp_fin(sk, skb);
441 dccp_time_wait(sk, DCCP_TIME_WAIT, 0); 461 dccp_time_wait(sk, DCCP_TIME_WAIT, 0);
442 return 0; 462 return 0;
@@ -450,10 +470,12 @@ int dccp_rcv_state_process(struct sock *sk, struct sk_buff *skb,
450 * Drop packet and return 470 * Drop packet and return
451 */ 471 */
452 } else if ((dp->dccps_role != DCCP_ROLE_CLIENT && 472 } else if ((dp->dccps_role != DCCP_ROLE_CLIENT &&
453 (dh->dccph_type == DCCP_PKT_RESPONSE || dh->dccph_type == DCCP_PKT_CLOSEREQ)) || 473 (dh->dccph_type == DCCP_PKT_RESPONSE ||
474 dh->dccph_type == DCCP_PKT_CLOSEREQ)) ||
454 (dp->dccps_role == DCCP_ROLE_CLIENT && 475 (dp->dccps_role == DCCP_ROLE_CLIENT &&
455 dh->dccph_type == DCCP_PKT_REQUEST) || 476 dh->dccph_type == DCCP_PKT_REQUEST) ||
456 (sk->sk_state == DCCP_RESPOND && dh->dccph_type == DCCP_PKT_DATA)) { 477 (sk->sk_state == DCCP_RESPOND &&
478 dh->dccph_type == DCCP_PKT_DATA)) {
457 dccp_send_sync(sk, DCCP_SKB_CB(skb)->dccpd_seq); 479 dccp_send_sync(sk, DCCP_SKB_CB(skb)->dccpd_seq);
458 goto discard; 480 goto discard;
459 } 481 }
@@ -491,11 +513,13 @@ int dccp_rcv_state_process(struct sock *sk, struct sk_buff *skb,
491 513
492 case DCCP_RESPOND: 514 case DCCP_RESPOND:
493 case DCCP_PARTOPEN: 515 case DCCP_PARTOPEN:
494 queued = dccp_rcv_respond_partopen_state_process(sk, skb, dh, len); 516 queued = dccp_rcv_respond_partopen_state_process(sk, skb,
517 dh, len);
495 break; 518 break;
496 } 519 }
497 520
498 if (dh->dccph_type == DCCP_PKT_ACK || dh->dccph_type == DCCP_PKT_DATAACK) { 521 if (dh->dccph_type == DCCP_PKT_ACK ||
522 dh->dccph_type == DCCP_PKT_DATAACK) {
499 switch (old_state) { 523 switch (old_state) {
500 case DCCP_PARTOPEN: 524 case DCCP_PARTOPEN:
501 sk->sk_state_change(sk); 525 sk->sk_state_change(sk);
diff --git a/net/dccp/ipv4.c b/net/dccp/ipv4.c
index d3770aed3b15..42d9c878d4c3 100644
--- a/net/dccp/ipv4.c
+++ b/net/dccp/ipv4.c
@@ -29,7 +29,7 @@
29struct inet_hashinfo __cacheline_aligned dccp_hashinfo = { 29struct inet_hashinfo __cacheline_aligned dccp_hashinfo = {
30 .lhash_lock = RW_LOCK_UNLOCKED, 30 .lhash_lock = RW_LOCK_UNLOCKED,
31 .lhash_users = ATOMIC_INIT(0), 31 .lhash_users = ATOMIC_INIT(0),
32 .lhash_wait = __WAIT_QUEUE_HEAD_INITIALIZER(dccp_hashinfo.lhash_wait), 32 .lhash_wait = __WAIT_QUEUE_HEAD_INITIALIZER(dccp_hashinfo.lhash_wait),
33 .portalloc_lock = SPIN_LOCK_UNLOCKED, 33 .portalloc_lock = SPIN_LOCK_UNLOCKED,
34 .port_rover = 1024 - 1, 34 .port_rover = 1024 - 1,
35}; 35};
@@ -61,7 +61,8 @@ static int __dccp_v4_check_established(struct sock *sk, const __u16 lport,
61 const int dif = sk->sk_bound_dev_if; 61 const int dif = sk->sk_bound_dev_if;
62 INET_ADDR_COOKIE(acookie, saddr, daddr) 62 INET_ADDR_COOKIE(acookie, saddr, daddr)
63 const __u32 ports = INET_COMBINED_PORTS(inet->dport, lport); 63 const __u32 ports = INET_COMBINED_PORTS(inet->dport, lport);
64 const int hash = inet_ehashfn(daddr, lport, saddr, inet->dport, dccp_hashinfo.ehash_size); 64 const int hash = inet_ehashfn(daddr, lport, saddr, inet->dport,
65 dccp_hashinfo.ehash_size);
65 struct inet_ehash_bucket *head = &dccp_hashinfo.ehash[hash]; 66 struct inet_ehash_bucket *head = &dccp_hashinfo.ehash[hash];
66 const struct sock *sk2; 67 const struct sock *sk2;
67 const struct hlist_node *node; 68 const struct hlist_node *node;
@@ -133,11 +134,12 @@ static int dccp_v4_hash_connect(struct sock *sk)
133 local_bh_disable(); 134 local_bh_disable();
134 135
135 /* TODO. Actually it is not so bad idea to remove 136 /* TODO. Actually it is not so bad idea to remove
136 * dccp_hashinfo.portalloc_lock before next submission to Linus. 137 * dccp_hashinfo.portalloc_lock before next submission to
138 * Linus.
137 * As soon as we touch this place at all it is time to think. 139 * As soon as we touch this place at all it is time to think.
138 * 140 *
139 * Now it protects single _advisory_ variable dccp_hashinfo.port_rover, 141 * Now it protects single _advisory_ variable
140 * hence it is mostly useless. 142 * dccp_hashinfo.port_rover, hence it is mostly useless.
141 * Code will work nicely if we just delete it, but 143 * Code will work nicely if we just delete it, but
142 * I am afraid in contented case it will work not better or 144 * I am afraid in contented case it will work not better or
143 * even worse: another cpu just will hit the same bucket 145 * even worse: another cpu just will hit the same bucket
@@ -152,7 +154,8 @@ static int dccp_v4_hash_connect(struct sock *sk)
152 rover++; 154 rover++;
153 if ((rover < low) || (rover > high)) 155 if ((rover < low) || (rover > high))
154 rover = low; 156 rover = low;
155 head = &dccp_hashinfo.bhash[inet_bhashfn(rover, dccp_hashinfo.bhash_size)]; 157 head = &dccp_hashinfo.bhash[inet_bhashfn(rover,
158 dccp_hashinfo.bhash_size)];
156 spin_lock(&head->lock); 159 spin_lock(&head->lock);
157 160
158 /* Does not bother with rcv_saddr checks, 161 /* Does not bother with rcv_saddr checks,
@@ -172,7 +175,8 @@ static int dccp_v4_hash_connect(struct sock *sk)
172 } 175 }
173 } 176 }
174 177
175 tb = inet_bind_bucket_create(dccp_hashinfo.bind_bucket_cachep, head, rover); 178 tb = inet_bind_bucket_create(dccp_hashinfo.bind_bucket_cachep,
179 head, rover);
176 if (tb == NULL) { 180 if (tb == NULL) {
177 spin_unlock(&head->lock); 181 spin_unlock(&head->lock);
178 break; 182 break;
@@ -211,7 +215,8 @@ ok:
211 goto out; 215 goto out;
212 } 216 }
213 217
214 head = &dccp_hashinfo.bhash[inet_bhashfn(snum, dccp_hashinfo.bhash_size)]; 218 head = &dccp_hashinfo.bhash[inet_bhashfn(snum,
219 dccp_hashinfo.bhash_size)];
215 tb = inet_csk(sk)->icsk_bind_hash; 220 tb = inet_csk(sk)->icsk_bind_hash;
216 spin_lock_bh(&head->lock); 221 spin_lock_bh(&head->lock);
217 if (sk_head(&tb->owners) == sk && sk->sk_bind_node.next == NULL) { 222 if (sk_head(&tb->owners) == sk && sk->sk_bind_node.next == NULL) {
@@ -313,7 +318,9 @@ static int dccp_v4_connect(struct sock *sk, struct sockaddr *uaddr,
313out: 318out:
314 return err; 319 return err;
315failure: 320failure:
316 /* This unhashes the socket and releases the local port, if necessary. */ 321 /*
322 * This unhashes the socket and releases the local port, if necessary.
323 */
317 dccp_set_state(sk, DCCP_CLOSED); 324 dccp_set_state(sk, DCCP_CLOSED);
318 ip_rt_put(rt); 325 ip_rt_put(rt);
319 sk->sk_route_caps = 0; 326 sk->sk_route_caps = 0;
@@ -365,8 +372,9 @@ static inline void dccp_do_pmtu_discovery(struct sock *sk,
365 /* 372 /*
366 * From: draft-ietf-dccp-spec-11.txt 373 * From: draft-ietf-dccp-spec-11.txt
367 * 374 *
368 * DCCP-Sync packets are the best choice for upward probing, 375 * DCCP-Sync packets are the best choice for upward
369 * since DCCP-Sync probes do not risk application data loss. 376 * probing, since DCCP-Sync probes do not risk application
377 * data loss.
370 */ 378 */
371 dccp_send_sync(sk, dp->dccps_gsr); 379 dccp_send_sync(sk, dp->dccps_gsr);
372 } /* else let the usual retransmit timer handle it */ 380 } /* else let the usual retransmit timer handle it */
@@ -405,11 +413,13 @@ static void dccp_v4_ctl_send_ack(struct sk_buff *rxskb)
405 dh->dccph_x = 1; 413 dh->dccph_x = 1;
406 414
407 dccp_hdr_set_seq(dh, DCCP_SKB_CB(rxskb)->dccpd_ack_seq); 415 dccp_hdr_set_seq(dh, DCCP_SKB_CB(rxskb)->dccpd_ack_seq);
408 dccp_hdr_set_ack(dccp_hdr_ack_bits(skb), DCCP_SKB_CB(rxskb)->dccpd_seq); 416 dccp_hdr_set_ack(dccp_hdr_ack_bits(skb),
417 DCCP_SKB_CB(rxskb)->dccpd_seq);
409 418
410 bh_lock_sock(dccp_ctl_socket->sk); 419 bh_lock_sock(dccp_ctl_socket->sk);
411 err = ip_build_and_send_pkt(skb, dccp_ctl_socket->sk, 420 err = ip_build_and_send_pkt(skb, dccp_ctl_socket->sk,
412 rxskb->nh.iph->daddr, rxskb->nh.iph->saddr, NULL); 421 rxskb->nh.iph->daddr,
422 rxskb->nh.iph->saddr, NULL);
413 bh_unlock_sock(dccp_ctl_socket->sk); 423 bh_unlock_sock(dccp_ctl_socket->sk);
414 424
415 if (err == NET_XMIT_CN || err == 0) { 425 if (err == NET_XMIT_CN || err == 0) {
@@ -418,7 +428,8 @@ static void dccp_v4_ctl_send_ack(struct sk_buff *rxskb)
418 } 428 }
419} 429}
420 430
421static void dccp_v4_reqsk_send_ack(struct sk_buff *skb, struct request_sock *req) 431static void dccp_v4_reqsk_send_ack(struct sk_buff *skb,
432 struct request_sock *req)
422{ 433{
423 dccp_v4_ctl_send_ack(skb); 434 dccp_v4_ctl_send_ack(skb);
424} 435}
@@ -465,7 +476,8 @@ out:
465void dccp_v4_err(struct sk_buff *skb, u32 info) 476void dccp_v4_err(struct sk_buff *skb, u32 info)
466{ 477{
467 const struct iphdr *iph = (struct iphdr *)skb->data; 478 const struct iphdr *iph = (struct iphdr *)skb->data;
468 const struct dccp_hdr *dh = (struct dccp_hdr *)(skb->data + (iph->ihl << 2)); 479 const struct dccp_hdr *dh = (struct dccp_hdr *)(skb->data +
480 (iph->ihl << 2));
469 struct dccp_sock *dp; 481 struct dccp_sock *dp;
470 struct inet_sock *inet; 482 struct inet_sock *inet;
471 const int type = skb->h.icmph->type; 483 const int type = skb->h.icmph->type;
@@ -605,7 +617,8 @@ out:
605 sock_put(sk); 617 sock_put(sk);
606} 618}
607 619
608extern struct sk_buff *dccp_make_reset(struct sock *sk, struct dst_entry *dst, enum dccp_reset_codes code); 620extern struct sk_buff *dccp_make_reset(struct sock *sk, struct dst_entry *dst,
621 enum dccp_reset_codes code);
609 622
610int dccp_v4_send_reset(struct sock *sk, enum dccp_reset_codes code) 623int dccp_v4_send_reset(struct sock *sk, enum dccp_reset_codes code)
611{ 624{
@@ -689,7 +702,8 @@ int dccp_v4_conn_request(struct sock *sk, struct sk_buff *skb)
689 ireq->loc_addr = daddr; 702 ireq->loc_addr = daddr;
690 ireq->rmt_addr = saddr; 703 ireq->rmt_addr = saddr;
691 /* FIXME: Merge Aristeu's option parsing code when ready */ 704 /* FIXME: Merge Aristeu's option parsing code when ready */
692 req->rcv_wnd = 100; /* Fake, option parsing will get the right value */ 705 req->rcv_wnd = 100; /* Fake, option parsing will get the
706 right value */
693 ireq->opt = NULL; 707 ireq->opt = NULL;
694 708
695 /* 709 /*
@@ -804,7 +818,8 @@ static struct sock *dccp_v4_hnd_req(struct sock *sk, struct sk_buff *skb)
804 return sk; 818 return sk;
805} 819}
806 820
807int dccp_v4_checksum(const struct sk_buff *skb, const u32 saddr, const u32 daddr) 821int dccp_v4_checksum(const struct sk_buff *skb, const u32 saddr,
822 const u32 daddr)
808{ 823{
809 const struct dccp_hdr* dh = dccp_hdr(skb); 824 const struct dccp_hdr* dh = dccp_hdr(skb);
810 int checksum_len; 825 int checksum_len;
@@ -814,11 +829,13 @@ int dccp_v4_checksum(const struct sk_buff *skb, const u32 saddr, const u32 daddr
814 checksum_len = skb->len; 829 checksum_len = skb->len;
815 else { 830 else {
816 checksum_len = (dh->dccph_cscov + dh->dccph_x) * sizeof(u32); 831 checksum_len = (dh->dccph_cscov + dh->dccph_x) * sizeof(u32);
817 checksum_len = checksum_len < skb->len ? checksum_len : skb->len; 832 checksum_len = checksum_len < skb->len ? checksum_len :
833 skb->len;
818 } 834 }
819 835
820 tmp = csum_partial((unsigned char *)dh, checksum_len, 0); 836 tmp = csum_partial((unsigned char *)dh, checksum_len, 0);
821 return csum_tcpudp_magic(saddr, daddr, checksum_len, IPPROTO_DCCP, tmp); 837 return csum_tcpudp_magic(saddr, daddr, checksum_len,
838 IPPROTO_DCCP, tmp);
822} 839}
823 840
824static int dccp_v4_verify_checksum(struct sk_buff *skb, 841static int dccp_v4_verify_checksum(struct sk_buff *skb,
@@ -832,10 +849,12 @@ static int dccp_v4_verify_checksum(struct sk_buff *skb,
832 checksum_len = skb->len; 849 checksum_len = skb->len;
833 else { 850 else {
834 checksum_len = (dh->dccph_cscov + dh->dccph_x) * sizeof(u32); 851 checksum_len = (dh->dccph_cscov + dh->dccph_x) * sizeof(u32);
835 checksum_len = checksum_len < skb->len ? checksum_len : skb->len; 852 checksum_len = checksum_len < skb->len ? checksum_len :
853 skb->len;
836 } 854 }
837 tmp = csum_partial((unsigned char *)dh, checksum_len, 0); 855 tmp = csum_partial((unsigned char *)dh, checksum_len, 0);
838 return csum_tcpudp_magic(saddr, daddr, checksum_len, IPPROTO_DCCP, tmp) == 0 ? 0 : -1; 856 return csum_tcpudp_magic(saddr, daddr, checksum_len,
857 IPPROTO_DCCP, tmp) == 0 ? 0 : -1;
839} 858}
840 859
841static struct dst_entry* dccp_v4_route_skb(struct sock *sk, 860static struct dst_entry* dccp_v4_route_skb(struct sock *sk,
@@ -850,7 +869,9 @@ static struct dst_entry* dccp_v4_route_skb(struct sock *sk,
850 .proto = sk->sk_protocol, 869 .proto = sk->sk_protocol,
851 .uli_u = { .ports = 870 .uli_u = { .ports =
852 { .sport = dccp_hdr(skb)->dccph_dport, 871 { .sport = dccp_hdr(skb)->dccph_dport,
853 .dport = dccp_hdr(skb)->dccph_sport } } }; 872 .dport = dccp_hdr(skb)->dccph_sport }
873 }
874 };
854 875
855 if (ip_route_output_flow(&rt, &fl, sk, 0)) { 876 if (ip_route_output_flow(&rt, &fl, sk, 0)) {
856 IP_INC_STATS_BH(IPSTATS_MIB_OUTNOROUTES); 877 IP_INC_STATS_BH(IPSTATS_MIB_OUTNOROUTES);
@@ -899,17 +920,20 @@ void dccp_v4_ctl_send_reset(struct sk_buff *rxskb)
899 dh->dccph_dport = rxdh->dccph_sport; 920 dh->dccph_dport = rxdh->dccph_sport;
900 dh->dccph_doff = dccp_hdr_reset_len / 4; 921 dh->dccph_doff = dccp_hdr_reset_len / 4;
901 dh->dccph_x = 1; 922 dh->dccph_x = 1;
902 dccp_hdr_reset(skb)->dccph_reset_code = DCCP_SKB_CB(rxskb)->dccpd_reset_code; 923 dccp_hdr_reset(skb)->dccph_reset_code =
924 DCCP_SKB_CB(rxskb)->dccpd_reset_code;
903 925
904 dccp_hdr_set_seq(dh, DCCP_SKB_CB(rxskb)->dccpd_ack_seq); 926 dccp_hdr_set_seq(dh, DCCP_SKB_CB(rxskb)->dccpd_ack_seq);
905 dccp_hdr_set_ack(dccp_hdr_ack_bits(skb), DCCP_SKB_CB(rxskb)->dccpd_seq); 927 dccp_hdr_set_ack(dccp_hdr_ack_bits(skb),
928 DCCP_SKB_CB(rxskb)->dccpd_seq);
906 929
907 dh->dccph_checksum = dccp_v4_checksum(skb, rxskb->nh.iph->saddr, 930 dh->dccph_checksum = dccp_v4_checksum(skb, rxskb->nh.iph->saddr,
908 rxskb->nh.iph->daddr); 931 rxskb->nh.iph->daddr);
909 932
910 bh_lock_sock(dccp_ctl_socket->sk); 933 bh_lock_sock(dccp_ctl_socket->sk);
911 err = ip_build_and_send_pkt(skb, dccp_ctl_socket->sk, 934 err = ip_build_and_send_pkt(skb, dccp_ctl_socket->sk,
912 rxskb->nh.iph->daddr, rxskb->nh.iph->saddr, NULL); 935 rxskb->nh.iph->daddr,
936 rxskb->nh.iph->saddr, NULL);
913 bh_unlock_sock(dccp_ctl_socket->sk); 937 bh_unlock_sock(dccp_ctl_socket->sk);
914 938
915 if (err == NET_XMIT_CN || err == 0) { 939 if (err == NET_XMIT_CN || err == 0) {
@@ -933,7 +957,8 @@ int dccp_v4_do_rcv(struct sock *sk, struct sk_buff *skb)
933 /* 957 /*
934 * Step 3: Process LISTEN state 958 * Step 3: Process LISTEN state
935 * If S.state == LISTEN, 959 * If S.state == LISTEN,
936 * If P.type == Request or P contains a valid Init Cookie option, 960 * If P.type == Request or P contains a valid Init Cookie
961 * option,
937 * * Must scan the packet's options to check for an Init 962 * * Must scan the packet's options to check for an Init
938 * Cookie. Only the Init Cookie is processed here, 963 * Cookie. Only the Init Cookie is processed here,
939 * however; other options are processed in Step 8. This 964 * however; other options are processed in Step 8. This
@@ -950,7 +975,8 @@ int dccp_v4_do_rcv(struct sock *sk, struct sk_buff *skb)
950 * Generate Reset(No Connection) unless P.type == Reset 975 * Generate Reset(No Connection) unless P.type == Reset
951 * Drop packet and return 976 * Drop packet and return
952 * 977 *
953 * NOTE: the check for the packet types is done in dccp_rcv_state_process 978 * NOTE: the check for the packet types is done in
979 * dccp_rcv_state_process
954 */ 980 */
955 if (sk->sk_state == DCCP_LISTEN) { 981 if (sk->sk_state == DCCP_LISTEN) {
956 struct sock *nsk = dccp_v4_hnd_req(sk, skb); 982 struct sock *nsk = dccp_v4_hnd_req(sk, skb);
@@ -1007,7 +1033,8 @@ static inline int dccp_invalid_packet(struct sk_buff *skb)
1007 } 1033 }
1008 1034
1009 if (!pskb_may_pull(skb, dh->dccph_doff * sizeof(u32))) { 1035 if (!pskb_may_pull(skb, dh->dccph_doff * sizeof(u32))) {
1010 dccp_pr_debug("P.Data Offset(%u) too small 2\n", dh->dccph_doff); 1036 dccp_pr_debug("P.Data Offset(%u) too small 2\n",
1037 dh->dccph_doff);
1011 return 1; 1038 return 1;
1012 } 1039 }
1013 1040
@@ -1021,8 +1048,8 @@ static inline int dccp_invalid_packet(struct sk_buff *skb)
1021 dh->dccph_type != DCCP_PKT_DATA && 1048 dh->dccph_type != DCCP_PKT_DATA &&
1022 dh->dccph_type != DCCP_PKT_ACK && 1049 dh->dccph_type != DCCP_PKT_ACK &&
1023 dh->dccph_type != DCCP_PKT_DATAACK) { 1050 dh->dccph_type != DCCP_PKT_DATAACK) {
1024 dccp_pr_debug("P.type (%s) not Data, Ack nor DataAck and P.X == 0\n", 1051 dccp_pr_debug("P.type (%s) not Data, Ack nor DataAck and "
1025 dccp_packet_name(dh->dccph_type)); 1052 "P.X == 0\n", dccp_packet_name(dh->dccph_type));
1026 return 1; 1053 return 1;
1027 } 1054 }
1028 1055
@@ -1055,10 +1082,11 @@ int dccp_v4_rcv(struct sk_buff *skb)
1055 * dccp_ackpkts_add, you'll get something like this on a session that 1082 * dccp_ackpkts_add, you'll get something like this on a session that
1056 * sends 10 DATA/DATAACK packets: 1083 * sends 10 DATA/DATAACK packets:
1057 * 1084 *
1058 * dccp_ackpkts_print: 281473596467422 |0,0|3,0|0,0|3,0|0,0|3,0|0,0|3,0|0,1| 1085 * ackpkts_print: 281473596467422 |0,0|3,0|0,0|3,0|0,0|3,0|0,0|3,0|0,1|
1059 * 1086 *
1060 * 0, 0 means: DCCP_ACKPKTS_STATE_RECEIVED, RLE == just this packet 1087 * 0, 0 means: DCCP_ACKPKTS_STATE_RECEIVED, RLE == just this packet
1061 * 0, 1 means: DCCP_ACKPKTS_STATE_RECEIVED, RLE == two adjacent packets with the same state 1088 * 0, 1 means: DCCP_ACKPKTS_STATE_RECEIVED, RLE == two adjacent packets
1089 * with the same state
1062 * 3, 0 means: DCCP_ACKPKTS_STATE_NOT_RECEIVED, RLE == just this packet 1090 * 3, 0 means: DCCP_ACKPKTS_STATE_NOT_RECEIVED, RLE == just this packet
1063 * 1091 *
1064 * So... 1092 * So...
@@ -1072,10 +1100,12 @@ int dccp_v4_rcv(struct sk_buff *skb)
1072 * 281473596467416 was received 1100 * 281473596467416 was received
1073 * 281473596467415 was not received 1101 * 281473596467415 was not received
1074 * 281473596467414 was received 1102 * 281473596467414 was received
1075 * 281473596467413 was received (this one was the 3way handshake RESPONSE) 1103 * 281473596467413 was received (this one was the 3way handshake
1104 * RESPONSE)
1076 * 1105 *
1077 */ 1106 */
1078 if (dh->dccph_type == DCCP_PKT_DATA || dh->dccph_type == DCCP_PKT_DATAACK) { 1107 if (dh->dccph_type == DCCP_PKT_DATA ||
1108 dh->dccph_type == DCCP_PKT_DATAACK) {
1079 static int discard = 0; 1109 static int discard = 0;
1080 1110
1081 if (discard) { 1111 if (discard) {
@@ -1170,7 +1200,8 @@ no_dccp_socket:
1170 * Drop packet and return 1200 * Drop packet and return
1171 */ 1201 */
1172 if (dh->dccph_type != DCCP_PKT_RESET) { 1202 if (dh->dccph_type != DCCP_PKT_RESET) {
1173 DCCP_SKB_CB(skb)->dccpd_reset_code = DCCP_RESET_CODE_NO_CONNECTION; 1203 DCCP_SKB_CB(skb)->dccpd_reset_code =
1204 DCCP_RESET_CODE_NO_CONNECTION;
1174 dccp_v4_ctl_send_reset(skb); 1205 dccp_v4_ctl_send_reset(skb);
1175 } 1206 }
1176 1207
@@ -1196,8 +1227,9 @@ static int dccp_v4_init_sock(struct sock *sk)
1196 dccp_options_init(&dp->dccps_options); 1227 dccp_options_init(&dp->dccps_options);
1197 1228
1198 if (dp->dccps_options.dccpo_send_ack_vector) { 1229 if (dp->dccps_options.dccpo_send_ack_vector) {
1199 dp->dccps_hc_rx_ackpkts = dccp_ackpkts_alloc(DCCP_MAX_ACK_VECTOR_LEN, 1230 dp->dccps_hc_rx_ackpkts =
1200 GFP_KERNEL); 1231 dccp_ackpkts_alloc(DCCP_MAX_ACK_VECTOR_LEN,
1232 GFP_KERNEL);
1201 1233
1202 if (dp->dccps_hc_rx_ackpkts == NULL) 1234 if (dp->dccps_hc_rx_ackpkts == NULL)
1203 return -ENOMEM; 1235 return -ENOMEM;
@@ -1211,8 +1243,10 @@ static int dccp_v4_init_sock(struct sock *sk)
1211 * setsockopt(CCIDs-I-want/accept). -acme 1243 * setsockopt(CCIDs-I-want/accept). -acme
1212 */ 1244 */
1213 if (likely(!dccp_ctl_socket_init)) { 1245 if (likely(!dccp_ctl_socket_init)) {
1214 dp->dccps_hc_rx_ccid = ccid_init(dp->dccps_options.dccpo_ccid, sk); 1246 dp->dccps_hc_rx_ccid = ccid_init(dp->dccps_options.dccpo_ccid,
1215 dp->dccps_hc_tx_ccid = ccid_init(dp->dccps_options.dccpo_ccid, sk); 1247 sk);
1248 dp->dccps_hc_tx_ccid = ccid_init(dp->dccps_options.dccpo_ccid,
1249 sk);
1216 if (dp->dccps_hc_rx_ccid == NULL || 1250 if (dp->dccps_hc_rx_ccid == NULL ||
1217 dp->dccps_hc_tx_ccid == NULL) { 1251 dp->dccps_hc_tx_ccid == NULL) {
1218 ccid_exit(dp->dccps_hc_rx_ccid, sk); 1252 ccid_exit(dp->dccps_hc_rx_ccid, sk);
diff --git a/net/dccp/minisocks.c b/net/dccp/minisocks.c
index a6a0b270fb6c..b8e67207e97e 100644
--- a/net/dccp/minisocks.c
+++ b/net/dccp/minisocks.c
@@ -69,8 +69,8 @@ void dccp_time_wait(struct sock *sk, int state, int timeo)
69 * socket up. We've got bigger problems than 69 * socket up. We've got bigger problems than
70 * non-graceful socket closings. 70 * non-graceful socket closings.
71 */ 71 */
72 if (net_ratelimit()) 72 LIMIT_NETDEBUG(KERN_INFO "DCCP: time wait bucket "
73 printk(KERN_INFO "DCCP: time wait bucket table overflow\n"); 73 "table overflow\n");
74 } 74 }
75 75
76 dccp_done(sk); 76 dccp_done(sk);
@@ -98,19 +98,23 @@ struct sock *dccp_create_openreq_child(struct sock *sk,
98 newicsk->icsk_rto = DCCP_TIMEOUT_INIT; 98 newicsk->icsk_rto = DCCP_TIMEOUT_INIT;
99 99
100 if (newdp->dccps_options.dccpo_send_ack_vector) { 100 if (newdp->dccps_options.dccpo_send_ack_vector) {
101 newdp->dccps_hc_rx_ackpkts = dccp_ackpkts_alloc(DCCP_MAX_ACK_VECTOR_LEN, 101 newdp->dccps_hc_rx_ackpkts =
102 GFP_ATOMIC); 102 dccp_ackpkts_alloc(DCCP_MAX_ACK_VECTOR_LEN,
103 GFP_ATOMIC);
103 /* 104 /*
104 * XXX: We're using the same CCIDs set on the parent, i.e. sk_clone 105 * XXX: We're using the same CCIDs set on the parent,
105 * copied the master sock and left the CCID pointers for this child, 106 * i.e. sk_clone copied the master sock and left the
106 * that is why we do the __ccid_get calls. 107 * CCID pointers for this child, that is why we do the
108 * __ccid_get calls.
107 */ 109 */
108 if (unlikely(newdp->dccps_hc_rx_ackpkts == NULL)) 110 if (unlikely(newdp->dccps_hc_rx_ackpkts == NULL))
109 goto out_free; 111 goto out_free;
110 } 112 }
111 113
112 if (unlikely(ccid_hc_rx_init(newdp->dccps_hc_rx_ccid, newsk) != 0 || 114 if (unlikely(ccid_hc_rx_init(newdp->dccps_hc_rx_ccid,
113 ccid_hc_tx_init(newdp->dccps_hc_tx_ccid, newsk) != 0)) { 115 newsk) != 0 ||
116 ccid_hc_tx_init(newdp->dccps_hc_tx_ccid,
117 newsk) != 0)) {
114 dccp_ackpkts_free(newdp->dccps_hc_rx_ackpkts); 118 dccp_ackpkts_free(newdp->dccps_hc_rx_ackpkts);
115 ccid_hc_rx_exit(newdp->dccps_hc_rx_ccid, newsk); 119 ccid_hc_rx_exit(newdp->dccps_hc_rx_ccid, newsk);
116 ccid_hc_tx_exit(newdp->dccps_hc_tx_ccid, newsk); 120 ccid_hc_tx_exit(newdp->dccps_hc_tx_ccid, newsk);
@@ -129,7 +133,8 @@ out_free:
129 * Step 3: Process LISTEN state 133 * Step 3: Process LISTEN state
130 * 134 *
131 * Choose S.ISS (initial seqno) or set from Init Cookie 135 * Choose S.ISS (initial seqno) or set from Init Cookie
132 * Set S.ISR, S.GSR, S.SWL, S.SWH from packet or Init Cookie 136 * Set S.ISR, S.GSR, S.SWL, S.SWH from packet or Init
137 * Cookie
133 */ 138 */
134 139
135 /* See dccp_v4_conn_request */ 140 /* See dccp_v4_conn_request */
@@ -160,13 +165,15 @@ struct sock *dccp_check_req(struct sock *sk, struct sk_buff *skb,
160 165
161 /* Check for retransmitted REQUEST */ 166 /* Check for retransmitted REQUEST */
162 if (dccp_hdr(skb)->dccph_type == DCCP_PKT_REQUEST) { 167 if (dccp_hdr(skb)->dccph_type == DCCP_PKT_REQUEST) {
163 if (after48(DCCP_SKB_CB(skb)->dccpd_seq, dccp_rsk(req)->dreq_isr)) { 168 if (after48(DCCP_SKB_CB(skb)->dccpd_seq,
169 dccp_rsk(req)->dreq_isr)) {
164 struct dccp_request_sock *dreq = dccp_rsk(req); 170 struct dccp_request_sock *dreq = dccp_rsk(req);
165 171
166 dccp_pr_debug("Retransmitted REQUEST\n"); 172 dccp_pr_debug("Retransmitted REQUEST\n");
167 /* Send another RESPONSE packet */ 173 /* Send another RESPONSE packet */
168 dccp_set_seqno(&dreq->dreq_iss, dreq->dreq_iss + 1); 174 dccp_set_seqno(&dreq->dreq_iss, dreq->dreq_iss + 1);
169 dccp_set_seqno(&dreq->dreq_isr, DCCP_SKB_CB(skb)->dccpd_seq); 175 dccp_set_seqno(&dreq->dreq_isr,
176 DCCP_SKB_CB(skb)->dccpd_seq);
170 req->rsk_ops->rtx_syn_ack(sk, req, NULL); 177 req->rsk_ops->rtx_syn_ack(sk, req, NULL);
171 } 178 }
172 /* Network Duplicate, discard packet */ 179 /* Network Duplicate, discard packet */
@@ -181,7 +188,8 @@ struct sock *dccp_check_req(struct sock *sk, struct sk_buff *skb,
181 188
182 /* Invalid ACK */ 189 /* Invalid ACK */
183 if (DCCP_SKB_CB(skb)->dccpd_ack_seq != dccp_rsk(req)->dreq_iss) { 190 if (DCCP_SKB_CB(skb)->dccpd_ack_seq != dccp_rsk(req)->dreq_iss) {
184 dccp_pr_debug("Invalid ACK number: ack_seq=%llu, dreq_iss=%llu\n", 191 dccp_pr_debug("Invalid ACK number: ack_seq=%llu, "
192 "dreq_iss=%llu\n",
185 (unsigned long long) 193 (unsigned long long)
186 DCCP_SKB_CB(skb)->dccpd_ack_seq, 194 DCCP_SKB_CB(skb)->dccpd_ack_seq,
187 (unsigned long long) 195 (unsigned long long)
@@ -223,7 +231,8 @@ int dccp_child_process(struct sock *parent, struct sock *child,
223 const int state = child->sk_state; 231 const int state = child->sk_state;
224 232
225 if (!sock_owned_by_user(child)) { 233 if (!sock_owned_by_user(child)) {
226 ret = dccp_rcv_state_process(child, skb, dccp_hdr(skb), skb->len); 234 ret = dccp_rcv_state_process(child, skb, dccp_hdr(skb),
235 skb->len);
227 236
228 /* Wakeup parent, send SIGIO */ 237 /* Wakeup parent, send SIGIO */
229 if (state == DCCP_RESPOND && child->sk_state != state) 238 if (state == DCCP_RESPOND && child->sk_state != state)
diff --git a/net/dccp/options.c b/net/dccp/options.c
index 5bf997683a16..68d6614edcf1 100644
--- a/net/dccp/options.c
+++ b/net/dccp/options.c
@@ -59,14 +59,15 @@ int dccp_parse_options(struct sock *sk, struct sk_buff *skb)
59{ 59{
60 struct dccp_sock *dp = dccp_sk(sk); 60 struct dccp_sock *dp = dccp_sk(sk);
61#ifdef DCCP_DEBUG 61#ifdef DCCP_DEBUG
62 const char *debug_prefix = dp->dccps_role == DCCP_ROLE_CLIENT ? "CLIENT rx opt: " : 62 const char *debug_prefix = dp->dccps_role == DCCP_ROLE_CLIENT ?
63 "server rx opt: "; 63 "CLIENT rx opt: " : "server rx opt: ";
64#endif 64#endif
65 const struct dccp_hdr *dh = dccp_hdr(skb); 65 const struct dccp_hdr *dh = dccp_hdr(skb);
66 const u8 pkt_type = DCCP_SKB_CB(skb)->dccpd_type; 66 const u8 pkt_type = DCCP_SKB_CB(skb)->dccpd_type;
67 unsigned char *options = (unsigned char *)dh + dccp_hdr_len(skb); 67 unsigned char *options = (unsigned char *)dh + dccp_hdr_len(skb);
68 unsigned char *opt_ptr = options; 68 unsigned char *opt_ptr = options;
69 const unsigned char *opt_end = (unsigned char *)dh + (dh->dccph_doff * 4); 69 const unsigned char *opt_end = (unsigned char *)dh +
70 (dh->dccph_doff * 4);
70 struct dccp_options_received *opt_recv = &dp->dccps_options_received; 71 struct dccp_options_received *opt_recv = &dp->dccps_options_received;
71 unsigned char opt, len; 72 unsigned char opt, len;
72 unsigned char *value; 73 unsigned char *value;
@@ -106,7 +107,8 @@ int dccp_parse_options(struct sock *sk, struct sk_buff *skb)
106 goto out_invalid_option; 107 goto out_invalid_option;
107 108
108 opt_recv->dccpor_ndp = dccp_decode_value_var(value, len); 109 opt_recv->dccpor_ndp = dccp_decode_value_var(value, len);
109 dccp_pr_debug("%sNDP count=%d\n", debug_prefix, opt_recv->dccpor_ndp); 110 dccp_pr_debug("%sNDP count=%d\n", debug_prefix,
111 opt_recv->dccpor_ndp);
110 break; 112 break;
111 case DCCPO_ACK_VECTOR_0: 113 case DCCPO_ACK_VECTOR_0:
112 if (len > DCCP_MAX_ACK_VECTOR_LEN) 114 if (len > DCCP_MAX_ACK_VECTOR_LEN)
@@ -124,8 +126,9 @@ int dccp_parse_options(struct sock *sk, struct sk_buff *skb)
124 DCCP_SKB_CB(skb)->dccpd_ack_seq); 126 DCCP_SKB_CB(skb)->dccpd_ack_seq);
125 dccp_ackvector_print(DCCP_SKB_CB(skb)->dccpd_ack_seq, 127 dccp_ackvector_print(DCCP_SKB_CB(skb)->dccpd_ack_seq,
126 value, len); 128 value, len);
127 dccp_ackpkts_check_rcv_ackvector(dp->dccps_hc_rx_ackpkts, sk, 129 dccp_ackpkts_check_rcv_ackvector(dp->dccps_hc_rx_ackpkts,
128 DCCP_SKB_CB(skb)->dccpd_ack_seq, 130 sk,
131 DCCP_SKB_CB(skb)->dccpd_ack_seq,
129 len, value); 132 len, value);
130 break; 133 break;
131 case DCCPO_TIMESTAMP: 134 case DCCPO_TIMESTAMP:
@@ -148,15 +151,21 @@ int dccp_parse_options(struct sock *sk, struct sk_buff *skb)
148 151
149 opt_recv->dccpor_timestamp_echo = ntohl(*(u32 *)value); 152 opt_recv->dccpor_timestamp_echo = ntohl(*(u32 *)value);
150 153
151 dccp_pr_debug("%sTIMESTAMP_ECHO=%u, len=%d, ackno=%llu, diff=%u\n", 154 dccp_pr_debug("%sTIMESTAMP_ECHO=%u, len=%d, ackno=%llu, "
152 debug_prefix, opt_recv->dccpor_timestamp_echo, 155 "diff=%u\n",
156 debug_prefix,
157 opt_recv->dccpor_timestamp_echo,
153 len + 2, 158 len + 2,
154 (unsigned long long) 159 (unsigned long long)
155 DCCP_SKB_CB(skb)->dccpd_ack_seq, 160 DCCP_SKB_CB(skb)->dccpd_ack_seq,
156 tcp_time_stamp - opt_recv->dccpor_timestamp_echo); 161 (tcp_time_stamp -
157 162 opt_recv->dccpor_timestamp_echo));
158 opt_recv->dccpor_elapsed_time = dccp_decode_value_var(value + 4, len - 4); 163
159 dccp_pr_debug("%sTIMESTAMP_ECHO ELAPSED_TIME=%d\n", debug_prefix, 164 opt_recv->dccpor_elapsed_time =
165 dccp_decode_value_var(value + 4,
166 len - 4);
167 dccp_pr_debug("%sTIMESTAMP_ECHO ELAPSED_TIME=%d\n",
168 debug_prefix,
160 opt_recv->dccpor_elapsed_time); 169 opt_recv->dccpor_elapsed_time);
161 break; 170 break;
162 case DCCPO_ELAPSED_TIME: 171 case DCCPO_ELAPSED_TIME:
@@ -165,33 +174,41 @@ int dccp_parse_options(struct sock *sk, struct sk_buff *skb)
165 174
166 if (pkt_type == DCCP_PKT_DATA) 175 if (pkt_type == DCCP_PKT_DATA)
167 continue; 176 continue;
168 opt_recv->dccpor_elapsed_time = dccp_decode_value_var(value, len); 177 opt_recv->dccpor_elapsed_time =
178 dccp_decode_value_var(value, len);
169 dccp_pr_debug("%sELAPSED_TIME=%d\n", debug_prefix, 179 dccp_pr_debug("%sELAPSED_TIME=%d\n", debug_prefix,
170 opt_recv->dccpor_elapsed_time); 180 opt_recv->dccpor_elapsed_time);
171 break; 181 break;
172 /* 182 /*
173 * From draft-ietf-dccp-spec-11.txt: 183 * From draft-ietf-dccp-spec-11.txt:
174 * 184 *
175 * Option numbers 128 through 191 are for options sent from the HC- 185 * Option numbers 128 through 191 are for
176 * Sender to the HC-Receiver; option numbers 192 through 255 are for 186 * options sent from the HC-Sender to the
177 * options sent from the HC-Receiver to the HC-Sender. 187 * HC-Receiver; option numbers 192 through 255
188 * are for options sent from the HC-Receiver to
189 * the HC-Sender.
178 */ 190 */
179 case 128 ... 191: { 191 case 128 ... 191: {
180 const u16 idx = value - options; 192 const u16 idx = value - options;
181 193
182 if (ccid_hc_rx_parse_options(dp->dccps_hc_rx_ccid, sk, opt, len, idx, value) != 0) 194 if (ccid_hc_rx_parse_options(dp->dccps_hc_rx_ccid, sk,
195 opt, len, idx,
196 value) != 0)
183 goto out_invalid_option; 197 goto out_invalid_option;
184 } 198 }
185 break; 199 break;
186 case 192 ... 255: { 200 case 192 ... 255: {
187 const u16 idx = value - options; 201 const u16 idx = value - options;
188 202
189 if (ccid_hc_tx_parse_options(dp->dccps_hc_tx_ccid, sk, opt, len, idx, value) != 0) 203 if (ccid_hc_tx_parse_options(dp->dccps_hc_tx_ccid, sk,
204 opt, len, idx,
205 value) != 0)
190 goto out_invalid_option; 206 goto out_invalid_option;
191 } 207 }
192 break; 208 break;
193 default: 209 default:
194 pr_info("DCCP(%p): option %d(len=%d) not implemented, ignoring\n", 210 pr_info("DCCP(%p): option %d(len=%d) not "
211 "implemented, ignoring\n",
195 sk, opt, len); 212 sk, opt, len);
196 break; 213 break;
197 } 214 }
@@ -231,7 +248,8 @@ void dccp_insert_option(struct sock *sk, struct sk_buff *skb,
231 unsigned char *to; 248 unsigned char *to;
232 249
233 if (DCCP_SKB_CB(skb)->dccpd_opt_len + len + 2 > DCCP_MAX_OPT_LEN) { 250 if (DCCP_SKB_CB(skb)->dccpd_opt_len + len + 2 > DCCP_MAX_OPT_LEN) {
234 LIMIT_NETDEBUG(KERN_INFO "DCCP: packet too small to insert %d option!\n", option); 251 LIMIT_NETDEBUG(KERN_INFO "DCCP: packet too small to insert "
252 "%d option!\n", option);
235 return; 253 return;
236 } 254 }
237 255
@@ -287,8 +305,8 @@ void dccp_insert_option_elapsed_time(struct sock *sk,
287{ 305{
288#ifdef DCCP_DEBUG 306#ifdef DCCP_DEBUG
289 struct dccp_sock *dp = dccp_sk(sk); 307 struct dccp_sock *dp = dccp_sk(sk);
290 const char *debug_prefix = dp->dccps_role == DCCP_ROLE_CLIENT ? "CLIENT TX opt: " : 308 const char *debug_prefix = dp->dccps_role == DCCP_ROLE_CLIENT ?
291 "server TX opt: "; 309 "CLIENT TX opt: " : "server TX opt: ";
292#endif 310#endif
293 const int elapsed_time_len = dccp_elapsed_time_len(elapsed_time); 311 const int elapsed_time_len = dccp_elapsed_time_len(elapsed_time);
294 const int len = 2 + elapsed_time_len; 312 const int len = 2 + elapsed_time_len;
@@ -299,7 +317,8 @@ void dccp_insert_option_elapsed_time(struct sock *sk,
299 return; 317 return;
300 318
301 if (DCCP_SKB_CB(skb)->dccpd_opt_len + len > DCCP_MAX_OPT_LEN) { 319 if (DCCP_SKB_CB(skb)->dccpd_opt_len + len > DCCP_MAX_OPT_LEN) {
302 LIMIT_NETDEBUG(KERN_INFO "DCCP: packet too small to insert elapsed time!\n"); 320 LIMIT_NETDEBUG(KERN_INFO "DCCP: packet too small to "
321 "insert elapsed time!\n");
303 return; 322 return;
304 } 323 }
305 324
@@ -323,8 +342,8 @@ static void dccp_insert_option_ack_vector(struct sock *sk, struct sk_buff *skb)
323{ 342{
324 struct dccp_sock *dp = dccp_sk(sk); 343 struct dccp_sock *dp = dccp_sk(sk);
325#ifdef DCCP_DEBUG 344#ifdef DCCP_DEBUG
326 const char *debug_prefix = dp->dccps_role == DCCP_ROLE_CLIENT ? "CLIENT TX opt: " : 345 const char *debug_prefix = dp->dccps_role == DCCP_ROLE_CLIENT ?
327 "server TX opt: "; 346 "CLIENT TX opt: " : "server TX opt: ";
328#endif 347#endif
329 struct dccp_ackpkts *ap = dp->dccps_hc_rx_ackpkts; 348 struct dccp_ackpkts *ap = dp->dccps_hc_rx_ackpkts;
330 int len = ap->dccpap_buf_vector_len + 2; 349 int len = ap->dccpap_buf_vector_len + 2;
@@ -335,7 +354,8 @@ static void dccp_insert_option_ack_vector(struct sock *sk, struct sk_buff *skb)
335 dccp_insert_option_elapsed_time(sk, skb, elapsed_time); 354 dccp_insert_option_elapsed_time(sk, skb, elapsed_time);
336 355
337 if (DCCP_SKB_CB(skb)->dccpd_opt_len + len > DCCP_MAX_OPT_LEN) { 356 if (DCCP_SKB_CB(skb)->dccpd_opt_len + len > DCCP_MAX_OPT_LEN) {
338 LIMIT_NETDEBUG(KERN_INFO "DCCP: packet too small to insert ACK Vector!\n"); 357 LIMIT_NETDEBUG(KERN_INFO "DCCP: packet too small to "
358 "insert ACK Vector!\n");
339 return; 359 return;
340 } 360 }
341 361
@@ -360,7 +380,8 @@ static void dccp_insert_option_ack_vector(struct sock *sk, struct sk_buff *skb)
360 380
361 /* Check if buf_head wraps */ 381 /* Check if buf_head wraps */
362 if (ap->dccpap_buf_head + len > ap->dccpap_buf_len) { 382 if (ap->dccpap_buf_head + len > ap->dccpap_buf_len) {
363 const unsigned int tailsize = ap->dccpap_buf_len - ap->dccpap_buf_head; 383 const unsigned int tailsize = (ap->dccpap_buf_len -
384 ap->dccpap_buf_head);
364 385
365 memcpy(to, from, tailsize); 386 memcpy(to, from, tailsize);
366 to += tailsize; 387 to += tailsize;
@@ -375,8 +396,8 @@ static void dccp_insert_option_ack_vector(struct sock *sk, struct sk_buff *skb)
375 * For each acknowledgement it sends, the HC-Receiver will add an 396 * For each acknowledgement it sends, the HC-Receiver will add an
376 * acknowledgement record. ack_seqno will equal the HC-Receiver 397 * acknowledgement record. ack_seqno will equal the HC-Receiver
377 * sequence number it used for the ack packet; ack_ptr will equal 398 * sequence number it used for the ack packet; ack_ptr will equal
378 * buf_head; ack_ackno will equal buf_ackno; and ack_nonce will equal 399 * buf_head; ack_ackno will equal buf_ackno; and ack_nonce will
379 * buf_nonce. 400 * equal buf_nonce.
380 * 401 *
381 * This implemention uses just one ack record for now. 402 * This implemention uses just one ack record for now.
382 */ 403 */
@@ -386,33 +407,38 @@ static void dccp_insert_option_ack_vector(struct sock *sk, struct sk_buff *skb)
386 ap->dccpap_ack_nonce = ap->dccpap_buf_nonce; 407 ap->dccpap_ack_nonce = ap->dccpap_buf_nonce;
387 ap->dccpap_ack_vector_len = ap->dccpap_buf_vector_len; 408 ap->dccpap_ack_vector_len = ap->dccpap_buf_vector_len;
388 409
389 dccp_pr_debug("%sACK Vector 0, len=%d, ack_seqno=%llu, ack_ackno=%llu\n", 410 dccp_pr_debug("%sACK Vector 0, len=%d, ack_seqno=%llu, "
411 "ack_ackno=%llu\n",
390 debug_prefix, ap->dccpap_ack_vector_len, 412 debug_prefix, ap->dccpap_ack_vector_len,
391 (unsigned long long) ap->dccpap_ack_seqno, 413 (unsigned long long) ap->dccpap_ack_seqno,
392 (unsigned long long) ap->dccpap_ack_ackno); 414 (unsigned long long) ap->dccpap_ack_ackno);
393} 415}
394 416
395static inline void dccp_insert_option_timestamp(struct sock *sk, struct sk_buff *skb) 417static inline void dccp_insert_option_timestamp(struct sock *sk,
418 struct sk_buff *skb)
396{ 419{
397 const u32 now = htonl(tcp_time_stamp); 420 const u32 now = htonl(tcp_time_stamp);
398 dccp_insert_option(sk, skb, DCCPO_TIMESTAMP, &now, sizeof(now)); 421 dccp_insert_option(sk, skb, DCCPO_TIMESTAMP, &now, sizeof(now));
399} 422}
400 423
401static void dccp_insert_option_timestamp_echo(struct sock *sk, struct sk_buff *skb) 424static void dccp_insert_option_timestamp_echo(struct sock *sk,
425 struct sk_buff *skb)
402{ 426{
403 struct dccp_sock *dp = dccp_sk(sk); 427 struct dccp_sock *dp = dccp_sk(sk);
404#ifdef DCCP_DEBUG 428#ifdef DCCP_DEBUG
405 const char *debug_prefix = dp->dccps_role == DCCP_ROLE_CLIENT ? "CLIENT TX opt: " : 429 const char *debug_prefix = dp->dccps_role == DCCP_ROLE_CLIENT ?
406 "server TX opt: "; 430 "CLIENT TX opt: " : "server TX opt: ";
407#endif 431#endif
408 u32 tstamp_echo; 432 u32 tstamp_echo;
409 const u32 elapsed_time = jiffies_to_usecs(jiffies - dp->dccps_timestamp_time) / 10; 433 const u32 elapsed_time = jiffies_to_usecs(jiffies -
434 dp->dccps_timestamp_time) / 10;
410 const int elapsed_time_len = dccp_elapsed_time_len(elapsed_time); 435 const int elapsed_time_len = dccp_elapsed_time_len(elapsed_time);
411 const int len = 6 + elapsed_time_len; 436 const int len = 6 + elapsed_time_len;
412 unsigned char *to; 437 unsigned char *to;
413 438
414 if (DCCP_SKB_CB(skb)->dccpd_opt_len + len > DCCP_MAX_OPT_LEN) { 439 if (DCCP_SKB_CB(skb)->dccpd_opt_len + len > DCCP_MAX_OPT_LEN) {
415 LIMIT_NETDEBUG(KERN_INFO "DCCP: packet too small to insert timestamp echo!\n"); 440 LIMIT_NETDEBUG(KERN_INFO "DCCP: packet too small to insert "
441 "timestamp echo!\n");
416 return; 442 return;
417 } 443 }
418 444
@@ -447,7 +473,8 @@ void dccp_insert_options(struct sock *sk, struct sk_buff *skb)
447 473
448 if (!dccp_packet_without_ack(skb)) { 474 if (!dccp_packet_without_ack(skb)) {
449 if (dp->dccps_options.dccpo_send_ack_vector && 475 if (dp->dccps_options.dccpo_send_ack_vector &&
450 dp->dccps_hc_rx_ackpkts->dccpap_buf_ackno != DCCP_MAX_SEQNO + 1) 476 (dp->dccps_hc_rx_ackpkts->dccpap_buf_ackno !=
477 DCCP_MAX_SEQNO + 1))
451 dccp_insert_option_ack_vector(sk, skb); 478 dccp_insert_option_ack_vector(sk, skb);
452 479
453 dccp_insert_option_timestamp(sk, skb); 480 dccp_insert_option_timestamp(sk, skb);
@@ -480,12 +507,16 @@ struct dccp_ackpkts *dccp_ackpkts_alloc(unsigned int len, int priority)
480#ifdef DCCP_DEBUG 507#ifdef DCCP_DEBUG
481 memset(ap->dccpap_buf, 0xFF, len); 508 memset(ap->dccpap_buf, 0xFF, len);
482#endif 509#endif
483 ap->dccpap_buf_len = len; 510 ap->dccpap_buf_len = len;
484 ap->dccpap_buf_head = ap->dccpap_buf_tail = ap->dccpap_buf_len - 1; 511 ap->dccpap_buf_head =
485 ap->dccpap_buf_ackno = ap->dccpap_ack_ackno = ap->dccpap_ack_seqno = DCCP_MAX_SEQNO + 1; 512 ap->dccpap_buf_tail =
486 ap->dccpap_buf_nonce = ap->dccpap_buf_nonce = 0; 513 ap->dccpap_buf_len - 1;
487 ap->dccpap_ack_ptr = 0; 514 ap->dccpap_buf_ackno =
488 ap->dccpap_time = 0; 515 ap->dccpap_ack_ackno =
516 ap->dccpap_ack_seqno = DCCP_MAX_SEQNO + 1;
517 ap->dccpap_buf_nonce = ap->dccpap_buf_nonce = 0;
518 ap->dccpap_ack_ptr = 0;
519 ap->dccpap_time = 0;
489 ap->dccpap_buf_vector_len = ap->dccpap_ack_vector_len = 0; 520 ap->dccpap_buf_vector_len = ap->dccpap_ack_vector_len = 0;
490 } 521 }
491 522
@@ -567,15 +598,16 @@ int dccp_ackpkts_add(struct dccp_ackpkts *ap, u64 ackno, u8 state)
567 * 598 *
568 * From Appendix A: 599 * From Appendix A:
569 * 600 *
570 * Of course, the circular buffer may overflow, either when the HC- 601 * Of course, the circular buffer may overflow, either when the
571 * Sender is sending data at a very high rate, when the HC-Receiver's 602 * HC-Sender is sending data at a very high rate, when the
572 * acknowledgements are not reaching the HC-Sender, or when the HC- 603 * HC-Receiver's acknowledgements are not reaching the HC-Sender,
573 * Sender is forgetting to acknowledge those acks (so the HC-Receiver 604 * or when the HC-Sender is forgetting to acknowledge those acks
574 * is unable to clean up old state). In this case, the HC-Receiver 605 * (so the HC-Receiver is unable to clean up old state). In this
575 * should either compress the buffer (by increasing run lengths when 606 * case, the HC-Receiver should either compress the buffer (by
576 * possible), transfer its state to a larger buffer, or, as a last 607 * increasing run lengths when possible), transfer its state to
577 * resort, drop all received packets, without processing them 608 * a larger buffer, or, as a last resort, drop all received
578 * whatsoever, until its buffer shrinks again. 609 * packets, without processing them whatsoever, until its buffer
610 * shrinks again.
579 */ 611 */
580 612
581 /* See if this is the first ackno being inserted */ 613 /* See if this is the first ackno being inserted */
@@ -583,15 +615,17 @@ int dccp_ackpkts_add(struct dccp_ackpkts *ap, u64 ackno, u8 state)
583 ap->dccpap_buf[ap->dccpap_buf_head] = state; 615 ap->dccpap_buf[ap->dccpap_buf_head] = state;
584 ap->dccpap_buf_vector_len = 1; 616 ap->dccpap_buf_vector_len = 1;
585 } else if (after48(ackno, ap->dccpap_buf_ackno)) { 617 } else if (after48(ackno, ap->dccpap_buf_ackno)) {
586 const u64 delta = dccp_delta_seqno(ap->dccpap_buf_ackno, ackno); 618 const u64 delta = dccp_delta_seqno(ap->dccpap_buf_ackno,
619 ackno);
587 620
588 /* 621 /*
589 * Look if the state of this packet is the same as the previous ackno 622 * Look if the state of this packet is the same as the
590 * and if so if we can bump the head len. 623 * previous ackno and if so if we can bump the head len.
591 */ 624 */
592 if (delta == 1 && 625 if (delta == 1 &&
593 dccp_ackpkts_state(ap, ap->dccpap_buf_head) == state && 626 dccp_ackpkts_state(ap, ap->dccpap_buf_head) == state &&
594 dccp_ackpkts_len(ap, ap->dccpap_buf_head) < DCCP_ACKPKTS_LEN_MASK) 627 (dccp_ackpkts_len(ap, ap->dccpap_buf_head) <
628 DCCP_ACKPKTS_LEN_MASK))
595 ap->dccpap_buf[ap->dccpap_buf_head]++; 629 ap->dccpap_buf[ap->dccpap_buf_head]++;
596 else if (dccp_ackpkts_set_buf_head_state(ap, delta, state)) 630 else if (dccp_ackpkts_set_buf_head_state(ap, delta, state))
597 return -ENOBUFS; 631 return -ENOBUFS;
@@ -599,9 +633,10 @@ int dccp_ackpkts_add(struct dccp_ackpkts *ap, u64 ackno, u8 state)
599 /* 633 /*
600 * A.1.2. Old Packets 634 * A.1.2. Old Packets
601 * 635 *
602 * When a packet with Sequence Number S arrives, and S <= buf_ackno, 636 * When a packet with Sequence Number S arrives, and
603 * the HC-Receiver will scan the table for the byte corresponding to S. 637 * S <= buf_ackno, the HC-Receiver will scan the table
604 * (Indexing structures could reduce the complexity of this scan.) 638 * for the byte corresponding to S. (Indexing structures
639 * could reduce the complexity of this scan.)
605 */ 640 */
606 u64 delta = dccp_delta_seqno(ackno, ap->dccpap_buf_ackno); 641 u64 delta = dccp_delta_seqno(ackno, ap->dccpap_buf_ackno);
607 unsigned int index = ap->dccpap_buf_head; 642 unsigned int index = ap->dccpap_buf_head;
@@ -610,11 +645,12 @@ int dccp_ackpkts_add(struct dccp_ackpkts *ap, u64 ackno, u8 state)
610 const u8 len = dccp_ackpkts_len(ap, index); 645 const u8 len = dccp_ackpkts_len(ap, index);
611 const u8 state = dccp_ackpkts_state(ap, index); 646 const u8 state = dccp_ackpkts_state(ap, index);
612 /* 647 /*
613 * valid packets not yet in dccpap_buf have a reserved entry, with 648 * valid packets not yet in dccpap_buf have a reserved
614 * a len equal to 0 649 * entry, with a len equal to 0.
615 */ 650 */
616 if (state == DCCP_ACKPKTS_STATE_NOT_RECEIVED && 651 if (state == DCCP_ACKPKTS_STATE_NOT_RECEIVED &&
617 len == 0 && delta == 0) { /* Found our reserved seat! */ 652 len == 0 && delta == 0) { /* Found our
653 reserved seat! */
618 dccp_pr_debug("Found %llu reserved seat!\n", 654 dccp_pr_debug("Found %llu reserved seat!\n",
619 (unsigned long long) ackno); 655 (unsigned long long) ackno);
620 ap->dccpap_buf[index] = state; 656 ap->dccpap_buf[index] = state;
@@ -639,13 +675,14 @@ out:
639 675
640out_duplicate: 676out_duplicate:
641 /* Duplicate packet */ 677 /* Duplicate packet */
642 dccp_pr_debug("Received a dup or already considered lost packet: %llu\n", 678 dccp_pr_debug("Received a dup or already considered lost "
643 (unsigned long long) ackno); 679 "packet: %llu\n", (unsigned long long) ackno);
644 return -EILSEQ; 680 return -EILSEQ;
645} 681}
646 682
647#ifdef DCCP_DEBUG 683#ifdef DCCP_DEBUG
648void dccp_ackvector_print(const u64 ackno, const unsigned char *vector, int len) 684void dccp_ackvector_print(const u64 ackno, const unsigned char *vector,
685 int len)
649{ 686{
650 if (!dccp_debug) 687 if (!dccp_debug)
651 return; 688 return;
@@ -678,8 +715,9 @@ static void dccp_ackpkts_trow_away_ack_record(struct dccp_ackpkts *ap)
678 * As we're keeping track of the ack vector size 715 * As we're keeping track of the ack vector size
679 * (dccpap_buf_vector_len) and the sent ack vector size 716 * (dccpap_buf_vector_len) and the sent ack vector size
680 * (dccpap_ack_vector_len) we don't need dccpap_buf_tail at all, but 717 * (dccpap_ack_vector_len) we don't need dccpap_buf_tail at all, but
681 * keep this code here as in the future we'll implement a vector of ack 718 * keep this code here as in the future we'll implement a vector of
682 * records, as suggested in draft-ietf-dccp-spec-11.txt Appendix A. -acme 719 * ack records, as suggested in draft-ietf-dccp-spec-11.txt
720 * Appendix A. -acme
683 */ 721 */
684#if 0 722#if 0
685 ap->dccpap_buf_tail = ap->dccpap_ack_ptr + 1; 723 ap->dccpap_buf_tail = ap->dccpap_ack_ptr + 1;
@@ -699,10 +737,11 @@ void dccp_ackpkts_check_rcv_ackno(struct dccp_ackpkts *ap, struct sock *sk,
699 if (ackno == ap->dccpap_ack_seqno) { 737 if (ackno == ap->dccpap_ack_seqno) {
700#ifdef DCCP_DEBUG 738#ifdef DCCP_DEBUG
701 struct dccp_sock *dp = dccp_sk(sk); 739 struct dccp_sock *dp = dccp_sk(sk);
702 const char *debug_prefix = dp->dccps_role == DCCP_ROLE_CLIENT ? "CLIENT rx ack: " : 740 const char *debug_prefix = dp->dccps_role == DCCP_ROLE_CLIENT ?
703 "server rx ack: "; 741 "CLIENT rx ack: " : "server rx ack: ";
704#endif 742#endif
705 dccp_pr_debug("%sACK packet 0, len=%d, ack_seqno=%llu, ack_ackno=%llu, ACKED!\n", 743 dccp_pr_debug("%sACK packet 0, len=%d, ack_seqno=%llu, "
744 "ack_ackno=%llu, ACKED!\n",
706 debug_prefix, 1, 745 debug_prefix, 1,
707 (unsigned long long) ap->dccpap_ack_seqno, 746 (unsigned long long) ap->dccpap_ack_seqno,
708 (unsigned long long) ap->dccpap_ack_ackno); 747 (unsigned long long) ap->dccpap_ack_ackno);
@@ -722,20 +761,21 @@ static void dccp_ackpkts_check_rcv_ackvector(struct dccp_ackpkts *ap,
722 if (ap->dccpap_ack_seqno == DCCP_MAX_SEQNO + 1) 761 if (ap->dccpap_ack_seqno == DCCP_MAX_SEQNO + 1)
723 return; 762 return;
724 /* 763 /*
725 * We're in the receiver half connection, so if the received an ACK vector 764 * We're in the receiver half connection, so if the received an ACK
726 * ackno (e.g. 50) before dccpap_ack_seqno (e.g. 52), we're not interested. 765 * vector ackno (e.g. 50) before dccpap_ack_seqno (e.g. 52), we're
766 * not interested.
727 * 767 *
728 * Extra explanation with example: 768 * Extra explanation with example:
729 * 769 *
730 * if we received an ACK vector with ackno 50, it can only be acking 770 * if we received an ACK vector with ackno 50, it can only be acking
731 * 50, 49, 48, etc, not 52 (the seqno for the ACK vector we sent). 771 * 50, 49, 48, etc, not 52 (the seqno for the ACK vector we sent).
732 */ 772 */
733 // dccp_pr_debug("is %llu < %llu? ", ackno, ap->dccpap_ack_seqno); 773 /* dccp_pr_debug("is %llu < %llu? ", ackno, ap->dccpap_ack_seqno); */
734 if (before48(ackno, ap->dccpap_ack_seqno)) { 774 if (before48(ackno, ap->dccpap_ack_seqno)) {
735 // dccp_pr_debug_cat("yes\n"); 775 /* dccp_pr_debug_cat("yes\n"); */
736 return; 776 return;
737 } 777 }
738 // dccp_pr_debug_cat("no\n"); 778 /* dccp_pr_debug_cat("no\n"); */
739 779
740 i = len; 780 i = len;
741 while (i--) { 781 while (i--) {
@@ -744,18 +784,25 @@ static void dccp_ackpkts_check_rcv_ackvector(struct dccp_ackpkts *ap,
744 784
745 dccp_set_seqno(&ackno_end_rl, ackno - rl); 785 dccp_set_seqno(&ackno_end_rl, ackno - rl);
746 786
747 // dccp_pr_debug("is %llu <= %llu <= %llu? ", ackno_end_rl, ap->dccpap_ack_seqno, ackno); 787 /*
788 * dccp_pr_debug("is %llu <= %llu <= %llu? ", ackno_end_rl,
789 * ap->dccpap_ack_seqno, ackno);
790 */
748 if (between48(ap->dccpap_ack_seqno, ackno_end_rl, ackno)) { 791 if (between48(ap->dccpap_ack_seqno, ackno_end_rl, ackno)) {
749 const u8 state = (*vector & DCCP_ACKPKTS_STATE_MASK) >> 6; 792 const u8 state = (*vector &
750 // dccp_pr_debug_cat("yes\n"); 793 DCCP_ACKPKTS_STATE_MASK) >> 6;
794 /* dccp_pr_debug_cat("yes\n"); */
751 795
752 if (state != DCCP_ACKPKTS_STATE_NOT_RECEIVED) { 796 if (state != DCCP_ACKPKTS_STATE_NOT_RECEIVED) {
753#ifdef DCCP_DEBUG 797#ifdef DCCP_DEBUG
754 struct dccp_sock *dp = dccp_sk(sk); 798 struct dccp_sock *dp = dccp_sk(sk);
755 const char *debug_prefix = dp->dccps_role == DCCP_ROLE_CLIENT ? "CLIENT rx ack: " : 799 const char *debug_prefix =
756 "server rx ack: "; 800 dp->dccps_role == DCCP_ROLE_CLIENT ?
801 "CLIENT rx ack: " : "server rx ack: ";
757#endif 802#endif
758 dccp_pr_debug("%sACK vector 0, len=%d, ack_seqno=%llu, ack_ackno=%llu, ACKED!\n", 803 dccp_pr_debug("%sACK vector 0, len=%d, "
804 "ack_seqno=%llu, ack_ackno=%llu, "
805 "ACKED!\n",
759 debug_prefix, len, 806 debug_prefix, len,
760 (unsigned long long) 807 (unsigned long long)
761 ap->dccpap_ack_seqno, 808 ap->dccpap_ack_seqno,
@@ -764,13 +811,13 @@ static void dccp_ackpkts_check_rcv_ackvector(struct dccp_ackpkts *ap,
764 dccp_ackpkts_trow_away_ack_record(ap); 811 dccp_ackpkts_trow_away_ack_record(ap);
765 } 812 }
766 /* 813 /*
767 * If dccpap_ack_seqno was not received, no problem we'll 814 * If dccpap_ack_seqno was not received, no problem
768 * send another ACK vector. 815 * we'll send another ACK vector.
769 */ 816 */
770 ap->dccpap_ack_seqno = DCCP_MAX_SEQNO + 1; 817 ap->dccpap_ack_seqno = DCCP_MAX_SEQNO + 1;
771 break; 818 break;
772 } 819 }
773 // dccp_pr_debug_cat("no\n"); 820 /* dccp_pr_debug_cat("no\n"); */
774 821
775 dccp_set_seqno(&ackno, ackno_end_rl - 1); 822 dccp_set_seqno(&ackno, ackno_end_rl - 1);
776 ++vector; 823 ++vector;
diff --git a/net/dccp/output.c b/net/dccp/output.c
index 50292c0605fb..dcc061bed924 100644
--- a/net/dccp/output.c
+++ b/net/dccp/output.c
@@ -40,13 +40,13 @@ int dccp_transmit_skb(struct sock *sk, struct sk_buff *skb)
40 /* XXX For now we're using only 48 bits sequence numbers */ 40 /* XXX For now we're using only 48 bits sequence numbers */
41 const int dccp_header_size = sizeof(*dh) + 41 const int dccp_header_size = sizeof(*dh) +
42 sizeof(struct dccp_hdr_ext) + 42 sizeof(struct dccp_hdr_ext) +
43 dccp_packet_hdr_len(dcb->dccpd_type); 43 dccp_packet_hdr_len(dcb->dccpd_type);
44 int err, set_ack = 1; 44 int err, set_ack = 1;
45 u64 ackno = dp->dccps_gsr; 45 u64 ackno = dp->dccps_gsr;
46 46
47 /* 47 /*
48 * FIXME: study DCCP_PKT_SYNC[ACK] to see what is the right thing 48 * FIXME: study DCCP_PKT_SYNC[ACK] to see what is the right
49 * to do here... 49 * thing to do here...
50 */ 50 */
51 dccp_inc_seqno(&dp->dccps_gss); 51 dccp_inc_seqno(&dp->dccps_gss);
52 52
@@ -65,7 +65,9 @@ int dccp_transmit_skb(struct sock *sk, struct sk_buff *skb)
65 65
66 skb->h.raw = skb_push(skb, dccp_header_size); 66 skb->h.raw = skb_push(skb, dccp_header_size);
67 dh = dccp_hdr(skb); 67 dh = dccp_hdr(skb);
68 /* Data packets are not cloned as they are never retransmitted */ 68 /*
69 * Data packets are not cloned as they are never retransmitted
70 */
69 if (skb_cloned(skb)) 71 if (skb_cloned(skb))
70 skb_set_owner_w(skb, sk); 72 skb_set_owner_w(skb, sk);
71 73
@@ -86,10 +88,12 @@ int dccp_transmit_skb(struct sock *sk, struct sk_buff *skb)
86 88
87 switch (dcb->dccpd_type) { 89 switch (dcb->dccpd_type) {
88 case DCCP_PKT_REQUEST: 90 case DCCP_PKT_REQUEST:
89 dccp_hdr_request(skb)->dccph_req_service = dcb->dccpd_service; 91 dccp_hdr_request(skb)->dccph_req_service =
92 dcb->dccpd_service;
90 break; 93 break;
91 case DCCP_PKT_RESET: 94 case DCCP_PKT_RESET:
92 dccp_hdr_reset(skb)->dccph_reset_code = dcb->dccpd_reset_code; 95 dccp_hdr_reset(skb)->dccph_reset_code =
96 dcb->dccpd_reset_code;
93 break; 97 break;
94 } 98 }
95 99
@@ -123,10 +127,13 @@ unsigned int dccp_sync_mss(struct sock *sk, u32 pmtu)
123 int mss_now; 127 int mss_now;
124 128
125 /* 129 /*
126 * FIXME: we really should be using the af_specific thing to support IPv6. 130 * FIXME: we really should be using the af_specific thing to support
127 * mss_now = pmtu - tp->af_specific->net_header_len - sizeof(struct dccp_hdr) - sizeof(struct dccp_hdr_ext); 131 * IPv6.
132 * mss_now = pmtu - tp->af_specific->net_header_len -
133 * sizeof(struct dccp_hdr) - sizeof(struct dccp_hdr_ext);
128 */ 134 */
129 mss_now = pmtu - sizeof(struct iphdr) - sizeof(struct dccp_hdr) - sizeof(struct dccp_hdr_ext); 135 mss_now = pmtu - sizeof(struct iphdr) - sizeof(struct dccp_hdr) -
136 sizeof(struct dccp_hdr_ext);
130 137
131 /* Now subtract optional transport overhead */ 138 /* Now subtract optional transport overhead */
132 mss_now -= dp->dccps_ext_header_len; 139 mss_now -= dp->dccps_ext_header_len;
@@ -223,7 +230,8 @@ struct sk_buff *dccp_make_response(struct sock *sk, struct dst_entry *dst,
223 230
224 dh->dccph_sport = inet_sk(sk)->sport; 231 dh->dccph_sport = inet_sk(sk)->sport;
225 dh->dccph_dport = inet_rsk(req)->rmt_port; 232 dh->dccph_dport = inet_rsk(req)->rmt_port;
226 dh->dccph_doff = (dccp_header_size + DCCP_SKB_CB(skb)->dccpd_opt_len) / 4; 233 dh->dccph_doff = (dccp_header_size +
234 DCCP_SKB_CB(skb)->dccpd_opt_len) / 4;
227 dh->dccph_type = DCCP_PKT_RESPONSE; 235 dh->dccph_type = DCCP_PKT_RESPONSE;
228 dh->dccph_x = 1; 236 dh->dccph_x = 1;
229 dccp_hdr_set_seq(dh, dccp_rsk(req)->dreq_iss); 237 dccp_hdr_set_seq(dh, dccp_rsk(req)->dreq_iss);
@@ -271,7 +279,8 @@ struct sk_buff *dccp_make_reset(struct sock *sk, struct dst_entry *dst,
271 279
272 dh->dccph_sport = inet_sk(sk)->sport; 280 dh->dccph_sport = inet_sk(sk)->sport;
273 dh->dccph_dport = inet_sk(sk)->dport; 281 dh->dccph_dport = inet_sk(sk)->dport;
274 dh->dccph_doff = (dccp_header_size + DCCP_SKB_CB(skb)->dccpd_opt_len) / 4; 282 dh->dccph_doff = (dccp_header_size +
283 DCCP_SKB_CB(skb)->dccpd_opt_len) / 4;
275 dh->dccph_type = DCCP_PKT_RESET; 284 dh->dccph_type = DCCP_PKT_RESET;
276 dh->dccph_x = 1; 285 dh->dccph_x = 1;
277 dccp_hdr_set_seq(dh, dp->dccps_gss); 286 dccp_hdr_set_seq(dh, dp->dccps_gss);
@@ -348,7 +357,9 @@ void dccp_send_ack(struct sock *sk)
348 if (skb == NULL) { 357 if (skb == NULL) {
349 inet_csk_schedule_ack(sk); 358 inet_csk_schedule_ack(sk);
350 inet_csk(sk)->icsk_ack.ato = TCP_ATO_MIN; 359 inet_csk(sk)->icsk_ack.ato = TCP_ATO_MIN;
351 inet_csk_reset_xmit_timer(sk, ICSK_TIME_DACK, TCP_DELACK_MAX, TCP_RTO_MAX); 360 inet_csk_reset_xmit_timer(sk, ICSK_TIME_DACK,
361 TCP_DELACK_MAX,
362 DCCP_RTO_MAX);
352 return; 363 return;
353 } 364 }
354 365
@@ -416,8 +427,10 @@ void dccp_send_sync(struct sock *sk, u64 seq)
416 dccp_transmit_skb(sk, skb); 427 dccp_transmit_skb(sk, skb);
417} 428}
418 429
419/* Send a DCCP_PKT_CLOSE/CLOSEREQ. The caller locks the socket for us. This cannot be 430/*
420 * allowed to fail queueing a DCCP_PKT_CLOSE/CLOSEREQ frame under any circumstances. 431 * Send a DCCP_PKT_CLOSE/CLOSEREQ. The caller locks the socket for us. This
432 * cannot be allowed to fail queueing a DCCP_PKT_CLOSE/CLOSEREQ frame under
433 * any circumstances.
421 */ 434 */
422void dccp_send_close(struct sock *sk) 435void dccp_send_close(struct sock *sk)
423{ 436{
@@ -435,7 +448,8 @@ void dccp_send_close(struct sock *sk)
435 /* Reserve space for headers and prepare control bits. */ 448 /* Reserve space for headers and prepare control bits. */
436 skb_reserve(skb, sk->sk_prot->max_header); 449 skb_reserve(skb, sk->sk_prot->max_header);
437 skb->csum = 0; 450 skb->csum = 0;
438 DCCP_SKB_CB(skb)->dccpd_type = dp->dccps_role == DCCP_ROLE_CLIENT ? DCCP_PKT_CLOSE : DCCP_PKT_CLOSEREQ; 451 DCCP_SKB_CB(skb)->dccpd_type = dp->dccps_role == DCCP_ROLE_CLIENT ?
452 DCCP_PKT_CLOSE : DCCP_PKT_CLOSEREQ;
439 453
440 skb_set_owner_w(skb, sk); 454 skb_set_owner_w(skb, sk);
441 dccp_transmit_skb(sk, skb); 455 dccp_transmit_skb(sk, skb);
diff --git a/net/dccp/packet_history.c b/net/dccp/packet_history.c
index 6b414898f0c4..2d9ef5ae0bf6 100644
--- a/net/dccp/packet_history.c
+++ b/net/dccp/packet_history.c
@@ -55,7 +55,7 @@ struct dccp_rx_hist *dccp_rx_hist_new(const char *name)
55 55
56 sprintf(slab_name, dccp_rx_hist_mask, name); 56 sprintf(slab_name, dccp_rx_hist_mask, name);
57 hist->dccprxh_slab = kmem_cache_create(slab_name, 57 hist->dccprxh_slab = kmem_cache_create(slab_name,
58 sizeof(struct dccp_rx_hist_entry), 58 sizeof(struct dccp_rx_hist_entry),
59 0, SLAB_HWCACHE_ALIGN, 59 0, SLAB_HWCACHE_ALIGN,
60 NULL, NULL); 60 NULL, NULL);
61 if (hist->dccprxh_slab == NULL) 61 if (hist->dccprxh_slab == NULL)
@@ -128,7 +128,7 @@ struct dccp_tx_hist *dccp_tx_hist_new(const char *name)
128 128
129 sprintf(slab_name, dccp_tx_hist_mask, name); 129 sprintf(slab_name, dccp_tx_hist_mask, name);
130 hist->dccptxh_slab = kmem_cache_create(slab_name, 130 hist->dccptxh_slab = kmem_cache_create(slab_name,
131 sizeof(struct dccp_tx_hist_entry), 131 sizeof(struct dccp_tx_hist_entry),
132 0, SLAB_HWCACHE_ALIGN, 132 0, SLAB_HWCACHE_ALIGN,
133 NULL, NULL); 133 NULL, NULL);
134 if (hist->dccptxh_slab == NULL) 134 if (hist->dccptxh_slab == NULL)
@@ -156,8 +156,8 @@ void dccp_tx_hist_delete(struct dccp_tx_hist *hist)
156 156
157EXPORT_SYMBOL_GPL(dccp_tx_hist_delete); 157EXPORT_SYMBOL_GPL(dccp_tx_hist_delete);
158 158
159struct dccp_tx_hist_entry *dccp_tx_hist_find_entry(const struct list_head *list, 159struct dccp_tx_hist_entry *
160 const u64 seq) 160 dccp_tx_hist_find_entry(const struct list_head *list, const u64 seq)
161{ 161{
162 struct dccp_tx_hist_entry *packet = NULL, *entry; 162 struct dccp_tx_hist_entry *packet = NULL, *entry;
163 163
@@ -172,7 +172,8 @@ struct dccp_tx_hist_entry *dccp_tx_hist_find_entry(const struct list_head *list,
172 172
173EXPORT_SYMBOL_GPL(dccp_tx_hist_find_entry); 173EXPORT_SYMBOL_GPL(dccp_tx_hist_find_entry);
174 174
175void dccp_tx_hist_purge_older(struct dccp_tx_hist *hist, struct list_head *list, 175void dccp_tx_hist_purge_older(struct dccp_tx_hist *hist,
176 struct list_head *list,
176 struct dccp_tx_hist_entry *packet) 177 struct dccp_tx_hist_entry *packet)
177{ 178{
178 struct dccp_tx_hist_entry *next; 179 struct dccp_tx_hist_entry *next;
diff --git a/net/dccp/packet_history.h b/net/dccp/packet_history.h
index 0056525a656c..489fff45ccdf 100644
--- a/net/dccp/packet_history.h
+++ b/net/dccp/packet_history.h
@@ -115,7 +115,8 @@ extern void dccp_tx_hist_purge_older(struct dccp_tx_hist *hist,
115extern void dccp_tx_hist_purge(struct dccp_tx_hist *hist, 115extern void dccp_tx_hist_purge(struct dccp_tx_hist *hist,
116 struct list_head *list); 116 struct list_head *list);
117 117
118static inline struct dccp_tx_hist_entry *dccp_tx_hist_head(struct list_head *list) 118static inline struct dccp_tx_hist_entry *
119 dccp_tx_hist_head(struct list_head *list)
119{ 120{
120 struct dccp_tx_hist_entry *head = NULL; 121 struct dccp_tx_hist_entry *head = NULL;
121 122
@@ -163,7 +164,8 @@ static inline void dccp_rx_hist_add_entry(struct list_head *list,
163 list_add(&entry->dccphrx_node, list); 164 list_add(&entry->dccphrx_node, list);
164} 165}
165 166
166static inline struct dccp_rx_hist_entry *dccp_rx_hist_head(struct list_head *list) 167static inline struct dccp_rx_hist_entry *
168 dccp_rx_hist_head(struct list_head *list)
167{ 169{
168 struct dccp_rx_hist_entry *head = NULL; 170 struct dccp_rx_hist_entry *head = NULL;
169 171
diff --git a/net/dccp/proto.c b/net/dccp/proto.c
index 877c1e0e3c48..46dd489f66cf 100644
--- a/net/dccp/proto.c
+++ b/net/dccp/proto.c
@@ -255,12 +255,16 @@ int dccp_recvmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg,
255 255
256 /* FIXME */ 256 /* FIXME */
257#if 0 257#if 0
258 /* Are we at urgent data? Stop if we have read anything or have SIGURG pending. */ 258 /*
259 * Are we at urgent data? Stop if we have read anything or
260 * have SIGURG pending.
261 */
259 if (tp->urg_data && tp->urg_seq == *seq) { 262 if (tp->urg_data && tp->urg_seq == *seq) {
260 if (copied) 263 if (copied)
261 break; 264 break;
262 if (signal_pending(current)) { 265 if (signal_pending(current)) {
263 copied = timeo ? sock_intr_errno(timeo) : -EAGAIN; 266 copied = timeo ? sock_intr_errno(timeo) :
267 -EAGAIN;
264 break; 268 break;
265 } 269 }
266 } 270 }
@@ -285,7 +289,8 @@ int dccp_recvmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg,
285 dccp_pr_debug("found fin ok!\n"); 289 dccp_pr_debug("found fin ok!\n");
286 goto found_fin_ok; 290 goto found_fin_ok;
287 } 291 }
288 dccp_pr_debug("packet_type=%s\n", dccp_packet_name(dh->dccph_type)); 292 dccp_pr_debug("packet_type=%s\n",
293 dccp_packet_name(dh->dccph_type));
289 BUG_TRAP(flags & MSG_PEEK); 294 BUG_TRAP(flags & MSG_PEEK);
290 skb = skb->next; 295 skb = skb->next;
291 } while (skb != (struct sk_buff *)&sk->sk_receive_queue); 296 } while (skb != (struct sk_buff *)&sk->sk_receive_queue);
@@ -439,16 +444,16 @@ out:
439} 444}
440 445
441static const unsigned char dccp_new_state[] = { 446static const unsigned char dccp_new_state[] = {
442 /* current state: new state: action: */ 447 /* current state: new state: action: */
443 [0] = DCCP_CLOSED, 448 [0] = DCCP_CLOSED,
444 [DCCP_OPEN] = DCCP_CLOSING | DCCP_ACTION_FIN, 449 [DCCP_OPEN] = DCCP_CLOSING | DCCP_ACTION_FIN,
445 [DCCP_REQUESTING] = DCCP_CLOSED, 450 [DCCP_REQUESTING] = DCCP_CLOSED,
446 [DCCP_PARTOPEN] = DCCP_CLOSING | DCCP_ACTION_FIN, 451 [DCCP_PARTOPEN] = DCCP_CLOSING | DCCP_ACTION_FIN,
447 [DCCP_LISTEN] = DCCP_CLOSED, 452 [DCCP_LISTEN] = DCCP_CLOSED,
448 [DCCP_RESPOND] = DCCP_CLOSED, 453 [DCCP_RESPOND] = DCCP_CLOSED,
449 [DCCP_CLOSING] = DCCP_CLOSED, 454 [DCCP_CLOSING] = DCCP_CLOSED,
450 [DCCP_TIME_WAIT] = DCCP_CLOSED, 455 [DCCP_TIME_WAIT] = DCCP_CLOSED,
451 [DCCP_CLOSED] = DCCP_CLOSED, 456 [DCCP_CLOSED] = DCCP_CLOSED,
452}; 457};
453 458
454static int dccp_close_state(struct sock *sk) 459static int dccp_close_state(struct sock *sk)
@@ -541,7 +546,8 @@ struct proto_ops inet_dccp_ops = {
541 .getname = inet_getname, 546 .getname = inet_getname,
542 .poll = sock_no_poll, 547 .poll = sock_no_poll,
543 .ioctl = inet_ioctl, 548 .ioctl = inet_ioctl,
544 .listen = inet_dccp_listen, /* FIXME: work on inet_listen to rename it to sock_common_listen */ 549 /* FIXME: work on inet_listen to rename it to sock_common_listen */
550 .listen = inet_dccp_listen,
545 .shutdown = inet_shutdown, 551 .shutdown = inet_shutdown,
546 .setsockopt = sock_common_setsockopt, 552 .setsockopt = sock_common_setsockopt,
547 .getsockopt = sock_common_getsockopt, 553 .getsockopt = sock_common_getsockopt,
@@ -638,10 +644,10 @@ static int __init dccp_init(void)
638 if (rc) 644 if (rc)
639 goto out; 645 goto out;
640 646
641 dccp_hashinfo.bind_bucket_cachep = kmem_cache_create("dccp_bind_bucket", 647 dccp_hashinfo.bind_bucket_cachep =
642 sizeof(struct inet_bind_bucket), 648 kmem_cache_create("dccp_bind_bucket",
643 0, SLAB_HWCACHE_ALIGN, 649 sizeof(struct inet_bind_bucket), 0,
644 NULL, NULL); 650 SLAB_HWCACHE_ALIGN, NULL, NULL);
645 if (!dccp_hashinfo.bind_bucket_cachep) 651 if (!dccp_hashinfo.bind_bucket_cachep)
646 goto out_proto_unregister; 652 goto out_proto_unregister;
647 653
@@ -657,14 +663,16 @@ static int __init dccp_init(void)
657 goal = num_physpages >> (23 - PAGE_SHIFT); 663 goal = num_physpages >> (23 - PAGE_SHIFT);
658 664
659 if (thash_entries) 665 if (thash_entries)
660 goal = (thash_entries * sizeof(struct inet_ehash_bucket)) >> PAGE_SHIFT; 666 goal = (thash_entries *
667 sizeof(struct inet_ehash_bucket)) >> PAGE_SHIFT;
661 for (ehash_order = 0; (1UL << ehash_order) < goal; ehash_order++) 668 for (ehash_order = 0; (1UL << ehash_order) < goal; ehash_order++)
662 ; 669 ;
663 do { 670 do {
664 dccp_hashinfo.ehash_size = (1UL << ehash_order) * PAGE_SIZE / 671 dccp_hashinfo.ehash_size = (1UL << ehash_order) * PAGE_SIZE /
665 sizeof(struct inet_ehash_bucket); 672 sizeof(struct inet_ehash_bucket);
666 dccp_hashinfo.ehash_size >>= 1; 673 dccp_hashinfo.ehash_size >>= 1;
667 while (dccp_hashinfo.ehash_size & (dccp_hashinfo.ehash_size - 1)) 674 while (dccp_hashinfo.ehash_size &
675 (dccp_hashinfo.ehash_size - 1))
668 dccp_hashinfo.ehash_size--; 676 dccp_hashinfo.ehash_size--;
669 dccp_hashinfo.ehash = (struct inet_ehash_bucket *) 677 dccp_hashinfo.ehash = (struct inet_ehash_bucket *)
670 __get_free_pages(GFP_ATOMIC, ehash_order); 678 __get_free_pages(GFP_ATOMIC, ehash_order);
@@ -686,7 +694,8 @@ static int __init dccp_init(void)
686 do { 694 do {
687 dccp_hashinfo.bhash_size = (1UL << bhash_order) * PAGE_SIZE / 695 dccp_hashinfo.bhash_size = (1UL << bhash_order) * PAGE_SIZE /
688 sizeof(struct inet_bind_hashbucket); 696 sizeof(struct inet_bind_hashbucket);
689 if ((dccp_hashinfo.bhash_size > (64 * 1024)) && bhash_order > 0) 697 if ((dccp_hashinfo.bhash_size > (64 * 1024)) &&
698 bhash_order > 0)
690 continue; 699 continue;
691 dccp_hashinfo.bhash = (struct inet_bind_hashbucket *) 700 dccp_hashinfo.bhash = (struct inet_bind_hashbucket *)
692 __get_free_pages(GFP_ATOMIC, bhash_order); 701 __get_free_pages(GFP_ATOMIC, bhash_order);
diff --git a/net/dccp/timer.c b/net/dccp/timer.c
index 9f1f1ab9e2b4..47b1616e6189 100644
--- a/net/dccp/timer.c
+++ b/net/dccp/timer.c
@@ -45,11 +45,13 @@ static int dccp_write_timeout(struct sock *sk)
45 if (sk->sk_state == DCCP_REQUESTING || sk->sk_state == DCCP_PARTOPEN) { 45 if (sk->sk_state == DCCP_REQUESTING || sk->sk_state == DCCP_PARTOPEN) {
46 if (icsk->icsk_retransmits != 0) 46 if (icsk->icsk_retransmits != 0)
47 dst_negative_advice(&sk->sk_dst_cache); 47 dst_negative_advice(&sk->sk_dst_cache);
48 retry_until = icsk->icsk_syn_retries ? : /* FIXME! */ 3 /* FIXME! sysctl_tcp_syn_retries */; 48 retry_until = icsk->icsk_syn_retries ? :
49 /* FIXME! */ 3 /* FIXME! sysctl_tcp_syn_retries */;
49 } else { 50 } else {
50 if (icsk->icsk_retransmits >= /* FIXME! sysctl_tcp_retries1 */ 5 /* FIXME! */) { 51 if (icsk->icsk_retransmits >=
51 /* NOTE. draft-ietf-tcpimpl-pmtud-01.txt requires pmtu black 52 /* FIXME! sysctl_tcp_retries1 */ 5 /* FIXME! */) {
52 hole detection. :-( 53 /* NOTE. draft-ietf-tcpimpl-pmtud-01.txt requires pmtu
54 black hole detection. :-(
53 55
54 It is place to make it. It is not made. I do not want 56 It is place to make it. It is not made. I do not want
55 to make it. It is disguisting. It does not work in any 57 to make it. It is disguisting. It does not work in any
@@ -96,14 +98,17 @@ static void dccp_delack_timer(unsigned long data)
96 /* Try again later. */ 98 /* Try again later. */
97 icsk->icsk_ack.blocked = 1; 99 icsk->icsk_ack.blocked = 1;
98 NET_INC_STATS_BH(LINUX_MIB_DELAYEDACKLOCKED); 100 NET_INC_STATS_BH(LINUX_MIB_DELAYEDACKLOCKED);
99 sk_reset_timer(sk, &icsk->icsk_delack_timer, jiffies + TCP_DELACK_MIN); 101 sk_reset_timer(sk, &icsk->icsk_delack_timer,
102 jiffies + TCP_DELACK_MIN);
100 goto out; 103 goto out;
101 } 104 }
102 105
103 if (sk->sk_state == DCCP_CLOSED || !(icsk->icsk_ack.pending & ICSK_ACK_TIMER)) 106 if (sk->sk_state == DCCP_CLOSED ||
107 !(icsk->icsk_ack.pending & ICSK_ACK_TIMER))
104 goto out; 108 goto out;
105 if (time_after(icsk->icsk_ack.timeout, jiffies)) { 109 if (time_after(icsk->icsk_ack.timeout, jiffies)) {
106 sk_reset_timer(sk, &icsk->icsk_delack_timer, icsk->icsk_ack.timeout); 110 sk_reset_timer(sk, &icsk->icsk_delack_timer,
111 icsk->icsk_ack.timeout);
107 goto out; 112 goto out;
108 } 113 }
109 114
@@ -112,7 +117,8 @@ static void dccp_delack_timer(unsigned long data)
112 if (inet_csk_ack_scheduled(sk)) { 117 if (inet_csk_ack_scheduled(sk)) {
113 if (!icsk->icsk_ack.pingpong) { 118 if (!icsk->icsk_ack.pingpong) {
114 /* Delayed ACK missed: inflate ATO. */ 119 /* Delayed ACK missed: inflate ATO. */
115 icsk->icsk_ack.ato = min(icsk->icsk_ack.ato << 1, icsk->icsk_rto); 120 icsk->icsk_ack.ato = min(icsk->icsk_ack.ato << 1,
121 icsk->icsk_rto);
116 } else { 122 } else {
117 /* Delayed ACK missed: leave pingpong mode and 123 /* Delayed ACK missed: leave pingpong mode and
118 * deflate ATO. 124 * deflate ATO.
@@ -167,7 +173,7 @@ static void dccp_retransmit_timer(struct sock *sk)
167 inet_csk_reset_xmit_timer(sk, ICSK_TIME_RETRANS, 173 inet_csk_reset_xmit_timer(sk, ICSK_TIME_RETRANS,
168 min(icsk->icsk_rto, 174 min(icsk->icsk_rto,
169 TCP_RESOURCE_PROBE_INTERVAL), 175 TCP_RESOURCE_PROBE_INTERVAL),
170 TCP_RTO_MAX); 176 DCCP_RTO_MAX);
171 goto out; 177 goto out;
172 } 178 }
173 179
@@ -175,7 +181,8 @@ static void dccp_retransmit_timer(struct sock *sk)
175 icsk->icsk_retransmits++; 181 icsk->icsk_retransmits++;
176 182
177 icsk->icsk_rto = min(icsk->icsk_rto << 1, DCCP_RTO_MAX); 183 icsk->icsk_rto = min(icsk->icsk_rto << 1, DCCP_RTO_MAX);
178 inet_csk_reset_xmit_timer(sk, ICSK_TIME_RETRANS, icsk->icsk_rto, TCP_RTO_MAX); 184 inet_csk_reset_xmit_timer(sk, ICSK_TIME_RETRANS, icsk->icsk_rto,
185 DCCP_RTO_MAX);
179 if (icsk->icsk_retransmits > 3 /* FIXME: sysctl_dccp_retries1 */) 186 if (icsk->icsk_retransmits > 3 /* FIXME: sysctl_dccp_retries1 */)
180 __sk_dst_reset(sk); 187 __sk_dst_reset(sk);
181out:; 188out:;
@@ -190,7 +197,8 @@ static void dccp_write_timer(unsigned long data)
190 bh_lock_sock(sk); 197 bh_lock_sock(sk);
191 if (sock_owned_by_user(sk)) { 198 if (sock_owned_by_user(sk)) {
192 /* Try again later */ 199 /* Try again later */
193 sk_reset_timer(sk, &icsk->icsk_retransmit_timer, jiffies + (HZ / 20)); 200 sk_reset_timer(sk, &icsk->icsk_retransmit_timer,
201 jiffies + (HZ / 20));
194 goto out; 202 goto out;
195 } 203 }
196 204
@@ -198,7 +206,8 @@ static void dccp_write_timer(unsigned long data)
198 goto out; 206 goto out;
199 207
200 if (time_after(icsk->icsk_timeout, jiffies)) { 208 if (time_after(icsk->icsk_timeout, jiffies)) {
201 sk_reset_timer(sk, &icsk->icsk_retransmit_timer, icsk->icsk_timeout); 209 sk_reset_timer(sk, &icsk->icsk_retransmit_timer,
210 icsk->icsk_timeout);
202 goto out; 211 goto out;
203 } 212 }
204 213
@@ -220,7 +229,8 @@ out:
220 */ 229 */
221static void dccp_response_timer(struct sock *sk) 230static void dccp_response_timer(struct sock *sk)
222{ 231{
223 inet_csk_reqsk_queue_prune(sk, TCP_SYNQ_INTERVAL, DCCP_TIMEOUT_INIT, DCCP_RTO_MAX); 232 inet_csk_reqsk_queue_prune(sk, TCP_SYNQ_INTERVAL, DCCP_TIMEOUT_INIT,
233 DCCP_RTO_MAX);
224} 234}
225 235
226static void dccp_keepalive_timer(unsigned long data) 236static void dccp_keepalive_timer(unsigned long data)