patch to fix shaper in 2.1.88

Stanislav V. Voronyi (stas@cnti.uanet.kharkov.ua)
Thu, 26 Feb 1998 18:20:45 +0200


This is my own unofficial patch that fix broken shaper
in all 2.1.[78]* kernels. As for me now it's fork fine.

----------------------- cut here ----------------------------
diff -u --recursive --new-file linux/drivers/net/shaper.c linux.new/drivers/net/shaper.c
--- linux/drivers/net/shaper.c Tue Feb 10 22:56:45 1998
+++ linux.new/drivers/net/shaper.c Thu Feb 26 17:55:35 1998
@@ -74,7 +74,7 @@

int sh_debug; /* Debug flag */

-#define SHAPER_BANNER "CymruNet Traffic Shaper BETA 0.04 for Linux 2.1\n"
+#define SHAPER_BANNER "CymruNet Traffic Shaper BETA 0.05 for Linux 2.1\n"

/*
* Locking
@@ -128,6 +128,7 @@
static void shaper_setspeed(struct shaper *shaper, int bitspersec)
{
shaper->bytespertick=(bitspersec/HZ)/8;
+ printk("set speed to %d bytes per tick\n",shaper->bytespertick);
if(!shaper->bytespertick)
shaper->bytespertick++;
}
@@ -257,7 +258,7 @@
newskb->priority=2;
if(sh_debug)
printk("Kick new frame to %s, %d\n",
- shaper->dev->name,newskb->priority);
+ newskb->dev->name,newskb->priority);
dev_queue_xmit(newskb);
if(sh_debug)
printk("Kicked new frame out.\n");
@@ -470,11 +471,20 @@
sh->header_cache_update(hh, sh->dev, haddr);
}

+static int shaper_neigh_setup(struct neighbour *n)
+{
+ struct shaper *sh=(struct shaper *)n->dev->priv;
+ n->vdev=n->dev;
+ n->dev=sh->dev;
+ return 0;
+}
+
static int shaper_attach(struct device *shdev, struct shaper *sh, struct device *dev)
{
sh->dev = dev;
sh->hard_start_xmit=dev->hard_start_xmit;
sh->get_stats=dev->get_stats;
+ printk("%s attached to %s\n",shdev->name,dev->name);
if(dev->hard_header)
{
sh->hard_header=dev->hard_header;
@@ -512,11 +522,16 @@
#else
shdev->header_cache_update = NULL;
shdev->hard_header_cache = NULL;
-#endif
-
+#endif
+
+ shdev->neigh_setup=shaper_neigh_setup;
shdev->hard_header_len=dev->hard_header_len;
shdev->type=dev->type;
shdev->addr_len=dev->addr_len;
+ for ( i=0 ; i<dev->addr_len ; i++ ) /* for look with ifconfig */
+ shdev->dev_addr[i] = dev->dev_addr[i];
+ for ( i=0 ; i<dev->addr_len ; i++ ) /* for make arp possible */
+ shdev->broadcast[i] = dev->broadcast[i];
shdev->mtu=dev->mtu;
return 0;
}
@@ -525,16 +540,17 @@
{
struct shaperconf *ss= (struct shaperconf *)&ifr->ifr_data;
struct shaper *sh=dev->priv;
- struct device *them=dev_get(ss->ss_name);
+ struct device *them;
switch(ss->ss_cmd)
{
case SHAPER_SET_DEV:
- if(them==NULL)
+ if((them=dev_get(ss->ss_name))==NULL)
return -ENODEV;
if(sh->dev)
return -EBUSY;
return shaper_attach(dev,dev->priv, them);
case SHAPER_SET_SPEED:
+ printk("%s ",dev->name);
shaper_setspeed(sh,ss->ss_speed);
return 0;
default:
diff -u --recursive --new-file linux/include/net/neighbour.h linux.new/include/net/neighbour.h
--- linux/include/net/neighbour.h Tue Feb 10 23:34:26 1998
+++ linux.new/include/net/neighbour.h Thu Feb 26 15:27:31 1998
@@ -84,6 +84,7 @@
struct neigh_table *tbl;
struct neigh_parms *parms;
struct device *dev;
+ struct device *vdev; /* virtual device f.e. shaper */
unsigned long used;
unsigned long confirmed;
unsigned long updated;
diff -u --recursive --new-file linux/net/core/neighbour.c linux.new/net/core/neighbour.c
--- linux/net/core/neighbour.c Thu Feb 26 17:28:24 1998
+++ linux.new/net/core/neighbour.c Thu Feb 26 17:12:57 1998
@@ -112,7 +112,7 @@

np = &tbl->hash_buckets[i];
while ((n = *np) != NULL) {
- if (dev && n->dev != dev) {
+ if (dev && (n->dev != dev && n->vdev != dev)) {
np = &n->next;
continue;
}
@@ -196,10 +196,10 @@
hash_val ^= (hash_val>>16);
hash_val ^= hash_val>>8;
hash_val ^= hash_val>>3;
- hash_val = (hash_val^dev->ifindex)&NEIGH_HASHMASK;
+ hash_val &= NEIGH_HASHMASK; /* don't use anything exept pkey to support vdev */

for (n = tbl->hash_buckets[hash_val]; n; n = n->next) {
- if (dev == n->dev &&
+ if ((dev == n->dev || dev == n->vdev) &&
memcmp(n->primary_key, pkey, key_len) == 0) {
atomic_inc(&n->refcnt);
return n;
diff -u --recursive --new-file linux/net/ipv4/arp.c linux.new/net/ipv4/arp.c
--- linux/net/ipv4/arp.c Thu Feb 26 17:29:19 1998
+++ linux.new/net/ipv4/arp.c Thu Feb 26 15:33:27 1998
@@ -913,7 +913,7 @@
for(i=0; i<=NEIGH_HASHMASK; i++) {
struct neighbour *n;
for (n=arp_tbl.hash_buckets[i]; n; n=n->next) {
- struct device *dev = n->dev;
+ struct device *dev = n->vdev?n->vdev:n->dev;
int hatype = dev->type;

/* I'd get great pleasure deleting
----------------------- cut here -----------------------------

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu