hostap_80211_tx.c 16 KB

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