提交 f9214b26 编写于 作者: A Al Viro 提交者: David S. Miller

[NET]: ipvs checksum annotations.

Signed-off-by: NAl Viro <viro@zeniv.linux.org.uk>
Signed-off-by: NDavid S. Miller <davem@davemloft.net>
上级 5c78f275
...@@ -990,12 +990,18 @@ extern void ip_vs_nat_icmp(struct sk_buff *skb, struct ip_vs_protocol *pp, ...@@ -990,12 +990,18 @@ extern void ip_vs_nat_icmp(struct sk_buff *skb, struct ip_vs_protocol *pp,
extern __sum16 ip_vs_checksum_complete(struct sk_buff *skb, int offset); extern __sum16 ip_vs_checksum_complete(struct sk_buff *skb, int offset);
static inline u16 ip_vs_check_diff(u32 old, u32 new, u16 oldsum) static inline __wsum ip_vs_check_diff4(__be32 old, __be32 new, __wsum oldsum)
{ {
u32 diff[2] = { old, new }; __be32 diff[2] = { ~old, new };
return csum_fold(csum_partial((char *) diff, sizeof(diff), return csum_partial((char *) diff, sizeof(diff), oldsum);
oldsum ^ 0xFFFF)); }
static inline __wsum ip_vs_check_diff2(__be16 old, __be16 new, __wsum oldsum)
{
__be16 diff[2] = { ~old, new };
return csum_partial((char *) diff, sizeof(diff), oldsum);
} }
#endif /* __KERNEL__ */ #endif /* __KERNEL__ */
......
...@@ -116,9 +116,9 @@ tcp_fast_csum_update(struct tcphdr *tcph, __be32 oldip, __be32 newip, ...@@ -116,9 +116,9 @@ tcp_fast_csum_update(struct tcphdr *tcph, __be32 oldip, __be32 newip,
__be16 oldport, __be16 newport) __be16 oldport, __be16 newport)
{ {
tcph->check = tcph->check =
ip_vs_check_diff(~oldip, newip, csum_fold(ip_vs_check_diff4(oldip, newip,
ip_vs_check_diff(oldport ^ htons(0xFFFF), ip_vs_check_diff2(oldport, newport,
newport, tcph->check)); ~csum_unfold(tcph->check))));
} }
......
...@@ -121,9 +121,9 @@ udp_fast_csum_update(struct udphdr *uhdr, __be32 oldip, __be32 newip, ...@@ -121,9 +121,9 @@ udp_fast_csum_update(struct udphdr *uhdr, __be32 oldip, __be32 newip,
__be16 oldport, __be16 newport) __be16 oldport, __be16 newport)
{ {
uhdr->check = uhdr->check =
ip_vs_check_diff(~oldip, newip, csum_fold(ip_vs_check_diff4(oldip, newip,
ip_vs_check_diff(oldport ^ htons(0xFFFF), ip_vs_check_diff2(oldport, newport,
newport, uhdr->check)); ~csum_unfold(uhdr->check))));
if (!uhdr->check) if (!uhdr->check)
uhdr->check = CSUM_MANGLED_0; uhdr->check = CSUM_MANGLED_0;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册