From a76238143218ea348cec4b5d26fe9411338ae09e Mon Sep 17 00:00:00 2001
From: Aaradhana Sahu <quic_aarasahu@quicinc.com>
Date: Fri, 6 Oct 2023 18:19:53 +0530
Subject: [PATCH] mac80211: fix mesh ping issue

Signed-off-by: Aaradhana Sahu <quic_aarasahu@quicinc.com>
---
 net/mac80211/rx.c | 68 +++--------------------------------------------
 1 file changed, 4 insertions(+), 64 deletions(-)

--- a/net/mac80211/rx.c
+++ b/net/mac80211/rx.c
@@ -4727,16 +4727,14 @@ void ieee80211_check_fast_rx(struct sta_
 
 		break;
 	case NL80211_IFTYPE_MESH_POINT:
-		/* Not required for NSS mode */
-		if (ieee80211_hw_check(&local->hw, SUPPORTS_NSS_OFFLOAD))
-			goto clear;
 		/* Note: da and sa offs are not static, determine in fast rx path */
 
 		fastrx.expected_ds_bits = cpu_to_le16(IEEE80211_FCTL_FROMDS |
 						      IEEE80211_FCTL_TODS);
-
-		fastrx.internal_forward = 0;
+		fastrx.da_offs = offsetof(struct ieee80211_hdr, addr3);
+		fastrx.sa_offs = offsetof(struct ieee80211_hdr, addr4);
 		break;
+
 	default:
 		goto clear;
 	}
@@ -4958,10 +4956,7 @@ static bool ieee80211_invoke_fast_rx(str
 		u8 sa[ETH_ALEN];
 	} addrs __aligned(2);
 	struct ieee80211_sta_rx_stats *stats;
-	struct ieee80211s_hdr *mesh_hdr;
-	struct mesh_path *mppath;
 	u8 da_offs = fast_rx->da_offs, sa_offs = fast_rx->sa_offs;
-	struct ieee80211_sub_if_data *sdata = rx->sdata;
 
 	/* for parallel-rx, we need to have DUP_VALIDATED, otherwise we write
 	 * to a common data structure; drivers can implement that per queue
@@ -5011,37 +5006,6 @@ static bool ieee80211_invoke_fast_rx(str
 		snap_offs += IEEE80211_CCMP_HDR_LEN;
 	}
 
-	/* Find corresponding offsets for mesh hdr */
-	if (ieee80211_vif_is_mesh(&sdata->vif)) {
-		if (status->rx_flags & IEEE80211_RX_AMSDU)
-			return false;
-
-		/* All mesh data frames needs to be QoS Data */
-		if (unlikely(!ieee80211_is_data_qos(hdr->frame_control)))
-			return false;
-
-		/* TODO forwarding not handled yet in fast rx */
-		if (!ether_addr_equal(fast_rx->vif_addr, hdr->addr3))
-			return false;
-
-		/* Check if Min Mesh hdr is present */
-		if (!pskb_may_pull(skb, hdrlen + 6))
-			goto drop;
-
-		/* Goto mesh hdr, located at snap offs compared to AP/STA */
-		mesh_hdr = (struct ieee80211s_hdr *) (skb->data + snap_offs);
-
-		/* Only Ext Mesh hdr supported in this path now */
-		if ((mesh_hdr->flags & MESH_FLAGS_AE) != MESH_FLAGS_AE_A5_A6)
-			return false;
-
-		/* Point to eaddr1 and eaddr2 */
-		da_offs = snap_offs + ETH_ALEN;
-		sa_offs = da_offs + ETH_ALEN;
-
-		snap_offs += sizeof(struct ieee80211s_hdr);
-	}
-
 	if (!ieee80211_vif_is_mesh(&rx->sdata->vif) &&
 	    !(status->rx_flags & IEEE80211_RX_AMSDU)) {
 		if (!pskb_may_pull(skb, snap_offs + sizeof(*payload)))
@@ -5079,30 +5043,6 @@ static bool ieee80211_invoke_fast_rx(str
 		return true;
 	}
 
-	/* Update MPP table for the received packet */
-	if (ieee80211_vif_is_mesh(&sdata->vif)) {
-		char *proxied_addr, *mpp_addr;
-
-		mpp_addr = hdr->addr4;
-		proxied_addr = mesh_hdr->eaddr2;
-
-		/* Update mpp for the SA */
-		rcu_read_lock();
-		mppath = mpp_path_lookup(sdata, proxied_addr);
-		if (!mppath) {
-			mpp_path_add(sdata, proxied_addr, mpp_addr);
-		} else {
-			spin_lock_bh(&mppath->state_lock);
-
-			if (!ether_addr_equal(mppath->mpp, mpp_addr))
-				ether_addr_copy(mppath->mpp, mpp_addr);
-
-			mppath->exp_time = jiffies;
-			spin_unlock_bh(&mppath->state_lock);
-		}
-		rcu_read_unlock();
-	}
-
 	/* do the header conversion - first grab the addresses */
 	ether_addr_copy(addrs.da, skb->data + da_offs);
 	ether_addr_copy(addrs.sa, skb->data + sa_offs);
