Received: by 2002:a05:7412:d1aa:b0:fc:a2b0:25d7 with SMTP id ba42csp580296rdb; Mon, 29 Jan 2024 11:05:11 -0800 (PST) X-Google-Smtp-Source: AGHT+IHmGhogOftMR/a7ZxjpxZUJddGiSUu44aDf7K7ZybT5DiJSXaUEm6AtxZjMmEqqx1OvMHYQ X-Received: by 2002:a17:906:f34f:b0:a35:e8e5:a54c with SMTP id hg15-20020a170906f34f00b00a35e8e5a54cmr1702487ejb.74.1706555110947; Mon, 29 Jan 2024 11:05:10 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706555110; cv=pass; d=google.com; s=arc-20160816; b=Dhggz3Es9OU9bovP4KzOAOJqerBqxcwTXUrCMhn81ZkN6Dybb0doGTrEglQLcLZ/oR gM9sPYuA0iWecpdeIFnn0jUGoK3+70RtBnwXYIqnT2JZuJHvRooWHixduKnWvnCJ7s9q qde6BSZ0iqt8tM24YepG+Gsb7GwIEVrzrlWMN1v1mUiYdNtO+nxkVxEVqiy5LtxO5ZTe bLSvp81eRwDrk59u1OOZ0KPP1v8uoanSUjbj+H3Be9w/Ogf031PoUWSLtrBNZzxry2aJ 1XlrAie+QmF7j0k5n2nktOQyupLTvyxOT2QdfQBUUPRpwE6myQuilPLek/DyRIN1o8qR 3xyA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=SpyDBUKuC20VCKu+8OT+E+sPIsgGAsqVi4QD8tGGaoM=; fh=xKFRSh8Yd5COHE68OMD75P5tyifS8Z6l8fU7goaCMjM=; b=OJQwl+1XgfcyE6pKmwBU8HhbF5x4WTu9B+kCB15mt3V8DW1WuZJH7XNfPAorjfjpBA u0RwiGEuy9/oF3DbOnKuMqN6vAEZ2YB39g7hIC/Jop5qS+Uqo9fhsxdruHXUp/mkkv59 1gsRHAkstQlk6mEtywu3eVR2LqLkvrOCM0GfxWw7qHL33CnLTRizQTP8GktqU0AMTcHF oCtUvbAXqnwkA/nJTDwDJ6azZIPNTGYDs7HkhRhOACk1mi+o/NmILlLTUrbCHorcZwAT B+c/xDAfJJvwccVEVtlG+acLZLVfTygS/GI+YpVs0twzsDLDsL1zjhdrivWjYhFnNYMA XdIQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@sipsolutions.net header.s=mail header.b="e3F/sQZL"; arc=pass (i=1 spf=pass spfdomain=sipsolutions.net dkim=pass dkdomain=sipsolutions.net dmarc=pass fromdomain=sipsolutions.net); spf=pass (google.com: domain of linux-wireless+bounces-2705-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-wireless+bounces-2705-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=REJECT dis=NONE) header.from=sipsolutions.net X-Forwarded-Encrypted: i=1; AJvYcCVctDrNCQOG5wWUEhf3RPe+p65n8MeMFGuHJFU2oDPLX0o/cPbcu1pCcM2Dr/DQ5u7/NJrlTRORkJYcR0CWfi7M+A1zAG58ALls85PYoQ== Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id xo26-20020a170907bb9a00b00a35e84b0bfcsi568277ejc.827.2024.01.29.11.05.10 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Jan 2024 11:05:10 -0800 (PST) Received-SPF: pass (google.com: domain of linux-wireless+bounces-2705-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@sipsolutions.net header.s=mail header.b="e3F/sQZL"; arc=pass (i=1 spf=pass spfdomain=sipsolutions.net dkim=pass dkdomain=sipsolutions.net dmarc=pass fromdomain=sipsolutions.net); spf=pass (google.com: domain of linux-wireless+bounces-2705-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-wireless+bounces-2705-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=REJECT dis=NONE) header.from=sipsolutions.net Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 8709A1F27702 for ; Mon, 29 Jan 2024 19:05:10 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id BD1F731755; Mon, 29 Jan 2024 19:05:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=sipsolutions.net header.i=@sipsolutions.net header.b="e3F/sQZL" X-Original-To: linux-wireless@vger.kernel.org Received: from sipsolutions.net (s3.sipsolutions.net [168.119.38.16]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2D99014290 for ; Mon, 29 Jan 2024 19:05:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=168.119.38.16 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706555103; cv=none; b=T1E5r5Pp63XMcplTLaqmHCJb/zmcwHT1S+oc1J8tR5HIgbKIIVDLdGELdZKtXL1kjvhtmEOLLv4SFKJPhJZFXk4FvGuKMDopFuNUcsEH/7EqcBhRXIdklwAnlQKtPO/Gz5YCZNlDXAgjj2902wOZ6HYt1vvvHLHaJe9syu4SVco= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706555103; c=relaxed/simple; bh=aUJw8lHt9wBagvcqvxcAGHAMJIw1Gqkck/Y1F7xckTI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Auqrs7R/dCAizyyEPNgJRh1nUY+E4YUdvj8r5pQOf03xsQoPEwHHoXdK64Q4QAqc2/JvNm0ByQRJRRjsJUFLuZFZaCfhrbqEFgAWQaRuuBjJbb0hZX37qDOKx12rwXVOoUH/Q6Qz05K1nRS2yjp9HjKHa8tWhTQIL7skul5nRGA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=sipsolutions.net; spf=pass smtp.mailfrom=sipsolutions.net; dkim=pass (2048-bit key) header.d=sipsolutions.net header.i=@sipsolutions.net header.b=e3F/sQZL; arc=none smtp.client-ip=168.119.38.16 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=sipsolutions.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=sipsolutions.net DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sipsolutions.net; s=mail; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From:Content-Type:Sender :Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From:Resent-To: Resent-Cc:Resent-Message-ID; bh=SpyDBUKuC20VCKu+8OT+E+sPIsgGAsqVi4QD8tGGaoM=; t=1706555102; x=1707764702; b=e3F/sQZLSBtqL64imgJJZ9FpinCBNkpuac++UPzo7N+PcWW RDpNJfepxeuoQOksXJP0t2n1RVy/C7JTUssnDxY/NExDfG/wc2bM55wXkT0KueLy/zIOue3Kn0gfB Xbr9RKfJuY1BJlymlep9jrSZnAB41+efiLOFv4s+8+bN0TluNeXzh7wGt8/Q1qUFgs0NkBO+sS8L2 RrX66a6OgAcwD2qqxlLo+Yciy76RPh9rms+IbHguvivafbkpUCuVYu5/dZHRaGWNXc8SnC3G6sFSw rDi227elvyokeWhlSicLjI0LgRnH9Oxm/tMOaEvVaBBWpKI3roxY0QsTGKz27sFw==; Received: by sipsolutions.net with esmtpsa (TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim 4.97) (envelope-from ) id 1rUWwF-0000000506V-2c7G; Mon, 29 Jan 2024 20:04:59 +0100 From: Johannes Berg To: linux-wireless@vger.kernel.org Cc: Johannes Berg Subject: [PATCH 2/2] wifi: mac80211: implement MLO multicast deduplication Date: Mon, 29 Jan 2024 20:04:57 +0100 Message-ID: <20240129200456.693b77d14b44.I491846f2bea0058c14eab6422962c10bfae9b675@changeid> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240129200456.f0ff49c80006.I850d2785ab1640e56e262d3ad7343b87f6962552@changeid> References: <20240129200456.f0ff49c80006.I850d2785ab1640e56e262d3ad7343b87f6962552@changeid> Precedence: bulk X-Mailing-List: linux-wireless@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: Johannes Berg If the vif is an MLD then it may receive multicast from different links, and should drop those frames according to the SN. Implement that. Signed-off-by: Johannes Berg --- include/linux/ieee80211.h | 5 +++++ net/mac80211/ieee80211_i.h | 4 +++- net/mac80211/mlme.c | 3 +++ net/mac80211/rx.c | 22 ++++++++++++++++++++-- 4 files changed, 31 insertions(+), 3 deletions(-) diff --git a/include/linux/ieee80211.h b/include/linux/ieee80211.h index b9367d5f04c4..e9078143b822 100644 --- a/include/linux/ieee80211.h +++ b/include/linux/ieee80211.h @@ -191,6 +191,11 @@ static inline bool ieee80211_sn_less(u16 sn1, u16 sn2) return ((sn1 - sn2) & IEEE80211_SN_MASK) > (IEEE80211_SN_MODULO >> 1); } +static inline bool ieee80211_sn_less_eq(u16 sn1, u16 sn2) +{ + return ((sn2 - sn1) & IEEE80211_SN_MASK) <= (IEEE80211_SN_MODULO >> 1); +} + static inline u16 ieee80211_sn_add(u16 sn1, u16 sn2) { return (sn1 + sn2) & IEEE80211_SN_MASK; diff --git a/net/mac80211/ieee80211_i.h b/net/mac80211/ieee80211_i.h index 534cac3fc8df..46b517cf47ea 100644 --- a/net/mac80211/ieee80211_i.h +++ b/net/mac80211/ieee80211_i.h @@ -5,7 +5,7 @@ * Copyright 2006-2007 Jiri Benc * Copyright 2007-2010 Johannes Berg * Copyright 2013-2015 Intel Mobile Communications GmbH - * Copyright (C) 2018-2022 Intel Corporation + * Copyright (C) 2018-2024 Intel Corporation */ #ifndef IEEE80211_I_H @@ -523,6 +523,8 @@ struct ieee80211_if_managed { unsigned int flags; + u16 mcast_seq_last; + bool status_acked; bool status_received; __le16 status_fc; diff --git a/net/mac80211/mlme.c b/net/mac80211/mlme.c index 64367cb141ca..d5293e715558 100644 --- a/net/mac80211/mlme.c +++ b/net/mac80211/mlme.c @@ -3350,6 +3350,8 @@ static void ieee80211_set_disassoc(struct ieee80211_sub_if_data *sdata, wiphy_delayed_work_cancel(sdata->local->hw.wiphy, &ifmgd->neg_ttlm_timeout_work); ieee80211_vif_set_links(sdata, 0, 0); + + ifmgd->mcast_seq_last = IEEE80211_SN_MODULO; } static void ieee80211_reset_ap_probe(struct ieee80211_sub_if_data *sdata) @@ -7514,6 +7516,7 @@ void ieee80211_sta_setup_sdata(struct ieee80211_sub_if_data *sdata) spin_lock_init(&ifmgd->teardown_lock); ifmgd->teardown_skb = NULL; ifmgd->orig_teardown_skb = NULL; + ifmgd->mcast_seq_last = IEEE80211_SN_MODULO; } static void ieee80211_recalc_smps_work(struct wiphy *wiphy, diff --git a/net/mac80211/rx.c b/net/mac80211/rx.c index 16d8783a469d..1ee00547c0a4 100644 --- a/net/mac80211/rx.c +++ b/net/mac80211/rx.c @@ -1434,13 +1434,31 @@ ieee80211_rx_h_check_dup(struct ieee80211_rx_data *rx) return RX_CONTINUE; if (ieee80211_is_ctl(hdr->frame_control) || - ieee80211_is_any_nullfunc(hdr->frame_control) || - is_multicast_ether_addr(hdr->addr1)) + ieee80211_is_any_nullfunc(hdr->frame_control)) return RX_CONTINUE; if (!rx->sta) return RX_CONTINUE; + if (unlikely(is_multicast_ether_addr(hdr->addr1))) { + struct ieee80211_sub_if_data *sdata = rx->sdata; + u16 sn = ieee80211_get_sn(hdr); + + if (!ieee80211_is_data_present(hdr->frame_control)) + return RX_CONTINUE; + + if (!ieee80211_vif_is_mld(&sdata->vif) || + sdata->vif.type != NL80211_IFTYPE_STATION) + return RX_CONTINUE; + + if (sdata->u.mgd.mcast_seq_last != IEEE80211_SN_MODULO && + ieee80211_sn_less_eq(sn, sdata->u.mgd.mcast_seq_last)) + return RX_DROP_U_DUP; + + sdata->u.mgd.mcast_seq_last = sn; + return RX_CONTINUE; + } + if (unlikely(ieee80211_has_retry(hdr->frame_control) && rx->sta->last_seq_ctrl[rx->seqno_idx] == hdr->seq_ctrl)) { I802_DEBUG_INC(rx->local->dot11FrameDuplicateCount); -- 2.43.0