Received: by 2002:a05:6a10:1a4d:0:0:0:0 with SMTP id nk13csp1713162pxb; Wed, 2 Feb 2022 10:48:31 -0800 (PST) X-Google-Smtp-Source: ABdhPJxVynrWfq+aiazNYczMg4rIh/kpO5U+mEjm8FUcqPehfxPgOtlVwfX29NigoiZLfez92pFA X-Received: by 2002:a17:90a:d907:: with SMTP id c7mr9675569pjv.245.1643827711739; Wed, 02 Feb 2022 10:48:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643827711; cv=none; d=google.com; s=arc-20160816; b=DQNvTkoXZTyA7SKp+AU1xL6xgukiP2XM5czJsKl5as8qADB6RK8vLqpCERRwV08mB4 w+7Qbn9vAStr4ZLQZ1vcAMjS9gA16mHmaGAgjraCTyMuyFTwFLyKA2EDU/geovF6mla+ f/pCdYwMuMqqlPa/+S0UnelEeEHhKZ4PqoQb7BXo5+m2euyB+Ub0zp/OveYs0Yglot1s UyWsDDLbcyyb0IwKojjcdMCPn6SCpwy+tceZzfjbm/VZ1FrDLinzeDD2KUtnstjJqEoj gzsSWxWd3/9qsfISRdN+TCnXs5PZ7mKJ6FPQiFgb6+U9+qsiPg1lI5W9ky1ovVJhWfkK +KLg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:subject:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:cc:to:from; bh=g5yrFJajBGRAoaoPI+0Dcn+IsRBFzsyuhumseL94iPA=; b=Fiqxg345A5wehlmCpNWw+XdmK0v5mjQhlCx3SYrMcp1z6BPgrdSXp/XoV8vU855Pv2 Nkelf5Pss7R/ENqp1pfNCuSIOWh09pMIwlbrpcC6ZgQHkb1wfOssCg5dsIefD1ObH777 3KfyjjKfOQM5JAr4x5fyAkC5t4z5LAxi5BsTYNaqsQIWvKsOXR/bR2pD7Vau7EPzilDZ ig17Zzz7QabHdvPEllqY1PE2A/6r0hjHUNlXxbdL58zI6xT1D9+sj7dC+RkAgqKtx1m1 PezrsveTsAQPyNXJLXfVjTBn9labPUFTMume7w3csBH+i45DrQrwx9+++Cr0gjZlrbij OGBQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id f1si11717435plr.436.2022.02.02.10.48.17; Wed, 02 Feb 2022 10:48:31 -0800 (PST) Received-SPF: pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S245224AbiBBIuB (ORCPT + 65 others); Wed, 2 Feb 2022 03:50:01 -0500 Received: from paleale.coelho.fi ([176.9.41.70]:37928 "EHLO farmhouse.coelho.fi" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S245216AbiBBIuB (ORCPT ); Wed, 2 Feb 2022 03:50:01 -0500 Received: from 91-156-4-210.elisa-laajakaista.fi ([91.156.4.210] helo=kveik.lan) by farmhouse.coelho.fi with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1nFBKw-0004v8-OT; Wed, 02 Feb 2022 10:50:00 +0200 From: Luca Coelho To: johannes@sipsolutions.net Cc: luca@coelho.fi, linux-wireless@vger.kernel.org Date: Wed, 2 Feb 2022 10:49:36 +0200 Message-Id: X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220202084947.370289-1-luca@coelho.fi> References: <20220202084947.370289-1-luca@coelho.fi> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on farmhouse.coelho.fi X-Spam-Level: X-Spam-Status: No, score=-2.9 required=5.0 tests=ALL_TRUSTED,BAYES_00, TVD_RCVD_IP autolearn=ham autolearn_force=no version=3.4.6 Subject: [PATCH 03/14] cfg80211/mac80211: assume CHECKSUM_COMPLETE includes SNAP Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org From: Johannes Berg There's currently only one driver that reports CHECKSUM_COMPLETE, that is iwlwifi. The current hardware there calculates checksum after the SNAP header, but only RFC 1042 (and some other cases, but replicating the exact hardware logic for corner cases in the driver seemed awkward.) Newer generations of hardware will checksum _including_ the SNAP, which makes things easier. To handle that, simply always assume the checksum _includes_ the SNAP header, which this patch does, requiring to first add it for older iwlwifi hardware, and then remove it again later on conversion. Alternatively, we could have: 1) Always assumed the checksum starts _after_ the SNAP header; the problem with this is that we'd have to replace the exact "what is the SNAP" check in iwlwifi that cfg80211 has. 2) Made it configurable with some flag, but that seemed like too much complexity. Signed-off-by: Johannes Berg Signed-off-by: Luca Coelho --- drivers/net/wireless/intel/iwlwifi/mvm/rxmq.c | 3 +++ net/mac80211/rx.c | 2 ++ net/wireless/util.c | 8 +++++--- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/rxmq.c b/drivers/net/wireless/intel/iwlwifi/mvm/rxmq.c index 18f5b1b14ae7..2c43a9989783 100644 --- a/drivers/net/wireless/intel/iwlwifi/mvm/rxmq.c +++ b/drivers/net/wireless/intel/iwlwifi/mvm/rxmq.c @@ -209,6 +209,9 @@ static int iwl_mvm_create_skb(struct iwl_mvm *mvm, struct sk_buff *skb, shdr->type != htons(ETH_P_PAE) && shdr->type != htons(ETH_P_TDLS)))) skb->ip_summed = CHECKSUM_NONE; + else + /* mac80211 assumes full CSUM including SNAP header */ + skb_postpush_rcsum(skb, shdr, sizeof(*shdr)); } fraglen = len - headlen; diff --git a/net/mac80211/rx.c b/net/mac80211/rx.c index 93680af62c47..d54a4d98c648 100644 --- a/net/mac80211/rx.c +++ b/net/mac80211/rx.c @@ -4629,6 +4629,8 @@ static bool ieee80211_invoke_fast_rx(struct ieee80211_rx_data *rx, /* 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); + skb_postpull_rcsum(skb, skb->data + snap_offs, + sizeof(rfc1042_header) + 2); /* remove the SNAP but leave the ethertype */ skb_pull(skb, snap_offs + sizeof(rfc1042_header)); /* push the addresses in front */ diff --git a/net/wireless/util.c b/net/wireless/util.c index 41ea65deb6e1..e02f1702806e 100644 --- a/net/wireless/util.c +++ b/net/wireless/util.c @@ -5,7 +5,7 @@ * Copyright 2007-2009 Johannes Berg * Copyright 2013-2014 Intel Mobile Communications GmbH * Copyright 2017 Intel Deutschland GmbH - * Copyright (C) 2018-2020 Intel Corporation + * Copyright (C) 2018-2021 Intel Corporation */ #include #include @@ -634,12 +634,14 @@ int ieee80211_data_to_8023_exthdr(struct sk_buff *skb, struct ethhdr *ehdr, if (likely((!is_amsdu && ether_addr_equal(payload.hdr, rfc1042_header) && tmp.h_proto != htons(ETH_P_AARP) && tmp.h_proto != htons(ETH_P_IPX)) || - ether_addr_equal(payload.hdr, bridge_tunnel_header))) + ether_addr_equal(payload.hdr, bridge_tunnel_header))) { /* remove RFC1042 or Bridge-Tunnel encapsulation and * replace EtherType */ hdrlen += ETH_ALEN + 2; - else + skb_postpull_rcsum(skb, &payload, ETH_ALEN + 2); + } else { tmp.h_proto = htons(skb->len - hdrlen); + } pskb_pull(skb, hdrlen); -- 2.34.1