hostap_80211_tx.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552
  1. #include <linux/slab.h>
  2. #include "hostap_80211.h"
  3. #include "hostap_common.h"
  4. #include "hostap_wlan.h"
  5. #include "hostap.h"
  6. #include "hostap_ap.h"
  7. /* See IEEE 802.1H for LLC/SNAP encapsulation/decapsulation */
  8. /* Ethernet-II snap header (RFC1042 for most EtherTypes) */
  9. static unsigned char rfc1042_header[] =
  10. { 0xaa, 0xaa, 0x03, 0x00, 0x00, 0x00 };
  11. /* Bridge-Tunnel header (for EtherTypes ETH_P_AARP and ETH_P_IPX) */
  12. static unsigned char bridge_tunnel_header[] =
  13. { 0xaa, 0xaa, 0x03, 0x00, 0x00, 0xf8 };
  14. /* No encapsulation header if EtherType < 0x600 (=length) */
  15. void hostap_dump_tx_80211(const char *name, struct sk_buff *skb)
  16. {
  17. struct ieee80211_hdr *hdr;
  18. u16 fc;
  19. hdr = (struct ieee80211_hdr *) skb->data;
  20. printk(KERN_DEBUG "%s: TX len=%d jiffies=%ld\n",
  21. name, skb->len, jiffies);
  22. if (skb->len < 2)
  23. return;
  24. fc = le16_to_cpu(hdr->frame_control);
  25. printk(KERN_DEBUG " FC=0x%04x (type=%d:%d)%s%s",
  26. fc, (fc & IEEE80211_FCTL_FTYPE) >> 2,
  27. (fc & IEEE80211_FCTL_STYPE) >> 4,
  28. fc & IEEE80211_FCTL_TODS ? " [ToDS]" : "",
  29. fc & IEEE80211_FCTL_FROMDS ? " [FromDS]" : "");
  30. if (skb->len < IEEE80211_DATA_HDR3_LEN) {
  31. printk("\n");
  32. return;
  33. }
  34. printk(" dur=0x%04x seq=0x%04x\n", le16_to_cpu(hdr->duration_id),
  35. le16_to_cpu(hdr->seq_ctrl));
  36. printk(KERN_DEBUG " A1=%pM", hdr->addr1);
  37. printk(" A2=%pM", hdr->addr2);
  38. printk(" A3=%pM", hdr->addr3);
  39. if (skb->len >= 30)
  40. printk(" A4=%pM", hdr->addr4);
  41. printk("\n");
  42. }
  43. /* hard_start_xmit function for data interfaces (wlan#, wlan#wds#, wlan#sta)
  44. * Convert Ethernet header into a suitable IEEE 802.11 header depending on
  45. * device configuration. */
  46. netdev_tx_t hostap_data_start_xmit(struct sk_buff *skb,
  47. struct net_device *dev)
  48. {
  49. struct hostap_interface *iface;
  50. local_info_t *local;
  51. int need_headroom, need_tailroom = 0;
  52. struct ieee80211_hdr hdr;
  53. u16 fc, ethertype = 0;
  54. enum {
  55. WDS_NO = 0, WDS_OWN_FRAME, WDS_COMPLIANT_FRAME
  56. } use_wds = WDS_NO;
  57. u8 *encaps_data;
  58. int hdr_len, encaps_len, skip_header_bytes;
  59. int to_assoc_ap = 0;
  60. struct hostap_skb_tx_data *meta;
  61. iface = netdev_priv(dev);
  62. local = iface->local;
  63. if (skb->len < ETH_HLEN) {
  64. printk(KERN_DEBUG "%s: hostap_data_start_xmit: short skb "
  65. "(len=%d)\n", dev->name, skb->len);
  66. kfree_skb(skb);
  67. return NETDEV_TX_OK;
  68. }
  69. if (local->ddev != dev) {
  70. use_wds = (local->iw_mode == IW_MODE_MASTER &&
  71. !(local->wds_type & HOSTAP_WDS_STANDARD_FRAME)) ?
  72. WDS_OWN_FRAME : WDS_COMPLIANT_FRAME;
  73. if (dev == local->stadev) {
  74. to_assoc_ap = 1;
  75. use_wds = WDS_NO;
  76. } else if (dev == local->apdev) {
  77. printk(KERN_DEBUG "%s: prism2_tx: trying to use "
  78. "AP device with Ethernet net dev\n", dev->name);
  79. kfree_skb(skb);
  80. return NETDEV_TX_OK;
  81. }
  82. } else {
  83. if (local->iw_mode == IW_MODE_REPEAT) {
  84. printk(KERN_DEBUG "%s: prism2_tx: trying to use "
  85. "non-WDS link in Repeater mode\n", dev->name);
  86. kfree_skb(skb);
  87. return NETDEV_TX_OK;
  88. } else if (local->iw_mode == IW_MODE_INFRA &&
  89. (local->wds_type & HOSTAP_WDS_AP_CLIENT) &&
  90. memcmp(skb->data + ETH_ALEN, dev->dev_addr,
  91. ETH_ALEN) != 0) {
  92. /* AP client mode: send frames with foreign src addr
  93. * using 4-addr WDS frames */
  94. use_wds = WDS_COMPLIANT_FRAME;
  95. }
  96. }
  97. /* Incoming skb->data: dst_addr[6], src_addr[6], proto[2], payload
  98. * ==>
  99. * Prism2 TX frame with 802.11 header:
  100. * txdesc (address order depending on used mode; includes dst_addr and
  101. * src_addr), possible encapsulation (RFC1042/Bridge-Tunnel;
  102. * proto[2], payload {, possible addr4[6]} */
  103. ethertype = (skb->data[12] << 8) | skb->data[13];
  104. memset(&hdr, 0, sizeof(hdr));
  105. /* Length of data after IEEE 802.11 header */
  106. encaps_data = NULL;
  107. encaps_len = 0;
  108. skip_header_bytes = ETH_HLEN;
  109. if (ethertype == ETH_P_AARP || ethertype == ETH_P_IPX) {
  110. encaps_data = bridge_tunnel_header;
  111. encaps_len = sizeof(bridge_tunnel_header);
  112. skip_header_bytes -= 2;
  113. } else if (ethertype >= 0x600) {
  114. encaps_data = rfc1042_header;
  115. encaps_len = sizeof(rfc1042_header);
  116. skip_header_bytes -= 2;
  117. }
  118. fc = IEEE80211_FTYPE_DATA | IEEE80211_STYPE_DATA;
  119. hdr_len = IEEE80211_DATA_HDR3_LEN;
  120. if (use_wds != WDS_NO) {
  121. /* Note! Prism2 station firmware has problems with sending real
  122. * 802.11 frames with four addresses; until these problems can
  123. * be fixed or worked around, 4-addr frames needed for WDS are
  124. * using incompatible format: FromDS flag is not set and the
  125. * fourth address is added after the frame payload; it is
  126. * assumed, that the receiving station knows how to handle this
  127. * frame format */
  128. if (use_wds == WDS_COMPLIANT_FRAME) {
  129. fc |= IEEE80211_FCTL_FROMDS | IEEE80211_FCTL_TODS;
  130. /* From&To DS: Addr1 = RA, Addr2 = TA, Addr3 = DA,
  131. * Addr4 = SA */
  132. skb_copy_from_linear_data_offset(skb, ETH_ALEN,
  133. &hdr.addr4, ETH_ALEN);
  134. hdr_len += ETH_ALEN;
  135. } else {
  136. /* bogus 4-addr format to workaround Prism2 station
  137. * f/w bug */
  138. fc |= IEEE80211_FCTL_TODS;
  139. /* From DS: Addr1 = DA (used as RA),
  140. * Addr2 = BSSID (used as TA), Addr3 = SA (used as DA),
  141. */
  142. /* SA from skb->data + ETH_ALEN will be added after
  143. * frame payload; use hdr.addr4 as a temporary buffer
  144. */
  145. skb_copy_from_linear_data_offset(skb, ETH_ALEN,
  146. &hdr.addr4, ETH_ALEN);
  147. need_tailroom += ETH_ALEN;
  148. }
  149. /* send broadcast and multicast frames to broadcast RA, if
  150. * configured; otherwise, use unicast RA of the WDS link */
  151. if ((local->wds_type & HOSTAP_WDS_BROADCAST_RA) &&
  152. skb->data[0] & 0x01)
  153. memset(&hdr.addr1, 0xff, ETH_ALEN);
  154. else if (iface->type == HOSTAP_INTERFACE_WDS)
  155. memcpy(&hdr.addr1, iface->u.wds.remote_addr,
  156. ETH_ALEN);
  157. else
  158. memcpy(&hdr.addr1, local->bssid, ETH_ALEN);
  159. memcpy(&hdr.addr2, dev->dev_addr, ETH_ALEN);
  160. skb_copy_from_linear_data(skb, &hdr.addr3, ETH_ALEN);
  161. } else if (local->iw_mode == IW_MODE_MASTER && !to_assoc_ap) {
  162. fc |= IEEE80211_FCTL_FROMDS;
  163. /* From DS: Addr1 = DA, Addr2 = BSSID, Addr3 = SA */
  164. skb_copy_from_linear_data(skb, &hdr.addr1, ETH_ALEN);
  165. memcpy(&hdr.addr2, dev->dev_addr, ETH_ALEN);
  166. skb_copy_from_linear_data_offset(skb, ETH_ALEN, &hdr.addr3,
  167. ETH_ALEN);
  168. } else if (local->iw_mode == IW_MODE_INFRA || to_assoc_ap) {
  169. fc |= IEEE80211_FCTL_TODS;
  170. /* To DS: Addr1 = BSSID, Addr2 = SA, Addr3 = DA */
  171. memcpy(&hdr.addr1, to_assoc_ap ?
  172. local->assoc_ap_addr : local->bssid, ETH_ALEN);
  173. skb_copy_from_linear_data_offset(skb, ETH_ALEN, &hdr.addr2,
  174. ETH_ALEN);
  175. skb_copy_from_linear_data(skb, &hdr.addr3, ETH_ALEN);
  176. } else if (local->iw_mode == IW_MODE_ADHOC) {
  177. /* not From/To DS: Addr1 = DA, Addr2 = SA, Addr3 = BSSID */
  178. skb_copy_from_linear_data(skb, &hdr.addr1, ETH_ALEN);
  179. skb_copy_from_linear_data_offset(skb, ETH_ALEN, &hdr.addr2,
  180. ETH_ALEN);
  181. memcpy(&hdr.addr3, local->bssid, ETH_ALEN);
  182. }
  183. hdr.frame_control = cpu_to_le16(fc);
  184. skb_pull(skb, skip_header_bytes);
  185. need_headroom = local->func->need_tx_headroom + hdr_len + encaps_len;
  186. if (skb_tailroom(skb) < need_tailroom) {
  187. skb = skb_unshare(skb, GFP_ATOMIC);
  188. if (skb == NULL) {
  189. iface->stats.tx_dropped++;
  190. return NETDEV_TX_OK;
  191. }
  192. if (pskb_expand_head(skb, need_headroom, need_tailroom,
  193. GFP_ATOMIC)) {
  194. kfree_skb(skb);
  195. iface->stats.tx_dropped++;
  196. return NETDEV_TX_OK;
  197. }
  198. } else if (skb_headroom(skb) < need_headroom) {
  199. struct sk_buff *tmp = skb;
  200. skb = skb_realloc_headroom(skb, need_headroom);
  201. kfree_skb(tmp);
  202. if (skb == NULL) {
  203. iface->stats.tx_dropped++;
  204. return NETDEV_TX_OK;
  205. }
  206. } else {
  207. skb = skb_unshare(skb, GFP_ATOMIC);
  208. if (skb == NULL) {
  209. iface->stats.tx_dropped++;
  210. return NETDEV_TX_OK;
  211. }
  212. }
  213. if (encaps_data)
  214. memcpy(skb_push(skb, encaps_len), encaps_data, encaps_len);
  215. memcpy(skb_push(skb, hdr_len), &hdr, hdr_len);
  216. if (use_wds == WDS_OWN_FRAME) {
  217. memcpy(skb_put(skb, ETH_ALEN), &hdr.addr4, ETH_ALEN);
  218. }
  219. iface->stats.tx_packets++;
  220. iface->stats.tx_bytes += skb->len;
  221. skb_reset_mac_header(skb);
  222. meta = (struct hostap_skb_tx_data *) skb->cb;
  223. memset(meta, 0, sizeof(*meta));
  224. meta->magic = HOSTAP_SKB_TX_DATA_MAGIC;
  225. if (use_wds)
  226. meta->flags |= HOSTAP_TX_FLAGS_WDS;
  227. meta->ethertype = ethertype;
  228. meta->iface = iface;
  229. /* Send IEEE 802.11 encapsulated frame using the master radio device */
  230. skb->dev = local->dev;
  231. dev_queue_xmit(skb);
  232. return NETDEV_TX_OK;
  233. }
  234. /* hard_start_xmit function for hostapd wlan#ap interfaces */
  235. netdev_tx_t hostap_mgmt_start_xmit(struct sk_buff *skb,
  236. struct net_device *dev)
  237. {
  238. struct hostap_interface *iface;
  239. local_info_t *local;
  240. struct hostap_skb_tx_data *meta;
  241. struct ieee80211_hdr *hdr;
  242. u16 fc;
  243. iface = netdev_priv(dev);
  244. local = iface->local;
  245. if (skb->len < 10) {
  246. printk(KERN_DEBUG "%s: hostap_mgmt_start_xmit: short skb "
  247. "(len=%d)\n", dev->name, skb->len);
  248. kfree_skb(skb);
  249. return NETDEV_TX_OK;
  250. }
  251. iface->stats.tx_packets++;
  252. iface->stats.tx_bytes += skb->len;
  253. meta = (struct hostap_skb_tx_data *) skb->cb;
  254. memset(meta, 0, sizeof(*meta));
  255. meta->magic = HOSTAP_SKB_TX_DATA_MAGIC;
  256. meta->iface = iface;
  257. if (skb->len >= IEEE80211_DATA_HDR3_LEN + sizeof(rfc1042_header) + 2) {
  258. hdr = (struct ieee80211_hdr *) skb->data;
  259. fc = le16_to_cpu(hdr->frame_control);
  260. if (ieee80211_is_data(hdr->frame_control) &&
  261. (fc & IEEE80211_FCTL_STYPE) == IEEE80211_STYPE_DATA) {
  262. u8 *pos = &skb->data[IEEE80211_DATA_HDR3_LEN +
  263. sizeof(rfc1042_header)];
  264. meta->ethertype = (pos[0] << 8) | pos[1];
  265. }
  266. }
  267. /* Send IEEE 802.11 encapsulated frame using the master radio device */
  268. skb->dev = local->dev;
  269. dev_queue_xmit(skb);
  270. return NETDEV_TX_OK;
  271. }
  272. /* Called only from software IRQ */
  273. static struct sk_buff * hostap_tx_encrypt(struct sk_buff *skb,
  274. struct lib80211_crypt_data *crypt)
  275. {
  276. struct hostap_interface *iface;
  277. local_info_t *local;
  278. struct ieee80211_hdr *hdr;
  279. int prefix_len, postfix_len, hdr_len, res;
  280. iface = netdev_priv(skb->dev);
  281. local = iface->local;
  282. if (skb->len < IEEE80211_DATA_HDR3_LEN) {
  283. kfree_skb(skb);
  284. return NULL;
  285. }
  286. if (local->tkip_countermeasures &&
  287. strcmp(crypt->ops->name, "TKIP") == 0) {
  288. hdr = (struct ieee80211_hdr *) skb->data;
  289. if (net_ratelimit()) {
  290. printk(KERN_DEBUG "%s: TKIP countermeasures: dropped "
  291. "TX packet to %pM\n",
  292. local->dev->name, hdr->addr1);
  293. }
  294. kfree_skb(skb);
  295. return NULL;
  296. }
  297. skb = skb_unshare(skb, GFP_ATOMIC);
  298. if (skb == NULL)
  299. return NULL;
  300. prefix_len = crypt->ops->extra_mpdu_prefix_len +
  301. crypt->ops->extra_msdu_prefix_len;
  302. postfix_len = crypt->ops->extra_mpdu_postfix_len +
  303. crypt->ops->extra_msdu_postfix_len;
  304. if ((skb_headroom(skb) < prefix_len ||
  305. skb_tailroom(skb) < postfix_len) &&
  306. pskb_expand_head(skb, prefix_len, postfix_len, GFP_ATOMIC)) {
  307. kfree_skb(skb);
  308. return NULL;
  309. }
  310. hdr = (struct ieee80211_hdr *) skb->data;
  311. hdr_len = hostap_80211_get_hdrlen(hdr->frame_control);
  312. /* Host-based IEEE 802.11 fragmentation for TX is not yet supported, so
  313. * call both MSDU and MPDU encryption functions from here. */
  314. atomic_inc(&crypt->refcnt);
  315. res = 0;
  316. if (crypt->ops->encrypt_msdu)
  317. res = crypt->ops->encrypt_msdu(skb, hdr_len, crypt->priv);
  318. if (res == 0 && crypt->ops->encrypt_mpdu)
  319. res = crypt->ops->encrypt_mpdu(skb, hdr_len, crypt->priv);
  320. atomic_dec(&crypt->refcnt);
  321. if (res < 0) {
  322. kfree_skb(skb);
  323. return NULL;
  324. }
  325. return skb;
  326. }
  327. /* hard_start_xmit function for master radio interface wifi#.
  328. * AP processing (TX rate control, power save buffering, etc.).
  329. * Use hardware TX function to send the frame. */
  330. netdev_tx_t hostap_master_start_xmit(struct sk_buff *skb,
  331. struct net_device *dev)
  332. {
  333. struct hostap_interface *iface;
  334. local_info_t *local;
  335. netdev_tx_t ret = NETDEV_TX_BUSY;
  336. u16 fc;
  337. struct hostap_tx_data tx;
  338. ap_tx_ret tx_ret;
  339. struct hostap_skb_tx_data *meta;
  340. int no_encrypt = 0;
  341. struct ieee80211_hdr *hdr;
  342. iface = netdev_priv(dev);
  343. local = iface->local;
  344. tx.skb = skb;
  345. tx.sta_ptr = NULL;
  346. meta = (struct hostap_skb_tx_data *) skb->cb;
  347. if (meta->magic != HOSTAP_SKB_TX_DATA_MAGIC) {
  348. printk(KERN_DEBUG "%s: invalid skb->cb magic (0x%08x, "
  349. "expected 0x%08x)\n",
  350. dev->name, meta->magic, HOSTAP_SKB_TX_DATA_MAGIC);
  351. ret = NETDEV_TX_OK;
  352. iface->stats.tx_dropped++;
  353. goto fail;
  354. }
  355. if (local->host_encrypt) {
  356. /* Set crypt to default algorithm and key; will be replaced in
  357. * AP code if STA has own alg/key */
  358. tx.crypt = local->crypt_info.crypt[local->crypt_info.tx_keyidx];
  359. tx.host_encrypt = 1;
  360. } else {
  361. tx.crypt = NULL;
  362. tx.host_encrypt = 0;
  363. }
  364. if (skb->len < 24) {
  365. printk(KERN_DEBUG "%s: hostap_master_start_xmit: short skb "
  366. "(len=%d)\n", dev->name, skb->len);
  367. ret = NETDEV_TX_OK;
  368. iface->stats.tx_dropped++;
  369. goto fail;
  370. }
  371. /* FIX (?):
  372. * Wi-Fi 802.11b test plan suggests that AP should ignore power save
  373. * bit in authentication and (re)association frames and assume tha
  374. * STA remains awake for the response. */
  375. tx_ret = hostap_handle_sta_tx(local, &tx);
  376. skb = tx.skb;
  377. meta = (struct hostap_skb_tx_data *) skb->cb;
  378. hdr = (struct ieee80211_hdr *) skb->data;
  379. fc = le16_to_cpu(hdr->frame_control);
  380. switch (tx_ret) {
  381. case AP_TX_CONTINUE:
  382. break;
  383. case AP_TX_CONTINUE_NOT_AUTHORIZED:
  384. if (local->ieee_802_1x &&
  385. ieee80211_is_data(hdr->frame_control) &&
  386. meta->ethertype != ETH_P_PAE &&
  387. !(meta->flags & HOSTAP_TX_FLAGS_WDS)) {
  388. printk(KERN_DEBUG "%s: dropped frame to unauthorized "
  389. "port (IEEE 802.1X): ethertype=0x%04x\n",
  390. dev->name, meta->ethertype);
  391. hostap_dump_tx_80211(dev->name, skb);
  392. ret = NETDEV_TX_OK; /* drop packet */
  393. iface->stats.tx_dropped++;
  394. goto fail;
  395. }
  396. break;
  397. case AP_TX_DROP:
  398. ret = NETDEV_TX_OK; /* drop packet */
  399. iface->stats.tx_dropped++;
  400. goto fail;
  401. case AP_TX_RETRY:
  402. goto fail;
  403. case AP_TX_BUFFERED:
  404. /* do not free skb here, it will be freed when the
  405. * buffered frame is sent/timed out */
  406. ret = NETDEV_TX_OK;
  407. goto tx_exit;
  408. }
  409. /* Request TX callback if protocol version is 2 in 802.11 header;
  410. * this version 2 is a special case used between hostapd and kernel
  411. * driver */
  412. if (((fc & IEEE80211_FCTL_VERS) == BIT(1)) &&
  413. local->ap && local->ap->tx_callback_idx && meta->tx_cb_idx == 0) {
  414. meta->tx_cb_idx = local->ap->tx_callback_idx;
  415. /* remove special version from the frame header */
  416. fc &= ~IEEE80211_FCTL_VERS;
  417. hdr->frame_control = cpu_to_le16(fc);
  418. }
  419. if (!ieee80211_is_data(hdr->frame_control)) {
  420. no_encrypt = 1;
  421. tx.crypt = NULL;
  422. }
  423. if (local->ieee_802_1x && meta->ethertype == ETH_P_PAE && tx.crypt &&
  424. !(fc & IEEE80211_FCTL_PROTECTED)) {
  425. no_encrypt = 1;
  426. PDEBUG(DEBUG_EXTRA2, "%s: TX: IEEE 802.1X - passing "
  427. "unencrypted EAPOL frame\n", dev->name);
  428. tx.crypt = NULL; /* no encryption for IEEE 802.1X frames */
  429. }
  430. if (tx.crypt && (!tx.crypt->ops || !tx.crypt->ops->encrypt_mpdu))
  431. tx.crypt = NULL;
  432. else if ((tx.crypt ||
  433. local->crypt_info.crypt[local->crypt_info.tx_keyidx]) &&
  434. !no_encrypt) {
  435. /* Add ISWEP flag both for firmware and host based encryption
  436. */
  437. fc |= IEEE80211_FCTL_PROTECTED;
  438. hdr->frame_control = cpu_to_le16(fc);
  439. } else if (local->drop_unencrypted &&
  440. ieee80211_is_data(hdr->frame_control) &&
  441. meta->ethertype != ETH_P_PAE) {
  442. if (net_ratelimit()) {
  443. printk(KERN_DEBUG "%s: dropped unencrypted TX data "
  444. "frame (drop_unencrypted=1)\n", dev->name);
  445. }
  446. iface->stats.tx_dropped++;
  447. ret = NETDEV_TX_OK;
  448. goto fail;
  449. }
  450. if (tx.crypt) {
  451. skb = hostap_tx_encrypt(skb, tx.crypt);
  452. if (skb == NULL) {
  453. printk(KERN_DEBUG "%s: TX - encryption failed\n",
  454. dev->name);
  455. ret = NETDEV_TX_OK;
  456. goto fail;
  457. }
  458. meta = (struct hostap_skb_tx_data *) skb->cb;
  459. if (meta->magic != HOSTAP_SKB_TX_DATA_MAGIC) {
  460. printk(KERN_DEBUG "%s: invalid skb->cb magic (0x%08x, "
  461. "expected 0x%08x) after hostap_tx_encrypt\n",
  462. dev->name, meta->magic,
  463. HOSTAP_SKB_TX_DATA_MAGIC);
  464. ret = NETDEV_TX_OK;
  465. iface->stats.tx_dropped++;
  466. goto fail;
  467. }
  468. }
  469. if (local->func->tx == NULL || local->func->tx(skb, dev)) {
  470. ret = NETDEV_TX_OK;
  471. iface->stats.tx_dropped++;
  472. } else {
  473. ret = NETDEV_TX_OK;
  474. iface->stats.tx_packets++;
  475. iface->stats.tx_bytes += skb->len;
  476. }
  477. fail:
  478. if (ret == NETDEV_TX_OK && skb)
  479. dev_kfree_skb(skb);
  480. tx_exit:
  481. if (tx.sta_ptr)
  482. hostap_handle_sta_release(tx.sta_ptr);
  483. return ret;
  484. }
  485. EXPORT_SYMBOL(hostap_master_start_xmit);