Commit f6ab0288 authored by Al Viro's avatar Al Viro Committed by David S. Miller

[NET]: Make mangling a checksum (0 -> 0xffff on the wire) explicit.

Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent b51655b9
...@@ -92,4 +92,5 @@ static inline __wsum csum_unfold(__sum16 n) ...@@ -92,4 +92,5 @@ static inline __wsum csum_unfold(__sum16 n)
return (__force __wsum)n; return (__force __wsum)n;
} }
#define CSUM_MANGLED_0 ((__force __sum16)0xffff)
#endif #endif
...@@ -125,7 +125,7 @@ udp_fast_csum_update(struct udphdr *uhdr, __be32 oldip, __be32 newip, ...@@ -125,7 +125,7 @@ udp_fast_csum_update(struct udphdr *uhdr, __be32 oldip, __be32 newip,
ip_vs_check_diff(oldport ^ htons(0xFFFF), ip_vs_check_diff(oldport ^ htons(0xFFFF),
newport, uhdr->check)); newport, uhdr->check));
if (!uhdr->check) if (!uhdr->check)
uhdr->check = -1; uhdr->check = CSUM_MANGLED_0;
} }
static int static int
...@@ -173,7 +173,7 @@ udp_snat_handler(struct sk_buff **pskb, ...@@ -173,7 +173,7 @@ udp_snat_handler(struct sk_buff **pskb,
cp->protocol, cp->protocol,
(*pskb)->csum); (*pskb)->csum);
if (udph->check == 0) if (udph->check == 0)
udph->check = -1; udph->check = CSUM_MANGLED_0;
IP_VS_DBG(11, "O-pkt: %s O-csum=%d (+%zd)\n", IP_VS_DBG(11, "O-pkt: %s O-csum=%d (+%zd)\n",
pp->name, udph->check, pp->name, udph->check,
(char*)&(udph->check) - (char*)udph); (char*)&(udph->check) - (char*)udph);
...@@ -228,7 +228,7 @@ udp_dnat_handler(struct sk_buff **pskb, ...@@ -228,7 +228,7 @@ udp_dnat_handler(struct sk_buff **pskb,
cp->protocol, cp->protocol,
(*pskb)->csum); (*pskb)->csum);
if (udph->check == 0) if (udph->check == 0)
udph->check = -1; udph->check = CSUM_MANGLED_0;
(*pskb)->ip_summed = CHECKSUM_UNNECESSARY; (*pskb)->ip_summed = CHECKSUM_UNNECESSARY;
} }
return 1; return 1;
......
...@@ -264,7 +264,7 @@ ip_nat_mangle_udp_packet(struct sk_buff **pskb, ...@@ -264,7 +264,7 @@ ip_nat_mangle_udp_packet(struct sk_buff **pskb,
csum_partial((char *)udph, csum_partial((char *)udph,
datalen, 0)); datalen, 0));
if (!udph->check) if (!udph->check)
udph->check = -1; udph->check = CSUM_MANGLED_0;
} else } else
udph->check = nf_proto_csum_update(*pskb, udph->check = nf_proto_csum_update(*pskb,
htons(oldlen) ^ htons(0xFFFF), htons(oldlen) ^ htons(0xFFFF),
......
...@@ -121,7 +121,7 @@ udp_manip_pkt(struct sk_buff **pskb, ...@@ -121,7 +121,7 @@ udp_manip_pkt(struct sk_buff **pskb,
*portptr ^ htons(0xFFFF), newport, *portptr ^ htons(0xFFFF), newport,
hdr->check, 0); hdr->check, 0);
if (!hdr->check) if (!hdr->check)
hdr->check = -1; hdr->check = CSUM_MANGLED_0;
} }
*portptr = newport; *portptr = newport;
return 1; return 1;
......
...@@ -441,7 +441,7 @@ static void udp4_hwcsum_outgoing(struct sock *sk, struct sk_buff *skb, ...@@ -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); uh->check = csum_tcpudp_magic(src, dst, len, IPPROTO_UDP, csum);
if (uh->check == 0) 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) ...@@ -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, uh->check = csum_tcpudp_magic(fl->fl4_src, fl->fl4_dst, up->len,
sk->sk_protocol, csum ); sk->sk_protocol, csum );
if (uh->check == 0) if (uh->check == 0)
uh->check = -1; uh->check = CSUM_MANGLED_0;
send: send:
err = ip_push_pending_frames(sk); err = ip_push_pending_frames(sk);
......
...@@ -536,8 +536,8 @@ static int rawv6_push_pending_frames(struct sock *sk, struct flowi *fl, ...@@ -536,8 +536,8 @@ static int rawv6_push_pending_frames(struct sock *sk, struct flowi *fl,
&fl->fl6_dst, &fl->fl6_dst,
total_len, fl->proto, tmp_csum); total_len, fl->proto, tmp_csum);
if (tmp_csum == 0 && fl->proto == IPPROTO_UDP) if (csum == 0 && fl->proto == IPPROTO_UDP)
tmp_csum = -1; csum = CSUM_MANGLED_0;
if (skb_store_bits(skb, offset, &csum, 2)) if (skb_store_bits(skb, offset, &csum, 2))
BUG(); BUG();
......
...@@ -536,7 +536,7 @@ static int udp_v6_push_pending_frames(struct sock *sk, struct udp_sock *up) ...@@ -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, uh->check = csum_ipv6_magic(&fl->fl6_src, &fl->fl6_dst,
up->len, fl->proto, csum ); up->len, fl->proto, csum );
if (uh->check == 0) if (uh->check == 0)
uh->check = -1; uh->check = CSUM_MANGLED_0;
err = ip6_push_pending_frames(sk); err = ip6_push_pending_frames(sk);
out: out:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment