[NET]: Make mangling a checksum (0 -> 0xffff on the wire) explicit.
authorAl Viro <viro@zeniv.linux.org.uk>
Thu, 16 Nov 2006 10:36:50 +0000 (02:36 -0800)
committerDavid S. Miller <davem@sunset.davemloft.net>
Sun, 3 Dec 2006 05:23:39 +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/checksum.h
net/ipv4/ipvs/ip_vs_proto_udp.c
net/ipv4/netfilter/ip_nat_helper.c
net/ipv4/netfilter/ip_nat_proto_udp.c
net/ipv4/udp.c
net/ipv6/raw.c
net/ipv6/udp.c

index 2b3c8dc6c11d5f1ac03314a637addda67370c22d..124246172a88990ba6e04c1c7315a4e09f81ce0a 100644 (file)
@@ -92,4 +92,5 @@ static inline __wsum csum_unfold(__sum16 n)
        return (__force __wsum)n;
 }
 
+#define CSUM_MANGLED_0 ((__force __sum16)0xffff)
 #endif
index 261581e6a8142689390080bd01942f070d01f8ef..3647397e416d15681b6ecbd00b3eaf03558f786d 100644 (file)
@@ -125,7 +125,7 @@ udp_fast_csum_update(struct udphdr *uhdr, __be32 oldip, __be32 newip,
                                 ip_vs_check_diff(oldport ^ htons(0xFFFF),
                                                  newport, uhdr->check));
        if (!uhdr->check)
-               uhdr->check = -1;
+               uhdr->check = CSUM_MANGLED_0;
 }
 
 static int
@@ -173,7 +173,7 @@ udp_snat_handler(struct sk_buff **pskb,
                                                cp->protocol,
                                                (*pskb)->csum);
                if (udph->check == 0)
-                       udph->check = -1;
+                       udph->check = CSUM_MANGLED_0;
                IP_VS_DBG(11, "O-pkt: %s O-csum=%d (+%zd)\n",
                          pp->name, udph->check,
                          (char*)&(udph->check) - (char*)udph);
@@ -228,7 +228,7 @@ udp_dnat_handler(struct sk_buff **pskb,
                                                cp->protocol,
                                                (*pskb)->csum);
                if (udph->check == 0)
-                       udph->check = -1;
+                       udph->check = CSUM_MANGLED_0;
                (*pskb)->ip_summed = CHECKSUM_UNNECESSARY;
        }
        return 1;
index 3bf858480558fe26b4c93ef515ebcd9721340e65..3e7fd64c216257678de9548cce3db647f045091f 100644 (file)
@@ -264,7 +264,7 @@ ip_nat_mangle_udp_packet(struct sk_buff **pskb,
                                                csum_partial((char *)udph,
                                                             datalen, 0));
                if (!udph->check)
-                       udph->check = -1;
+                       udph->check = CSUM_MANGLED_0;
        } else
                udph->check = nf_proto_csum_update(*pskb,
                                                   htons(oldlen) ^ htons(0xFFFF),
index 4bbec7730d18b3fbbec444aee353bf0b07dc41dd..82f8a6ab07ecf6281a2b493f9343d0927f0842d7 100644 (file)
@@ -121,7 +121,7 @@ udp_manip_pkt(struct sk_buff **pskb,
                                                  *portptr ^ htons(0xFFFF), newport,
                                                  hdr->check, 0);
                if (!hdr->check)
-                       hdr->check = -1;
+                       hdr->check = CSUM_MANGLED_0;
        }
        *portptr = newport;
        return 1;
index f9c4ed7207bbee76e423699fb451491f3297d8ba..dc19ba1e73b5080121c890cfd153f9dff473df36 100644 (file)
@@ -441,7 +441,7 @@ static void udp4_hwcsum_outgoing(struct sock *sk, struct sk_buff *skb,
 
                uh->check = csum_tcpudp_magic(src, dst, len, IPPROTO_UDP, csum);
                if (uh->check == 0)
-                       uh->check = -1;
+                       uh->check = CSUM_MANGLED_0;
        }
 }
 
@@ -490,7 +490,7 @@ int udp_push_pending_frames(struct sock *sk, struct udp_sock *up)
        uh->check = csum_tcpudp_magic(fl->fl4_src, fl->fl4_dst, up->len,
                                      sk->sk_protocol, csum             );
        if (uh->check == 0)
-               uh->check = -1;
+               uh->check = CSUM_MANGLED_0;
 
 send:
        err = ip_push_pending_frames(sk);
index 9b21d67ca48cffee487a187e083be8f49b6aabdf..c2e629d6aea40e5519c3b865d62e1a092e6c9b60 100644 (file)
@@ -536,8 +536,8 @@ static int rawv6_push_pending_frames(struct sock *sk, struct flowi *fl,
                                   &fl->fl6_dst,
                                   total_len, fl->proto, tmp_csum);
 
-       if (tmp_csum == 0 && fl->proto == IPPROTO_UDP)
-               tmp_csum = -1;
+       if (csum == 0 && fl->proto == IPPROTO_UDP)
+               csum = CSUM_MANGLED_0;
 
        if (skb_store_bits(skb, offset, &csum, 2))
                BUG();
index 0d22008d522ead543c1324f098f0d571792cdfe3..bb45b9b7cbd946bff60c232b15191a4b2c9fc7e2 100644 (file)
@@ -536,7 +536,7 @@ static int udp_v6_push_pending_frames(struct sock *sk, struct udp_sock *up)
        uh->check = csum_ipv6_magic(&fl->fl6_src, &fl->fl6_dst,
                                    up->len, fl->proto, csum   );
        if (uh->check == 0)
-               uh->check = -1;
+               uh->check = CSUM_MANGLED_0;
 
        err = ip6_push_pending_frames(sk);
 out: