return 0;
 }
 
-static int ieee80211_store_ack_skb(struct ieee80211_local *local,
+static u16 ieee80211_store_ack_skb(struct ieee80211_local *local,
                                   struct sk_buff *skb,
-                                  u32 *info_flags)
+                                  u32 *info_flags,
+                                  u64 *cookie)
 {
-       struct sk_buff *ack_skb = skb_clone_sk(skb);
+       struct sk_buff *ack_skb;
        u16 info_id = 0;
 
+       if (skb->sk)
+               ack_skb = skb_clone_sk(skb);
+       else
+               ack_skb = skb_clone(skb, GFP_ATOMIC);
+
        if (ack_skb) {
                unsigned long flags;
                int id;
                if (id >= 0) {
                        info_id = id;
                        *info_flags |= IEEE80211_TX_CTL_REQ_TX_STATUS;
+                       if (cookie) {
+                               *cookie = ieee80211_mgmt_tx_cookie(local);
+                               IEEE80211_SKB_CB(ack_skb)->ack.cookie = *cookie;
+                       }
                } else {
                        kfree_skb(ack_skb);
                }
  */
 static struct sk_buff *ieee80211_build_hdr(struct ieee80211_sub_if_data *sdata,
                                           struct sk_buff *skb, u32 info_flags,
-                                          struct sta_info *sta, u32 ctrl_flags)
+                                          struct sta_info *sta, u32 ctrl_flags,
+                                          u64 *cookie)
 {
        struct ieee80211_local *local = sdata->local;
        struct ieee80211_tx_info *info;
                goto free;
        }
 
-       if (unlikely(!multicast && skb->sk &&
-                    skb_shinfo(skb)->tx_flags & SKBTX_WIFI_STATUS))
-               info_id = ieee80211_store_ack_skb(local, skb, &info_flags);
+       if (unlikely(!multicast && ((skb->sk &&
+                    skb_shinfo(skb)->tx_flags & SKBTX_WIFI_STATUS) ||
+                    ctrl_flags & IEEE80211_TX_CTL_REQ_TX_STATUS)))
+               info_id = ieee80211_store_ack_skb(local, skb, &info_flags,
+                                                 cookie);
 
        /*
         * If the skb is shared we need to obtain our own copy.
 void __ieee80211_subif_start_xmit(struct sk_buff *skb,
                                  struct net_device *dev,
                                  u32 info_flags,
-                                 u32 ctrl_flags)
+                                 u32 ctrl_flags,
+                                 u64 *cookie)
 {
        struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
        struct ieee80211_local *local = sdata->local;
                skb_mark_not_on_list(skb);
 
                skb = ieee80211_build_hdr(sdata, skb, info_flags,
-                                         sta, ctrl_flags);
+                                         sta, ctrl_flags, cookie);
                if (IS_ERR(skb)) {
                        kfree_skb_list(next);
                        goto out;
                __skb_queue_head_init(&queue);
                ieee80211_convert_to_unicast(skb, dev, &queue);
                while ((skb = __skb_dequeue(&queue)))
-                       __ieee80211_subif_start_xmit(skb, dev, 0, 0);
+                       __ieee80211_subif_start_xmit(skb, dev, 0, 0, NULL);
        } else {
-               __ieee80211_subif_start_xmit(skb, dev, 0, 0);
+               __ieee80211_subif_start_xmit(skb, dev, 0, 0, NULL);
        }
 
        return NETDEV_TX_OK;
 
        if (unlikely(!multicast && skb->sk &&
                     skb_shinfo(skb)->tx_flags & SKBTX_WIFI_STATUS))
-               ieee80211_store_ack_skb(local, skb, &info->flags);
+               ieee80211_store_ack_skb(local, skb, &info->flags, NULL);
 
        memset(info, 0, sizeof(*info));
 
                goto out;
        }
 
-       skb = ieee80211_build_hdr(sdata, skb, info_flags, sta, 0);
+       skb = ieee80211_build_hdr(sdata, skb, info_flags, sta, 0, NULL);
        if (IS_ERR(skb))
                goto out;
 
        struct sk_buff *skb;
        struct ethhdr *ehdr;
        u32 ctrl_flags = 0;
-       u32 flags;
+       u32 flags = 0;
 
        /* Only accept CONTROL_PORT_PROTOCOL configured in CONNECT/ASSOCIATE
         * or Pre-Authentication
                ctrl_flags |= IEEE80211_TX_CTRL_PORT_CTRL_PROTO;
 
        if (unencrypted)
-               flags = IEEE80211_TX_INTFL_DONT_ENCRYPT;
-       else
-               flags = 0;
+               flags |= IEEE80211_TX_INTFL_DONT_ENCRYPT;
+
+       if (cookie)
+               ctrl_flags |= IEEE80211_TX_CTL_REQ_TX_STATUS;
+
+       flags |= IEEE80211_TX_INTFL_NL80211_FRAME_TX |
+                IEEE80211_TX_CTL_INJECTED;
 
        skb = dev_alloc_skb(local->hw.extra_tx_headroom +
                            sizeof(struct ethhdr) + len);
        skb_reset_network_header(skb);
        skb_reset_mac_header(skb);
 
+       /* mutex lock is only needed for incrementing the cookie counter */
+       mutex_lock(&local->mtx);
+
        local_bh_disable();
-       __ieee80211_subif_start_xmit(skb, skb->dev, flags, ctrl_flags);
+       __ieee80211_subif_start_xmit(skb, skb->dev, flags, ctrl_flags, cookie);
        local_bh_enable();
 
+       mutex_unlock(&local->mtx);
+
        return 0;
 }
 
 
        local_bh_disable();
        __ieee80211_subif_start_xmit(skb, skb->dev, 0,
-                                    IEEE80211_TX_CTRL_SKIP_MPATH_LOOKUP);
+                                    IEEE80211_TX_CTRL_SKIP_MPATH_LOOKUP,
+                                    NULL);
        local_bh_enable();
 
        return 0;