ip_fw.c in kernel 1.3.64 (patch included)

Andrew Pollard (andrew@zycad.com)
Fri, 16 Feb 96 21:34:36 GMT


Hi All,

I've just got 1.3.64 and compiled it up. As it was compiling I noticed a
couple of compiler warnings in ip_fw.c relating to incorrect pointer types
being passed as the fifth parameter to tcp_send_check routines...

Now, for ages I have just posted comments to the list and never attempted to
fix anything... so I thought I'd give it a go :-)

Having a quick look at it I noticed a couple of things:

1) tcp_send_check's 5th parameter is a struct sk_buff *skb and it was being
passed an element of *skb instead (skb->sk). This has to be wrong :-)

2) ip_fw_demasquerade has a different meaning for skb_ptr than all the other
bits of code... ie skb usually refers to a 'struct sk_buff*' and skb_ptr to a
'struct sk_buff**', but this routine was using skb_ptr as a 'struct sk_buff*'

The following patch fixes these two points.. Hope it's correct :-)

Andrew.
===============================================================================
| Andrew Pollard, Zycad ?? Division (InCA) UK | Work: andrew@zycad.com |
| Tel:+44(0)1344 51515 Fax:+44(0)1344 421243 | Home: Andrew@odie.demon.co.uk |
===============================================================================

--- linux/net/ipv4/ip_fw.c Fri Feb 16 21:01:36 1996
+++ linux-1.3.64/net/ipv4/ip_fw.c Fri Feb 16 20:30:35 1996
@@ -895,7 +895,7 @@
}
else ms->timer.expires = jiffies+MASQUERADE_EXPIRE_TCP;

- tcp_send_check(th,iph->saddr,iph->daddr,size,skb->sk);
+ tcp_send_check(th,iph->saddr,iph->daddr,size,skb);
}
add_timer(&ms->timer);
ip_send_check(iph);
@@ -914,12 +914,12 @@
* this function.
*/

-int ip_fw_demasquerade(struct sk_buff *skb_ptr)
+int ip_fw_demasquerade(struct sk_buff *skb)
{
- struct iphdr *iph = skb_ptr->h.iph;
+ struct iphdr *iph = skb->h.iph;
unsigned short *portptr;
struct ip_masq *ms;
- struct tcphdr *th = (struct tcphdr *)(skb_ptr->h.raw+(iph->ihl<<2));
+ struct tcphdr *th = (struct tcphdr *)(skb->h.raw+(iph->ihl<<2));

if (iph->protocol!=IPPROTO_UDP && iph->protocol!=IPPROTO_TCP)
return 0;
@@ -954,7 +954,7 @@
portptr[1]==ms->mport)
{

- int size = skb_ptr->len - ((unsigned char *)portptr - skb_ptr->h.raw);
+ int size = skb->len - ((unsigned char *)portptr - skb->h.raw);
iph->daddr = ms->src;
portptr[1] = ms->sport;

@@ -1000,7 +1000,7 @@
#endif
}
}
- tcp_send_check((struct tcphdr *)portptr,iph->saddr,iph->daddr,size,skb_ptr->sk);
+ tcp_send_check((struct tcphdr *)portptr,iph->saddr,iph->daddr,size,skb);
}
ip_send_check(iph);
#ifdef DEBUG_MASQ