diff options
author | Gerrit Renker <gerrit@erg.abdn.ac.uk> | 2008-09-04 01:30:19 -0400 |
---|---|---|
committer | Gerrit Renker <gerrit@erg.abdn.ac.uk> | 2008-09-04 01:45:32 -0400 |
commit | 51c7d4fa2675c106a980ddcdbe308b54b5151945 (patch) | |
tree | 0c1f2b1a3323582fb8629ba7826e08710271ed49 | |
parent | 09856c108956c99088ead9267ccbd1dab77f7043 (diff) |
dccp: Implement both feature-local and feature-remote Sequence Window feature
This adds full support for local/remote Sequence Window feature, from which the
* sequence-number-validity (W) and
* acknowledgment-number-validity (W') windows
derive as specified in RFC 4340, 7.5.3.
Specifically, the following changes are introduced:
* integrated new socket fields into dccp_sk;
* updated the update_gsr/gss routines with regard to these fields;
* updated handler code: the Sequence Window feature is located at the TX side,
so the local feature is meant if the handler-rx flag is false;
* the initialisation of `rcv_wnd' in reqsk is removed, since
- rcv_wnd is not used by the code anywhere;
- sequence number checks are not done in the LISTEN state (cf. 7.5.3);
- dccp_check_req checks the Ack number validity more rigorously;
* the `struct dccp_minisock' became empty and is now removed.
Until the handshake completes with activating negotiated values, the local/remote
Sequence-Window values are undefined and thus can not reliably be estimated.
This issue is addressed in a separate patch.
Signed-off-by: Gerrit Renker <gerrit@erg.abdn.ac.uk>
Acked-by: Ian McDonald <ian.mcdonald@jandi.co.nz>
-rw-r--r-- | Documentation/networking/dccp.txt | 3 | ||||
-rw-r--r-- | include/linux/dccp.h | 24 | ||||
-rw-r--r-- | net/dccp/dccp.h | 16 | ||||
-rw-r--r-- | net/dccp/feat.c | 13 | ||||
-rw-r--r-- | net/dccp/minisocks.c | 11 | ||||
-rw-r--r-- | net/dccp/proto.c | 2 |
6 files changed, 24 insertions, 45 deletions
diff --git a/Documentation/networking/dccp.txt b/Documentation/networking/dccp.txt index 7a3bb1abb830..b132e4a3cf0f 100644 --- a/Documentation/networking/dccp.txt +++ b/Documentation/networking/dccp.txt | |||
@@ -141,7 +141,8 @@ rx_ccid = 2 | |||
141 | Default CCID for the receiver-sender half-connection; see tx_ccid. | 141 | Default CCID for the receiver-sender half-connection; see tx_ccid. |
142 | 142 | ||
143 | seq_window = 100 | 143 | seq_window = 100 |
144 | The initial sequence window (sec. 7.5.2). | 144 | The initial sequence window (sec. 7.5.2) of the sender. This influences |
145 | the local ackno validity and the remote seqno validity windows (7.5.1). | ||
145 | 146 | ||
146 | tx_qlen = 5 | 147 | tx_qlen = 5 |
147 | The size of the transmit buffer in packets. A value of 0 corresponds | 148 | The size of the transmit buffer in packets. A value of 0 corresponds |
diff --git a/include/linux/dccp.h b/include/linux/dccp.h index 990e97fa1f07..7a0502ab383a 100644 --- a/include/linux/dccp.h +++ b/include/linux/dccp.h | |||
@@ -364,19 +364,6 @@ static inline unsigned int dccp_hdr_len(const struct sk_buff *skb) | |||
364 | #define DCCPF_INITIAL_SEND_NDP_COUNT 1 | 364 | #define DCCPF_INITIAL_SEND_NDP_COUNT 1 |
365 | 365 | ||
366 | /** | 366 | /** |
367 | * struct dccp_minisock - Minimal DCCP connection representation | ||
368 | * | ||
369 | * Will be used to pass the state from dccp_request_sock to dccp_sock. | ||
370 | * | ||
371 | * @dccpms_sequence_window - Sequence Window Feature (section 7.5.2) | ||
372 | */ | ||
373 | struct dccp_minisock { | ||
374 | __u64 dccpms_sequence_window; | ||
375 | }; | ||
376 | |||
377 | extern void dccp_minisock_init(struct dccp_minisock *dmsk); | ||
378 | |||
379 | /** | ||
380 | * struct dccp_request_sock - represent DCCP-specific connection request | 367 | * struct dccp_request_sock - represent DCCP-specific connection request |
381 | * @dreq_inet_rsk: structure inherited from | 368 | * @dreq_inet_rsk: structure inherited from |
382 | * @dreq_iss: initial sequence number sent on the Response (RFC 4340, 7.1) | 369 | * @dreq_iss: initial sequence number sent on the Response (RFC 4340, 7.1) |
@@ -464,13 +451,14 @@ struct dccp_ackvec; | |||
464 | * @dccps_timestamp_time - time of receiving latest @dccps_timestamp_echo | 451 | * @dccps_timestamp_time - time of receiving latest @dccps_timestamp_echo |
465 | * @dccps_l_ack_ratio - feature-local Ack Ratio | 452 | * @dccps_l_ack_ratio - feature-local Ack Ratio |
466 | * @dccps_r_ack_ratio - feature-remote Ack Ratio | 453 | * @dccps_r_ack_ratio - feature-remote Ack Ratio |
454 | * @dccps_l_seq_win - local Sequence Window (influences ack number validity) | ||
455 | * @dccps_r_seq_win - remote Sequence Window (influences seq number validity) | ||
467 | * @dccps_pcslen - sender partial checksum coverage (via sockopt) | 456 | * @dccps_pcslen - sender partial checksum coverage (via sockopt) |
468 | * @dccps_pcrlen - receiver partial checksum coverage (via sockopt) | 457 | * @dccps_pcrlen - receiver partial checksum coverage (via sockopt) |
469 | * @dccps_send_ndp_count - local Send NDP Count feature (7.7.2) | 458 | * @dccps_send_ndp_count - local Send NDP Count feature (7.7.2) |
470 | * @dccps_ndp_count - number of Non Data Packets since last data packet | 459 | * @dccps_ndp_count - number of Non Data Packets since last data packet |
471 | * @dccps_mss_cache - current value of MSS (path MTU minus header sizes) | 460 | * @dccps_mss_cache - current value of MSS (path MTU minus header sizes) |
472 | * @dccps_rate_last - timestamp for rate-limiting DCCP-Sync (RFC 4340, 7.5.4) | 461 | * @dccps_rate_last - timestamp for rate-limiting DCCP-Sync (RFC 4340, 7.5.4) |
473 | * @dccps_minisock - associated minisock (accessed via dccp_msk) | ||
474 | * @dccps_featneg - tracks feature-negotiation state (mostly during handshake) | 462 | * @dccps_featneg - tracks feature-negotiation state (mostly during handshake) |
475 | * @dccps_hc_rx_ackvec - rx half connection ack vector | 463 | * @dccps_hc_rx_ackvec - rx half connection ack vector |
476 | * @dccps_hc_rx_ccid - CCID used for the receiver (or receiving half-connection) | 464 | * @dccps_hc_rx_ccid - CCID used for the receiver (or receiving half-connection) |
@@ -504,12 +492,13 @@ struct dccp_sock { | |||
504 | __u32 dccps_timestamp_time; | 492 | __u32 dccps_timestamp_time; |
505 | __u16 dccps_l_ack_ratio; | 493 | __u16 dccps_l_ack_ratio; |
506 | __u16 dccps_r_ack_ratio; | 494 | __u16 dccps_r_ack_ratio; |
495 | __u64 dccps_l_seq_win:48; | ||
496 | __u64 dccps_r_seq_win:48; | ||
507 | __u8 dccps_pcslen:4; | 497 | __u8 dccps_pcslen:4; |
508 | __u8 dccps_pcrlen:4; | 498 | __u8 dccps_pcrlen:4; |
509 | __u8 dccps_send_ndp_count:1; | 499 | __u8 dccps_send_ndp_count:1; |
510 | __u64 dccps_ndp_count:48; | 500 | __u64 dccps_ndp_count:48; |
511 | unsigned long dccps_rate_last; | 501 | unsigned long dccps_rate_last; |
512 | struct dccp_minisock dccps_minisock; | ||
513 | struct list_head dccps_featneg; | 502 | struct list_head dccps_featneg; |
514 | struct dccp_ackvec *dccps_hc_rx_ackvec; | 503 | struct dccp_ackvec *dccps_hc_rx_ackvec; |
515 | struct ccid *dccps_hc_rx_ccid; | 504 | struct ccid *dccps_hc_rx_ccid; |
@@ -527,11 +516,6 @@ static inline struct dccp_sock *dccp_sk(const struct sock *sk) | |||
527 | return (struct dccp_sock *)sk; | 516 | return (struct dccp_sock *)sk; |
528 | } | 517 | } |
529 | 518 | ||
530 | static inline struct dccp_minisock *dccp_msk(const struct sock *sk) | ||
531 | { | ||
532 | return (struct dccp_minisock *)&dccp_sk(sk)->dccps_minisock; | ||
533 | } | ||
534 | |||
535 | static inline const char *dccp_role(const struct sock *sk) | 519 | static inline const char *dccp_role(const struct sock *sk) |
536 | { | 520 | { |
537 | switch (dccp_sk(sk)->dccps_role) { | 521 | switch (dccp_sk(sk)->dccps_role) { |
diff --git a/net/dccp/dccp.h b/net/dccp/dccp.h index 3fd16e82c003..6101ecdb85b6 100644 --- a/net/dccp/dccp.h +++ b/net/dccp/dccp.h | |||
@@ -409,23 +409,21 @@ static inline void dccp_hdr_set_ack(struct dccp_hdr_ack_bits *dhack, | |||
409 | static inline void dccp_update_gsr(struct sock *sk, u64 seq) | 409 | static inline void dccp_update_gsr(struct sock *sk, u64 seq) |
410 | { | 410 | { |
411 | struct dccp_sock *dp = dccp_sk(sk); | 411 | struct dccp_sock *dp = dccp_sk(sk); |
412 | const struct dccp_minisock *dmsk = dccp_msk(sk); | ||
413 | 412 | ||
414 | dp->dccps_gsr = seq; | 413 | dp->dccps_gsr = seq; |
415 | dccp_set_seqno(&dp->dccps_swl, | 414 | /* Sequence validity window depends on remote Sequence Window (7.5.1) */ |
416 | dp->dccps_gsr + 1 - (dmsk->dccpms_sequence_window / 4)); | 415 | dp->dccps_swl = SUB48(ADD48(dp->dccps_gsr, 1), dp->dccps_r_seq_win / 4); |
417 | dccp_set_seqno(&dp->dccps_swh, | 416 | dp->dccps_swh = ADD48(dp->dccps_gsr, (3 * dp->dccps_r_seq_win) / 4); |
418 | dp->dccps_gsr + (3 * dmsk->dccpms_sequence_window) / 4); | ||
419 | } | 417 | } |
420 | 418 | ||
421 | static inline void dccp_update_gss(struct sock *sk, u64 seq) | 419 | static inline void dccp_update_gss(struct sock *sk, u64 seq) |
422 | { | 420 | { |
423 | struct dccp_sock *dp = dccp_sk(sk); | 421 | struct dccp_sock *dp = dccp_sk(sk); |
424 | 422 | ||
425 | dp->dccps_awh = dp->dccps_gss = seq; | 423 | dp->dccps_gss = seq; |
426 | dccp_set_seqno(&dp->dccps_awl, | 424 | /* Ack validity window depends on local Sequence Window value (7.5.1) */ |
427 | (dp->dccps_gss - | 425 | dp->dccps_awl = SUB48(ADD48(dp->dccps_gss, 1), dp->dccps_l_seq_win); |
428 | dccp_msk(sk)->dccpms_sequence_window + 1)); | 426 | dp->dccps_awh = dp->dccps_gss; |
429 | } | 427 | } |
430 | 428 | ||
431 | static inline int dccp_ack_pending(const struct sock *sk) | 429 | static inline int dccp_ack_pending(const struct sock *sk) |
diff --git a/net/dccp/feat.c b/net/dccp/feat.c index 9a4938092783..843465999854 100644 --- a/net/dccp/feat.c +++ b/net/dccp/feat.c | |||
@@ -52,8 +52,17 @@ static int dccp_hdlr_ccid(struct sock *sk, u64 ccid, bool rx) | |||
52 | 52 | ||
53 | static int dccp_hdlr_seq_win(struct sock *sk, u64 seq_win, bool rx) | 53 | static int dccp_hdlr_seq_win(struct sock *sk, u64 seq_win, bool rx) |
54 | { | 54 | { |
55 | if (!rx) | 55 | struct dccp_sock *dp = dccp_sk(sk); |
56 | dccp_msk(sk)->dccpms_sequence_window = seq_win; | 56 | |
57 | if (rx) { | ||
58 | dp->dccps_r_seq_win = seq_win; | ||
59 | /* propagate changes to update SWL/SWH */ | ||
60 | dccp_update_gsr(sk, dp->dccps_gsr); | ||
61 | } else { | ||
62 | dp->dccps_l_seq_win = seq_win; | ||
63 | /* propagate changes to update AWL */ | ||
64 | dccp_update_gss(sk, dp->dccps_gss); | ||
65 | } | ||
57 | return 0; | 66 | return 0; |
58 | } | 67 | } |
59 | 68 | ||
diff --git a/net/dccp/minisocks.c b/net/dccp/minisocks.c index 0ebf8ebcf3de..0ecb19c5e8ce 100644 --- a/net/dccp/minisocks.c +++ b/net/dccp/minisocks.c | |||
@@ -42,11 +42,6 @@ struct inet_timewait_death_row dccp_death_row = { | |||
42 | 42 | ||
43 | EXPORT_SYMBOL_GPL(dccp_death_row); | 43 | EXPORT_SYMBOL_GPL(dccp_death_row); |
44 | 44 | ||
45 | void dccp_minisock_init(struct dccp_minisock *dmsk) | ||
46 | { | ||
47 | dmsk->dccpms_sequence_window = sysctl_dccp_feat_sequence_window; | ||
48 | } | ||
49 | |||
50 | void dccp_time_wait(struct sock *sk, int state, int timeo) | 45 | void dccp_time_wait(struct sock *sk, int state, int timeo) |
51 | { | 46 | { |
52 | struct inet_timewait_sock *tw = NULL; | 47 | struct inet_timewait_sock *tw = NULL; |
@@ -110,7 +105,6 @@ struct sock *dccp_create_openreq_child(struct sock *sk, | |||
110 | struct dccp_request_sock *dreq = dccp_rsk(req); | 105 | struct dccp_request_sock *dreq = dccp_rsk(req); |
111 | struct inet_connection_sock *newicsk = inet_csk(newsk); | 106 | struct inet_connection_sock *newicsk = inet_csk(newsk); |
112 | struct dccp_sock *newdp = dccp_sk(newsk); | 107 | struct dccp_sock *newdp = dccp_sk(newsk); |
113 | struct dccp_minisock *newdmsk = dccp_msk(newsk); | ||
114 | 108 | ||
115 | newdp->dccps_role = DCCP_ROLE_SERVER; | 109 | newdp->dccps_role = DCCP_ROLE_SERVER; |
116 | newdp->dccps_hc_rx_ackvec = NULL; | 110 | newdp->dccps_hc_rx_ackvec = NULL; |
@@ -128,10 +122,6 @@ struct sock *dccp_create_openreq_child(struct sock *sk, | |||
128 | * Initialize S.GAR := S.ISS | 122 | * Initialize S.GAR := S.ISS |
129 | * Set S.ISR, S.GSR, S.SWL, S.SWH from packet or Init Cookies | 123 | * Set S.ISR, S.GSR, S.SWL, S.SWH from packet or Init Cookies |
130 | */ | 124 | */ |
131 | |||
132 | /* See dccp_v4_conn_request */ | ||
133 | newdmsk->dccpms_sequence_window = req->rcv_wnd; | ||
134 | |||
135 | newdp->dccps_gar = newdp->dccps_iss = dreq->dreq_iss; | 125 | newdp->dccps_gar = newdp->dccps_iss = dreq->dreq_iss; |
136 | dccp_update_gss(newsk, dreq->dreq_iss); | 126 | dccp_update_gss(newsk, dreq->dreq_iss); |
137 | 127 | ||
@@ -289,7 +279,6 @@ int dccp_reqsk_init(struct request_sock *req, | |||
289 | 279 | ||
290 | inet_rsk(req)->rmt_port = dccp_hdr(skb)->dccph_sport; | 280 | inet_rsk(req)->rmt_port = dccp_hdr(skb)->dccph_sport; |
291 | inet_rsk(req)->acked = 0; | 281 | inet_rsk(req)->acked = 0; |
292 | req->rcv_wnd = sysctl_dccp_feat_sequence_window; | ||
293 | dreq->dreq_timestamp_echo = 0; | 282 | dreq->dreq_timestamp_echo = 0; |
294 | 283 | ||
295 | /* inherit feature negotiation options from listening socket */ | 284 | /* inherit feature negotiation options from listening socket */ |
diff --git a/net/dccp/proto.c b/net/dccp/proto.c index 775eaa3d0c49..392a5d822b33 100644 --- a/net/dccp/proto.c +++ b/net/dccp/proto.c | |||
@@ -180,8 +180,6 @@ int dccp_init_sock(struct sock *sk, const __u8 ctl_sock_initialized) | |||
180 | struct dccp_sock *dp = dccp_sk(sk); | 180 | struct dccp_sock *dp = dccp_sk(sk); |
181 | struct inet_connection_sock *icsk = inet_csk(sk); | 181 | struct inet_connection_sock *icsk = inet_csk(sk); |
182 | 182 | ||
183 | dccp_minisock_init(&dp->dccps_minisock); | ||
184 | |||
185 | icsk->icsk_rto = DCCP_TIMEOUT_INIT; | 183 | icsk->icsk_rto = DCCP_TIMEOUT_INIT; |
186 | icsk->icsk_syn_retries = sysctl_dccp_request_retries; | 184 | icsk->icsk_syn_retries = sysctl_dccp_request_retries; |
187 | sk->sk_state = DCCP_CLOSED; | 185 | sk->sk_state = DCCP_CLOSED; |