hostap_80211_tx.c 16 KB

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