diff options
author | David S. Miller <davem@davemloft.net> | 2008-09-08 20:28:59 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2008-09-08 20:28:59 -0400 |
commit | 0a68a20cc3eafa73bb54097c28b921147d7d3685 (patch) | |
tree | 8e5f315226b618cb8e050a0c7653c8ec134501e3 /net/dccp/dccp.h | |
parent | 17dce5dfe38ae2fb359b61e855f5d8a3a8b7892b (diff) | |
parent | a3cbdde8e9c38b66b4f13ac5d6ff1939ded0ff20 (diff) |
Merge branch 'dccp' of git://eden-feed.erg.abdn.ac.uk/dccp_exp
Conflicts:
net/dccp/input.c
net/dccp/options.c
Diffstat (limited to 'net/dccp/dccp.h')
-rw-r--r-- | net/dccp/dccp.h | 104 |
1 files changed, 77 insertions, 27 deletions
diff --git a/net/dccp/dccp.h b/net/dccp/dccp.h index b4bc6e095a0e..5281190aa19c 100644 --- a/net/dccp/dccp.h +++ b/net/dccp/dccp.h | |||
@@ -42,9 +42,11 @@ | |||
42 | extern int dccp_debug; | 42 | extern int dccp_debug; |
43 | #define dccp_pr_debug(format, a...) DCCP_PR_DEBUG(dccp_debug, format, ##a) | 43 | #define dccp_pr_debug(format, a...) DCCP_PR_DEBUG(dccp_debug, format, ##a) |
44 | #define dccp_pr_debug_cat(format, a...) DCCP_PRINTK(dccp_debug, format, ##a) | 44 | #define dccp_pr_debug_cat(format, a...) DCCP_PRINTK(dccp_debug, format, ##a) |
45 | #define dccp_debug(fmt, a...) dccp_pr_debug_cat(KERN_DEBUG fmt, ##a) | ||
45 | #else | 46 | #else |
46 | #define dccp_pr_debug(format, a...) | 47 | #define dccp_pr_debug(format, a...) |
47 | #define dccp_pr_debug_cat(format, a...) | 48 | #define dccp_pr_debug_cat(format, a...) |
49 | #define dccp_debug(format, a...) | ||
48 | #endif | 50 | #endif |
49 | 51 | ||
50 | extern struct inet_hashinfo dccp_hashinfo; | 52 | extern struct inet_hashinfo dccp_hashinfo; |
@@ -61,11 +63,14 @@ extern void dccp_time_wait(struct sock *sk, int state, int timeo); | |||
61 | * - DCCP-Reset with ACK Subheader and 4 bytes of Reset Code fields | 63 | * - DCCP-Reset with ACK Subheader and 4 bytes of Reset Code fields |
62 | * Hence a safe upper bound for the maximum option length is 1020-28 = 992 | 64 | * Hence a safe upper bound for the maximum option length is 1020-28 = 992 |
63 | */ | 65 | */ |
64 | #define MAX_DCCP_SPECIFIC_HEADER (255 * sizeof(int)) | 66 | #define MAX_DCCP_SPECIFIC_HEADER (255 * sizeof(uint32_t)) |
65 | #define DCCP_MAX_PACKET_HDR 28 | 67 | #define DCCP_MAX_PACKET_HDR 28 |
66 | #define DCCP_MAX_OPT_LEN (MAX_DCCP_SPECIFIC_HEADER - DCCP_MAX_PACKET_HDR) | 68 | #define DCCP_MAX_OPT_LEN (MAX_DCCP_SPECIFIC_HEADER - DCCP_MAX_PACKET_HDR) |
67 | #define MAX_DCCP_HEADER (MAX_DCCP_SPECIFIC_HEADER + MAX_HEADER) | 69 | #define MAX_DCCP_HEADER (MAX_DCCP_SPECIFIC_HEADER + MAX_HEADER) |
68 | 70 | ||
71 | /* Upper bound for initial feature-negotiation overhead (padded to 32 bits) */ | ||
72 | #define DCCP_FEATNEG_OVERHEAD (32 * sizeof(uint32_t)) | ||
73 | |||
69 | #define DCCP_TIMEWAIT_LEN (60 * HZ) /* how long to wait to destroy TIME-WAIT | 74 | #define DCCP_TIMEWAIT_LEN (60 * HZ) /* how long to wait to destroy TIME-WAIT |
70 | * state, about 60 seconds */ | 75 | * state, about 60 seconds */ |
71 | 76 | ||
@@ -81,10 +86,13 @@ extern void dccp_time_wait(struct sock *sk, int state, int timeo); | |||
81 | */ | 86 | */ |
82 | #define DCCP_RTO_MAX ((unsigned)(64 * HZ)) | 87 | #define DCCP_RTO_MAX ((unsigned)(64 * HZ)) |
83 | 88 | ||
89 | /* DCCP base time resolution - 10 microseconds (RFC 4340, 13.1 ... 13.3) */ | ||
90 | #define DCCP_TIME_RESOLUTION 10 | ||
91 | |||
84 | /* | 92 | /* |
85 | * RTT sampling: sanity bounds and fallback RTT value from RFC 4340, section 3.4 | 93 | * RTT sampling: sanity bounds and fallback RTT value from RFC 4340, section 3.4 |
86 | */ | 94 | */ |
87 | #define DCCP_SANE_RTT_MIN 100 | 95 | #define DCCP_SANE_RTT_MIN (10 * DCCP_TIME_RESOLUTION) |
88 | #define DCCP_FALLBACK_RTT (USEC_PER_SEC / 5) | 96 | #define DCCP_FALLBACK_RTT (USEC_PER_SEC / 5) |
89 | #define DCCP_SANE_RTT_MAX (3 * USEC_PER_SEC) | 97 | #define DCCP_SANE_RTT_MAX (3 * USEC_PER_SEC) |
90 | 98 | ||
@@ -95,12 +103,6 @@ extern void dccp_time_wait(struct sock *sk, int state, int timeo); | |||
95 | extern int sysctl_dccp_request_retries; | 103 | extern int sysctl_dccp_request_retries; |
96 | extern int sysctl_dccp_retries1; | 104 | extern int sysctl_dccp_retries1; |
97 | extern int sysctl_dccp_retries2; | 105 | extern int sysctl_dccp_retries2; |
98 | extern int sysctl_dccp_feat_sequence_window; | ||
99 | extern int sysctl_dccp_feat_rx_ccid; | ||
100 | extern int sysctl_dccp_feat_tx_ccid; | ||
101 | extern int sysctl_dccp_feat_ack_ratio; | ||
102 | extern int sysctl_dccp_feat_send_ack_vector; | ||
103 | extern int sysctl_dccp_feat_send_ndp_count; | ||
104 | extern int sysctl_dccp_tx_qlen; | 106 | extern int sysctl_dccp_tx_qlen; |
105 | extern int sysctl_dccp_sync_ratelimit; | 107 | extern int sysctl_dccp_sync_ratelimit; |
106 | 108 | ||
@@ -235,8 +237,22 @@ extern void dccp_reqsk_send_ack(struct sock *sk, struct sk_buff *skb, | |||
235 | extern void dccp_send_sync(struct sock *sk, const u64 seq, | 237 | extern void dccp_send_sync(struct sock *sk, const u64 seq, |
236 | const enum dccp_pkt_type pkt_type); | 238 | const enum dccp_pkt_type pkt_type); |
237 | 239 | ||
238 | extern void dccp_write_xmit(struct sock *sk, int block); | 240 | /* |
241 | * TX Packet Dequeueing Interface | ||
242 | */ | ||
243 | extern void dccp_qpolicy_push(struct sock *sk, struct sk_buff *skb); | ||
244 | extern bool dccp_qpolicy_full(struct sock *sk); | ||
245 | extern void dccp_qpolicy_drop(struct sock *sk, struct sk_buff *skb); | ||
246 | extern struct sk_buff *dccp_qpolicy_top(struct sock *sk); | ||
247 | extern struct sk_buff *dccp_qpolicy_pop(struct sock *sk); | ||
248 | extern bool dccp_qpolicy_param_ok(struct sock *sk, __be32 param); | ||
249 | |||
250 | /* | ||
251 | * TX Packet Output and TX Timers | ||
252 | */ | ||
253 | extern void dccp_write_xmit(struct sock *sk); | ||
239 | extern void dccp_write_space(struct sock *sk); | 254 | extern void dccp_write_space(struct sock *sk); |
255 | extern void dccp_flush_write_queue(struct sock *sk, long *time_budget); | ||
240 | 256 | ||
241 | extern void dccp_init_xmit_timers(struct sock *sk); | 257 | extern void dccp_init_xmit_timers(struct sock *sk); |
242 | static inline void dccp_clear_xmit_timers(struct sock *sk) | 258 | static inline void dccp_clear_xmit_timers(struct sock *sk) |
@@ -252,7 +268,8 @@ extern const char *dccp_state_name(const int state); | |||
252 | extern void dccp_set_state(struct sock *sk, const int state); | 268 | extern void dccp_set_state(struct sock *sk, const int state); |
253 | extern void dccp_done(struct sock *sk); | 269 | extern void dccp_done(struct sock *sk); |
254 | 270 | ||
255 | extern void dccp_reqsk_init(struct request_sock *req, struct sk_buff *skb); | 271 | extern int dccp_reqsk_init(struct request_sock *rq, struct dccp_sock const *dp, |
272 | struct sk_buff const *skb); | ||
256 | 273 | ||
257 | extern int dccp_v4_conn_request(struct sock *sk, struct sk_buff *skb); | 274 | extern int dccp_v4_conn_request(struct sock *sk, struct sk_buff *skb); |
258 | 275 | ||
@@ -317,7 +334,14 @@ extern struct sk_buff *dccp_ctl_make_reset(struct sock *sk, | |||
317 | extern int dccp_send_reset(struct sock *sk, enum dccp_reset_codes code); | 334 | extern int dccp_send_reset(struct sock *sk, enum dccp_reset_codes code); |
318 | extern void dccp_send_close(struct sock *sk, const int active); | 335 | extern void dccp_send_close(struct sock *sk, const int active); |
319 | extern int dccp_invalid_packet(struct sk_buff *skb); | 336 | extern int dccp_invalid_packet(struct sk_buff *skb); |
320 | extern u32 dccp_sample_rtt(struct sock *sk, long delta); | 337 | |
338 | static inline u32 dccp_sane_rtt(long usec_sample) | ||
339 | { | ||
340 | if (unlikely(usec_sample <= 0 || usec_sample > DCCP_SANE_RTT_MAX)) | ||
341 | DCCP_WARN("RTT sample %ld out of bounds!\n", usec_sample); | ||
342 | return clamp_val(usec_sample, DCCP_SANE_RTT_MIN, DCCP_SANE_RTT_MAX); | ||
343 | } | ||
344 | extern u32 dccp_sample_rtt(struct sock *sk, long delta); | ||
321 | 345 | ||
322 | static inline int dccp_bad_service_code(const struct sock *sk, | 346 | static inline int dccp_bad_service_code(const struct sock *sk, |
323 | const __be32 service) | 347 | const __be32 service) |
@@ -411,36 +435,62 @@ static inline void dccp_hdr_set_ack(struct dccp_hdr_ack_bits *dhack, | |||
411 | static inline void dccp_update_gsr(struct sock *sk, u64 seq) | 435 | static inline void dccp_update_gsr(struct sock *sk, u64 seq) |
412 | { | 436 | { |
413 | struct dccp_sock *dp = dccp_sk(sk); | 437 | struct dccp_sock *dp = dccp_sk(sk); |
414 | const struct dccp_minisock *dmsk = dccp_msk(sk); | ||
415 | 438 | ||
416 | dp->dccps_gsr = seq; | 439 | dp->dccps_gsr = seq; |
417 | dccp_set_seqno(&dp->dccps_swl, | 440 | /* Sequence validity window depends on remote Sequence Window (7.5.1) */ |
418 | dp->dccps_gsr + 1 - (dmsk->dccpms_sequence_window / 4)); | 441 | dp->dccps_swl = SUB48(ADD48(dp->dccps_gsr, 1), dp->dccps_r_seq_win / 4); |
419 | dccp_set_seqno(&dp->dccps_swh, | 442 | /* |
420 | dp->dccps_gsr + (3 * dmsk->dccpms_sequence_window) / 4); | 443 | * Adjust SWL so that it is not below ISR. In contrast to RFC 4340, |
444 | * 7.5.1 we perform this check beyond the initial handshake: W/W' are | ||
445 | * always > 32, so for the first W/W' packets in the lifetime of a | ||
446 | * connection we always have to adjust SWL. | ||
447 | * A second reason why we are doing this is that the window depends on | ||
448 | * the feature-remote value of Sequence Window: nothing stops the peer | ||
449 | * from updating this value while we are busy adjusting SWL for the | ||
450 | * first W packets (we would have to count from scratch again then). | ||
451 | * Therefore it is safer to always make sure that the Sequence Window | ||
452 | * is not artificially extended by a peer who grows SWL downwards by | ||
453 | * continually updating the feature-remote Sequence-Window. | ||
454 | * If sequence numbers wrap it is bad luck. But that will take a while | ||
455 | * (48 bit), and this measure prevents Sequence-number attacks. | ||
456 | */ | ||
457 | if (before48(dp->dccps_swl, dp->dccps_isr)) | ||
458 | dp->dccps_swl = dp->dccps_isr; | ||
459 | dp->dccps_swh = ADD48(dp->dccps_gsr, (3 * dp->dccps_r_seq_win) / 4); | ||
421 | } | 460 | } |
422 | 461 | ||
423 | static inline void dccp_update_gss(struct sock *sk, u64 seq) | 462 | static inline void dccp_update_gss(struct sock *sk, u64 seq) |
424 | { | 463 | { |
425 | struct dccp_sock *dp = dccp_sk(sk); | 464 | struct dccp_sock *dp = dccp_sk(sk); |
426 | 465 | ||
427 | dp->dccps_awh = dp->dccps_gss = seq; | 466 | dp->dccps_gss = seq; |
428 | dccp_set_seqno(&dp->dccps_awl, | 467 | /* Ack validity window depends on local Sequence Window value (7.5.1) */ |
429 | (dp->dccps_gss - | 468 | dp->dccps_awl = SUB48(ADD48(dp->dccps_gss, 1), dp->dccps_l_seq_win); |
430 | dccp_msk(sk)->dccpms_sequence_window + 1)); | 469 | /* Adjust AWL so that it is not below ISS - see comment above for SWL */ |
470 | if (before48(dp->dccps_awl, dp->dccps_iss)) | ||
471 | dp->dccps_awl = dp->dccps_iss; | ||
472 | dp->dccps_awh = dp->dccps_gss; | ||
473 | } | ||
474 | |||
475 | static inline int dccp_ackvec_pending(const struct sock *sk) | ||
476 | { | ||
477 | return dccp_sk(sk)->dccps_hc_rx_ackvec != NULL && | ||
478 | !dccp_ackvec_is_empty(dccp_sk(sk)->dccps_hc_rx_ackvec); | ||
431 | } | 479 | } |
432 | 480 | ||
433 | static inline int dccp_ack_pending(const struct sock *sk) | 481 | static inline int dccp_ack_pending(const struct sock *sk) |
434 | { | 482 | { |
435 | const struct dccp_sock *dp = dccp_sk(sk); | 483 | return dccp_ackvec_pending(sk) || inet_csk_ack_scheduled(sk); |
436 | return dp->dccps_timestamp_echo != 0 || | ||
437 | #ifdef CONFIG_IP_DCCP_ACKVEC | ||
438 | (dccp_msk(sk)->dccpms_send_ack_vector && | ||
439 | dccp_ackvec_pending(dp->dccps_hc_rx_ackvec)) || | ||
440 | #endif | ||
441 | inet_csk_ack_scheduled(sk); | ||
442 | } | 484 | } |
443 | 485 | ||
486 | extern int dccp_feat_signal_nn_change(struct sock *sk, u8 feat, u64 nn_val); | ||
487 | extern int dccp_feat_finalise_settings(struct dccp_sock *dp); | ||
488 | extern int dccp_feat_server_ccid_dependencies(struct dccp_request_sock *dreq); | ||
489 | extern int dccp_feat_insert_opts(struct dccp_sock*, struct dccp_request_sock*, | ||
490 | struct sk_buff *skb); | ||
491 | extern int dccp_feat_activate_values(struct sock *sk, struct list_head *fn); | ||
492 | extern void dccp_feat_list_purge(struct list_head *fn_list); | ||
493 | |||
444 | extern int dccp_insert_options(struct sock *sk, struct sk_buff *skb); | 494 | extern int dccp_insert_options(struct sock *sk, struct sk_buff *skb); |
445 | extern int dccp_insert_options_rsk(struct dccp_request_sock*, struct sk_buff*); | 495 | extern int dccp_insert_options_rsk(struct dccp_request_sock*, struct sk_buff*); |
446 | extern int dccp_insert_option_elapsed_time(struct sock *sk, | 496 | extern int dccp_insert_option_elapsed_time(struct sock *sk, |