hostap_80211_tx.c 16 KB

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