patch-2.1.129 linux/drivers/net/shaper.c

Next file: linux/drivers/net/sunhme.c
Previous file: linux/drivers/net/sgiseeq.c
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.1.128/linux/drivers/net/shaper.c linux/drivers/net/shaper.c
@@ -157,7 +157,7 @@
  	 
  	skb->shapelatency=0;
  	skb->shapeclock=shaper->recovery;
- 	if(skb->shapeclock<jiffies)
+ 	if(time_before(skb->shapeclock, jiffies))
  		skb->shapeclock=jiffies;
  	skb->priority=0;	/* short term bug fix */
  	skb->shapestamp=jiffies;
@@ -320,7 +320,7 @@
 		 
 		if(sh_debug)
 			printk("Clock = %d, jiffies = %ld\n", skb->shapeclock, jiffies);
-		if(skb->shapeclock <= jiffies + SHAPER_BURST)
+		if(skb->shapeclock - jiffies <= SHAPER_BURST)
 		{
 			/*
 			 *	Pull the frame and get interrupts back on.
@@ -385,10 +385,14 @@
 	
 	/*
 	 *	Can't open until attached.
+	 *	Also can't open until speed is set, or we'll get
+	 *	a division by zero.
 	 */
 	 
 	if(shaper->dev==NULL)
 		return -ENODEV;
+	if(shaper->bitspersec==0)
+		return -EINVAL;
 	MOD_INC_USE_COUNT;
 	return 0;
 }
@@ -543,6 +547,7 @@
 	shdev->type=dev->type;
 	shdev->addr_len=dev->addr_len;
 	shdev->mtu=dev->mtu;
+	sh->bitspersec=0;
 	return 0;
 }
 
@@ -564,7 +569,7 @@
 		case SHAPER_GET_DEV:
 			if(sh->dev==NULL)
 				return -ENODEV;
-			memcpy(ss->ss_name, sh->dev->name, sizeof(ss->ss_name));
+			strcpy(ss->ss_name, sh->dev->name);
 			return 0;
 		case SHAPER_SET_SPEED:
 			shaper_setspeed(sh,ss->ss_speed);

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen, slshen@lbl.gov