patch-1.3.54 linux/net/ipv4/ip_forward.c

Next file: linux/net/ipv4/ip_output.c
Previous file: linux/net/core/net_alias.c
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v1.3.53/linux/net/ipv4/ip_forward.c linux/net/ipv4/ip_forward.c
@@ -9,6 +9,7 @@
  *
  * Fixes:
  *		Many		:	Split from ip.c , see ip_input.c for history.
+ *		Dave Gregorich	:	NULL ip_rt_put fix for multicast routing.
  */
 
 #include <linux/config.h>
@@ -242,11 +243,13 @@
 #endif
 		IS_SKB(skb);
 
-		if (skb->len+encap > dev2->mtu && (ntohs(iph->frag_off) & IP_DF)) {
-		  ip_statistics.IpFragFails++;
-		  icmp_send(skb, ICMP_DEST_UNREACH, ICMP_FRAG_NEEDED, htonl(dev2->mtu), dev);
-		  ip_rt_put(rt);
-		  return -1;
+		if (skb->len+encap > dev2->mtu && (ntohs(iph->frag_off) & IP_DF)) 
+		{
+			ip_statistics.IpFragFails++;
+			icmp_send(skb, ICMP_DEST_UNREACH, ICMP_FRAG_NEEDED, htonl(dev2->mtu), dev);
+			if(rt)
+				ip_rt_put(rt);
+			return -1;
 		}
 
 #ifdef CONFIG_IP_MROUTE
@@ -266,7 +269,8 @@
 			if (skb2 == NULL)
 			{
 				NETDEBUG(printk("\nIP: No memory available for IP forward\n"));
-				ip_rt_put(rt);
+				if(rt)
+					ip_rt_put(rt);
 				return -1;
 			}
 		
@@ -427,10 +431,12 @@
 	}
 	else
 	{
-	        ip_rt_put(rt);
+	        if(rt)
+	        	ip_rt_put(rt);
 		return -1;
 	}
-	ip_rt_put(rt);
+	if(rt)
+		ip_rt_put(rt);
 	
 	/*
 	 *	Tell the caller if their buffer is free.

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