mac80211: fix direct probe loop on ieee80211_work_purge
[safe/jmp/linux-2.6] / net / core / pktgen.c
index 6e79e96..a23b45f 100644 (file)
@@ -340,6 +340,7 @@ struct pktgen_dev {
        __u16 cur_udp_src;
        __u16 cur_queue_map;
        __u32 cur_pkt_size;
+       __u32 last_pkt_size;
 
        __u8 hh[14];
        /* = {
@@ -2051,9 +2052,8 @@ static void pktgen_setup_inject(struct pktgen_dev *pkt_dev)
                                read_lock_bh(&idev->lock);
                                for (ifp = idev->addr_list; ifp;
                                     ifp = ifp->if_next) {
-                                       if (ifp->scope == IFA_LINK
-                                           && !(ifp->
-                                                flags & IFA_F_TENTATIVE)) {
+                                       if (ifp->scope == IFA_LINK &&
+                                           !(ifp->flags & IFA_F_TENTATIVE)) {
                                                ipv6_addr_copy(&pkt_dev->
                                                               cur_in6_saddr,
                                                               &ifp->addr);
@@ -3436,7 +3436,7 @@ static void pktgen_xmit(struct pktgen_dev *pkt_dev)
                        pkt_dev->clone_count--; /* back out increment, OOM */
                        return;
                }
-
+               pkt_dev->last_pkt_size = pkt_dev->skb->len;
                pkt_dev->allocated_skbs++;
                pkt_dev->clone_count = 0;       /* reset counter */
        }
@@ -3448,12 +3448,14 @@ static void pktgen_xmit(struct pktgen_dev *pkt_dev)
        txq = netdev_get_tx_queue(odev, queue_map);
 
        __netif_tx_lock_bh(txq);
-       atomic_inc(&(pkt_dev->skb->users));
 
-       if (unlikely(netif_tx_queue_stopped(txq) || netif_tx_queue_frozen(txq)))
+       if (unlikely(netif_tx_queue_stopped(txq) || netif_tx_queue_frozen(txq))) {
                ret = NETDEV_TX_BUSY;
-       else
-               ret = (*xmit)(pkt_dev->skb, odev);
+               pkt_dev->last_ok = 0;
+               goto unlock;
+       }
+       atomic_inc(&(pkt_dev->skb->users));
+       ret = (*xmit)(pkt_dev->skb, odev);
 
        switch (ret) {
        case NETDEV_TX_OK:
@@ -3461,7 +3463,7 @@ static void pktgen_xmit(struct pktgen_dev *pkt_dev)
                pkt_dev->last_ok = 1;
                pkt_dev->sofar++;
                pkt_dev->seq_num++;
-               pkt_dev->tx_bytes += pkt_dev->cur_pkt_size;
+               pkt_dev->tx_bytes += pkt_dev->last_pkt_size;
                break;
        default: /* Drivers are not supposed to return other values! */
                if (net_ratelimit())
@@ -3475,6 +3477,7 @@ static void pktgen_xmit(struct pktgen_dev *pkt_dev)
                atomic_dec(&(pkt_dev->skb->users));
                pkt_dev->last_ok = 0;
        }
+unlock:
        __netif_tx_unlock_bh(txq);
 
        /* If pkt_dev->count is zero, then run forever */
@@ -3622,6 +3625,7 @@ static int pktgen_add_device(struct pktgen_thread *t, const char *ifname)
 {
        struct pktgen_dev *pkt_dev;
        int err;
+       int node = cpu_to_node(t->cpu);
 
        /* We don't allow a device to be on several threads */
 
@@ -3631,12 +3635,13 @@ static int pktgen_add_device(struct pktgen_thread *t, const char *ifname)
                return -EBUSY;
        }
 
-       pkt_dev = kzalloc(sizeof(struct pktgen_dev), GFP_KERNEL);
+       pkt_dev = kzalloc_node(sizeof(struct pktgen_dev), GFP_KERNEL, node);
        if (!pkt_dev)
                return -ENOMEM;
 
        strcpy(pkt_dev->odevname, ifname);
-       pkt_dev->flows = vmalloc(MAX_CFLOWS * sizeof(struct flow_state));
+       pkt_dev->flows = vmalloc_node(MAX_CFLOWS * sizeof(struct flow_state),
+                                     node);
        if (pkt_dev->flows == NULL) {
                kfree(pkt_dev);
                return -ENOMEM;
@@ -3698,7 +3703,8 @@ static int __init pktgen_create_thread(int cpu)
        struct proc_dir_entry *pe;
        struct task_struct *p;
 
-       t = kzalloc(sizeof(struct pktgen_thread), GFP_KERNEL);
+       t = kzalloc_node(sizeof(struct pktgen_thread), GFP_KERNEL,
+                        cpu_to_node(cpu));
        if (!t) {
                printk(KERN_ERR "pktgen: ERROR: out of memory, can't "
                       "create new thread.\n");