hostap_80211_tx.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542
  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 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. if ((skb_headroom(skb) < crypt->ops->extra_mpdu_prefix_len ||
  297. skb_tailroom(skb) < crypt->ops->extra_mpdu_postfix_len) &&
  298. pskb_expand_head(skb, crypt->ops->extra_mpdu_prefix_len,
  299. crypt->ops->extra_mpdu_postfix_len, GFP_ATOMIC)) {
  300. kfree_skb(skb);
  301. return NULL;
  302. }
  303. hdr = (struct ieee80211_hdr_4addr *) skb->data;
  304. fc = le16_to_cpu(hdr->frame_ctl);
  305. hdr_len = hostap_80211_get_hdrlen(fc);
  306. /* Host-based IEEE 802.11 fragmentation for TX is not yet supported, so
  307. * call both MSDU and MPDU encryption functions from here. */
  308. atomic_inc(&crypt->refcnt);
  309. res = 0;
  310. if (crypt->ops->encrypt_msdu)
  311. res = crypt->ops->encrypt_msdu(skb, hdr_len, crypt->priv);
  312. if (res == 0 && crypt->ops->encrypt_mpdu)
  313. res = crypt->ops->encrypt_mpdu(skb, hdr_len, crypt->priv);
  314. atomic_dec(&crypt->refcnt);
  315. if (res < 0) {
  316. kfree_skb(skb);
  317. return NULL;
  318. }
  319. return skb;
  320. }
  321. /* hard_start_xmit function for master radio interface wifi#.
  322. * AP processing (TX rate control, power save buffering, etc.).
  323. * Use hardware TX function to send the frame. */
  324. int hostap_master_start_xmit(struct sk_buff *skb, struct net_device *dev)
  325. {
  326. struct hostap_interface *iface;
  327. local_info_t *local;
  328. int ret = 1;
  329. u16 fc;
  330. struct hostap_tx_data tx;
  331. ap_tx_ret tx_ret;
  332. struct hostap_skb_tx_data *meta;
  333. int no_encrypt = 0;
  334. struct ieee80211_hdr_4addr *hdr;
  335. iface = netdev_priv(dev);
  336. local = iface->local;
  337. tx.skb = skb;
  338. tx.sta_ptr = NULL;
  339. meta = (struct hostap_skb_tx_data *) skb->cb;
  340. if (meta->magic != HOSTAP_SKB_TX_DATA_MAGIC) {
  341. printk(KERN_DEBUG "%s: invalid skb->cb magic (0x%08x, "
  342. "expected 0x%08x)\n",
  343. dev->name, meta->magic, HOSTAP_SKB_TX_DATA_MAGIC);
  344. ret = 0;
  345. iface->stats.tx_dropped++;
  346. goto fail;
  347. }
  348. if (local->host_encrypt) {
  349. /* Set crypt to default algorithm and key; will be replaced in
  350. * AP code if STA has own alg/key */
  351. tx.crypt = local->crypt[local->tx_keyidx];
  352. tx.host_encrypt = 1;
  353. } else {
  354. tx.crypt = NULL;
  355. tx.host_encrypt = 0;
  356. }
  357. if (skb->len < 24) {
  358. printk(KERN_DEBUG "%s: hostap_master_start_xmit: short skb "
  359. "(len=%d)\n", dev->name, skb->len);
  360. ret = 0;
  361. iface->stats.tx_dropped++;
  362. goto fail;
  363. }
  364. /* FIX (?):
  365. * Wi-Fi 802.11b test plan suggests that AP should ignore power save
  366. * bit in authentication and (re)association frames and assume tha
  367. * STA remains awake for the response. */
  368. tx_ret = hostap_handle_sta_tx(local, &tx);
  369. skb = tx.skb;
  370. meta = (struct hostap_skb_tx_data *) skb->cb;
  371. hdr = (struct ieee80211_hdr_4addr *) skb->data;
  372. fc = le16_to_cpu(hdr->frame_ctl);
  373. switch (tx_ret) {
  374. case AP_TX_CONTINUE:
  375. break;
  376. case AP_TX_CONTINUE_NOT_AUTHORIZED:
  377. if (local->ieee_802_1x &&
  378. WLAN_FC_GET_TYPE(fc) == IEEE80211_FTYPE_DATA &&
  379. meta->ethertype != ETH_P_PAE &&
  380. !(meta->flags & HOSTAP_TX_FLAGS_WDS)) {
  381. printk(KERN_DEBUG "%s: dropped frame to unauthorized "
  382. "port (IEEE 802.1X): ethertype=0x%04x\n",
  383. dev->name, meta->ethertype);
  384. hostap_dump_tx_80211(dev->name, skb);
  385. ret = 0; /* drop packet */
  386. iface->stats.tx_dropped++;
  387. goto fail;
  388. }
  389. break;
  390. case AP_TX_DROP:
  391. ret = 0; /* drop packet */
  392. iface->stats.tx_dropped++;
  393. goto fail;
  394. case AP_TX_RETRY:
  395. goto fail;
  396. case AP_TX_BUFFERED:
  397. /* do not free skb here, it will be freed when the
  398. * buffered frame is sent/timed out */
  399. ret = 0;
  400. goto tx_exit;
  401. }
  402. /* Request TX callback if protocol version is 2 in 802.11 header;
  403. * this version 2 is a special case used between hostapd and kernel
  404. * driver */
  405. if (((fc & IEEE80211_FCTL_VERS) == BIT(1)) &&
  406. local->ap && local->ap->tx_callback_idx && meta->tx_cb_idx == 0) {
  407. meta->tx_cb_idx = local->ap->tx_callback_idx;
  408. /* remove special version from the frame header */
  409. fc &= ~IEEE80211_FCTL_VERS;
  410. hdr->frame_ctl = cpu_to_le16(fc);
  411. }
  412. if (WLAN_FC_GET_TYPE(fc) != IEEE80211_FTYPE_DATA) {
  413. no_encrypt = 1;
  414. tx.crypt = NULL;
  415. }
  416. if (local->ieee_802_1x && meta->ethertype == ETH_P_PAE && tx.crypt &&
  417. !(fc & IEEE80211_FCTL_PROTECTED)) {
  418. no_encrypt = 1;
  419. PDEBUG(DEBUG_EXTRA2, "%s: TX: IEEE 802.1X - passing "
  420. "unencrypted EAPOL frame\n", dev->name);
  421. tx.crypt = NULL; /* no encryption for IEEE 802.1X frames */
  422. }
  423. if (tx.crypt && (!tx.crypt->ops || !tx.crypt->ops->encrypt_mpdu))
  424. tx.crypt = NULL;
  425. else if ((tx.crypt || local->crypt[local->tx_keyidx]) && !no_encrypt) {
  426. /* Add ISWEP flag both for firmware and host based encryption
  427. */
  428. fc |= IEEE80211_FCTL_PROTECTED;
  429. hdr->frame_ctl = cpu_to_le16(fc);
  430. } else if (local->drop_unencrypted &&
  431. WLAN_FC_GET_TYPE(fc) == IEEE80211_FTYPE_DATA &&
  432. meta->ethertype != ETH_P_PAE) {
  433. if (net_ratelimit()) {
  434. printk(KERN_DEBUG "%s: dropped unencrypted TX data "
  435. "frame (drop_unencrypted=1)\n", dev->name);
  436. }
  437. iface->stats.tx_dropped++;
  438. ret = 0;
  439. goto fail;
  440. }
  441. if (tx.crypt) {
  442. skb = hostap_tx_encrypt(skb, tx.crypt);
  443. if (skb == NULL) {
  444. printk(KERN_DEBUG "%s: TX - encryption failed\n",
  445. dev->name);
  446. ret = 0;
  447. goto fail;
  448. }
  449. meta = (struct hostap_skb_tx_data *) skb->cb;
  450. if (meta->magic != HOSTAP_SKB_TX_DATA_MAGIC) {
  451. printk(KERN_DEBUG "%s: invalid skb->cb magic (0x%08x, "
  452. "expected 0x%08x) after hostap_tx_encrypt\n",
  453. dev->name, meta->magic,
  454. HOSTAP_SKB_TX_DATA_MAGIC);
  455. ret = 0;
  456. iface->stats.tx_dropped++;
  457. goto fail;
  458. }
  459. }
  460. if (local->func->tx == NULL || local->func->tx(skb, dev)) {
  461. ret = 0;
  462. iface->stats.tx_dropped++;
  463. } else {
  464. ret = 0;
  465. iface->stats.tx_packets++;
  466. iface->stats.tx_bytes += skb->len;
  467. }
  468. fail:
  469. if (!ret && skb)
  470. dev_kfree_skb(skb);
  471. tx_exit:
  472. if (tx.sta_ptr)
  473. hostap_handle_sta_release(tx.sta_ptr);
  474. return ret;
  475. }
  476. EXPORT_SYMBOL(hostap_master_start_xmit);