IP Masquerading fix for 2.1.14

Matt Cross (profesor@harmless.gweep.net)
Wed, 11 Dec 1996 21:56:34 -0500 (EST)


Between me noticing that UDP worked and TCP didn't, and someone
pointing out to me that IP masquerading worked in 2.1.6 (Thanks
Dennis!) clued me in enough to find the problem. Here's a patch
against the 2.1.14 ip_masq.c fixes the problem:

--- linux-2.1.14/net/ipv4/ip_masq.c Wed Dec 11 21:52:38 1996
+++ linux/net/ipv4/ip_masq.c Wed Dec 11 19:45:07 1996
@@ -566,8 +566,10 @@
else timeout = ip_masq_expire->tcp_timeout;

skb->csum = csum_partial((void *)(th + 1), size - sizeof(*th), 0);
- tcp_v4_check(th, size, iph->saddr, iph->daddr,
- skb->csum);
+ th->check = 0;
+ th->check = tcp_v4_check(th, size, iph->saddr, iph->daddr,
+ csum_partial ((char *)th, sizeof(*th),
+ skb->csum));
}
ip_masq_set_expire(ms, timeout);
ip_send_check(iph);
@@ -899,9 +901,11 @@
len - sizeof(struct tcphdr), 0);
th = (struct tcphdr *) portptr;
th->check = 0;
-
- tcp_v4_check(th, len, iph->saddr, iph->daddr,
- skb->csum);
+ th->check = tcp_v4_check(th, len, iph->saddr,
+ iph->daddr,
+ csum_partial((char *)th,
+ sizeof(*th),
+ skb->csum));

/* Check if TCP FIN or RST */