diff options
Diffstat (limited to 'net/dccp/dccp.h')
-rw-r--r-- | net/dccp/dccp.h | 75 |
1 files changed, 41 insertions, 34 deletions
diff --git a/net/dccp/dccp.h b/net/dccp/dccp.h index e33a9edb4036..d8ad27bfe01a 100644 --- a/net/dccp/dccp.h +++ b/net/dccp/dccp.h | |||
@@ -31,13 +31,9 @@ | |||
31 | __stringify(cond)); \ | 31 | __stringify(cond)); \ |
32 | } while (0) | 32 | } while (0) |
33 | 33 | ||
34 | #ifdef MODULE | ||
35 | #define DCCP_PRINTK(enable, fmt, args...) do { if (enable) \ | 34 | #define DCCP_PRINTK(enable, fmt, args...) do { if (enable) \ |
36 | printk(fmt, ##args); \ | 35 | printk(fmt, ##args); \ |
37 | } while(0) | 36 | } while(0) |
38 | #else | ||
39 | #define DCCP_PRINTK(enable, fmt, args...) printk(fmt, ##args) | ||
40 | #endif | ||
41 | #define DCCP_PR_DEBUG(enable, fmt, a...) DCCP_PRINTK(enable, KERN_DEBUG \ | 37 | #define DCCP_PR_DEBUG(enable, fmt, a...) DCCP_PRINTK(enable, KERN_DEBUG \ |
42 | "%s: " fmt, __FUNCTION__, ##a) | 38 | "%s: " fmt, __FUNCTION__, ##a) |
43 | 39 | ||
@@ -75,11 +71,15 @@ extern void dccp_time_wait(struct sock *sk, int state, int timeo); | |||
75 | /* RFC 1122, 4.2.3.1 initial RTO value */ | 71 | /* RFC 1122, 4.2.3.1 initial RTO value */ |
76 | #define DCCP_TIMEOUT_INIT ((unsigned)(3 * HZ)) | 72 | #define DCCP_TIMEOUT_INIT ((unsigned)(3 * HZ)) |
77 | 73 | ||
74 | #define DCCP_RTO_MAX ((unsigned)(120 * HZ)) /* FIXME: using TCP value */ | ||
75 | |||
76 | /* bounds for sampled RTT values from packet exchanges (in usec) */ | ||
77 | #define DCCP_SANE_RTT_MIN 100 | ||
78 | #define DCCP_SANE_RTT_MAX (4 * USEC_PER_SEC) | ||
79 | |||
78 | /* Maximal interval between probes for local resources. */ | 80 | /* Maximal interval between probes for local resources. */ |
79 | #define DCCP_RESOURCE_PROBE_INTERVAL ((unsigned)(HZ / 2U)) | 81 | #define DCCP_RESOURCE_PROBE_INTERVAL ((unsigned)(HZ / 2U)) |
80 | 82 | ||
81 | #define DCCP_RTO_MAX ((unsigned)(120 * HZ)) /* FIXME: using TCP value */ | ||
82 | |||
83 | /* sysctl variables for DCCP */ | 83 | /* sysctl variables for DCCP */ |
84 | extern int sysctl_dccp_request_retries; | 84 | extern int sysctl_dccp_request_retries; |
85 | extern int sysctl_dccp_retries1; | 85 | extern int sysctl_dccp_retries1; |
@@ -92,17 +92,43 @@ extern int sysctl_dccp_feat_send_ack_vector; | |||
92 | extern int sysctl_dccp_feat_send_ndp_count; | 92 | extern int sysctl_dccp_feat_send_ndp_count; |
93 | extern int sysctl_dccp_tx_qlen; | 93 | extern int sysctl_dccp_tx_qlen; |
94 | 94 | ||
95 | /* | ||
96 | * 48-bit sequence number arithmetic (signed and unsigned) | ||
97 | */ | ||
98 | #define INT48_MIN 0x800000000000LL /* 2^47 */ | ||
99 | #define UINT48_MAX 0xFFFFFFFFFFFFLL /* 2^48 - 1 */ | ||
100 | #define COMPLEMENT48(x) (0x1000000000000LL - (x)) /* 2^48 - x */ | ||
101 | #define TO_SIGNED48(x) (((x) < INT48_MIN)? (x) : -COMPLEMENT48( (x))) | ||
102 | #define TO_UNSIGNED48(x) (((x) >= 0)? (x) : COMPLEMENT48(-(x))) | ||
103 | #define ADD48(a, b) (((a) + (b)) & UINT48_MAX) | ||
104 | #define SUB48(a, b) ADD48((a), COMPLEMENT48(b)) | ||
105 | |||
106 | static inline void dccp_set_seqno(u64 *seqno, u64 value) | ||
107 | { | ||
108 | *seqno = value & UINT48_MAX; | ||
109 | } | ||
110 | |||
111 | static inline void dccp_inc_seqno(u64 *seqno) | ||
112 | { | ||
113 | *seqno = ADD48(*seqno, 1); | ||
114 | } | ||
115 | |||
116 | /* signed mod-2^48 distance: pos. if seqno1 < seqno2, neg. if seqno1 > seqno2 */ | ||
117 | static inline s64 dccp_delta_seqno(const u64 seqno1, const u64 seqno2) | ||
118 | { | ||
119 | u64 delta = SUB48(seqno2, seqno1); | ||
120 | |||
121 | return TO_SIGNED48(delta); | ||
122 | } | ||
123 | |||
95 | /* is seq1 < seq2 ? */ | 124 | /* is seq1 < seq2 ? */ |
96 | static inline int before48(const u64 seq1, const u64 seq2) | 125 | static inline int before48(const u64 seq1, const u64 seq2) |
97 | { | 126 | { |
98 | return (s64)((seq1 << 16) - (seq2 << 16)) < 0; | 127 | return (s64)((seq2 << 16) - (seq1 << 16)) > 0; |
99 | } | 128 | } |
100 | 129 | ||
101 | /* is seq1 > seq2 ? */ | 130 | /* is seq1 > seq2 ? */ |
102 | static inline int after48(const u64 seq1, const u64 seq2) | 131 | #define after48(seq1, seq2) before48(seq2, seq1) |
103 | { | ||
104 | return (s64)((seq2 << 16) - (seq1 << 16)) < 0; | ||
105 | } | ||
106 | 132 | ||
107 | /* is seq2 <= seq1 <= seq3 ? */ | 133 | /* is seq2 <= seq1 <= seq3 ? */ |
108 | static inline int between48(const u64 seq1, const u64 seq2, const u64 seq3) | 134 | static inline int between48(const u64 seq1, const u64 seq2, const u64 seq3) |
@@ -118,9 +144,7 @@ static inline u64 max48(const u64 seq1, const u64 seq2) | |||
118 | /* is seq1 next seqno after seq2 */ | 144 | /* is seq1 next seqno after seq2 */ |
119 | static inline int follows48(const u64 seq1, const u64 seq2) | 145 | static inline int follows48(const u64 seq1, const u64 seq2) |
120 | { | 146 | { |
121 | int diff = (seq1 & 0xFFFF) - (seq2 & 0xFFFF); | 147 | return dccp_delta_seqno(seq2, seq1) == 1; |
122 | |||
123 | return diff==1; | ||
124 | } | 148 | } |
125 | 149 | ||
126 | enum { | 150 | enum { |
@@ -272,6 +296,8 @@ extern int dccp_v4_connect(struct sock *sk, struct sockaddr *uaddr, | |||
272 | extern int dccp_send_reset(struct sock *sk, enum dccp_reset_codes code); | 296 | extern int dccp_send_reset(struct sock *sk, enum dccp_reset_codes code); |
273 | extern void dccp_send_close(struct sock *sk, const int active); | 297 | extern void dccp_send_close(struct sock *sk, const int active); |
274 | extern int dccp_invalid_packet(struct sk_buff *skb); | 298 | extern int dccp_invalid_packet(struct sk_buff *skb); |
299 | extern u32 dccp_sample_rtt(struct sock *sk, struct timeval *t_recv, | ||
300 | struct timeval *t_history); | ||
275 | 301 | ||
276 | static inline int dccp_bad_service_code(const struct sock *sk, | 302 | static inline int dccp_bad_service_code(const struct sock *sk, |
277 | const __be32 service) | 303 | const __be32 service) |
@@ -313,26 +339,7 @@ static inline int dccp_packet_without_ack(const struct sk_buff *skb) | |||
313 | return type == DCCP_PKT_DATA || type == DCCP_PKT_REQUEST; | 339 | return type == DCCP_PKT_DATA || type == DCCP_PKT_REQUEST; |
314 | } | 340 | } |
315 | 341 | ||
316 | #define DCCP_MAX_SEQNO ((((u64)1) << 48) - 1) | 342 | #define DCCP_PKT_WITHOUT_ACK_SEQ (UINT48_MAX << 2) |
317 | #define DCCP_PKT_WITHOUT_ACK_SEQ (DCCP_MAX_SEQNO << 2) | ||
318 | |||
319 | static inline void dccp_set_seqno(u64 *seqno, u64 value) | ||
320 | { | ||
321 | if (value > DCCP_MAX_SEQNO) | ||
322 | value -= DCCP_MAX_SEQNO + 1; | ||
323 | *seqno = value; | ||
324 | } | ||
325 | |||
326 | static inline u64 dccp_delta_seqno(u64 seqno1, u64 seqno2) | ||
327 | { | ||
328 | return ((seqno2 << 16) - (seqno1 << 16)) >> 16; | ||
329 | } | ||
330 | |||
331 | static inline void dccp_inc_seqno(u64 *seqno) | ||
332 | { | ||
333 | if (++*seqno > DCCP_MAX_SEQNO) | ||
334 | *seqno = 0; | ||
335 | } | ||
336 | 343 | ||
337 | static inline void dccp_hdr_set_seq(struct dccp_hdr *dh, const u64 gss) | 344 | static inline void dccp_hdr_set_seq(struct dccp_hdr *dh, const u64 gss) |
338 | { | 345 | { |