patch-1.3.51 linux/net/ipv4/igmp.c

Next file: linux/net/ipv4/ip_alias.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.50/linux/net/ipv4/igmp.c linux/net/ipv4/igmp.c
@@ -2,9 +2,11 @@
  *	Linux NET3:	Internet Gateway Management Protocol  [IGMP]
  *
  *	This code implements the IGMP protocol as defined in RFC1122. There has
- *	been a further revision of this protocol since, but since it is not
- *	cleanly specified in any IETF standards we implement the old one properly
- *	rather than play a game of guess the BSD unofficial extensions.
+ *	been a further revision of this protocol since which is now supported.
+ *
+ *	If you have trouble with this module be careful what gcc you have used,
+ *	the older version didnt come out right using gcc 2.5.8, the newer one
+ *	seems to fall out with gcc 2.6.2.
  *
  *	Authors:
  *		Alan Cox <Alan.Cox@linux.org>
@@ -42,6 +44,8 @@
  *					and do what the IGMP version 2 specified.
  *		Chih-Jen Chang	:	Added a timer to revert to IGMP V2 router
  *		Tsu-Sheng Tsao		if the specified time expired.
+ *		Alan Cox	:	Stop IGMP from 0.0.0.0 being accepted.
+ *		Alan Cox	:	Use GFP_ATOMIC in the right places.
  */
 
 
@@ -107,7 +111,10 @@
 	/*
 	 *  Not found. Create a new entry. The default is IGMP V2 router
 	 */
-	i=(struct ip_router_info *)kmalloc(sizeof(*i), GFP_KERNEL);
+	 
+	i=(struct ip_router_info *)kmalloc(sizeof(*i), GFP_ATOMIC);
+	if(i==NULL)
+		return NULL;
 	i->dev = dev;
 	i->type = IGMP_NEW_ROUTER;
 	i->time = IGMP_AGE_THRESHOLD;
@@ -153,7 +160,9 @@
 	/*
 	 *  Not found. Create a new entry.
 	 */
-	i=(struct ip_router_info *)kmalloc(sizeof(*i), GFP_KERNEL);
+	i=(struct ip_router_info *)kmalloc(sizeof(*i), GFP_ATOMIC);
+	if(i==NULL)
+		return NULL;
 	i->dev = dev;
 	i->type = type;
 	i->time = time;
@@ -242,6 +251,8 @@
 	struct ip_router_info *r;
 	igmp_stop_timer(im);
 	r=igmp_get_mrouter_info(im->interface);
+	if(r==NULL)
+		return;
 	if(r->type==IGMP_NEW_ROUTER)
 		igmp_send_report(im->interface, im->multiaddr, IGMP_HOST_NEW_MEMBERSHIP_REPORT);
 	else
@@ -277,7 +288,8 @@
 	{
 		mrouter_type=IGMP_NEW_ROUTER;
 
-		igmp_set_mrouter_info(dev,mrouter_type,0);
+		if(igmp_set_mrouter_info(dev,mrouter_type,0)==NULL)
+			return;
 		/*
 		 * - Start the timers in all of our membership records
 		 *   that the query applies to for the interface on
@@ -310,7 +322,8 @@
 		mrouter_type=IGMP_OLD_ROUTER;
 		max_resp_time=IGMP_MAX_HOST_REPORT_DELAY*IGMP_TIMER_SCALE;
 
-		igmp_set_mrouter_info(dev,mrouter_type,IGMP_AGE_THRESHOLD);
+		if(igmp_set_mrouter_info(dev,mrouter_type,IGMP_AGE_THRESHOLD)==NULL)
+			return;
 
 		/*
 		 * Start the timers in all of our membership records for
@@ -383,6 +396,8 @@
 	igmp_init_timer(im);
 	ip_mc_filter_add(im->interface, im->multiaddr);
 	r=igmp_get_mrouter_info(im->interface);
+	if(r==NULL)
+		return;
 	if(r->type==IGMP_NEW_ROUTER)
 		igmp_send_report(im->interface, im->multiaddr, IGMP_HOST_NEW_MEMBERSHIP_REPORT);
 	else
@@ -412,6 +427,18 @@
 
 	if(skb->len <sizeof(struct igmphdr) || skb->ip_hdr->ttl>1 || ip_compute_csum((void *)skb->h.raw,sizeof(struct igmphdr)))
 	{
+		kfree_skb(skb, FREE_READ);
+		return 0;
+	}
+	
+	/*
+	 *	I have a report that someone does this!
+	 */
+	 
+	if(saddr==0)
+	{
+		printk("Broken multicast host using 0.0.0.0 heard on %s\n",
+			dev->name);
 		kfree_skb(skb, FREE_READ);
 		return 0;
 	}

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