aboutsummaryrefslogtreecommitdiffstats
path: root/net/dccp/dccp.h
diff options
context:
space:
mode:
authorGerrit Renker <gerrit@erg.abdn.ac.uk>2006-11-10 14:43:06 -0500
committerDavid S. Miller <davem@sunset.davemloft.net>2006-12-03 00:22:09 -0500
commit6f4e5fff1e4d46714ea554fd83e44eab534e8b11 (patch)
tree4b14344fd825bbcefb6e8514e98e3e796b2dc1bd /net/dccp/dccp.h
parenta11d206d0f88e092419877c7f706cafb5e1c2e57 (diff)
[DCCP]: Support for partial checksums (RFC 4340, sec. 9.2)
This patch does the following: a) introduces variable-length checksums as specified in [RFC 4340, sec. 9.2] b) provides necessary socket options and documentation as to how to use them c) basic support and infrastructure for the Minimum Checksum Coverage feature [RFC 4340, sec. 9.2.1]: acceptability tests, user notification and user interface In addition, it (1) fixes two bugs in the DCCPv4 checksum computation: * pseudo-header used checksum_len instead of skb->len * incorrect checksum coverage calculation based on dccph_x (2) removes dccp_v4_verify_checksum() since it reduplicates code of the checksum computation; code calling this function is updated accordingly. (3) now uses skb_checksum(), which is safer than checksum_partial() if the sk_buff has is a non-linear buffer (has pages attached to it). (4) fixes an outstanding TODO item: * If P.CsCov is too large for the packet size, drop packet and return. The code has been tested with applications, the latest version of tcpdump now comes with support for partial DCCP checksums. Signed-off-by: Gerrit Renker <gerrit@erg.abdn.ac.uk> Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
Diffstat (limited to 'net/dccp/dccp.h')
-rw-r--r--net/dccp/dccp.h29
1 files changed, 24 insertions, 5 deletions
diff --git a/net/dccp/dccp.h b/net/dccp/dccp.h
index 2990bfb12587..d5c414bf7819 100644
--- a/net/dccp/dccp.h
+++ b/net/dccp/dccp.h
@@ -129,6 +129,30 @@ DECLARE_SNMP_STAT(struct dccp_mib, dccp_statistics);
129#define DCCP_ADD_STATS_USER(field, val) \ 129#define DCCP_ADD_STATS_USER(field, val) \
130 SNMP_ADD_STATS_USER(dccp_statistics, field, val) 130 SNMP_ADD_STATS_USER(dccp_statistics, field, val)
131 131
132/*
133 * Checksumming routines
134 */
135static inline int dccp_csum_coverage(const struct sk_buff *skb)
136{
137 const struct dccp_hdr* dh = dccp_hdr(skb);
138
139 if (dh->dccph_cscov == 0)
140 return skb->len;
141 return (dh->dccph_doff + dh->dccph_cscov - 1) * sizeof(u32);
142}
143
144static inline void dccp_csum_outgoing(struct sk_buff *skb)
145{
146 int cov = dccp_csum_coverage(skb);
147
148 if (cov >= skb->len)
149 dccp_hdr(skb)->dccph_cscov = 0;
150
151 skb->csum = skb_checksum(skb, 0, (cov > skb->len)? skb->len : cov, 0);
152}
153
154extern void dccp_v4_send_check(struct sock *sk, int len, struct sk_buff *skb);
155
132extern int dccp_retransmit_skb(struct sock *sk, struct sk_buff *skb); 156extern int dccp_retransmit_skb(struct sock *sk, struct sk_buff *skb);
133 157
134extern void dccp_send_ack(struct sock *sk); 158extern void dccp_send_ack(struct sock *sk);
@@ -214,14 +238,9 @@ extern void dccp_shutdown(struct sock *sk, int how);
214extern int inet_dccp_listen(struct socket *sock, int backlog); 238extern int inet_dccp_listen(struct socket *sock, int backlog);
215extern unsigned int dccp_poll(struct file *file, struct socket *sock, 239extern unsigned int dccp_poll(struct file *file, struct socket *sock,
216 poll_table *wait); 240 poll_table *wait);
217extern void dccp_v4_send_check(struct sock *sk, int len,
218 struct sk_buff *skb);
219extern int dccp_v4_connect(struct sock *sk, struct sockaddr *uaddr, 241extern int dccp_v4_connect(struct sock *sk, struct sockaddr *uaddr,
220 int addr_len); 242 int addr_len);
221 243
222extern int dccp_v4_checksum(const struct sk_buff *skb,
223 const __be32 saddr, const __be32 daddr);
224
225extern int dccp_send_reset(struct sock *sk, enum dccp_reset_codes code); 244extern int dccp_send_reset(struct sock *sk, enum dccp_reset_codes code);
226extern void dccp_send_close(struct sock *sk, const int active); 245extern void dccp_send_close(struct sock *sk, const int active);
227extern int dccp_invalid_packet(struct sk_buff *skb); 246extern int dccp_invalid_packet(struct sk_buff *skb);