mac80211: add a fix for kernel warnings when forwarding packets in mesh mode
authorFelix Fietkau <nbd@nbd.name>
Wed, 24 Nov 2021 13:02:09 +0000 (14:02 +0100)
committerFelix Fietkau <nbd@nbd.name>
Wed, 24 Nov 2021 14:42:20 +0000 (15:42 +0100)
Signed-off-by: Felix Fietkau <nbd@nbd.name>
(cherry-picked from commit d439c7d85a05c3548e5566bec292292a4f6b7ef5)

package/kernel/mac80211/patches/subsys/306-mac80211-set-up-the-fwd_skb-dev-for-mesh-forwarding.patch [new file with mode: 0644]
package/kernel/mac80211/patches/subsys/315-mac80211-add-rx-decapsulation-offload-support.patch
package/kernel/mac80211/patches/subsys/390-mac80211-introduce-individual-TWT-support-in-AP-mode.patch

diff --git a/package/kernel/mac80211/patches/subsys/306-mac80211-set-up-the-fwd_skb-dev-for-mesh-forwarding.patch b/package/kernel/mac80211/patches/subsys/306-mac80211-set-up-the-fwd_skb-dev-for-mesh-forwarding.patch
new file mode 100644 (file)
index 0000000..c8cac93
--- /dev/null
@@ -0,0 +1,62 @@
+From: Xing Song <xing.song@mediatek.com>
+Date: Tue, 23 Nov 2021 11:31:23 +0800
+Subject: [PATCH] mac80211: set up the fwd_skb->dev for mesh forwarding
+
+Mesh forwarding requires that the fwd_skb->dev is set up for TX handling,
+otherwise the following warning will be generated, so set it up for the
+pending frames.
+
+[   72.835674 ] WARNING: CPU: 0 PID: 1193 at __skb_flow_dissect+0x284/0x1298
+[   72.842379 ] Modules linked in: ksmbd pppoe ppp_async l2tp_ppp ...
+[   72.962020 ] CPU: 0 PID: 1193 Comm: kworker/u5:1 Tainted: P S 5.4.137 #0
+[   72.969938 ] Hardware name: MT7622_MT7531 RFB (DT)
+[   72.974659 ] Workqueue: napi_workq napi_workfn
+[   72.979025 ] pstate: 60000005 (nZCv daif -PAN -UAO)
+[   72.983822 ] pc : __skb_flow_dissect+0x284/0x1298
+[   72.988444 ] lr : __skb_flow_dissect+0x54/0x1298
+[   72.992977 ] sp : ffffffc010c738c0
+[   72.996293 ] x29: ffffffc010c738c0 x28: 0000000000000000
+[   73.001615 ] x27: 000000000000ffc2 x26: ffffff800c2eb818
+[   73.006937 ] x25: ffffffc010a987c8 x24: 00000000000000ce
+[   73.012259 ] x23: ffffffc010c73a28 x22: ffffffc010a99c60
+[   73.017581 ] x21: 000000000000ffc2 x20: ffffff80094da800
+[   73.022903 ] x19: 0000000000000000 x18: 0000000000000014
+[   73.028226 ] x17: 00000000084d16af x16: 00000000d1fc0bab
+[   73.033548 ] x15: 00000000715f6034 x14: 000000009dbdd301
+[   73.038870 ] x13: 00000000ea4dcbc3 x12: 0000000000000040
+[   73.044192 ] x11: 000000000eb00ff0 x10: 0000000000000000
+[   73.049513 ] x9 : 000000000eb00073 x8 : 0000000000000088
+[   73.054834 ] x7 : 0000000000000000 x6 : 0000000000000001
+[   73.060155 ] x5 : 0000000000000000 x4 : 0000000000000000
+[   73.065476 ] x3 : ffffffc010a98000 x2 : 0000000000000000
+[   73.070797 ] x1 : 0000000000000000 x0 : 0000000000000000
+[   73.076120 ] Call trace:
+[   73.078572 ]  __skb_flow_dissect+0x284/0x1298
+[   73.082846 ]  __skb_get_hash+0x7c/0x228
+[   73.086629 ]  ieee80211_txq_may_transmit+0x7fc/0x17b8 [mac80211]
+[   73.092564 ]  ieee80211_tx_prepare_skb+0x20c/0x268 [mac80211]
+[   73.098238 ]  ieee80211_tx_pending+0x144/0x330 [mac80211]
+[   73.103560 ]  tasklet_action_common.isra.16+0xb4/0x158
+[   73.108618 ]  tasklet_action+0x2c/0x38
+[   73.112286 ]  __do_softirq+0x168/0x3b0
+[   73.115954 ]  do_softirq.part.15+0x88/0x98
+[   73.119969 ]  __local_bh_enable_ip+0xb0/0xb8
+[   73.124156 ]  napi_workfn+0x58/0x90
+[   73.127565 ]  process_one_work+0x20c/0x478
+[   73.131579 ]  worker_thread+0x50/0x4f0
+[   73.135249 ]  kthread+0x124/0x128
+[   73.138484 ]  ret_from_fork+0x10/0x1c
+
+Signed-off-by: Xing Song <xing.song@mediatek.com>
+---
+
+--- a/net/mac80211/rx.c
++++ b/net/mac80211/rx.c
+@@ -2940,6 +2940,7 @@ ieee80211_rx_h_mesh_fwding(struct ieee80
+       if (!fwd_skb)
+               goto out;
++      fwd_skb->dev = sdata->dev;
+       fwd_hdr =  (struct ieee80211_hdr *) fwd_skb->data;
+       fwd_hdr->frame_control &= ~cpu_to_le16(IEEE80211_FCTL_RETRY);
+       info = IEEE80211_SKB_CB(fwd_skb);
index 49af25eb1d09ea366ccd9ecccd9a050343ebbdbb..ee441bcbdc171e6edca29346213ff18f8c722211 100644 (file)
@@ -183,7 +183,7 @@ Signed-off-by: Felix Fietkau <nbd@nbd.name>
        enabled = bss->vif.offload_flags & IEEE80211_OFFLOAD_ENCAP_ENABLED;
 --- a/net/mac80211/rx.c
 +++ b/net/mac80211/rx.c
-@@ -4195,7 +4195,9 @@ void ieee80211_check_fast_rx(struct sta_
+@@ -4196,7 +4196,9 @@ void ieee80211_check_fast_rx(struct sta_
                .vif_type = sdata->vif.type,
                .control_port_protocol = sdata->control_port_protocol,
        }, *old, *new = NULL;
@@ -193,7 +193,7 @@ Signed-off-by: Felix Fietkau <nbd@nbd.name>
  
        /* use sparse to check that we don't return without updating */
        __acquire(check_fast_rx);
-@@ -4308,6 +4310,17 @@ void ieee80211_check_fast_rx(struct sta_
+@@ -4309,6 +4311,17 @@ void ieee80211_check_fast_rx(struct sta_
        if (assign)
                new = kmemdup(&fastrx, sizeof(fastrx), GFP_KERNEL);
  
@@ -211,7 +211,7 @@ Signed-off-by: Felix Fietkau <nbd@nbd.name>
        spin_lock_bh(&sta->lock);
        old = rcu_dereference_protected(sta->fast_rx, true);
        rcu_assign_pointer(sta->fast_rx, new);
-@@ -4354,6 +4367,108 @@ void ieee80211_check_fast_rx_iface(struc
+@@ -4355,6 +4368,108 @@ void ieee80211_check_fast_rx_iface(struc
        mutex_unlock(&local->sta_mtx);
  }
  
@@ -320,7 +320,7 @@ Signed-off-by: Felix Fietkau <nbd@nbd.name>
  static bool ieee80211_invoke_fast_rx(struct ieee80211_rx_data *rx,
                                     struct ieee80211_fast_rx *fast_rx)
  {
-@@ -4374,9 +4489,6 @@ static bool ieee80211_invoke_fast_rx(str
+@@ -4375,9 +4490,6 @@ static bool ieee80211_invoke_fast_rx(str
        } addrs __aligned(2);
        struct ieee80211_sta_rx_stats *stats = &sta->rx_stats;
  
@@ -330,7 +330,7 @@ Signed-off-by: Felix Fietkau <nbd@nbd.name>
        /* for parallel-rx, we need to have DUP_VALIDATED, otherwise we write
         * to a common data structure; drivers can implement that per queue
         * but we don't have that information in mac80211
-@@ -4450,32 +4562,6 @@ static bool ieee80211_invoke_fast_rx(str
+@@ -4451,32 +4563,6 @@ static bool ieee80211_invoke_fast_rx(str
            pskb_trim(skb, skb->len - fast_rx->icv_len))
                goto drop;
  
@@ -363,7 +363,7 @@ Signed-off-by: Felix Fietkau <nbd@nbd.name>
        if (rx->key && !ieee80211_has_protected(hdr->frame_control))
                goto drop;
  
-@@ -4487,12 +4573,6 @@ static bool ieee80211_invoke_fast_rx(str
+@@ -4488,12 +4574,6 @@ static bool ieee80211_invoke_fast_rx(str
                return true;
        }
  
@@ -376,7 +376,7 @@ Signed-off-by: Felix Fietkau <nbd@nbd.name>
        /* do the header conversion - first grab the addresses */
        ether_addr_copy(addrs.da, skb->data + fast_rx->da_offs);
        ether_addr_copy(addrs.sa, skb->data + fast_rx->sa_offs);
-@@ -4501,62 +4581,14 @@ static bool ieee80211_invoke_fast_rx(str
+@@ -4502,62 +4582,14 @@ static bool ieee80211_invoke_fast_rx(str
        /* push the addresses in front */
        memcpy(skb_push(skb, sizeof(addrs)), &addrs, sizeof(addrs));
  
@@ -443,7 +443,7 @@ Signed-off-by: Felix Fietkau <nbd@nbd.name>
        stats->dropped++;
        return true;
  }
-@@ -4610,6 +4642,47 @@ static bool ieee80211_prepare_and_rx_han
+@@ -4611,6 +4643,47 @@ static bool ieee80211_prepare_and_rx_han
        return true;
  }
  
@@ -491,7 +491,7 @@ Signed-off-by: Felix Fietkau <nbd@nbd.name>
  /*
   * This is the actual Rx frames handler. as it belongs to Rx path it must
   * be called with rcu_read_lock protection.
-@@ -4847,15 +4920,20 @@ void ieee80211_rx_list(struct ieee80211_
+@@ -4848,15 +4921,20 @@ void ieee80211_rx_list(struct ieee80211_
         * if it was previously present.
         * Also, frames with less than 16 bytes are dropped.
         */
index e889a0f84611e65cb81ffaf24dd8f9a82c1057cc..6ed0ebbb3514a4578d4f403f359fb3709181db46 100644 (file)
@@ -187,7 +187,7 @@ Signed-off-by: Johannes Berg <johannes.berg@intel.com>
        INIT_WORK(&sdata->csa_finalize_work, ieee80211_csa_finalize_work);
 --- a/net/mac80211/rx.c
 +++ b/net/mac80211/rx.c
-@@ -3208,6 +3208,68 @@ ieee80211_rx_h_mgmt_check(struct ieee802
+@@ -3209,6 +3209,68 @@ ieee80211_rx_h_mgmt_check(struct ieee802
        return RX_CONTINUE;
  }
  
@@ -256,7 +256,7 @@ Signed-off-by: Johannes Berg <johannes.berg@intel.com>
  static ieee80211_rx_result debug_noinline
  ieee80211_rx_h_action(struct ieee80211_rx_data *rx)
  {
-@@ -3487,6 +3549,17 @@ ieee80211_rx_h_action(struct ieee80211_r
+@@ -3488,6 +3550,17 @@ ieee80211_rx_h_action(struct ieee80211_r
                    !mesh_path_sel_is_hwmp(sdata))
                        break;
                goto queue;