patch-1.3.25 linux/net/ipv4/ip.c

Next file: linux/net/ipv4/ip_fw.c
Previous file: linux/net/ipv4/arp.c
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v1.3.24/linux/net/ipv4/ip.c linux/net/ipv4/ip.c
@@ -1055,6 +1055,9 @@
 	unsigned long raddr;	/* Router IP address */
 #ifdef CONFIG_IP_FIREWALL
 	int fw_res = 0;		/* Forwarding result */	
+#ifdef CONFIG_IP_MASQUERADE	
+	struct sk_buff *skb_in = skb;	/* So we can remember if the masquerader did some swaps */
+#endif	
 	
 	/* 
 	 *	See if we are allowed to forward this.
@@ -1295,10 +1298,22 @@
 	
 	/*
 	 *	Tell the caller if their buffer is free.
-	 */
+	 */	 
 	 
 	if(skb==skb2)
+		return 0;	
+
+#ifdef CONFIG_IP_MASQUERADE	
+	/*
+	 *	The original is free. Free our copy and
+	 *	tell the caller not to free.
+	 */
+	if(skb!=skb_in)
+	{
+		kfree_skb(skb_in, FREE_WRITE);
 		return 0;
+	}
+#endif	
 	return 1;
 }
 
@@ -2557,6 +2572,8 @@
 			if(dev->hard_header(skb,dev,ETH_P_IP,NULL,NULL,0)>0)
 				skb->arp=1;
 		}
+		else
+			skb->arp=1;
 		skb->ip_hdr=iph=(struct iphdr *)skb_put(skb,length);
 		dev_lock_list();
 		if(!sk->ip_hdrincl)

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen, slshen@lbl.gov with Sam's (original) version
of this