History

cfg80211: remove unused function ieee80211_data_from_8023()

This function hasn't been used since the removal of iwmc3200wifi in 2012. It also appears to have a bug when qos=True, since then it'll copy uninitialized stack memory to the SKB. Just remove the function entirely.

Johannes Berg committed 9 years ago

Commit a6bcda41 parent 62b093b3 files · +0 −131Browse files

Unified · Split

3 files
  1. Documentation/driver-api/80211/cfg80211.rst +0 −3
  2. include/net/cfg80211.h +0 −13
  3. net/wireless/util.c +0 −115
Documentation/driver-api/80211/cfg80211.rst+0−3
@@ -299,9 +299,6 @@ Data path helpers · 298 unmodified lines
299.. kernel-doc:: include/net/cfg80211.h299.. kernel-doc:: include/net/cfg80211.h
300 :functions: ieee80211_data_to_8023300 :functions: ieee80211_data_to_8023
301 301
302.. kernel-doc:: include/net/cfg80211.h
303 :functions: ieee80211_data_from_8023
304
305.. kernel-doc:: include/net/cfg80211.h302.. kernel-doc:: include/net/cfg80211.h
306 :functions: ieee80211_amsdu_to_8023s303 :functions: ieee80211_amsdu_to_8023s
307 304
include/net/cfg80211.h+0−13
@@ -4346,19 +4346,6 @@ static inline int ieee80211_data_to_8023(struct sk_buff *skb, const u8 *addr, · 4345 unmodified lines
4346 return ieee80211_data_to_8023_exthdr(skb, NULL, addr, iftype);4346 return ieee80211_data_to_8023_exthdr(skb, NULL, addr, iftype);
4347}4347}
4348 4348
4349/**
4350 * ieee80211_data_from_8023 - convert an 802.3 frame to 802.11
4351 * @skb: the 802.3 frame
4352 * @addr: the device MAC address
4353 * @iftype: the virtual interface type
4354 * @bssid: the network bssid (used only for iftype STATION and ADHOC)
4355 * @qos: build 802.11 QoS data frame
4356 * Return: 0 on success, or a negative error code.
4357 */
4358int ieee80211_data_from_8023(struct sk_buff *skb, const u8 *addr,
4359 enum nl80211_iftype iftype, const u8 *bssid,
4360 bool qos);
4361
4362/**4349/**
4363 * ieee80211_amsdu_to_8023s - decode an IEEE 802.11n A-MSDU frame4350 * ieee80211_amsdu_to_8023s - decode an IEEE 802.11n A-MSDU frame
4364 *4351 *
net/wireless/util.c+0−115
@@ -529,121 +529,6 @@ int ieee80211_data_to_8023_exthdr(struct sk_buff *skb, struct ethhdr *ehdr, · 528 unmodified lines
529}529}
530EXPORT_SYMBOL(ieee80211_data_to_8023_exthdr);530EXPORT_SYMBOL(ieee80211_data_to_8023_exthdr);
531 531
532int ieee80211_data_from_8023(struct sk_buff *skb, const u8 *addr,
533 enum nl80211_iftype iftype,
534 const u8 *bssid, bool qos)
535{
536 struct ieee80211_hdr hdr;
537 u16 hdrlen, ethertype;
538 __le16 fc;
539 const u8 *encaps_data;
540 int encaps_len, skip_header_bytes;
541 int nh_pos, h_pos;
542 int head_need;
543
544 if (unlikely(skb->len < ETH_HLEN))
545 return -EINVAL;
546
547 nh_pos = skb_network_header(skb) - skb->data;
548 h_pos = skb_transport_header(skb) - skb->data;
549
550 /* convert Ethernet header to proper 802.11 header (based on
551 * operation mode) */
552 ethertype = (skb->data[12] << 8) | skb->data[13];
553 fc = cpu_to_le16(IEEE80211_FTYPE_DATA | IEEE80211_STYPE_DATA);
554
555 switch (iftype) {
556 case NL80211_IFTYPE_AP:
557 case NL80211_IFTYPE_AP_VLAN:
558 case NL80211_IFTYPE_P2P_GO:
559 fc |= cpu_to_le16(IEEE80211_FCTL_FROMDS);
560 /* DA BSSID SA */
561 memcpy(hdr.addr1, skb->data, ETH_ALEN);
562 memcpy(hdr.addr2, addr, ETH_ALEN);
563 memcpy(hdr.addr3, skb->data + ETH_ALEN, ETH_ALEN);
564 hdrlen = 24;
565 break;
566 case NL80211_IFTYPE_STATION:
567 case NL80211_IFTYPE_P2P_CLIENT:
568 fc |= cpu_to_le16(IEEE80211_FCTL_TODS);
569 /* BSSID SA DA */
570 memcpy(hdr.addr1, bssid, ETH_ALEN);
571 memcpy(hdr.addr2, skb->data + ETH_ALEN, ETH_ALEN);
572 memcpy(hdr.addr3, skb->data, ETH_ALEN);
573 hdrlen = 24;
574 break;
575 case NL80211_IFTYPE_OCB:
576 case NL80211_IFTYPE_ADHOC:
577 /* DA SA BSSID */
578 memcpy(hdr.addr1, skb->data, ETH_ALEN);
579 memcpy(hdr.addr2, skb->data + ETH_ALEN, ETH_ALEN);
580 memcpy(hdr.addr3, bssid, ETH_ALEN);
581 hdrlen = 24;
582 break;
583 default:
584 return -EOPNOTSUPP;
585 }
586
587 if (qos) {
588 fc |= cpu_to_le16(IEEE80211_STYPE_QOS_DATA);
589 hdrlen += 2;
590 }
591
592 hdr.frame_control = fc;
593 hdr.duration_id = 0;
594 hdr.seq_ctrl = 0;
595
596 skip_header_bytes = ETH_HLEN;
597 if (ethertype == ETH_P_AARP || ethertype == ETH_P_IPX) {
598 encaps_data = bridge_tunnel_header;
599 encaps_len = sizeof(bridge_tunnel_header);
600 skip_header_bytes -= 2;
601 } else if (ethertype >= ETH_P_802_3_MIN) {
602 encaps_data = rfc1042_header;
603 encaps_len = sizeof(rfc1042_header);
604 skip_header_bytes -= 2;
605 } else {
606 encaps_data = NULL;
607 encaps_len = 0;
608 }
609
610 skb_pull(skb, skip_header_bytes);
611 nh_pos -= skip_header_bytes;
612 h_pos -= skip_header_bytes;
613
614 head_need = hdrlen + encaps_len - skb_headroom(skb);
615
616 if (head_need > 0 || skb_cloned(skb)) {
617 head_need = max(head_need, 0);
618 if (head_need)
619 skb_orphan(skb);
620
621 if (pskb_expand_head(skb, head_need, 0, GFP_ATOMIC))
622 return -ENOMEM;
623 }
624
625 if (encaps_data) {
626 memcpy(skb_push(skb, encaps_len), encaps_data, encaps_len);
627 nh_pos += encaps_len;
628 h_pos += encaps_len;
629 }
630
631 memcpy(skb_push(skb, hdrlen), &hdr, hdrlen);
632
633 nh_pos += hdrlen;
634 h_pos += hdrlen;
635
636 /* Update skb pointers to various headers since this modified frame
637 * is going to go through Linux networking code that may potentially
638 * need things like pointer to IP header. */
639 skb_reset_mac_header(skb);
640 skb_set_network_header(skb, nh_pos);
641 skb_set_transport_header(skb, h_pos);
642
643 return 0;
644}
645EXPORT_SYMBOL(ieee80211_data_from_8023);
646
647static void532static void
648__frame_add_frag(struct sk_buff *skb, struct page *page,533__frame_add_frag(struct sk_buff *skb, struct page *page,
649 void *ptr, int len, int size)534 void *ptr, int len, int size)