[NET]: ipvs checksum annotations.
authorAl Viro <viro@zeniv.linux.org.uk>
Thu, 16 Nov 2006 10:41:18 +0000 (02:41 -0800)
committerDavid S. Miller <davem@sunset.davemloft.net>
Sun, 3 Dec 2006 05:23:41 +0000 (21:23 -0800)
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Signed-off-by: David S. Miller <davem@davemloft.net>
include/net/ip_vs.h
net/ipv4/ipvs/ip_vs_proto_tcp.c
net/ipv4/ipvs/ip_vs_proto_udp.c

index fedea8db156a61199d968b1f7dd04dbb836b35a7..672564e5a81dc9e3972edcec2b50b57d139052be 100644 (file)
@@ -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);
 
-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),
-                                     oldsum ^ 0xFFFF));
+       return csum_partial((char *) diff, sizeof(diff), oldsum);
+}
+
+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__ */
index b60a07910df7b8a8678cb97e618facd0da6ce252..16a9ebee2fe67f28708fc1ece8cb15a77b04ccda 100644 (file)
@@ -116,9 +116,9 @@ tcp_fast_csum_update(struct tcphdr *tcph, __be32 oldip, __be32 newip,
                     __be16 oldport, __be16 newport)
 {
        tcph->check =
-               ip_vs_check_diff(~oldip, newip,
-                                ip_vs_check_diff(oldport ^ htons(0xFFFF),
-                                                 newport, tcph->check));
+               csum_fold(ip_vs_check_diff4(oldip, newip,
+                                ip_vs_check_diff2(oldport, newport,
+                                               ~csum_unfold(tcph->check))));
 }
 
 
index 3647397e416d15681b6ecbd00b3eaf03558f786d..03f0a414cfa406bce2505c269d6a9b1d24a5bed5 100644 (file)
@@ -121,9 +121,9 @@ udp_fast_csum_update(struct udphdr *uhdr, __be32 oldip, __be32 newip,
                     __be16 oldport, __be16 newport)
 {
        uhdr->check =
-               ip_vs_check_diff(~oldip, newip,
-                                ip_vs_check_diff(oldport ^ htons(0xFFFF),
-                                                 newport, uhdr->check));
+               csum_fold(ip_vs_check_diff4(oldip, newip,
+                                ip_vs_check_diff2(oldport, newport,
+                                       ~csum_unfold(uhdr->check))));
        if (!uhdr->check)
                uhdr->check = CSUM_MANGLED_0;
 }