15 #include <linux/dccp.h>
25 #define DCCP_WARN(fmt, a...) LIMIT_NETDEBUG(KERN_WARNING "%s: " fmt, \
27 #define DCCP_CRIT(fmt, a...) printk(KERN_CRIT fmt " at %s:%d/%s()\n", ##a, \
28 __FILE__, __LINE__, __func__)
29 #define DCCP_BUG(a...) do { DCCP_CRIT("BUG: " a); dump_stack(); } while(0)
30 #define DCCP_BUG_ON(cond) do { if (unlikely((cond) != 0)) \
31 DCCP_BUG("\"%s\" holds (exception!)", \
35 #define DCCP_PRINTK(enable, fmt, args...) do { if (enable) \
36 printk(fmt, ##args); \
38 #define DCCP_PR_DEBUG(enable, fmt, a...) DCCP_PRINTK(enable, KERN_DEBUG \
39 "%s: " fmt, __func__, ##a)
41 #ifdef CONFIG_IP_DCCP_DEBUG
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)
45 #define dccp_debug(fmt, a...) dccp_pr_debug_cat(KERN_DEBUG fmt, ##a)
47 #define dccp_pr_debug(format, a...)
48 #define dccp_pr_debug_cat(format, a...)
49 #define dccp_debug(format, a...)
66 #define MAX_DCCP_SPECIFIC_HEADER (255 * sizeof(uint32_t))
67 #define DCCP_MAX_PACKET_HDR 28
68 #define DCCP_MAX_OPT_LEN (MAX_DCCP_SPECIFIC_HEADER - DCCP_MAX_PACKET_HDR)
69 #define MAX_DCCP_HEADER (MAX_DCCP_SPECIFIC_HEADER + MAX_HEADER)
72 #define DCCP_FEATNEG_OVERHEAD (32 * sizeof(uint32_t))
74 #define DCCP_TIMEWAIT_LEN (60 * HZ)
78 #define DCCP_TIMEOUT_INIT ((unsigned int)(3 * HZ))
87 #define DCCP_RTO_MAX ((unsigned int)(64 * HZ))
92 #define DCCP_SANE_RTT_MIN 100
93 #define DCCP_FALLBACK_RTT (USEC_PER_SEC / 5)
94 #define DCCP_SANE_RTT_MAX (3 * USEC_PER_SEC)
106 #define INT48_MIN 0x800000000000LL
107 #define UINT48_MAX 0xFFFFFFFFFFFFLL
108 #define COMPLEMENT48(x) (0x1000000000000LL - (x))
109 #define TO_SIGNED48(x) (((x) < INT48_MIN)? (x) : -COMPLEMENT48( (x)))
110 #define TO_UNSIGNED48(x) (((x) >= 0)? (x) : COMPLEMENT48(-(x)))
111 #define ADD48(a, b) (((a) + (b)) & UINT48_MAX)
112 #define SUB48(a, b) ADD48((a), COMPLEMENT48(b))
119 static inline void dccp_inc_seqno(
u64 *
seqno)
121 *seqno =
ADD48(*seqno, 1);
125 static inline s64 dccp_delta_seqno(
const u64 seqno1,
const u64 seqno2)
133 static inline int before48(
const u64 seq1,
const u64 seq2)
135 return (
s64)((seq2 << 16) - (seq1 << 16)) > 0;
139 #define after48(seq1, seq2) before48(seq2, seq1)
142 static inline int between48(
const u64 seq1,
const u64 seq2,
const u64 seq3)
144 return (seq3 << 16) - (seq2 << 16) >= (seq1 << 16) - (seq2 << 16);
147 static inline u64 max48(
const u64 seq1,
const u64 seq2)
149 return after48(seq1, seq2) ? seq1 : seq2;
158 static inline u64 dccp_loss_count(
const u64 s1,
const u64 s2,
const u64 ndp)
160 s64 delta = dccp_delta_seqno(s1, s2);
165 return delta > 0 ? delta : 0;
171 static inline bool dccp_loss_free(
const u64 s1,
const u64 s2,
const u64 ndp)
173 return dccp_loss_count(s1, s2, ndp) == 0;
195 #define DCCP_MIB_MAX __DCCP_MIB_MAX
201 #define DCCP_INC_STATS(field) SNMP_INC_STATS(dccp_statistics, field)
202 #define DCCP_INC_STATS_BH(field) SNMP_INC_STATS_BH(dccp_statistics, field)
203 #define DCCP_DEC_STATS(field) SNMP_DEC_STATS(dccp_statistics, field)
208 static inline unsigned int dccp_csum_coverage(
const struct sk_buff *
skb)
212 if (dh->dccph_cscov == 0)
217 static inline void dccp_csum_outgoing(
struct sk_buff *
skb)
219 unsigned int cov = dccp_csum_coverage(skb);
256 static inline void dccp_clear_xmit_timers(
struct sock *
sk)
292 const struct dccp_hdr *dh,
const unsigned int len);
305 char __user *optval,
int __user *optlen);
307 char __user *optval,
unsigned int optlen);
309 extern int compat_dccp_getsockopt(
struct sock *
sk,
310 int level,
int optname,
311 char __user *optval,
int __user *optlen);
312 extern int compat_dccp_setsockopt(
struct sock *
sk,
313 int level,
int optname,
314 char __user *optval,
unsigned int optlen);
321 int flags,
int *addr_len);
336 static inline int dccp_bad_service_code(
const struct sock *
sk,
361 #if IS_ENABLED(CONFIG_IPV6)
374 #define DCCP_SKB_CB(__skb) ((struct dccp_skb_cb *)&((__skb)->cb[0]))
377 static inline int dccp_non_data_packet(
const struct sk_buff *skb)
390 static inline int dccp_data_packet(
const struct sk_buff *skb)
400 static inline int dccp_packet_without_ack(
const struct sk_buff *skb)
407 #define DCCP_PKT_WITHOUT_ACK_SEQ (UINT48_MAX << 2)
409 static inline void dccp_hdr_set_seq(
struct dccp_hdr *dh,
const u64 gss)
426 static inline void dccp_update_gsr(
struct sock *sk,
u64 seq)
454 static inline void dccp_update_gss(
struct sock *sk,
u64 seq)
467 static inline int dccp_ackvec_pending(
const struct sock *sk)
469 return dccp_sk(sk)->dccps_hc_rx_ackvec !=
NULL &&
473 static inline int dccp_ack_pending(
const struct sock *sk)
475 return dccp_ackvec_pending(sk) || inet_csk_ack_scheduled(sk);
492 const void *
value,
unsigned char len);