diff options
author | Patrick McHardy <kaber@trash.net> | 2007-11-29 09:14:30 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2008-01-28 17:55:14 -0500 |
commit | a99a00cf1adef2d3dce745c93c9cc8b0a1612c50 (patch) | |
tree | 4629669029f845ae141693578a899505cde577e9 | |
parent | 3159afe0d2c1994392c269cf9dee2797830d016b (diff) |
[NET]: Move netfilter checksum helpers to net/core/utils.c
This allows to get rid of the CONFIG_NETFILTER dependency of NET_ACT_NAT.
This patch redefines the old names to keep the noise low, the next patch
converts all users.
Signed-off-by: Patrick McHardy <kaber@trash.net>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r-- | include/linux/netfilter.h | 25 | ||||
-rw-r--r-- | include/net/checksum.h | 25 | ||||
-rw-r--r-- | net/core/utils.c | 16 | ||||
-rw-r--r-- | net/netfilter/core.c | 16 |
4 files changed, 45 insertions, 37 deletions
diff --git a/include/linux/netfilter.h b/include/linux/netfilter.h index 25fc12260340..e2bf6d2ffb6c 100644 --- a/include/linux/netfilter.h +++ b/include/linux/netfilter.h | |||
@@ -298,27 +298,10 @@ extern void nf_invalidate_cache(int pf); | |||
298 | Returns true or false. */ | 298 | Returns true or false. */ |
299 | extern int skb_make_writable(struct sk_buff *skb, unsigned int writable_len); | 299 | extern int skb_make_writable(struct sk_buff *skb, unsigned int writable_len); |
300 | 300 | ||
301 | static inline void nf_csum_replace4(__sum16 *sum, __be32 from, __be32 to) | 301 | #define nf_csum_replace4 csum_replace4 |
302 | { | 302 | #define nf_csum_replace2 csum_replace2 |
303 | __be32 diff[] = { ~from, to }; | 303 | #define nf_proto_csum_replace4 inet_proto_csum_replace4 |
304 | 304 | #define nf_proto_csum_replace2 inet_proto_csum_replace2 | |
305 | *sum = csum_fold(csum_partial((char *)diff, sizeof(diff), ~csum_unfold(*sum))); | ||
306 | } | ||
307 | |||
308 | static inline void nf_csum_replace2(__sum16 *sum, __be16 from, __be16 to) | ||
309 | { | ||
310 | nf_csum_replace4(sum, (__force __be32)from, (__force __be32)to); | ||
311 | } | ||
312 | |||
313 | extern void nf_proto_csum_replace4(__sum16 *sum, struct sk_buff *skb, | ||
314 | __be32 from, __be32 to, int pseudohdr); | ||
315 | |||
316 | static inline void nf_proto_csum_replace2(__sum16 *sum, struct sk_buff *skb, | ||
317 | __be16 from, __be16 to, int pseudohdr) | ||
318 | { | ||
319 | nf_proto_csum_replace4(sum, skb, (__force __be32)from, | ||
320 | (__force __be32)to, pseudohdr); | ||
321 | } | ||
322 | 305 | ||
323 | struct nf_afinfo { | 306 | struct nf_afinfo { |
324 | unsigned short family; | 307 | unsigned short family; |
diff --git a/include/net/checksum.h b/include/net/checksum.h index 124246172a88..07602b7fa218 100644 --- a/include/net/checksum.h +++ b/include/net/checksum.h | |||
@@ -93,4 +93,29 @@ static inline __wsum csum_unfold(__sum16 n) | |||
93 | } | 93 | } |
94 | 94 | ||
95 | #define CSUM_MANGLED_0 ((__force __sum16)0xffff) | 95 | #define CSUM_MANGLED_0 ((__force __sum16)0xffff) |
96 | |||
97 | static inline void csum_replace4(__sum16 *sum, __be32 from, __be32 to) | ||
98 | { | ||
99 | __be32 diff[] = { ~from, to }; | ||
100 | |||
101 | *sum = csum_fold(csum_partial((char *)diff, sizeof(diff), ~csum_unfold(*sum))); | ||
102 | } | ||
103 | |||
104 | static inline void csum_replace2(__sum16 *sum, __be16 from, __be16 to) | ||
105 | { | ||
106 | csum_replace4(sum, (__force __be32)from, (__force __be32)to); | ||
107 | } | ||
108 | |||
109 | struct sk_buff; | ||
110 | extern void inet_proto_csum_replace4(__sum16 *sum, struct sk_buff *skb, | ||
111 | __be32 from, __be32 to, int pseudohdr); | ||
112 | |||
113 | static inline void inet_proto_csum_replace2(__sum16 *sum, struct sk_buff *skb, | ||
114 | __be16 from, __be16 to, | ||
115 | int pseudohdr) | ||
116 | { | ||
117 | inet_proto_csum_replace4(sum, skb, (__force __be32)from, | ||
118 | (__force __be32)to, pseudohdr); | ||
119 | } | ||
120 | |||
96 | #endif | 121 | #endif |
diff --git a/net/core/utils.c b/net/core/utils.c index 0bf17da40d52..34459c4c740c 100644 --- a/net/core/utils.c +++ b/net/core/utils.c | |||
@@ -293,3 +293,19 @@ out: | |||
293 | } | 293 | } |
294 | 294 | ||
295 | EXPORT_SYMBOL(in6_pton); | 295 | EXPORT_SYMBOL(in6_pton); |
296 | |||
297 | void inet_proto_csum_replace4(__sum16 *sum, struct sk_buff *skb, | ||
298 | __be32 from, __be32 to, int pseudohdr) | ||
299 | { | ||
300 | __be32 diff[] = { ~from, to }; | ||
301 | if (skb->ip_summed != CHECKSUM_PARTIAL) { | ||
302 | *sum = csum_fold(csum_partial(diff, sizeof(diff), | ||
303 | ~csum_unfold(*sum))); | ||
304 | if (skb->ip_summed == CHECKSUM_COMPLETE && pseudohdr) | ||
305 | skb->csum = ~csum_partial(diff, sizeof(diff), | ||
306 | ~skb->csum); | ||
307 | } else if (pseudohdr) | ||
308 | *sum = ~csum_fold(csum_partial(diff, sizeof(diff), | ||
309 | csum_unfold(*sum))); | ||
310 | } | ||
311 | EXPORT_SYMBOL(inet_proto_csum_replace4); | ||
diff --git a/net/netfilter/core.c b/net/netfilter/core.c index bed9ba01e8ec..631d26948314 100644 --- a/net/netfilter/core.c +++ b/net/netfilter/core.c | |||
@@ -217,22 +217,6 @@ int skb_make_writable(struct sk_buff *skb, unsigned int writable_len) | |||
217 | } | 217 | } |
218 | EXPORT_SYMBOL(skb_make_writable); | 218 | EXPORT_SYMBOL(skb_make_writable); |
219 | 219 | ||
220 | void nf_proto_csum_replace4(__sum16 *sum, struct sk_buff *skb, | ||
221 | __be32 from, __be32 to, int pseudohdr) | ||
222 | { | ||
223 | __be32 diff[] = { ~from, to }; | ||
224 | if (skb->ip_summed != CHECKSUM_PARTIAL) { | ||
225 | *sum = csum_fold(csum_partial(diff, sizeof(diff), | ||
226 | ~csum_unfold(*sum))); | ||
227 | if (skb->ip_summed == CHECKSUM_COMPLETE && pseudohdr) | ||
228 | skb->csum = ~csum_partial(diff, sizeof(diff), | ||
229 | ~skb->csum); | ||
230 | } else if (pseudohdr) | ||
231 | *sum = ~csum_fold(csum_partial(diff, sizeof(diff), | ||
232 | csum_unfold(*sum))); | ||
233 | } | ||
234 | EXPORT_SYMBOL(nf_proto_csum_replace4); | ||
235 | |||
236 | #if defined(CONFIG_NF_CONNTRACK) || defined(CONFIG_NF_CONNTRACK_MODULE) | 220 | #if defined(CONFIG_NF_CONNTRACK) || defined(CONFIG_NF_CONNTRACK_MODULE) |
237 | /* This does not belong here, but locally generated errors need it if connection | 221 | /* This does not belong here, but locally generated errors need it if connection |
238 | tracking in use: without this, connection may not be in hash table, and hence | 222 | tracking in use: without this, connection may not be in hash table, and hence |