]> git.hungrycats.org Git - linux/commitdiff
[PKTGEN]: Bug fixes, bump to version 2.56.
authorRobert Olsson <robert.olsson@data.slu.se>
Wed, 16 Feb 2005 00:09:40 +0000 (16:09 -0800)
committerLinus Torvalds <torvalds@ppc970.osdl.org>
Wed, 16 Feb 2005 00:09:40 +0000 (16:09 -0800)
- Fix printing of running list, do not stop at first
  not-running device, instead scan them all.
- Do not free SKB before final access via show_results()

Signed-off-by: David S. Miller <davem@davemloft.net>
net/core/pktgen.c

index 31c20a25b301d7b5297cb541d2a75d3ea1fd0876..689db7d8df9b0c35cb94116a40ea3bfc2444dc74 100644 (file)
 #include <asm/timex.h>
 
 
-#define VERSION  "pktgen v2.54: Packet Generator for packet performance testing.\n"
+#define VERSION  "pktgen v2.56: Packet Generator for packet performance testing.\n"
 
 /* #define PG_DEBUG(a) a */
 #define PG_DEBUG(a) 
 #define F_TXSIZE_RND  (1<<6)  /* Transmit size is random */
 #define F_IPV6        (1<<7)  /* Interface in IPV6 Mode */
 
-#define L_PUSH(t, i)              {i->next = t; t=i;}
-#define L_POP(t, i)               {i=t; if(i) t = i->next;}
-
 /* Thread control flag bits */
 #define T_TERMINATE   (1<<0)  
 #define T_STOP        (1<<1)  /* Stop run */
@@ -1366,19 +1363,15 @@ static int proc_thread_read(char *buf , char **start, off_t offset,
         p += sprintf(p, "Running: ");
         
         if_lock(t);
-        pkt_dev = t->if_list;
-        while (pkt_dev && pkt_dev->running) {
-                p += sprintf(p, "%s ", pkt_dev->ifname);
-                pkt_dev = pkt_dev->next;
-        }
+        for(pkt_dev = t->if_list;pkt_dev; pkt_dev = pkt_dev->next) 
+               if(pkt_dev->running)
+                       p += sprintf(p, "%s ", pkt_dev->ifname);
+        
         p += sprintf(p, "\nStopped: ");
 
-        pkt_dev = t->if_list;
-        while (pkt_dev && !pkt_dev->running) {
-                p += sprintf(p, "%s ", pkt_dev->ifname);
-                pkt_dev = pkt_dev->next;
-        }
-
+        for(pkt_dev = t->if_list;pkt_dev; pkt_dev = pkt_dev->next) 
+               if(!pkt_dev->running)
+                       p += sprintf(p, "%s ", pkt_dev->ifname);
 
        if (t->result[0])
                p += sprintf(p, "\nResult: %s\n", t->result);
@@ -2393,7 +2386,7 @@ static void pktgen_stop_all_threads_ifs(void)
        thread_unlock();
 }
 
-static int running(struct pktgen_thread *t )
+static int thread_is_running(struct pktgen_thread *t )
 {
         struct pktgen_dev *next;
         int res = 0;
@@ -2415,7 +2408,7 @@ static int pktgen_wait_thread_run(struct pktgen_thread *t )
         
         if_lock(t);
 
-        while(running(t)) {
+        while(thread_is_running(t)) {
                 if_unlock(t);
         
                 interruptible_sleep_on_timeout(&queue, HZ/10);
@@ -2520,13 +2513,15 @@ static int pktgen_stop_device(struct pktgen_dev *pkt_dev)
                 return -EINVAL;
         }
 
-       if (pkt_dev->skb) 
-               kfree_skb(pkt_dev->skb);
-
         pkt_dev->stopped_at = getCurUs();
         pkt_dev->running = 0;
 
        show_results(pkt_dev, skb_shinfo(pkt_dev->skb)->nr_frags);
+
+       if (pkt_dev->skb) 
+               kfree_skb(pkt_dev->skb);
+
+       pkt_dev->skb = NULL;
        
         return 0;
 }
@@ -2860,10 +2855,10 @@ static struct pktgen_dev *pktgen_find_dev(struct pktgen_thread *t, const char* i
 
         for(pkt_dev=t->if_list; pkt_dev; pkt_dev = pkt_dev->next ) {
                 if (strcmp(pkt_dev->ifname, ifname) == 0) {
-                        goto out;
+                        break;
                 }
         }
- out:
+
         if_unlock(t);
        PG_DEBUG(printk("pktgen: find_dev(%s) returning %p\n", ifname,pkt_dev));
         return pkt_dev;
@@ -2884,8 +2879,7 @@ static int add_dev_to_thread(struct pktgen_thread *t, struct pktgen_dev *pkt_dev
                 rv = -EBUSY;
                 goto out;
         }
-
-       L_PUSH(t->if_list, pkt_dev);
+       pkt_dev->next =t->if_list; t->if_list=pkt_dev;
         pkt_dev->pg_thread = t;
        pkt_dev->running = 0;