Skip to contentSkip to conversation

mac80211: optimize skb resizing

PATCH In review Felix Fietkau 2 participants 2 messages Mar 17, 2019 – Apr 8, 2019 mac80211

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mac80211: optimize skb resizing

When forwarding unicast packets from ethernet to batman-adv over 802.11s (with forwarding disabled), the typical required headroom to transmit encrypted packets on mt76 is 32 (802.11) + 6 (802.11s) + 8 (CCMP) + 2 (padding) + 6 (LLC) + 18 (batman-adv) - 14 (old ethernet header) = 58 bytes.

On systems where NET_SKB_PAD is 64 this leads to a call to pskb_expand_head for every packet, since mac80211 also tries to allocate 16 bytes status headroom for radiotap headers.

This patch fixes these unnecessary reallocations by only requiring the extra status headroom in ieee80211_tx_monitor()
If however a reallocation happens before that call, the status headroom gets added there as well, in order to avoid double reallocation.

The patch also cleans up the code by moving the headroom calculation to ieee80211_skb_resize.

---
 net/mac80211/ieee80211_i.h |  2 +
 net/mac80211/status.c      |  5 ++
 net/mac80211/tx.c          | 96 ++++++++++++++++----------------------
 3 files changed, 48 insertions(+), 55 deletions(-)
net/mac80211/ieee80211_i.h +2 -0
index 5b2626ca0e44..a36bfa1b43a9 100644
@@ -1779,6 +1779,8 @@ void ieee80211_clear_fast_xmit(struct sta_info *sta);
 int ieee80211_tx_control_port(struct wiphy *wiphy, struct net_device *dev,
 			      const u8 *buf, size_t len,
 			      const u8 *dest, __be16 proto, bool unencrypted);
+int ieee80211_skb_resize(struct ieee80211_sub_if_data *sdata,
+			 struct sk_buff *skb, int hdrlen, int hdr_add);
 
 /* HT */
 void ieee80211_apply_htcap_overrides(struct ieee80211_sub_if_data *sdata,
net/mac80211/status.c +5 -0
index 0af1c7a99d6c..1452011d7e91 100644
@@ -670,6 +670,11 @@ void ieee80211_tx_monitor(struct ieee80211_local *local, struct sk_buff *skb,
 		}
 	}
 
+	if (ieee80211_skb_resize(NULL, skb, 0, 0)) {
+		dev_kfree_skb(skb);
+		return;
+	}
+
 	/* send frame to monitor interfaces now */
 	rtap_len = ieee80211_tx_radiotap_len(info);
 	if (WARN_ON_ONCE(skb_headroom(skb) < rtap_len)) {
net/mac80211/tx.c +41 -55

143 lines not on this page · raw message

Signature · 1 line
2.17.0
maintainer
#1 lore raw
Quoted 9 lines · Felix Fietkau

When forwarding unicast packets from ethernet to batman-adv over 802.11s (with forwarding disabled), the typical required headroom to transmit encrypted packets on mt76 is 32 (802.11) + 6 (802.11s) + 8 (CCMP) + 2 (padding) + 6 (LLC) + 18 (batman-adv) - 14 (old ethernet header) = 58 bytes.

On systems where NET_SKB_PAD is 64 this leads to a call to pskb_expand_head for every packet, since mac80211 also tries to allocate 16 bytes status headroom for radiotap headers.

Quoted 7 lines

This patch fixes these unnecessary reallocations by only requiring the extra status headroom in ieee80211_tx_monitor()
If however a reallocation happens before that call, the status headroom gets added there as well, in order to avoid double reallocation.

The patch also cleans up the code by moving the headroom calculation to ieee80211_skb_resize.

This doesn't apply, not really sure why.

johannes