1
0

304-mac80211-add-hdrlen-to-ieee80211_tx_data.patch 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219
  1. From: Janusz Dziedzic <janusz.dziedzic@tieto.com>
  2. Date: Fri, 19 Feb 2016 11:01:49 +0100
  3. Subject: [PATCH] mac80211: add hdrlen to ieee80211_tx_data
  4. Add hdrlen to ieee80211_tx_data and use this
  5. when wep/ccmd/tkip. This is preparation for
  6. aligned4 code.
  7. Signed-off-by: Janusz Dziedzic <janusz.dziedzic@tieto.com>
  8. ---
  9. --- a/net/mac80211/ieee80211_i.h
  10. +++ b/net/mac80211/ieee80211_i.h
  11. @@ -175,6 +175,7 @@ struct ieee80211_tx_data {
  12. struct ieee80211_tx_rate rate;
  13. unsigned int flags;
  14. + unsigned int hdrlen;
  15. };
  16. --- a/net/mac80211/tx.c
  17. +++ b/net/mac80211/tx.c
  18. @@ -955,7 +955,7 @@ ieee80211_tx_h_fragment(struct ieee80211
  19. struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
  20. struct ieee80211_hdr *hdr = (void *)skb->data;
  21. int frag_threshold = tx->local->hw.wiphy->frag_threshold;
  22. - int hdrlen;
  23. + int hdrlen = tx->hdrlen;
  24. int fragnum;
  25. /* no matter what happens, tx->skb moves to tx->skbs */
  26. @@ -976,8 +976,6 @@ ieee80211_tx_h_fragment(struct ieee80211
  27. if (WARN_ON(info->flags & IEEE80211_TX_CTL_AMPDU))
  28. return TX_DROP;
  29. - hdrlen = ieee80211_hdrlen(hdr->frame_control);
  30. -
  31. /* internal error, why isn't DONTFRAG set? */
  32. if (WARN_ON(skb->len + FCS_LEN <= frag_threshold))
  33. return TX_DROP;
  34. @@ -1209,6 +1207,8 @@ ieee80211_tx_prepare(struct ieee80211_su
  35. hdr = (struct ieee80211_hdr *) skb->data;
  36. + tx->hdrlen = ieee80211_hdrlen(hdr->frame_control);
  37. +
  38. if (likely(sta)) {
  39. if (!IS_ERR(sta))
  40. tx->sta = sta;
  41. @@ -3414,6 +3414,7 @@ begin:
  42. tx.local = local;
  43. tx.skb = skb;
  44. tx.sdata = vif_to_sdata(info->control.vif);
  45. + tx.hdrlen = ieee80211_padded_hdrlen(hw, hdr->frame_control);
  46. if (txq->sta)
  47. tx.sta = container_of(txq->sta, struct sta_info, sta);
  48. @@ -3584,6 +3585,7 @@ ieee80211_build_data_template(struct iee
  49. hdr = (void *)skb->data;
  50. tx.sta = sta_info_get(sdata, hdr->addr1);
  51. tx.skb = skb;
  52. + tx.hdrlen = ieee80211_padded_hdrlen(&tx.local->hw, hdr->frame_control);
  53. if (ieee80211_tx_h_select_key(&tx) != TX_CONTINUE) {
  54. rcu_read_unlock();
  55. --- a/net/mac80211/util.c
  56. +++ b/net/mac80211/util.c
  57. @@ -1227,6 +1227,7 @@ void ieee80211_send_auth(struct ieee8021
  58. struct ieee80211_local *local = sdata->local;
  59. struct sk_buff *skb;
  60. struct ieee80211_mgmt *mgmt;
  61. + unsigned int hdrlen;
  62. int err;
  63. /* 24 + 6 = header + auth_algo + auth_transaction + status_code */
  64. @@ -1251,8 +1252,10 @@ void ieee80211_send_auth(struct ieee8021
  65. memcpy(skb_put(skb, extra_len), extra, extra_len);
  66. if (auth_alg == WLAN_AUTH_SHARED_KEY && transaction == 3) {
  67. + hdrlen = ieee80211_hdrlen(mgmt->frame_control);
  68. mgmt->frame_control |= cpu_to_le16(IEEE80211_FCTL_PROTECTED);
  69. - err = ieee80211_wep_encrypt(local, skb, key, key_len, key_idx);
  70. + err = ieee80211_wep_encrypt(local, skb, hdrlen, key,
  71. + key_len, key_idx);
  72. WARN_ON(err);
  73. }
  74. --- a/net/mac80211/wep.c
  75. +++ b/net/mac80211/wep.c
  76. @@ -89,11 +89,11 @@ static void ieee80211_wep_get_iv(struct
  77. static u8 *ieee80211_wep_add_iv(struct ieee80211_local *local,
  78. struct sk_buff *skb,
  79. + unsigned int hdrlen,
  80. int keylen, int keyidx)
  81. {
  82. struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data;
  83. struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
  84. - unsigned int hdrlen;
  85. u8 *newhdr;
  86. hdr->frame_control |= cpu_to_le16(IEEE80211_FCTL_PROTECTED);
  87. @@ -101,7 +101,6 @@ static u8 *ieee80211_wep_add_iv(struct i
  88. if (WARN_ON(skb_headroom(skb) < IEEE80211_WEP_IV_LEN))
  89. return NULL;
  90. - hdrlen = ieee80211_hdrlen(hdr->frame_control);
  91. newhdr = skb_push(skb, IEEE80211_WEP_IV_LEN);
  92. memmove(newhdr, newhdr + IEEE80211_WEP_IV_LEN, hdrlen);
  93. @@ -160,6 +159,7 @@ int ieee80211_wep_encrypt_data(struct cr
  94. */
  95. int ieee80211_wep_encrypt(struct ieee80211_local *local,
  96. struct sk_buff *skb,
  97. + unsigned int hdrlen,
  98. const u8 *key, int keylen, int keyidx)
  99. {
  100. u8 *iv;
  101. @@ -169,7 +169,7 @@ int ieee80211_wep_encrypt(struct ieee802
  102. if (WARN_ON(skb_tailroom(skb) < IEEE80211_WEP_ICV_LEN))
  103. return -1;
  104. - iv = ieee80211_wep_add_iv(local, skb, keylen, keyidx);
  105. + iv = ieee80211_wep_add_iv(local, skb, hdrlen, keylen, keyidx);
  106. if (!iv)
  107. return -1;
  108. @@ -306,13 +306,14 @@ static int wep_encrypt_skb(struct ieee80
  109. struct ieee80211_key_conf *hw_key = info->control.hw_key;
  110. if (!hw_key) {
  111. - if (ieee80211_wep_encrypt(tx->local, skb, tx->key->conf.key,
  112. + if (ieee80211_wep_encrypt(tx->local, skb, tx->hdrlen,
  113. + tx->key->conf.key,
  114. tx->key->conf.keylen,
  115. tx->key->conf.keyidx))
  116. return -1;
  117. } else if ((hw_key->flags & IEEE80211_KEY_FLAG_GENERATE_IV) ||
  118. (hw_key->flags & IEEE80211_KEY_FLAG_PUT_IV_SPACE)) {
  119. - if (!ieee80211_wep_add_iv(tx->local, skb,
  120. + if (!ieee80211_wep_add_iv(tx->local, skb, tx->hdrlen,
  121. tx->key->conf.keylen,
  122. tx->key->conf.keyidx))
  123. return -1;
  124. --- a/net/mac80211/wep.h
  125. +++ b/net/mac80211/wep.h
  126. @@ -22,6 +22,7 @@ int ieee80211_wep_encrypt_data(struct cr
  127. size_t klen, u8 *data, size_t data_len);
  128. int ieee80211_wep_encrypt(struct ieee80211_local *local,
  129. struct sk_buff *skb,
  130. + unsigned int hdrlen,
  131. const u8 *key, int keylen, int keyidx);
  132. int ieee80211_wep_decrypt_data(struct crypto_cipher *tfm, u8 *rc4key,
  133. size_t klen, u8 *data, size_t data_len);
  134. --- a/net/mac80211/wpa.c
  135. +++ b/net/mac80211/wpa.c
  136. @@ -43,7 +43,7 @@ ieee80211_tx_h_michael_mic_add(struct ie
  137. skb->len < 24 || !ieee80211_is_data_present(hdr->frame_control))
  138. return TX_CONTINUE;
  139. - hdrlen = ieee80211_hdrlen(hdr->frame_control);
  140. + hdrlen = tx->hdrlen;
  141. if (skb->len < hdrlen)
  142. return TX_DROP;
  143. @@ -186,7 +186,6 @@ mic_fail_no_key:
  144. static int tkip_encrypt_skb(struct ieee80211_tx_data *tx, struct sk_buff *skb)
  145. {
  146. - struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data;
  147. struct ieee80211_key *key = tx->key;
  148. struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
  149. unsigned int hdrlen;
  150. @@ -201,7 +200,7 @@ static int tkip_encrypt_skb(struct ieee8
  151. return 0;
  152. }
  153. - hdrlen = ieee80211_hdrlen(hdr->frame_control);
  154. + hdrlen = tx->hdrlen;
  155. len = skb->len - hdrlen;
  156. if (info->control.hw_key)
  157. @@ -418,7 +417,7 @@ static int ccmp_encrypt_skb(struct ieee8
  158. return 0;
  159. }
  160. - hdrlen = ieee80211_hdrlen(hdr->frame_control);
  161. + hdrlen = tx->hdrlen;
  162. len = skb->len - hdrlen;
  163. if (info->control.hw_key)
  164. @@ -651,7 +650,7 @@ static int gcmp_encrypt_skb(struct ieee8
  165. return 0;
  166. }
  167. - hdrlen = ieee80211_hdrlen(hdr->frame_control);
  168. + hdrlen = tx->hdrlen;
  169. len = skb->len - hdrlen;
  170. if (info->control.hw_key)
  171. @@ -791,7 +790,6 @@ static ieee80211_tx_result
  172. ieee80211_crypto_cs_encrypt(struct ieee80211_tx_data *tx,
  173. struct sk_buff *skb)
  174. {
  175. - struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data;
  176. struct ieee80211_key *key = tx->key;
  177. struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
  178. int hdrlen;
  179. @@ -807,8 +805,7 @@ ieee80211_crypto_cs_encrypt(struct ieee8
  180. pskb_expand_head(skb, iv_len, 0, GFP_ATOMIC)))
  181. return TX_DROP;
  182. - hdrlen = ieee80211_hdrlen(hdr->frame_control);
  183. -
  184. + hdrlen = tx->hdrlen;
  185. pos = skb_push(skb, iv_len);
  186. memmove(pos, pos + iv_len, hdrlen);