This moves the shaper local data into the skb->cb struct, removing
ugly ifdefs from the sk_buff. I also documented the purpose of
the control buffer better. For 2.3.x.
-Andi
--- linux/include/linux/skbuff.h-shaper Thu Mar 16 23:55:08 2000
+++ linux/include/linux/skbuff.h Sun Apr 23 00:40:05 2000
@@ -99,6 +99,12 @@
struct dst_entry *dst;
+ /*
+ * This is the control buffer. It is free to use for every
+ * layer. Please put your private variables there. If you
+ * want to keep them across layers you have to do a skb_clone()
+ * first. This is owned by whoever has the skb queued ATM.
+ */
char cb[48];
unsigned int len; /* Length of actual data
*/
@@ -132,13 +138,6 @@
unsigned int nf_debug;
#endif
#endif /*CONFIG_NETFILTER*/
-#if defined(CONFIG_SHAPER) || defined(CONFIG_SHAPER_MODULE)
- __u32 shapelatency; /* Latency on frame */
- __u32 shapeclock; /* Time it should go out */
- __u32 shapelen; /* Frame length in clocks */
- __u32 shapestamp; /* Stamp for shaper */
- __u16 shapepend; /* Pending */
-#endif
#if defined(CONFIG_HIPPI)
union{
--- linux/drivers/net/shaper.c-shaper Wed Mar 15 20:27:11 2000
+++ linux/drivers/net/shaper.c Tue Apr 4 09:33:48 2000
@@ -64,8 +64,12 @@
* Device statistics (tx_pakets, tx_bytes,
* tx_drops: queue_over_time and collisions: max_queue_exceded)
* 1999/06/18 Jordi Murgo <savage@xxxxxxxxxxxx>
+ *
+ * Use skb->cb for private data.
+ * 2000/03 Andi Kleen
*/
+#include <linux/config.h>
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/sched.h>
@@ -84,6 +88,15 @@
#include <net/arp.h>
#include <linux/if_shaper.h>
+struct shaper_cb {
+ __u32 shapelatency; /* Latency on frame */
+ __u32 shapeclock; /* Time it should go out */
+ __u32 shapelen; /* Frame length in clocks */
+ __u32 shapestamp; /* Stamp for shaper */
+ __u16 shapepend; /* Pending */
+};
+#define SHAPERCB(skb) ((struct shaper_cb *) ((skb)->cb))
+
int sh_debug; /* Debug flag */
#define SHAPER_BANNER "CymruNet Traffic Shaper BETA 0.04 for Linux 2.1\n"
@@ -148,7 +161,7 @@
static int shaper_qframe(struct shaper *shaper, struct sk_buff *skb)
{
struct sk_buff *ptr;
-
+
/*
* Get ready to work on this shaper. Lock may fail if its
* an interrupt and locked.
@@ -162,25 +175,25 @@
* Set up our packet details
*/
- skb->shapelatency=0;
- skb->shapeclock=shaper->recovery;
- if(time_before(skb->shapeclock, jiffies))
- skb->shapeclock=jiffies;
+ SHAPERCB(skb)->shapelatency=0;
+ SHAPERCB(skb)->shapeclock=shaper->recovery;
+ if(time_before(SHAPERCB(skb)->shapeclock, jiffies))
+ SHAPERCB(skb)->shapeclock=jiffies;
skb->priority=0; /* short term bug fix */
- skb->shapestamp=jiffies;
+ SHAPERCB(skb)->shapestamp=jiffies;
/*
* Time slots for this packet.
*/
- skb->shapelen= shaper_clocks(shaper,skb);
+ SHAPERCB(skb)->shapelen= shaper_clocks(shaper,skb);
#ifdef SHAPER_COMPLEX /* and broken.. */
while(ptr && ptr!=(struct sk_buff *)&shaper->sendq)
{
if(ptr->pri<skb->pri
- && jiffies - ptr->shapeclock < SHAPER_MAXSLIP)
+ && jiffies - SHAPERCB(ptr)->shapeclock < SHAPER_MAXSLIP)
{
struct sk_buff *tmp=ptr->prev;
@@ -189,14 +202,14 @@
* of the new frame.
*/
- ptr->shapeclock+=skb->shapelen;
- ptr->shapelatency+=skb->shapelen;
+ SHAPERCB(ptr)->shapeclock+=SHAPERCB(skb)->shapelen;
+ SHAPERCB(ptr)->shapelatency+=SHAPERCB(skb)->shapelen;
/*
* The packet may have slipped so far back it
* fell off.
*/
- if(ptr->shapelatency > SHAPER_LATENCY)
+ if(SHAPERCB(ptr)->shapelatency > SHAPER_LATENCY)
{
skb_unlink(ptr);
dev_kfree_skb(ptr);
@@ -217,7 +230,7 @@
* this loop.
*/
for(tmp=skb_peek(&shaper->sendq); tmp!=NULL && tmp!=ptr;
tmp=tmp->next)
- skb->shapeclock+=tmp->shapelen;
+ SHAPERCB(skb)->shapeclock+=tmp->shapelen;
skb_append(ptr,skb);
}
#else
@@ -229,11 +242,11 @@
*/
for(tmp=skb_peek(&shaper->sendq); tmp!=NULL &&
tmp!=(struct sk_buff *)&shaper->sendq; tmp=tmp->next)
- skb->shapeclock+=tmp->shapelen;
+ SHAPERCB(skb)->shapeclock+=SHAPERCB(tmp)->shapelen;
/*
* Queue over time. Spill packet.
*/
- if(skb->shapeclock-jiffies > SHAPER_LATENCY) {
+ if(SHAPERCB(skb)->shapeclock-jiffies > SHAPER_LATENCY) {
dev_kfree_skb(skb);
shaper->stats.tx_dropped++;
} else
@@ -324,22 +337,23 @@
*/
if(sh_debug)
- printk("Clock = %d, jiffies = %ld\n", skb->shapeclock,
jiffies);
- if(time_before_eq(skb->shapeclock - jiffies, SHAPER_BURST))
+ printk("Clock = %d, jiffies = %ld\n",
SHAPERCB(skb)->shapeclock, jiffies);
+ if(time_before_eq(SHAPERCB(skb)->shapeclock - jiffies,
SHAPER_BURST))
{
/*
* Pull the frame and get interrupts back on.
*/
skb_unlink(skb);
- if (shaper->recovery < skb->shapeclock + skb->shapelen)
- shaper->recovery = skb->shapeclock +
skb->shapelen;
+ if (shaper->recovery <
+ SHAPERCB(skb)->shapeclock + SHAPERCB(skb)->shapelen)
+ shaper->recovery = SHAPERCB(skb)->shapeclock +
SHAPERCB(skb)->shapelen;
/*
* Pass on to the physical target device via
* our low level packet thrower.
*/
- skb->shapepend=0;
+ SHAPERCB(skb)->shapepend=0;
shaper_queue_xmit(shaper, skb); /* Fire */
}
else
@@ -351,7 +365,7 @@
*/
if(skb!=NULL)
- mod_timer(&shaper->timer, skb->shapeclock);
+ mod_timer(&shaper->timer, SHAPERCB(skb)->shapeclock);
clear_bit(0, &shaper->locked);
}
--
This is like TV. I don't like TV.
|