hostap_80211_tx.c 16 KB

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