aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAl Viro <viro@zeniv.linux.org.uk>2006-11-16 05:41:18 -0500
committerDavid S. Miller <davem@sunset.davemloft.net>2006-12-03 00:23:41 -0500
commitf9214b2627fb8582af1986afc4aed5942086a535 (patch)
tree13bd40def90b1bcf77e2c79a4fcabf60a4d5d444
parent5c78f275e696a25a9919671aa8aa3d0a3d967978 (diff)
[NET]: ipvs checksum annotations.
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk> Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--include/net/ip_vs.h14
-rw-r--r--net/ipv4/ipvs/ip_vs_proto_tcp.c6
-rw-r--r--net/ipv4/ipvs/ip_vs_proto_udp.c6
3 files changed, 16 insertions, 10 deletions
diff --git a/include/net/ip_vs.h b/include/net/ip_vs.h
index fedea8db156a..672564e5a81d 100644
--- a/include/net/ip_vs.h
+++ b/include/net/ip_vs.h
@@ -990,12 +990,18 @@ extern void ip_vs_nat_icmp(struct sk_buff *skb, struct ip_vs_protocol *pp,
990 990
991extern __sum16 ip_vs_checksum_complete(struct sk_buff *skb, int offset); 991extern __sum16 ip_vs_checksum_complete(struct sk_buff *skb, int offset);
992 992
993static inline u16 ip_vs_check_diff(u32 old, u32 new, u16 oldsum) 993static inline __wsum ip_vs_check_diff4(__be32 old, __be32 new, __wsum oldsum)
994{ 994{
995 u32 diff[2] = { old, new }; 995 __be32 diff[2] = { ~old, new };
996 996
997 return csum_fold(csum_partial((char *) diff, sizeof(diff), 997 return csum_partial((char *) diff, sizeof(diff), oldsum);
998 oldsum ^ 0xFFFF)); 998}
999
1000static inline __wsum ip_vs_check_diff2(__be16 old, __be16 new, __wsum oldsum)
1001{
1002 __be16 diff[2] = { ~old, new };
1003
1004 return csum_partial((char *) diff, sizeof(diff), oldsum);
999} 1005}
1000 1006
1001#endif /* __KERNEL__ */ 1007#endif /* __KERNEL__ */
diff --git a/net/ipv4/ipvs/ip_vs_proto_tcp.c b/net/ipv4/ipvs/ip_vs_proto_tcp.c
index b60a07910df7..16a9ebee2fe6 100644
--- a/net/ipv4/ipvs/ip_vs_proto_tcp.c
+++ b/net/ipv4/ipvs/ip_vs_proto_tcp.c
@@ -116,9 +116,9 @@ tcp_fast_csum_update(struct tcphdr *tcph, __be32 oldip, __be32 newip,
116 __be16 oldport, __be16 newport) 116 __be16 oldport, __be16 newport)
117{ 117{
118 tcph->check = 118 tcph->check =
119 ip_vs_check_diff(~oldip, newip, 119 csum_fold(ip_vs_check_diff4(oldip, newip,
120 ip_vs_check_diff(oldport ^ htons(0xFFFF), 120 ip_vs_check_diff2(oldport, newport,
121 newport, tcph->check)); 121 ~csum_unfold(tcph->check))));
122} 122}
123 123
124 124
diff --git a/net/ipv4/ipvs/ip_vs_proto_udp.c b/net/ipv4/ipvs/ip_vs_proto_udp.c
index 3647397e416d..03f0a414cfa4 100644
--- a/net/ipv4/ipvs/ip_vs_proto_udp.c
+++ b/net/ipv4/ipvs/ip_vs_proto_udp.c
@@ -121,9 +121,9 @@ udp_fast_csum_update(struct udphdr *uhdr, __be32 oldip, __be32 newip,
121 __be16 oldport, __be16 newport) 121 __be16 oldport, __be16 newport)
122{ 122{
123 uhdr->check = 123 uhdr->check =
124 ip_vs_check_diff(~oldip, newip, 124 csum_fold(ip_vs_check_diff4(oldip, newip,
125 ip_vs_check_diff(oldport ^ htons(0xFFFF), 125 ip_vs_check_diff2(oldport, newport,
126 newport, uhdr->check)); 126 ~csum_unfold(uhdr->check))));
127 if (!uhdr->check) 127 if (!uhdr->check)
128 uhdr->check = CSUM_MANGLED_0; 128 uhdr->check = CSUM_MANGLED_0;
129} 129}