diff options
author | Patrick McHardy <kaber@trash.net> | 2006-04-06 17:18:43 -0400 |
---|---|---|
committer | David S. Miller <davem@sunset.davemloft.net> | 2006-04-10 01:25:41 -0400 |
commit | 422c346fad806e2abaeffac686860ebc98dfe33e (patch) | |
tree | dd554d11e80ad33afef4b438ec4c2d8943ad37f4 /include | |
parent | bce8032ef3cc58170ab3550e9e271dba7b4c4764 (diff) |
[NETFILTER]: Add address family specific checksum helpers
Add checksum operation which takes care of verifying the checksum and
dealing with HW checksum errors and avoids multiple checksum
operations by setting ip_summed to CHECKSUM_UNNECESSARY after
successful verification.
Signed-off-by: Patrick McHardy <kaber@trash.net>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'include')
-rw-r--r-- | include/linux/netfilter.h | 17 | ||||
-rw-r--r-- | include/linux/netfilter_ipv4.h | 2 | ||||
-rw-r--r-- | include/linux/netfilter_ipv6.h | 3 |
3 files changed, 22 insertions, 0 deletions
diff --git a/include/linux/netfilter.h b/include/linux/netfilter.h index 6ee168c4978a..b31a9bca9361 100644 --- a/include/linux/netfilter.h +++ b/include/linux/netfilter.h | |||
@@ -285,6 +285,8 @@ extern int skb_make_writable(struct sk_buff **pskb, unsigned int writable_len); | |||
285 | 285 | ||
286 | struct nf_afinfo { | 286 | struct nf_afinfo { |
287 | unsigned short family; | 287 | unsigned short family; |
288 | unsigned int (*checksum)(struct sk_buff *skb, unsigned int hook, | ||
289 | unsigned int dataoff, u_int8_t protocol); | ||
288 | void (*saveroute)(const struct sk_buff *skb, | 290 | void (*saveroute)(const struct sk_buff *skb, |
289 | struct nf_info *info); | 291 | struct nf_info *info); |
290 | int (*reroute)(struct sk_buff **skb, | 292 | int (*reroute)(struct sk_buff **skb, |
@@ -298,6 +300,21 @@ static inline struct nf_afinfo *nf_get_afinfo(unsigned short family) | |||
298 | return rcu_dereference(nf_afinfo[family]); | 300 | return rcu_dereference(nf_afinfo[family]); |
299 | } | 301 | } |
300 | 302 | ||
303 | static inline unsigned int | ||
304 | nf_checksum(struct sk_buff *skb, unsigned int hook, unsigned int dataoff, | ||
305 | u_int8_t protocol, unsigned short family) | ||
306 | { | ||
307 | struct nf_afinfo *afinfo; | ||
308 | unsigned int csum = 0; | ||
309 | |||
310 | rcu_read_lock(); | ||
311 | afinfo = nf_get_afinfo(family); | ||
312 | if (afinfo) | ||
313 | csum = afinfo->checksum(skb, hook, dataoff, protocol); | ||
314 | rcu_read_unlock(); | ||
315 | return csum; | ||
316 | } | ||
317 | |||
301 | extern int nf_register_afinfo(struct nf_afinfo *afinfo); | 318 | extern int nf_register_afinfo(struct nf_afinfo *afinfo); |
302 | extern void nf_unregister_afinfo(struct nf_afinfo *afinfo); | 319 | extern void nf_unregister_afinfo(struct nf_afinfo *afinfo); |
303 | 320 | ||
diff --git a/include/linux/netfilter_ipv4.h b/include/linux/netfilter_ipv4.h index 43c09d790b83..85301c5e8d24 100644 --- a/include/linux/netfilter_ipv4.h +++ b/include/linux/netfilter_ipv4.h | |||
@@ -80,6 +80,8 @@ enum nf_ip_hook_priorities { | |||
80 | #ifdef __KERNEL__ | 80 | #ifdef __KERNEL__ |
81 | extern int ip_route_me_harder(struct sk_buff **pskb); | 81 | extern int ip_route_me_harder(struct sk_buff **pskb); |
82 | extern int ip_xfrm_me_harder(struct sk_buff **pskb); | 82 | extern int ip_xfrm_me_harder(struct sk_buff **pskb); |
83 | extern unsigned int nf_ip_checksum(struct sk_buff *skb, unsigned int hook, | ||
84 | unsigned int dataoff, u_int8_t protocol); | ||
83 | #endif /*__KERNEL__*/ | 85 | #endif /*__KERNEL__*/ |
84 | 86 | ||
85 | #endif /*__LINUX_IP_NETFILTER_H*/ | 87 | #endif /*__LINUX_IP_NETFILTER_H*/ |
diff --git a/include/linux/netfilter_ipv6.h b/include/linux/netfilter_ipv6.h index 14f2bd010884..52a7b9e76428 100644 --- a/include/linux/netfilter_ipv6.h +++ b/include/linux/netfilter_ipv6.h | |||
@@ -73,6 +73,9 @@ enum nf_ip6_hook_priorities { | |||
73 | }; | 73 | }; |
74 | 74 | ||
75 | #ifdef CONFIG_NETFILTER | 75 | #ifdef CONFIG_NETFILTER |
76 | extern unsigned int nf_ip6_checksum(struct sk_buff *skb, unsigned int hook, | ||
77 | unsigned int dataoff, u_int8_t protocol); | ||
78 | |||
76 | extern int ipv6_netfilter_init(void); | 79 | extern int ipv6_netfilter_init(void); |
77 | extern void ipv6_netfilter_fini(void); | 80 | extern void ipv6_netfilter_fini(void); |
78 | #else /* CONFIG_NETFILTER */ | 81 | #else /* CONFIG_NETFILTER */ |