hostap_80211_tx.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547
  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. int hostap_data_start_xmit(struct sk_buff *skb, struct net_device *dev)
  46. {
  47. struct hostap_interface *iface;
  48. local_info_t *local;
  49. int need_headroom, need_tailroom = 0;
  50. struct ieee80211_hdr hdr;
  51. u16 fc, ethertype = 0;
  52. enum {
  53. WDS_NO = 0, WDS_OWN_FRAME, WDS_COMPLIANT_FRAME
  54. } use_wds = WDS_NO;
  55. u8 *encaps_data;
  56. int hdr_len, encaps_len, skip_header_bytes;
  57. int to_assoc_ap = 0;
  58. struct hostap_skb_tx_data *meta;
  59. iface = netdev_priv(dev);
  60. local = iface->local;
  61. if (skb->len < ETH_HLEN) {
  62. printk(KERN_DEBUG "%s: hostap_data_start_xmit: short skb "
  63. "(len=%d)\n", dev->name, skb->len);
  64. kfree_skb(skb);
  65. return 0;
  66. }
  67. if (local->ddev != dev) {
  68. use_wds = (local->iw_mode == IW_MODE_MASTER &&
  69. !(local->wds_type & HOSTAP_WDS_STANDARD_FRAME)) ?
  70. WDS_OWN_FRAME : WDS_COMPLIANT_FRAME;
  71. if (dev == local->stadev) {
  72. to_assoc_ap = 1;
  73. use_wds = WDS_NO;
  74. } else if (dev == local->apdev) {
  75. printk(KERN_DEBUG "%s: prism2_tx: trying to use "
  76. "AP device with Ethernet net dev\n", dev->name);
  77. kfree_skb(skb);
  78. return 0;
  79. }
  80. } else {
  81. if (local->iw_mode == IW_MODE_REPEAT) {
  82. printk(KERN_DEBUG "%s: prism2_tx: trying to use "
  83. "non-WDS link in Repeater mode\n", dev->name);
  84. kfree_skb(skb);
  85. return 0;
  86. } else if (local->iw_mode == IW_MODE_INFRA &&
  87. (local->wds_type & HOSTAP_WDS_AP_CLIENT) &&
  88. memcmp(skb->data + ETH_ALEN, dev->dev_addr,
  89. ETH_ALEN) != 0) {
  90. /* AP client mode: send frames with foreign src addr
  91. * using 4-addr WDS frames */
  92. use_wds = WDS_COMPLIANT_FRAME;
  93. }
  94. }
  95. /* Incoming skb->data: dst_addr[6], src_addr[6], proto[2], payload
  96. * ==>
  97. * Prism2 TX frame with 802.11 header:
  98. * txdesc (address order depending on used mode; includes dst_addr and
  99. * src_addr), possible encapsulation (RFC1042/Bridge-Tunnel;
  100. * proto[2], payload {, possible addr4[6]} */
  101. ethertype = (skb->data[12] << 8) | skb->data[13];
  102. memset(&hdr, 0, sizeof(hdr));
  103. /* Length of data after IEEE 802.11 header */
  104. encaps_data = NULL;
  105. encaps_len = 0;
  106. skip_header_bytes = ETH_HLEN;
  107. if (ethertype == ETH_P_AARP || ethertype == ETH_P_IPX) {
  108. encaps_data = bridge_tunnel_header;
  109. encaps_len = sizeof(bridge_tunnel_header);
  110. skip_header_bytes -= 2;
  111. } else if (ethertype >= 0x600) {
  112. encaps_data = rfc1042_header;
  113. encaps_len = sizeof(rfc1042_header);
  114. skip_header_bytes -= 2;
  115. }
  116. fc = IEEE80211_FTYPE_DATA | IEEE80211_STYPE_DATA;
  117. hdr_len = IEEE80211_DATA_HDR3_LEN;
  118. if (use_wds != WDS_NO) {
  119. /* Note! Prism2 station firmware has problems with sending real
  120. * 802.11 frames with four addresses; until these problems can
  121. * be fixed or worked around, 4-addr frames needed for WDS are
  122. * using incompatible format: FromDS flag is not set and the
  123. * fourth address is added after the frame payload; it is
  124. * assumed, that the receiving station knows how to handle this
  125. * frame format */
  126. if (use_wds == WDS_COMPLIANT_FRAME) {
  127. fc |= IEEE80211_FCTL_FROMDS | IEEE80211_FCTL_TODS;
  128. /* From&To DS: Addr1 = RA, Addr2 = TA, Addr3 = DA,
  129. * Addr4 = SA */
  130. skb_copy_from_linear_data_offset(skb, ETH_ALEN,
  131. &hdr.addr4, ETH_ALEN);
  132. hdr_len += ETH_ALEN;
  133. } else {
  134. /* bogus 4-addr format to workaround Prism2 station
  135. * f/w bug */
  136. fc |= IEEE80211_FCTL_TODS;
  137. /* From DS: Addr1 = DA (used as RA),
  138. * Addr2 = BSSID (used as TA), Addr3 = SA (used as DA),
  139. */
  140. /* SA from skb->data + ETH_ALEN will be added after
  141. * frame payload; use hdr.addr4 as a temporary buffer
  142. */
  143. skb_copy_from_linear_data_offset(skb, ETH_ALEN,
  144. &hdr.addr4, ETH_ALEN);
  145. need_tailroom += ETH_ALEN;
  146. }
  147. /* send broadcast and multicast frames to broadcast RA, if
  148. * configured; otherwise, use unicast RA of the WDS link */
  149. if ((local->wds_type & HOSTAP_WDS_BROADCAST_RA) &&
  150. skb->data[0] & 0x01)
  151. memset(&hdr.addr1, 0xff, ETH_ALEN);
  152. else if (iface->type == HOSTAP_INTERFACE_WDS)
  153. memcpy(&hdr.addr1, iface->u.wds.remote_addr,
  154. ETH_ALEN);
  155. else
  156. memcpy(&hdr.addr1, local->bssid, ETH_ALEN);
  157. memcpy(&hdr.addr2, dev->dev_addr, ETH_ALEN);
  158. skb_copy_from_linear_data(skb, &hdr.addr3, ETH_ALEN);
  159. } else if (local->iw_mode == IW_MODE_MASTER && !to_assoc_ap) {
  160. fc |= IEEE80211_FCTL_FROMDS;
  161. /* From DS: Addr1 = DA, Addr2 = BSSID, Addr3 = SA */
  162. skb_copy_from_linear_data(skb, &hdr.addr1, ETH_ALEN);
  163. memcpy(&hdr.addr2, dev->dev_addr, ETH_ALEN);
  164. skb_copy_from_linear_data_offset(skb, ETH_ALEN, &hdr.addr3,
  165. ETH_ALEN);
  166. } else if (local->iw_mode == IW_MODE_INFRA || to_assoc_ap) {
  167. fc |= IEEE80211_FCTL_TODS;
  168. /* To DS: Addr1 = BSSID, Addr2 = SA, Addr3 = DA */
  169. memcpy(&hdr.addr1, to_assoc_ap ?
  170. local->assoc_ap_addr : local->bssid, ETH_ALEN);
  171. skb_copy_from_linear_data_offset(skb, ETH_ALEN, &hdr.addr2,
  172. ETH_ALEN);
  173. skb_copy_from_linear_data(skb, &hdr.addr3, ETH_ALEN);
  174. } else if (local->iw_mode == IW_MODE_ADHOC) {
  175. /* not From/To DS: Addr1 = DA, Addr2 = SA, Addr3 = BSSID */
  176. skb_copy_from_linear_data(skb, &hdr.addr1, ETH_ALEN);
  177. skb_copy_from_linear_data_offset(skb, ETH_ALEN, &hdr.addr2,
  178. ETH_ALEN);
  179. memcpy(&hdr.addr3, local->bssid, ETH_ALEN);
  180. }
  181. hdr.frame_control = cpu_to_le16(fc);
  182. skb_pull(skb, skip_header_bytes);
  183. need_headroom = local->func->need_tx_headroom + hdr_len + encaps_len;
  184. if (skb_tailroom(skb) < need_tailroom) {
  185. skb = skb_unshare(skb, GFP_ATOMIC);
  186. if (skb == NULL) {
  187. iface->stats.tx_dropped++;
  188. return 0;
  189. }
  190. if (pskb_expand_head(skb, need_headroom, need_tailroom,
  191. GFP_ATOMIC)) {
  192. kfree_skb(skb);
  193. iface->stats.tx_dropped++;
  194. return 0;
  195. }
  196. } else if (skb_headroom(skb) < need_headroom) {
  197. struct sk_buff *tmp = skb;
  198. skb = skb_realloc_headroom(skb, need_headroom);
  199. kfree_skb(tmp);
  200. if (skb == NULL) {
  201. iface->stats.tx_dropped++;
  202. return 0;
  203. }
  204. } else {
  205. skb = skb_unshare(skb, GFP_ATOMIC);
  206. if (skb == NULL) {
  207. iface->stats.tx_dropped++;
  208. return 0;
  209. }
  210. }
  211. if (encaps_data)
  212. memcpy(skb_push(skb, encaps_len), encaps_data, encaps_len);
  213. memcpy(skb_push(skb, hdr_len), &hdr, hdr_len);
  214. if (use_wds == WDS_OWN_FRAME) {
  215. memcpy(skb_put(skb, ETH_ALEN), &hdr.addr4, ETH_ALEN);
  216. }
  217. iface->stats.tx_packets++;
  218. iface->stats.tx_bytes += skb->len;
  219. skb_reset_mac_header(skb);
  220. meta = (struct hostap_skb_tx_data *) skb->cb;
  221. memset(meta, 0, sizeof(*meta));
  222. meta->magic = HOSTAP_SKB_TX_DATA_MAGIC;
  223. if (use_wds)
  224. meta->flags |= HOSTAP_TX_FLAGS_WDS;
  225. meta->ethertype = ethertype;
  226. meta->iface = iface;
  227. /* Send IEEE 802.11 encapsulated frame using the master radio device */
  228. skb->dev = local->dev;
  229. dev_queue_xmit(skb);
  230. return 0;
  231. }
  232. /* hard_start_xmit function for hostapd wlan#ap interfaces */
  233. int hostap_mgmt_start_xmit(struct sk_buff *skb, struct net_device *dev)
  234. {
  235. struct hostap_interface *iface;
  236. local_info_t *local;
  237. struct hostap_skb_tx_data *meta;
  238. struct ieee80211_hdr *hdr;
  239. u16 fc;
  240. iface = netdev_priv(dev);
  241. local = iface->local;
  242. if (skb->len < 10) {
  243. printk(KERN_DEBUG "%s: hostap_mgmt_start_xmit: short skb "
  244. "(len=%d)\n", dev->name, skb->len);
  245. kfree_skb(skb);
  246. return 0;
  247. }
  248. iface->stats.tx_packets++;
  249. iface->stats.tx_bytes += skb->len;
  250. meta = (struct hostap_skb_tx_data *) skb->cb;
  251. memset(meta, 0, sizeof(*meta));
  252. meta->magic = HOSTAP_SKB_TX_DATA_MAGIC;
  253. meta->iface = iface;
  254. if (skb->len >= IEEE80211_DATA_HDR3_LEN + sizeof(rfc1042_header) + 2) {
  255. hdr = (struct ieee80211_hdr *) skb->data;
  256. fc = le16_to_cpu(hdr->frame_control);
  257. if (ieee80211_is_data(hdr->frame_control) &&
  258. (fc & IEEE80211_FCTL_STYPE) == IEEE80211_STYPE_DATA) {
  259. u8 *pos = &skb->data[IEEE80211_DATA_HDR3_LEN +
  260. sizeof(rfc1042_header)];
  261. meta->ethertype = (pos[0] << 8) | pos[1];
  262. }
  263. }
  264. /* Send IEEE 802.11 encapsulated frame using the master radio device */
  265. skb->dev = local->dev;
  266. dev_queue_xmit(skb);
  267. return 0;
  268. }
  269. /* Called only from software IRQ */
  270. static struct sk_buff * hostap_tx_encrypt(struct sk_buff *skb,
  271. struct lib80211_crypt_data *crypt)
  272. {
  273. struct hostap_interface *iface;
  274. local_info_t *local;
  275. struct ieee80211_hdr *hdr;
  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 *) 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 *) skb->data;
  308. hdr_len = hostap_80211_get_hdrlen(hdr->frame_control);
  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 = NETDEV_TX_BUSY;
  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 *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_info.crypt[local->crypt_info.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 *) skb->data;
  375. fc = le16_to_cpu(hdr->frame_control);
  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. ieee80211_is_data(hdr->frame_control) &&
  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_control = cpu_to_le16(fc);
  414. }
  415. if (!ieee80211_is_data(hdr->frame_control)) {
  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 ||
  429. local->crypt_info.crypt[local->crypt_info.tx_keyidx]) &&
  430. !no_encrypt) {
  431. /* Add ISWEP flag both for firmware and host based encryption
  432. */
  433. fc |= IEEE80211_FCTL_PROTECTED;
  434. hdr->frame_control = cpu_to_le16(fc);
  435. } else if (local->drop_unencrypted &&
  436. ieee80211_is_data(hdr->frame_control) &&
  437. meta->ethertype != ETH_P_PAE) {
  438. if (net_ratelimit()) {
  439. printk(KERN_DEBUG "%s: dropped unencrypted TX data "
  440. "frame (drop_unencrypted=1)\n", dev->name);
  441. }
  442. iface->stats.tx_dropped++;
  443. ret = 0;
  444. goto fail;
  445. }
  446. if (tx.crypt) {
  447. skb = hostap_tx_encrypt(skb, tx.crypt);
  448. if (skb == NULL) {
  449. printk(KERN_DEBUG "%s: TX - encryption failed\n",
  450. dev->name);
  451. ret = 0;
  452. goto fail;
  453. }
  454. meta = (struct hostap_skb_tx_data *) skb->cb;
  455. if (meta->magic != HOSTAP_SKB_TX_DATA_MAGIC) {
  456. printk(KERN_DEBUG "%s: invalid skb->cb magic (0x%08x, "
  457. "expected 0x%08x) after hostap_tx_encrypt\n",
  458. dev->name, meta->magic,
  459. HOSTAP_SKB_TX_DATA_MAGIC);
  460. ret = 0;
  461. iface->stats.tx_dropped++;
  462. goto fail;
  463. }
  464. }
  465. if (local->func->tx == NULL || local->func->tx(skb, dev)) {
  466. ret = 0;
  467. iface->stats.tx_dropped++;
  468. } else {
  469. ret = 0;
  470. iface->stats.tx_packets++;
  471. iface->stats.tx_bytes += skb->len;
  472. }
  473. fail:
  474. if (!ret && skb)
  475. dev_kfree_skb(skb);
  476. tx_exit:
  477. if (tx.sta_ptr)
  478. hostap_handle_sta_release(tx.sta_ptr);
  479. return ret;
  480. }
  481. EXPORT_SYMBOL(hostap_master_start_xmit);