From patchwork Sat Jun 12 14:37:29 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 459167 Delivered-To: patch@linaro.org Received: by 2002:a02:735a:0:0:0:0:0 with SMTP id a26csp1859526jae; Sat, 12 Jun 2021 07:39:01 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxC/pJnjYOTTudBYz6nZZyAL+qhuVCQEBN4lfLh3prAeVwcBtqzi9DI8Z5MQdeOjb+gpEAy X-Received: by 2002:a17:907:770a:: with SMTP id kw10mr8057136ejc.213.1623508741363; Sat, 12 Jun 2021 07:39:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623508741; cv=none; d=google.com; s=arc-20160816; b=f8f1yGDlAr+TQYuoftsDL8pE4DRRH8W7DrBbRgcM7darLBjmGSdlVFp98ErC6U6TcT YFYTouDASHJEZlUx4RdBIorqBfWI8TOfV+Qv89Dx1T0Iitd/B0wrrCq20T4Kxabc9KQC I0YNhXxnSZSPWCgLjcvqQKUFw50dOdiReKRyg7ZJpT7KOdr5JmBXUdqVSLE456l35dwO kmYBbiU23vBacW/GmPvNriL0j4vw+8NbW82btMga0XfctL9TKxu8xKqnx3KhsbSY4nWI O5WyJGRzvw1chNuLnAIw1anRATHb7ENjUdI7KoXC9DZLB/j/HLDQjr+fFDy16GA7DbFt PxzQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=RoTW6JTlZnNd0l9BUF/eHwMYa4PJcYiPHlW2YFHC00U=; b=xVtXEmXvOB8E9zBbswJzey2nkCB+kUEA17XHycPPAUfI1DOcXtBuvV2pehHB3g+en7 BTJPNcQ/0uUG+DIqQu7PaQrbMgxR34oRtZhoY/P4wk+9ArAHNUGvC7lfzCR+twG/eFa5 HkZPBpTeTTz/+IFGunOPvem9ifHGNGMN0FEf88fnOgjgOxME4tNKgJMw1Ak22tjzF3xD 941ISd1nNIK/VF7dVsmQNQw67hHOa9/e25fMba0EMdiljedIQHZQjAiTvxsMn9TYOo7a cXICzwbjjeieZhPFLV7qD6LpJAUaGV6jEV+hVzjRngIbbIQWC/Fr6nClEKUPBbjSC+V3 amJA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ll5Kwoii; spf=pass (google.com: domain of netdev-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=netdev-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id ly22si7281996ejb.565.2021.06.12.07.39.01; Sat, 12 Jun 2021 07:39:01 -0700 (PDT) Received-SPF: pass (google.com: domain of netdev-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ll5Kwoii; spf=pass (google.com: domain of netdev-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=netdev-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231521AbhFLOk6 (ORCPT + 8 others); Sat, 12 Jun 2021 10:40:58 -0400 Received: from mail-il1-f176.google.com ([209.85.166.176]:45681 "EHLO mail-il1-f176.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231314AbhFLOk4 (ORCPT ); Sat, 12 Jun 2021 10:40:56 -0400 Received: by mail-il1-f176.google.com with SMTP id b5so8128880ilc.12 for ; Sat, 12 Jun 2021 07:38:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=RoTW6JTlZnNd0l9BUF/eHwMYa4PJcYiPHlW2YFHC00U=; b=ll5Kwoii5v9IfxRGoOoezv9Cic/5ZupbSWJpSuJIdPv+MJtvXr3x/LeBFigQCJxHwg L3MePC8AAA35Y7ThNUcU4L1JEAo2iYrgHdsYd12sWNews8WtMYokBT5vqNf7T34vAl+J jT5j9QJ6u8oiOEgPerth7vmDQvNnr/0u+Avo59oLdauos/lFDv4LLlKSclwh6N/60+fm /shgX7jj5Db1AKPovKFL1PGhexMahw1C4ONE2XYj3Hs1t1MwtZX8RRxoEWf0qyRube9I ZeHDfH4tXpljVXDZJMYhgnZOYolUSkya8z3vGDtNfGfyiA66g7fDENN4Gz2Yh1lpBLNh gyuA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=RoTW6JTlZnNd0l9BUF/eHwMYa4PJcYiPHlW2YFHC00U=; b=Cb+qJo0QA8u2UgGx/ChxxtpBDSJxorIx1hp7OaeKcnmN7C/ZCQLJm7UtYMrdJqehVV pjksnST3KzX3PYm2OwGSh3dwvsJxZJLIKL0zEF/2SunPqyyeVX0CiG6+ex4dsuMVpSwu W0BNckChNDbrKAxZ/eyK+iohFK7LP8NtEJXfZcXDMBb9Hh1mu+bahbzlNl5ojGZ1OChe qd3Bp7swYHZAkjevtPqlT1RlLK1fYCXjJJlHsv4mik05S7bhUakQ+CXxPsTFpoNAlm2I jB/Q0ogRqEa4VMA6tY0JvY0nf7LJaihugnFYlL4l4qKGyitH/Gdx3Ydrh61zL4/M7UDq Xj4g== X-Gm-Message-State: AOAM532goNZHsWzMwCadGPARcL5yDk1Fsc5llS3NVGfY6WYgLm3Nk9ma M6dXAnOKWf+uqYuZx/qEB7LmDA== X-Received: by 2002:a92:4446:: with SMTP id a6mr7348379ilm.9.1623508660514; Sat, 12 Jun 2021 07:37:40 -0700 (PDT) Received: from presto.localdomain (c-73-185-129-58.hsd1.mn.comcast.net. [73.185.129.58]) by smtp.gmail.com with ESMTPSA id k4sm5126559ior.55.2021.06.12.07.37.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 12 Jun 2021 07:37:40 -0700 (PDT) From: Alex Elder To: subashab@codeaurora.org, stranche@codeaurora.org, davem@davemloft.net, kuba@kernel.org Cc: bjorn.andersson@linaro.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH net-next 1/8] net: qualcomm: rmnet: remove some local variables Date: Sat, 12 Jun 2021 09:37:29 -0500 Message-Id: <20210612143736.3498712-2-elder@linaro.org> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210612143736.3498712-1-elder@linaro.org> References: <20210612143736.3498712-1-elder@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org In rmnet_map_ipv4_dl_csum_trailer(), remove the "csum_temp" and "addend" local variables, and simplify a few lines of code. Remove the "csum_temp", "csum_value", "ip6_hdr_csum", and "addend" local variables in rmnet_map_ipv6_dl_csum_trailer(), and simplify a few lines of code there as well. Signed-off-by: Alex Elder --- .../ethernet/qualcomm/rmnet/rmnet_map_data.c | 37 +++++++------------ 1 file changed, 13 insertions(+), 24 deletions(-) -- 2.27.0 diff --git a/drivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c b/drivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c index d4d23ab446ef5..3e6feef0fd252 100644 --- a/drivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c +++ b/drivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c @@ -35,10 +35,9 @@ rmnet_map_ipv4_dl_csum_trailer(struct sk_buff *skb, { struct iphdr *ip4h = (struct iphdr *)skb->data; void *txporthdr = skb->data + ip4h->ihl * 4; - __sum16 *csum_field, csum_temp, pseudo_csum; + __sum16 *csum_field, pseudo_csum; __sum16 ip_payload_csum; - u16 csum_value_final; - __be16 addend; + __sum16 csum_value_final; /* Computing the checksum over just the IPv4 header--including its * checksum field--should yield 0. If it doesn't, the IP header @@ -83,14 +82,11 @@ rmnet_map_ipv4_dl_csum_trailer(struct sk_buff *skb, pseudo_csum = ~csum_tcpudp_magic(ip4h->saddr, ip4h->daddr, ntohs(ip4h->tot_len) - ip4h->ihl * 4, ip4h->protocol, 0); - addend = (__force __be16)pseudo_csum; - pseudo_csum = csum16_add(ip_payload_csum, addend); + pseudo_csum = csum16_add(ip_payload_csum, (__force __be16)pseudo_csum); - addend = (__force __be16)*csum_field; - csum_temp = ~csum16_sub(pseudo_csum, addend); - csum_value_final = (__force u16)csum_temp; + csum_value_final = ~csum16_sub(pseudo_csum, (__force __be16)*csum_field); - if (unlikely(csum_value_final == 0)) { + if (unlikely(!csum_value_final)) { switch (ip4h->protocol) { case IPPROTO_UDP: /* RFC 768 - DL4 1's complement rule for UDP csum 0 */ @@ -105,7 +101,7 @@ rmnet_map_ipv4_dl_csum_trailer(struct sk_buff *skb, } } - if (csum_value_final == (__force u16)*csum_field) { + if (csum_value_final == *csum_field) { priv->stats.csum_ok++; return 0; } else { @@ -122,12 +118,10 @@ rmnet_map_ipv6_dl_csum_trailer(struct sk_buff *skb, { struct ipv6hdr *ip6h = (struct ipv6hdr *)skb->data; void *txporthdr = skb->data + sizeof(*ip6h); - __sum16 *csum_field, pseudo_csum, csum_temp; - __be16 ip6_hdr_csum, addend; + __sum16 *csum_field, pseudo_csum; __sum16 ip6_payload_csum; __be16 ip_header_csum; - u16 csum_value_final; - __be16 csum_value; + __sum16 csum_value_final; u32 length; /* Checksum offload is only supported for UDP and TCP protocols; @@ -145,23 +139,18 @@ rmnet_map_ipv6_dl_csum_trailer(struct sk_buff *skb, * of the IP header from the trailer checksum. We then add the * checksum computed over the pseudo header. */ - csum_value = ~csum_trailer->csum_value; ip_header_csum = (__force __be16)ip_fast_csum(ip6h, sizeof(*ip6h) / 4); - ip6_hdr_csum = (__force __be16)~ip_header_csum; - ip6_payload_csum = csum16_sub((__force __sum16)csum_value, - ip6_hdr_csum); + ip6_payload_csum = csum16_sub((__force __sum16)~csum_trailer->csum_value, + ~ip_header_csum); length = (ip6h->nexthdr == IPPROTO_UDP) ? ntohs(((struct udphdr *)txporthdr)->len) : ntohs(ip6h->payload_len); pseudo_csum = ~csum_ipv6_magic(&ip6h->saddr, &ip6h->daddr, length, ip6h->nexthdr, 0); - addend = (__force __be16)pseudo_csum; - pseudo_csum = csum16_add(ip6_payload_csum, addend); + pseudo_csum = csum16_add(ip6_payload_csum, (__force __be16)pseudo_csum); - addend = (__force __be16)*csum_field; - csum_temp = ~csum16_sub(pseudo_csum, addend); - csum_value_final = (__force u16)csum_temp; + csum_value_final = ~csum16_sub(pseudo_csum, (__force __be16)*csum_field); if (unlikely(csum_value_final == 0)) { switch (ip6h->nexthdr) { @@ -180,7 +169,7 @@ rmnet_map_ipv6_dl_csum_trailer(struct sk_buff *skb, } } - if (csum_value_final == (__force u16)*csum_field) { + if (csum_value_final == *csum_field) { priv->stats.csum_ok++; return 0; } else { From patchwork Sat Jun 12 14:37:30 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 459164 Delivered-To: patch@linaro.org Received: by 2002:a02:735a:0:0:0:0:0 with SMTP id a26csp1859475jae; Sat, 12 Jun 2021 07:38:56 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzSOGjHVxDEkaqIQ8wWucwaKvyW9XcDTmDy7uTuWj+w9kkOLULEIVuWqYp98e5CnDupINJ6 X-Received: by 2002:a17:906:8a55:: with SMTP id gx21mr8192593ejc.179.1623508736550; Sat, 12 Jun 2021 07:38:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623508736; cv=none; d=google.com; s=arc-20160816; b=DZb3t88xHzO1yhR6PEXzl3Q3vGrx+r3X6h8bLwpV+9LWfIvx7+7jfjLduIM/F9eqMZ kPVVK2KmLiu/ypb1m2XjEFtcaTmdG2LTHri/yVH71I+9NsJBS8NJGwnSYo3TwTlcbSpW aOoO6IjXwcxuP+B5ZWKZsonsJMF86AG+DErI6VBIxTeN05IpMKGlwN7gRKpiqhnSJL/G jHQRH+gqXf/yDy42B8KD55iN/MnoUBs/JD7pkYCgbtB/5aJQIWHWvpUYkzBrRyhtnLeP uHZrrvlOJhWkjXNbK5kktWYPHZas36tW77YF/Tw23IFMilC5UlAqxWJ2E+neZ1sVwg2P 7t8w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=6MPm/CDH/wz97xhLG1zwJ5+gY1yCELg1LNPAC/aA5x8=; b=befz1qYu4zBlnajkN+uSggd3k9fAk3n528yck+bliZ8HsqtA59NJP+Xu9iO0ZNlEWc hsRP19/EP0DTDe8KLywGVro8ftU/9ap8/I1UfNqJf/bj1KTfv+FfuKL528Xv/vmGKP4k HJxTgpwc5gbisRRiMBqoa1RPxWKQDF81nBe48qhRz8pVKzBIhevB1RNDuMHHVNZZ6Qxb PbblnA4goSqrb6kB+HGThXAjrN+g1qaKY8s8/ycaaLqwn/mGS9ssediTYFFty0yZOl6u ELRXBhHqqCTrtqgVUKB1YSB/uDlHIJkGQUznG8T+2s9u8qe2xiYJqrfqiYwzpYzFdD7d b7iA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=pCoXZqOC; spf=pass (google.com: domain of netdev-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=netdev-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id ly22si7281996ejb.565.2021.06.12.07.38.56; Sat, 12 Jun 2021 07:38:56 -0700 (PDT) Received-SPF: pass (google.com: domain of netdev-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=pCoXZqOC; spf=pass (google.com: domain of netdev-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=netdev-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231423AbhFLOj4 (ORCPT + 8 others); Sat, 12 Jun 2021 10:39:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57990 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231408AbhFLOjx (ORCPT ); Sat, 12 Jun 2021 10:39:53 -0400 Received: from mail-il1-x135.google.com (mail-il1-x135.google.com [IPv6:2607:f8b0:4864:20::135]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4D22DC061767 for ; Sat, 12 Jun 2021 07:37:42 -0700 (PDT) Received: by mail-il1-x135.google.com with SMTP id b9so8162068ilr.2 for ; Sat, 12 Jun 2021 07:37:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=6MPm/CDH/wz97xhLG1zwJ5+gY1yCELg1LNPAC/aA5x8=; b=pCoXZqOCkaUfU2CKczK/N5M4NvRp5vOr3O96/Aj4IvXXFyqcuvkvtGtSbs9Z15v7Bq 7woSGdi9JzMR4m6QYiBQ5fi15KABSdUHyXBU/IiKAt7KWXeMW5Xno69yLZYBPgUWHoc9 NI4TpJwAY/mHm7AO/AYqeBNfeMmd19JvccI+9VpmQFCXxzoFi+7wj8ZHn3nAeml5fNge xfkZUDwC3/IoRDOCpVnh4uLfJC0vX1IMsAwbU0xRhfKc2hsLyyDSD7E79CGD1Ls7tjlV z8cZUoOpbwISZ6aQgaVbg8pZxXzPXVUozj/IaRubNMm6RqWUH62fnyv8UdZ0iMYsBRFf y6zA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=6MPm/CDH/wz97xhLG1zwJ5+gY1yCELg1LNPAC/aA5x8=; b=QcxmwnzaQfEKe8//4/8heX8N/ULTJuSyzsIsAMZ58nd4b748EpZs4D5dNQ/3ZDwcfY SUCewIE8eHXBZkMoJPMopCAJXJiTZwk2/934Vm/ryoKzEj3vUKx3iz56qgBGd8q71C4x to7kwUIeEpZGUWg19zt9mJ9PlvppDFpTf4oVykGhK+KS/B6FX2Ch7QzbGBtPtKv5uw2C 2oJGtWAKzygcgiT8VhTgRhom6IMI/eU1hvVHRYQzkASDNkAQVus4EWjezBrCTgca1flR xSUn6vwZLGv7aTbZK8mbJUeHI6tWwYhUdZpt+k7BsMhQuiZsUi4Pmmls5qegp+zXQ22R YBtQ== X-Gm-Message-State: AOAM5316Lp1Os7GST6o/2LirF0h6UVBMWBRCFPQCNycn5N+UNPMvwUus csPzzTtvjS2n8m7PZCxdcNJ1vQ== X-Received: by 2002:a05:6e02:219d:: with SMTP id j29mr7248404ila.64.1623508661372; Sat, 12 Jun 2021 07:37:41 -0700 (PDT) Received: from presto.localdomain (c-73-185-129-58.hsd1.mn.comcast.net. [73.185.129.58]) by smtp.gmail.com with ESMTPSA id k4sm5126559ior.55.2021.06.12.07.37.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 12 Jun 2021 07:37:41 -0700 (PDT) From: Alex Elder To: subashab@codeaurora.org, stranche@codeaurora.org, davem@davemloft.net, kuba@kernel.org Cc: bjorn.andersson@linaro.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH net-next 2/8] net: qualcomm: rmnet: rearrange some NOTs Date: Sat, 12 Jun 2021 09:37:30 -0500 Message-Id: <20210612143736.3498712-3-elder@linaro.org> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210612143736.3498712-1-elder@linaro.org> References: <20210612143736.3498712-1-elder@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org With the ones' complement arithmetic, the sum of two negated values is equal to the negation of the sum of the two original values [1]. Rearrange the calculation ip6_payload_sum using this property. [1] https://tools.ietf.org/html/rfc1071 Signed-off-by: Alex Elder --- drivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) -- 2.27.0 diff --git a/drivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c b/drivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c index 3e6feef0fd252..1b170e9189d8a 100644 --- a/drivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c +++ b/drivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c @@ -140,8 +140,8 @@ rmnet_map_ipv6_dl_csum_trailer(struct sk_buff *skb, * checksum computed over the pseudo header. */ ip_header_csum = (__force __be16)ip_fast_csum(ip6h, sizeof(*ip6h) / 4); - ip6_payload_csum = csum16_sub((__force __sum16)~csum_trailer->csum_value, - ~ip_header_csum); + ip6_payload_csum = ~csum16_sub((__force __sum16)csum_trailer->csum_value, + ip_header_csum); length = (ip6h->nexthdr == IPPROTO_UDP) ? ntohs(((struct udphdr *)txporthdr)->len) : From patchwork Sat Jun 12 14:37:31 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 459168 Delivered-To: patch@linaro.org Received: by 2002:a02:735a:0:0:0:0:0 with SMTP id a26csp1859906jae; Sat, 12 Jun 2021 07:39:44 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzQQ523Q7zI8zkdMUrkQnGYUIAps1R6+/d1hK/dbjLOIVhoierFMimgxumK1UjBXr+gS966 X-Received: by 2002:aa7:cac9:: with SMTP id l9mr8793694edt.373.1623508784364; Sat, 12 Jun 2021 07:39:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623508784; cv=none; d=google.com; s=arc-20160816; b=tDETAZAPPf7WpZgiXd5Snowh47v4p8kKrGfN/eCvt9ELlvRktnVhpDZqwh+vfQ/9IT Rl/56xb9ToObrUlcZkDYNJL+1czUR9+RLzYaw9SlqEPSyQjy85CMT0glvst7b5ruj3vD 4uBPVIDUgalACCfx8DtcKBpqEZgBvRIXUdj8Xhz6TyymeUZpLmPFUCeselRHI34OdCZf suwGxn94MWj3nw9P+MKzeToTgvqJiUUpsjZSKIKpJHGRbH/4Krsh9zLwzg71n2yiyZ5l F7Qti5i9NcedAjxQPVUzjSjwt7vn81JOj6Zln0tsJTfU7Fy/vxJ3zFXBaEednVFpPTJf 1c1g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=Zm655iiQBvNsM1zGTE3Z5YIWcNDBpgG+PR5dwnxy8PY=; b=lxiMVJ5YXh1TBJdjDP+1tf1ppScWjCLxHry1k/U8umrCrrqaM+VMMTirtILeWlZaME YBqggG7GLsAn6On/63zRiDdTpwRy11PsyP3L9S0yReoEv8aAqSkrOp6RQU+hqBcMrm/4 WDLapRK0gB2sT6vaaMOgn8hshxjJRI5DBg5Z+QLiLf0+UJUyZA3bzvSTduIOfmP8QZ3p 4DY1N6QmyrWJCi6fJfCA1ZFuwGXJMFgQBturOFHioT33A5+NOcWC3BdzjSzu3WBePBuH LwB611Vk+VRX71OpIGjtUYz2PL3jw2PTINbtzsD90QWpGcZ0qByAU46qDLKMLN/45LaG hxgg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=znbHIRfQ; spf=pass (google.com: domain of netdev-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=netdev-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id y21si7316454ejb.616.2021.06.12.07.39.44; Sat, 12 Jun 2021 07:39:44 -0700 (PDT) Received-SPF: pass (google.com: domain of netdev-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=znbHIRfQ; spf=pass (google.com: domain of netdev-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=netdev-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231540AbhFLOlA (ORCPT + 8 others); Sat, 12 Jun 2021 10:41:00 -0400 Received: from mail-io1-f50.google.com ([209.85.166.50]:33339 "EHLO mail-io1-f50.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231515AbhFLOk6 (ORCPT ); Sat, 12 Jun 2021 10:40:58 -0400 Received: by mail-io1-f50.google.com with SMTP id a6so34777966ioe.0 for ; Sat, 12 Jun 2021 07:38:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Zm655iiQBvNsM1zGTE3Z5YIWcNDBpgG+PR5dwnxy8PY=; b=znbHIRfQQsxi7yyp1vZex0OL8FYa7DTX2/4Ukwx5Qk4nUcoP0/3iEfVYw4koyVI23I 1/aLvM4kisHWHNzGsUkn3GIuKV9rEOQd1F+YP8+jQjZnu69WDmR+m9YWh61NalMWA3sn Huk9FCnB8BHM2dhR3IuUDsBP14YuGCGYb9Yf6LNbDAiUEFIPvHAJPNtmeK2nFGA+IH04 yE2GpEVX8V/me/ZLURyguAZYOgvnwQyAcQJ1SfDFlpsc2n2Ce2WPSD30ZDcNlRLtmjEZ dfaJaujqMlV1PrmUnQrzh+F2aKt1/fEgbJBYAN+Jp3mBNGBsOnkxoF74IFIkiCwngV3B L2Hg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Zm655iiQBvNsM1zGTE3Z5YIWcNDBpgG+PR5dwnxy8PY=; b=mcheCuFBWn6ELUdTMX8xT3wRxxA+uctJ++gyDxZ4CP8r2UyH2Ji5O1BGHvv+OFys0M Gfuu+HEqvQP3B36ZpYeOTt+K0qOif/u2iK9H30XxXnTa1Ru7M7DEJFogdFzgU0kyQNbE VMxqyFfTmDBvQCKjIA5VsY7dE3KonLOJ9gqkqxwL7cMGCuzwjvDDzGBVwiiCXcemtYZu qtSYDmUrQHea1A9SABPmFQCjVlYa1Yi2YSber/PkGABn35uEaF4gAH1tOtexZ7AT0MjF R6JfdJl+CKpE7aZZA6NVwHKBsvgIEs9/cxOQj8YpjZCzb/ESYq9Aco51IaKnFAFxn6r2 uTBw== X-Gm-Message-State: AOAM533kW/lTpIy13QUz5mBC89MohyWiw+TefLxxakp0qjv4Xj5SGMhZ a1+rQXWbF7ITdoNNuYBFO8BpsA== X-Received: by 2002:a05:6602:114:: with SMTP id s20mr7562158iot.98.1623508662310; Sat, 12 Jun 2021 07:37:42 -0700 (PDT) Received: from presto.localdomain (c-73-185-129-58.hsd1.mn.comcast.net. [73.185.129.58]) by smtp.gmail.com with ESMTPSA id k4sm5126559ior.55.2021.06.12.07.37.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 12 Jun 2021 07:37:41 -0700 (PDT) From: Alex Elder To: subashab@codeaurora.org, stranche@codeaurora.org, davem@davemloft.net, kuba@kernel.org Cc: bjorn.andersson@linaro.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH net-next 3/8] net: qualcomm: rmnet: show that an intermediate sum is zero Date: Sat, 12 Jun 2021 09:37:31 -0500 Message-Id: <20210612143736.3498712-4-elder@linaro.org> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210612143736.3498712-1-elder@linaro.org> References: <20210612143736.3498712-1-elder@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org This patch simply demonstrates that a checksum value computed when verifying an offloaded transport checksum value for both IPv4 and IPv6 is (normally) 0. It can be squashed into the next patch. Signed-off-by: Alex Elder --- drivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c | 9 +++++++++ 1 file changed, 9 insertions(+) -- 2.27.0 diff --git a/drivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c b/drivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c index 1b170e9189d8a..51909b8fa8a80 100644 --- a/drivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c +++ b/drivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c @@ -84,6 +84,11 @@ rmnet_map_ipv4_dl_csum_trailer(struct sk_buff *skb, ip4h->protocol, 0); pseudo_csum = csum16_add(ip_payload_csum, (__force __be16)pseudo_csum); + /* The trailer checksum *includes* the checksum in the transport + * header. Adding that to the pseudo checksum will yield 0xffff + * ("negative 0") if the message arrived intact. + */ + WARN_ON((__sum16)~pseudo_csum); csum_value_final = ~csum16_sub(pseudo_csum, (__force __be16)*csum_field); if (unlikely(!csum_value_final)) { @@ -150,6 +155,10 @@ rmnet_map_ipv6_dl_csum_trailer(struct sk_buff *skb, length, ip6h->nexthdr, 0); pseudo_csum = csum16_add(ip6_payload_csum, (__force __be16)pseudo_csum); + /* Adding the payload checksum to the pseudo checksum yields 0xffff + * ("negative 0") if the message arrived intact. + */ + WARN_ON((__sum16)~pseudo_csum); csum_value_final = ~csum16_sub(pseudo_csum, (__force __be16)*csum_field); if (unlikely(csum_value_final == 0)) { From patchwork Sat Jun 12 14:37:32 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 459163 Delivered-To: patch@linaro.org Received: by 2002:a02:735a:0:0:0:0:0 with SMTP id a26csp1859460jae; Sat, 12 Jun 2021 07:38:55 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwlwMBv1t7GIzDX9oTp3+IV1Fza8T1w0GMQ9c4HN9c/FRavjxwtwPWBUoLTP1Gdw7sTAo6+ X-Received: by 2002:a17:906:af7b:: with SMTP id os27mr8007553ejb.154.1623508735565; Sat, 12 Jun 2021 07:38:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623508735; cv=none; d=google.com; s=arc-20160816; b=qtmdXKCTZSkrNDQ23HlO4JFEvsHgIRIK5ekfwFOIb5+604v69di+lmCGV/hkiKI5cH iY4AMH5m0iEoD2gS0brZfF0fXuPbyZDQx7rwwsmN0Yr0STe0f0tk3YT594leEB5ZPT7m 9N4FulNaGzVxvdUJEmhkASRJlUED+vasaOxYXePE0si3dBmvQ754Ogcjp3I+BHhPAcVl RAV9lnYlaGNosNaMzhAjRukkBM/jjblW7eHG5s+RZ+rrgq1d3TWtLm66BDUDq17nztbN Q4Ok1QUSQN3GdaFYhw3wqAX7RxIREwY+4Gsb6355T+oFEJlB9NDx/XVQmJ9Ll8549Nde z2xA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=zqP3IpX5KiQhhBmq87TLRiNjOJuyARey26hrbTcZL4g=; b=Qh6tvx6OV+exsFwT0GdSLe+PWRGQpdoJghZIdVcKsWR6Y31tPSVSTjA4CkBRJ1rRYx fFbdxVzMfIp2N3g2nUTXhl0Fuv/iCFwvU+QOgnPWhRNumfzCnpYlbxr80wU5zvVGzbo6 UzOJF6HAWjsoCLkg2NTICN3hajOWPXxli0cVZLCTc2YWc9Mn6S/iXFolgVxG5E3QQZkp CC4ZbixchlvUnnIgsh6/zAijDAJLVXpsf3tgCr4wHwpkhoLsizMpFHadjSL5Y+5PJy1F ss+/8LsqP3t8hAmEm4O/JrW58u1k7ubj2sQiD+V5hvHYTksBpD0jxqc1HCbICTYRu//o qvNw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=YN2AbRlA; spf=pass (google.com: domain of netdev-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=netdev-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id ly22si7281996ejb.565.2021.06.12.07.38.55; Sat, 12 Jun 2021 07:38:55 -0700 (PDT) Received-SPF: pass (google.com: domain of netdev-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=YN2AbRlA; spf=pass (google.com: domain of netdev-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=netdev-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231417AbhFLOjq (ORCPT + 8 others); Sat, 12 Jun 2021 10:39:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57994 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231215AbhFLOjn (ORCPT ); Sat, 12 Jun 2021 10:39:43 -0400 Received: from mail-il1-x134.google.com (mail-il1-x134.google.com [IPv6:2607:f8b0:4864:20::134]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B366CC0617AF for ; Sat, 12 Jun 2021 07:37:43 -0700 (PDT) Received: by mail-il1-x134.google.com with SMTP id b14so8145475ilq.7 for ; Sat, 12 Jun 2021 07:37:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=zqP3IpX5KiQhhBmq87TLRiNjOJuyARey26hrbTcZL4g=; b=YN2AbRlAhsPS28DfKh+3EBOg+vNu9MCYfZ/Px/yQYsbPwaareJ5ft5GitViE0CiXnH V1o3G16d5IZIEdRoV9rThJDOF2DHtT6D2gKMUXm0FqqFFLCEQ2MrOcVFYz2kSbPl7uVg ssW3xE1TMHYEkcLaK2Plxbx6Kw1uv14O3BRXpnmJCpeMRMbpR9LWCHz8CmzYV6j7r5Ei 52I5x0btjz0dLoJjrkk6FgL8WpOwj6eOxJhwQrHmI7BRLNYS9ThF4C3oYC0JWv/xeg8r zmT1PFPxctNvgCKOeYfpb5QCWDpH6Jp/1C1TxxWYCLOZjSxhzl7ezwbLoi3NMjupeiBN jHuQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=zqP3IpX5KiQhhBmq87TLRiNjOJuyARey26hrbTcZL4g=; b=pGv4E/QSfvHnfFNBXRKogJ+lNrrDMvlUqbmreGibFtZRlCTno6OQtlAqZJBuSy2fQh dQgR12sxvyMQSX/Z6WFcm88vEyVZ+slddmU2NqOJOuonScojNbQo3wBII1B6Rdnrn1vO d9YaLPhGq6U9Z6o6GctE5W38wgzqncjm7O5TDm4tFrEjiVOMZbBkLe0+2UBmO+BEUpBh MvGd8+x5AAsFjNzKHiSGEvIyIFwZ8/4BrinwqZ7ae17vaTArEUIx14k+2OisczEYhPWl 9Vw9BQ7dpDc7ozY4061fiDidTn+BOToVY7ROr/qo50rkOPFtVKPPiCYsrd4AfD1EiTyL f6cQ== X-Gm-Message-State: AOAM532s8Qd9XQ9HTmKfmORUzzMeqVh+5y2Fh2OBpTcjhLJB/pJfi25Z 3/QML1o7noLVDLJyNKluZn+xAA== X-Received: by 2002:a05:6e02:66e:: with SMTP id l14mr7195684ilt.211.1623508663139; Sat, 12 Jun 2021 07:37:43 -0700 (PDT) Received: from presto.localdomain (c-73-185-129-58.hsd1.mn.comcast.net. [73.185.129.58]) by smtp.gmail.com with ESMTPSA id k4sm5126559ior.55.2021.06.12.07.37.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 12 Jun 2021 07:37:42 -0700 (PDT) From: Alex Elder To: subashab@codeaurora.org, stranche@codeaurora.org, davem@davemloft.net, kuba@kernel.org Cc: bjorn.andersson@linaro.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH net-next 4/8] net: qualcomm: rmnet: return earlier for bad checksum Date: Sat, 12 Jun 2021 09:37:32 -0500 Message-Id: <20210612143736.3498712-5-elder@linaro.org> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210612143736.3498712-1-elder@linaro.org> References: <20210612143736.3498712-1-elder@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org In rmnet_map_ipv4_dl_csum_trailer(), if the sum of the trailer checksum and the pseudo checksum is non-zero, checksum validation has failed. We can return an error as soon as we know that. We can do the same thing in rmnet_map_ipv6_dl_csum_trailer(). Add some comments that explain where we're headed. Signed-off-by: Alex Elder --- .../ethernet/qualcomm/rmnet/rmnet_map_data.c | 36 ++++++++++++++----- 1 file changed, 27 insertions(+), 9 deletions(-) -- 2.27.0 diff --git a/drivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c b/drivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c index 51909b8fa8a80..a05124eb8602e 100644 --- a/drivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c +++ b/drivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c @@ -76,6 +76,17 @@ rmnet_map_ipv4_dl_csum_trailer(struct sk_buff *skb, * We verified above that the IP header contributes zero to the * trailer checksum. Therefore the checksum in the trailer is * just the checksum computed over the IP payload. + + * If the IP payload arrives intact, adding the pseudo header + * checksum to the IP payload checksum will yield 0xffff (negative + * zero). This means the trailer checksum and the pseudo checksum + * are additive inverses of each other. Put another way, the + * message passes the checksum test if the trailer checksum value + * is the negated pseudo header checksum. + * + * Knowing this, we don't even need to examine the transport + * header checksum value; it is already accounted for in the + * checksum value found in the trailer. */ ip_payload_csum = (__force __sum16)~csum_trailer->csum_value; @@ -84,11 +95,11 @@ rmnet_map_ipv4_dl_csum_trailer(struct sk_buff *skb, ip4h->protocol, 0); pseudo_csum = csum16_add(ip_payload_csum, (__force __be16)pseudo_csum); - /* The trailer checksum *includes* the checksum in the transport - * header. Adding that to the pseudo checksum will yield 0xffff - * ("negative 0") if the message arrived intact. - */ - WARN_ON((__sum16)~pseudo_csum); + /* The cast is required to ensure only the low 16 bits are examined */ + if ((__sum16)~pseudo_csum) { + priv->stats.csum_validation_failed++; + return -EINVAL; + } csum_value_final = ~csum16_sub(pseudo_csum, (__force __be16)*csum_field); if (unlikely(!csum_value_final)) { @@ -143,6 +154,11 @@ rmnet_map_ipv6_dl_csum_trailer(struct sk_buff *skb, * transport checksum from this, we first subract the contribution * of the IP header from the trailer checksum. We then add the * checksum computed over the pseudo header. + * + * It's sufficient to compare the IP payload checksum with the + * negated pseudo checksum to determine whether the packet + * checksum was good. (See further explanation in comments + * in rmnet_map_ipv4_dl_csum_trailer()). */ ip_header_csum = (__force __be16)ip_fast_csum(ip6h, sizeof(*ip6h) / 4); ip6_payload_csum = ~csum16_sub((__force __sum16)csum_trailer->csum_value, @@ -155,10 +171,12 @@ rmnet_map_ipv6_dl_csum_trailer(struct sk_buff *skb, length, ip6h->nexthdr, 0); pseudo_csum = csum16_add(ip6_payload_csum, (__force __be16)pseudo_csum); - /* Adding the payload checksum to the pseudo checksum yields 0xffff - * ("negative 0") if the message arrived intact. - */ - WARN_ON((__sum16)~pseudo_csum); + /* The cast is required to ensure only the low 16 bits are examined */ + if ((__sum16)~pseudo_csum) { + priv->stats.csum_validation_failed++; + return -EINVAL; + } + csum_value_final = ~csum16_sub(pseudo_csum, (__force __be16)*csum_field); if (unlikely(csum_value_final == 0)) { From patchwork Sat Jun 12 14:37:33 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 459165 Delivered-To: patch@linaro.org Received: by 2002:a02:735a:0:0:0:0:0 with SMTP id a26csp1859504jae; Sat, 12 Jun 2021 07:38:59 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwT5yPL/Ifj685HoVlzf/1VDhip3ogR0Wdgd+nkG7zo1G9WqhzyhoGXDi+p7kt6lf4ALUge X-Received: by 2002:aa7:c68f:: with SMTP id n15mr8864538edq.145.1623508739334; Sat, 12 Jun 2021 07:38:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623508739; cv=none; d=google.com; s=arc-20160816; b=BPm6RaaWKaOXX7wM0snheehIN7Qkgt+Hm5xVWUgLPcM7BWQfO55X9Xd/WKCDoPxnnR 01XT8jXF1AtPkvySKVbilEApfjyIvgFB91C3+m+jquvIfRtiDeuuoM5viU1+E4R4yf4S t9lIqD1RarYsXpo0cpV4M6rZeTXbM+AIEuambHSLcamHJRRljHwpYd6eMlG2w5ZWD1Rm NlBhEeEApMp57IpC2GqO/BEGDfk3+nVcHX/nOWN61SyuI0dvxVB50b6yFbyMZsqiyJo9 GC18i/hBvWYS+VHh4Wc8VStlxG0PKzivWHhPh9lxKhTaOZ0fKjR+Aro8ytI9R41eQlD5 Vy8g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=DOiPwYtlpq2wzQJGSlttEKAlIzdpjRtakSuJWMKMdzU=; b=lMmrwz3noWkkrATd8NJBcO3qy4Ab/+X2pTt2JD5SlXDKoOTudfPsdcO7lOUENBSQox 8TVFDBeqFIyNtgm0P8lJ5/MZGvO4SDwapZDi9qJ77LBiIdjt695mQWjbjOqkifzDPRGc NF0K9Qimo32ZaPSlbGlZoB15AJEQet2+h22t7XykJ8faLm8BnmXFrhV0pefnxZftJ798 rXpE5WkhWxMS3oigikY36/JYHa4gjV2Bppb46uRgqef59+Nh8flHcVDGqPppOvZgVt8S 22oCWQC2E4LHCfcquv7DYtiLuJ51VqrRwuBbEu0KGxjKjmvo4D/0XzgsUErxcySEygX9 rtkA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=CQ3PfHIB; spf=pass (google.com: domain of netdev-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=netdev-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id ly22si7281996ejb.565.2021.06.12.07.38.59; Sat, 12 Jun 2021 07:38:59 -0700 (PDT) Received-SPF: pass (google.com: domain of netdev-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=CQ3PfHIB; spf=pass (google.com: domain of netdev-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=netdev-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231469AbhFLOko (ORCPT + 8 others); Sat, 12 Jun 2021 10:40:44 -0400 Received: from mail-io1-f52.google.com ([209.85.166.52]:39724 "EHLO mail-io1-f52.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231461AbhFLOkn (ORCPT ); Sat, 12 Jun 2021 10:40:43 -0400 Received: by mail-io1-f52.google.com with SMTP id f10so20205516iok.6 for ; Sat, 12 Jun 2021 07:38:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=DOiPwYtlpq2wzQJGSlttEKAlIzdpjRtakSuJWMKMdzU=; b=CQ3PfHIBoocPGBgi9mEMxvVt4UtAdr8escdEWJoT+CT1qDbAUTWY6U+wg0zhi8DE14 IZS9logweGEFTcfVXiGalKYfHe48WmdKDJZVRvsrag5crzT/1y85Kwmez+LkdmUPSEYU hNkAqfRa85i+8GUlsB5yfxyYpeN7fHzIV4rnyQ/T6BsfLE0YO9boKQ05XVN80xueJZOu dAOLjJXIozl1G4s7DcwoByuXB0ihzZHXgP/4OutTULb91AjbUKxuBGbg/te/414CqOe5 XiIRgeT8H2F+5I/2eKteEJj4MRpt5QYPT5Tuh7k6Y9QuSDq1sAJtKZNkGdI+ZmT1yILf vOSQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=DOiPwYtlpq2wzQJGSlttEKAlIzdpjRtakSuJWMKMdzU=; b=XQscw8KKdkZ5vK0dg6cZ67ZAiqnLmHbCMcIZM44bNXXR1Wrdfdie6QehvXx/aCA8+i 38YxsRzI0BpDH0d1VwVHpMrGcweHipFzFXW9JwNoLfsQF30mWhOCw+qGsxajWGaoukGn x88iOFALPXy5bS8KrxTEHtkfPnfdNb9mpCh4gP4GAJ3VNoHUidLJRy5NsaV8pl2E9ur/ mCN5sOAi+ycvkUTbF1kRE+1O0BDJb6cZrzqJuV58ycQ/UsN5wg/SkeKUDm+PlgqK3Cu6 +dEucg+kLwA+nRXH4ZOYBDcBUcxb+yP/UQ7O4QB2FGGAPB3dFb9e/DLp8S2Eqg5hU7yk KYgQ== X-Gm-Message-State: AOAM532XXFsrfeVZ/spcCkX9JjkMJer0UupdNY5Jrg8NulWe1HNM5GM8 Vv1p3okb8H86RhX9GZc61wGK2g== X-Received: by 2002:a6b:f41a:: with SMTP id i26mr7289471iog.162.1623508664042; Sat, 12 Jun 2021 07:37:44 -0700 (PDT) Received: from presto.localdomain (c-73-185-129-58.hsd1.mn.comcast.net. [73.185.129.58]) by smtp.gmail.com with ESMTPSA id k4sm5126559ior.55.2021.06.12.07.37.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 12 Jun 2021 07:37:43 -0700 (PDT) From: Alex Elder To: subashab@codeaurora.org, stranche@codeaurora.org, davem@davemloft.net, kuba@kernel.org Cc: bjorn.andersson@linaro.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH net-next 5/8] net: qualcomm: rmnet: remove unneeded code Date: Sat, 12 Jun 2021 09:37:33 -0500 Message-Id: <20210612143736.3498712-6-elder@linaro.org> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210612143736.3498712-1-elder@linaro.org> References: <20210612143736.3498712-1-elder@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org The previous patch makes rmnet_map_ipv4_dl_csum_trailer() return early with an error if it is determined that the computed checksum for the IP payload does not match what was expected. If the computed checksum *does* match the expected value, the IP payload (i.e., the transport message), can be considered good. There is no need to do any further processing of the message. This means a big block of code is unnecessary for validating the transport checksum value, and can be removed. Make comparable changes in rmnet_map_ipv6_dl_csum_trailer(). Signed-off-by: Alex Elder --- .../ethernet/qualcomm/rmnet/rmnet_map_data.c | 75 ++++--------------- 1 file changed, 14 insertions(+), 61 deletions(-) -- 2.27.0 diff --git a/drivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c b/drivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c index a05124eb8602e..033b8ad3d7356 100644 --- a/drivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c +++ b/drivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c @@ -37,7 +37,6 @@ rmnet_map_ipv4_dl_csum_trailer(struct sk_buff *skb, void *txporthdr = skb->data + ip4h->ihl * 4; __sum16 *csum_field, pseudo_csum; __sum16 ip_payload_csum; - __sum16 csum_value_final; /* Computing the checksum over just the IPv4 header--including its * checksum field--should yield 0. If it doesn't, the IP header @@ -93,37 +92,15 @@ rmnet_map_ipv4_dl_csum_trailer(struct sk_buff *skb, pseudo_csum = ~csum_tcpudp_magic(ip4h->saddr, ip4h->daddr, ntohs(ip4h->tot_len) - ip4h->ihl * 4, ip4h->protocol, 0); - pseudo_csum = csum16_add(ip_payload_csum, (__force __be16)pseudo_csum); /* The cast is required to ensure only the low 16 bits are examined */ - if ((__sum16)~pseudo_csum) { + if (ip_payload_csum != (__sum16)~pseudo_csum) { priv->stats.csum_validation_failed++; return -EINVAL; } - csum_value_final = ~csum16_sub(pseudo_csum, (__force __be16)*csum_field); - if (unlikely(!csum_value_final)) { - switch (ip4h->protocol) { - case IPPROTO_UDP: - /* RFC 768 - DL4 1's complement rule for UDP csum 0 */ - csum_value_final = ~csum_value_final; - break; - - case IPPROTO_TCP: - /* DL4 Non-RFC compliant TCP checksum found */ - if (*csum_field == (__force __sum16)0xFFFF) - csum_value_final = ~csum_value_final; - break; - } - } - - if (csum_value_final == *csum_field) { - priv->stats.csum_ok++; - return 0; - } else { - priv->stats.csum_validation_failed++; - return -EINVAL; - } + priv->stats.csum_ok++; + return 0; } #if IS_ENABLED(CONFIG_IPV6) @@ -137,7 +114,6 @@ rmnet_map_ipv6_dl_csum_trailer(struct sk_buff *skb, __sum16 *csum_field, pseudo_csum; __sum16 ip6_payload_csum; __be16 ip_header_csum; - __sum16 csum_value_final; u32 length; /* Checksum offload is only supported for UDP and TCP protocols; @@ -154,11 +130,6 @@ rmnet_map_ipv6_dl_csum_trailer(struct sk_buff *skb, * transport checksum from this, we first subract the contribution * of the IP header from the trailer checksum. We then add the * checksum computed over the pseudo header. - * - * It's sufficient to compare the IP payload checksum with the - * negated pseudo checksum to determine whether the packet - * checksum was good. (See further explanation in comments - * in rmnet_map_ipv4_dl_csum_trailer()). */ ip_header_csum = (__force __be16)ip_fast_csum(ip6h, sizeof(*ip6h) / 4); ip6_payload_csum = ~csum16_sub((__force __sum16)csum_trailer->csum_value, @@ -169,40 +140,22 @@ rmnet_map_ipv6_dl_csum_trailer(struct sk_buff *skb, ntohs(ip6h->payload_len); pseudo_csum = ~csum_ipv6_magic(&ip6h->saddr, &ip6h->daddr, length, ip6h->nexthdr, 0); - pseudo_csum = csum16_add(ip6_payload_csum, (__force __be16)pseudo_csum); - /* The cast is required to ensure only the low 16 bits are examined */ - if ((__sum16)~pseudo_csum) { + /* It's sufficient to compare the IP payload checksum with the + * negated pseudo checksum to determine whether the packet + * checksum was good. (See further explanation in comments + * in rmnet_map_ipv4_dl_csum_trailer()). + * + * The cast is required to ensure only the low 16 bits are + * examined. + */ + if (ip6_payload_csum != (__sum16)~pseudo_csum) { priv->stats.csum_validation_failed++; return -EINVAL; } - csum_value_final = ~csum16_sub(pseudo_csum, (__force __be16)*csum_field); - - if (unlikely(csum_value_final == 0)) { - switch (ip6h->nexthdr) { - case IPPROTO_UDP: - /* RFC 2460 section 8.1 - * DL6 One's complement rule for UDP checksum 0 - */ - csum_value_final = ~csum_value_final; - break; - - case IPPROTO_TCP: - /* DL6 Non-RFC compliant TCP checksum found */ - if (*csum_field == (__force __sum16)0xFFFF) - csum_value_final = ~csum_value_final; - break; - } - } - - if (csum_value_final == *csum_field) { - priv->stats.csum_ok++; - return 0; - } else { - priv->stats.csum_validation_failed++; - return -EINVAL; - } + priv->stats.csum_ok++; + return 0; } #endif From patchwork Sat Jun 12 14:37:34 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 459162 Delivered-To: patch@linaro.org Received: by 2002:a02:735a:0:0:0:0:0 with SMTP id a26csp1859466jae; Sat, 12 Jun 2021 07:38:56 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzv7oYN4NPaF5jeR6vCgGpEfUHUI2sHhVQFUDWUePaP0b5qRVjqXI4gvxqufrSCEvVm38+y X-Received: by 2002:aa7:cb8b:: with SMTP id r11mr8736656edt.233.1623508735972; Sat, 12 Jun 2021 07:38:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623508735; cv=none; d=google.com; s=arc-20160816; b=XdkQOAj1/0F4b5ZQ20RESOaZg42PD2+8L1uLx9uUX+S1dEBrXAm+Z28yUheD5IuYS4 DkdG/w3omC3Hnsh6cJvRMEikVsCH7yDJyYGqPZLp6ybaiJ9iZnu1XEwaWWtw4nRx20uN OupzB9geM98jp+QkAonVhVnALqqft7+sOQD3BuUHuK+whtXSA2SUNy3KB3uzq+7817OH ykXynFrU3eRFhSHgXow7xHYf91L1+TVHBNBhOWDi0kIhCsuTPFL39tO4NsPtWpIuFvMp fVOzSV3AnX5aV1+5GPkPKFzAcOK0AWpFphrupkgbEHzG0JRuz546jUaQZ5tHabhJpCLl qaHA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=sVpsNjSma8gM+rAIpOEpuls8lMMnYBT1zZkyUPGfEFw=; b=tTgkeEd345IauHAMJKw2te3m0soj00yYm1ZydOKCzF1K7UxkvQAH1YY4FZM55UCCff WWBa6UOvbtRHVTqWBBrTYsH/INIfhLwCg4p1sUoGZpCm+3LLhQUCSYIoaa3NvDqCW/4E edxrLl/hCAYjhXvzEjZ2qfM+sih7SC5dhE03Ck9gcyfENoDIerVzKe1R1YR7Sh9q6jol Wlt5RnOLLU4wYRD9pofQvzlpvcIS4gvfNORPafwohvXB+zuzrckikK1TFCOAf2UeBhMM J7pYMHytecGf0SsGeytud/0eETA8OqU2biDDxX98S9QR/K/ItaFgFHSxzkvSeMcVfdom MylA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=hOPtH3zp; spf=pass (google.com: domain of netdev-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=netdev-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id ly22si7281996ejb.565.2021.06.12.07.38.55; Sat, 12 Jun 2021 07:38:55 -0700 (PDT) Received-SPF: pass (google.com: domain of netdev-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=hOPtH3zp; spf=pass (google.com: domain of netdev-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=netdev-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231425AbhFLOjw (ORCPT + 8 others); Sat, 12 Jun 2021 10:39:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58008 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231408AbhFLOjp (ORCPT ); Sat, 12 Jun 2021 10:39:45 -0400 Received: from mail-io1-xd31.google.com (mail-io1-xd31.google.com [IPv6:2607:f8b0:4864:20::d31]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 85BE8C0613A3 for ; Sat, 12 Jun 2021 07:37:45 -0700 (PDT) Received: by mail-io1-xd31.google.com with SMTP id l64so13065707ioa.7 for ; Sat, 12 Jun 2021 07:37:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=sVpsNjSma8gM+rAIpOEpuls8lMMnYBT1zZkyUPGfEFw=; b=hOPtH3zpGyr1MV5KOt5zRKenpTYTd117KUeSynzayvtWHqD8DFx5VRUBZQy6mMwS6f eyOqfO9BuxOWigyV+lcbyc0fxYiE5vwb+Ds561lZQKBO/UpaSqc9+bMZOBrMfyCNp+N4 2yj9JKIsWP0btROkRPBboi26dkUSiDDeefvL1lKC7j9yO8AMIx+UwbH5/8/MVena7UdQ wUkzOR0cexOHVyeD4QRo/++Mc8E4VW41YpIEn5zjTA8f5cBpORVDDusFzTJbNsJNFQ7g S51+d8yf/WarPTfI7GofmR0jAtYUxhgBNbucwYJidKmPFhL8lrrT/cTHLWMRr90fALUY OtCg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=sVpsNjSma8gM+rAIpOEpuls8lMMnYBT1zZkyUPGfEFw=; b=Th6CdozC+Ml+vzjHqR+74uVqq+btnO+oD5tdlOcsQFHdqMRSEcJ9/eqx/Eh98F0stc xWhTAtV8bz2APLK5D2XLmook9jaWY+hY6oJBvWOWkf2w+TUhEPnk2kfyFVMs27wl+jsX pxpJvYuoeYgGLl2Ca9MUkMzKe/xQalSfWjxLqKy9u5iVPGgjX1UjxEiccy5dkXMgaZhQ 67tqdC4VqA615Sud2F+zScO0QLwoFsaiBXixmDgtO3vjIh5TlJSLclXLasRiy+OZ0T3u tPPNiFbg0CBzzDpvm2/v08pfhN3VY0PlIQ3AwwU2pBla7EtKWds6D2uAUlQovm2Bq1AY uasQ== X-Gm-Message-State: AOAM533faqVWBB1opDHrNRSaxPf25xyPz1iNEl7QdoPgcoTNlOybZZz8 2IGUhCST2yey0wp2MqCCSUBIWdOrLfpeLVjB X-Received: by 2002:a05:6602:2143:: with SMTP id y3mr7447828ioy.89.1623508664920; Sat, 12 Jun 2021 07:37:44 -0700 (PDT) Received: from presto.localdomain (c-73-185-129-58.hsd1.mn.comcast.net. [73.185.129.58]) by smtp.gmail.com with ESMTPSA id k4sm5126559ior.55.2021.06.12.07.37.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 12 Jun 2021 07:37:44 -0700 (PDT) From: Alex Elder To: subashab@codeaurora.org, stranche@codeaurora.org, davem@davemloft.net, kuba@kernel.org Cc: bjorn.andersson@linaro.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH net-next 6/8] net: qualcomm: rmnet: trailer value is a checksum Date: Sat, 12 Jun 2021 09:37:34 -0500 Message-Id: <20210612143736.3498712-7-elder@linaro.org> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210612143736.3498712-1-elder@linaro.org> References: <20210612143736.3498712-1-elder@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org The csum_value field in the rmnet_map_dl_csum_trailer structure is a "real" Internet checksum. It is a 16 bit value, in big endian format, which represents an inverted ones' complement sum over pairs of bytes. Make that clear by changing its type to __sum16. This makes a typecast in rmnet_map_ipv4_dl_csum_trailer() and another in rmnet_map_ipv6_dl_csum_trailer() unnecessary. Signed-off-by: Alex Elder --- drivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c | 5 ++--- include/linux/if_rmnet.h | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) -- 2.27.0 diff --git a/drivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c b/drivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c index 033b8ad3d7356..610c8b5a8f46a 100644 --- a/drivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c +++ b/drivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c @@ -87,7 +87,7 @@ rmnet_map_ipv4_dl_csum_trailer(struct sk_buff *skb, * header checksum value; it is already accounted for in the * checksum value found in the trailer. */ - ip_payload_csum = (__force __sum16)~csum_trailer->csum_value; + ip_payload_csum = ~csum_trailer->csum_value; pseudo_csum = ~csum_tcpudp_magic(ip4h->saddr, ip4h->daddr, ntohs(ip4h->tot_len) - ip4h->ihl * 4, @@ -132,8 +132,7 @@ rmnet_map_ipv6_dl_csum_trailer(struct sk_buff *skb, * checksum computed over the pseudo header. */ ip_header_csum = (__force __be16)ip_fast_csum(ip6h, sizeof(*ip6h) / 4); - ip6_payload_csum = ~csum16_sub((__force __sum16)csum_trailer->csum_value, - ip_header_csum); + ip6_payload_csum = ~csum16_sub(csum_trailer->csum_value, ip_header_csum); length = (ip6h->nexthdr == IPPROTO_UDP) ? ntohs(((struct udphdr *)txporthdr)->len) : diff --git a/include/linux/if_rmnet.h b/include/linux/if_rmnet.h index be17610a981ef..10e7521ecb6cd 100644 --- a/include/linux/if_rmnet.h +++ b/include/linux/if_rmnet.h @@ -25,7 +25,7 @@ struct rmnet_map_dl_csum_trailer { u8 flags; /* MAP_CSUM_DL_VALID_FLAG */ __be16 csum_start_offset; __be16 csum_length; - __be16 csum_value; + __sum16 csum_value; } __aligned(1); /* rmnet_map_dl_csum_trailer flags field: From patchwork Sat Jun 12 14:37:35 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 459166 Delivered-To: patch@linaro.org Received: by 2002:a02:735a:0:0:0:0:0 with SMTP id a26csp1859512jae; Sat, 12 Jun 2021 07:38:59 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy2bymtcgs4jAmgGcbd/Kg3B+/VENjRAAcJvY8xIrucrGtvEJCfGi3sihGqskHUiYaQX2cy X-Received: by 2002:aa7:db90:: with SMTP id u16mr8723225edt.106.1623508739736; Sat, 12 Jun 2021 07:38:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623508739; cv=none; d=google.com; s=arc-20160816; b=z1PNCoRp7bFkDjedPnH2afmDwCgw7OxP0KBq8odErSOb74HW8MCC/mO34xSDPF2sfZ 1Aa/VBcoCrCe8EuDG0vn9U6f9FrVUc0cMBJXhHmyjfwDwUZCBSISqgKimTJU/643IOGh j4epUzmfpiUA5UvkggyeNQQcpB72NSEnT2ZpL0y8dxvHsIE5FZNYWyQfZjXKDV3CUDg6 i/tNqs65p9lRt9iVDXOJbdyQQCjn0H8iGZv3xwavy1bDX5TCRxGgfJByHW6DL4Xcyq4T k91VSzG/76TbrUN8uF7fYaRWIwA3wzxd8NU8LAukkK9WMRAwNJTDCkmTjBjjiFxx9iAv BhQw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=XdGocdnkWEhyGlWBEvMTXuqlG7P/EjC9lkmvGdkeF8Y=; b=QygLi9H9D2r7r5N7GXdt+DMXb3WFDrIK0OvQADt2mnd8o+UrBa+8vNipdeBkZPjREe nUugw/UxAUXix16WJrkJD3Q67B7Or7UkTCzbmG7tQIVGOszlJLjsGb3qaTUxhKHhqqEK 9C2Q2td0OUee0J1NGIMf36aP6tYqM+bitdRk+aBF0VCXvdx/jLdSruvhpQFULQI12mhd vHfKLZHYdp3JtozsTqhY0pF1oEDFNASq+Zoh0i/WAOpn4kKrT2+5p7COS5qqdirVl9gq /MCaplyTCCqquGo4OMunJJWugKj0r+OkkXzLWD+8n9rjR63V/qXy8P/lScbVG0MsJS2V 3/tg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Zm4N0uZc; spf=pass (google.com: domain of netdev-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=netdev-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id ly22si7281996ejb.565.2021.06.12.07.38.59; Sat, 12 Jun 2021 07:38:59 -0700 (PDT) Received-SPF: pass (google.com: domain of netdev-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Zm4N0uZc; spf=pass (google.com: domain of netdev-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=netdev-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231252AbhFLOkr (ORCPT + 8 others); Sat, 12 Jun 2021 10:40:47 -0400 Received: from mail-io1-f42.google.com ([209.85.166.42]:39717 "EHLO mail-io1-f42.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231461AbhFLOkp (ORCPT ); Sat, 12 Jun 2021 10:40:45 -0400 Received: by mail-io1-f42.google.com with SMTP id f10so20205601iok.6 for ; Sat, 12 Jun 2021 07:38:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=XdGocdnkWEhyGlWBEvMTXuqlG7P/EjC9lkmvGdkeF8Y=; b=Zm4N0uZcjB0fKwr+fcqoXcomkjX5uGAtQwpxvbw9ddhNqvUSCkXVPiDHenZ5/H4Bpg zIdROMvqaBPtm1ynaHGl9WiCt+K2P4bTQQueHqqhO50QnoN2hnZdtTK8sxdenRJT28hF BT+z3Lu913mpAh+x8OadVadY6Xihwh0ifuUvvujgm5dWHH/EDTWX4pTHq+mux0JzNTG2 sP/0iZs0hZqwH+z0OK3Zg5CB/eKVoEYndhIoosDiRXI6+ZhgejITCkU37qrjjEjWNWpp zG+p2nHnmjiqvfDE4T0yMozGHXF5rOSVQBStxK6XdDWglwD4ZRmFI1lN+joRRpwvADMv 1RBg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=XdGocdnkWEhyGlWBEvMTXuqlG7P/EjC9lkmvGdkeF8Y=; b=KhFMoRwnAW4YLkYYoMU/Vo++gxBjVQ2/u4lK1qh0bnbY+BUkIk2pSkYd2HIVmp5Cus 7FUJ3+uBIxinyJT4hHw8s3H/v5qfl7FB0TAdLzLPQKh5s7Jue8Lxn9Rc4bthYVxfQ7I+ zSpEQFb6mpyoDjUcJCxe9fTYaFKsizRaiseVFHgz5EQCfIIusISXZaQNPy8DtZPYFwc/ Y8v9bmsKG68MuDePxcD+oqyv/XOEuovh8OZcSpwKOOq5hI+twC2BoT7H62ENloM7c8li 5Qzfp7NEFf9wAy3JVmDrbwukTZmyVRwWi/y5cCZ4dBXrtxbVECB86L95dNBMQTYZY15H txAg== X-Gm-Message-State: AOAM531Z5nko8dlHUZETXwLe/5JF/lQ1dgGX2zgFB5pvQmzT6cqLIF+G BHYKn7Wu4SV2PmfkZ+Dfhma4/w== X-Received: by 2002:a6b:b7d6:: with SMTP id h205mr7554507iof.188.1623508665772; Sat, 12 Jun 2021 07:37:45 -0700 (PDT) Received: from presto.localdomain (c-73-185-129-58.hsd1.mn.comcast.net. [73.185.129.58]) by smtp.gmail.com with ESMTPSA id k4sm5126559ior.55.2021.06.12.07.37.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 12 Jun 2021 07:37:45 -0700 (PDT) From: Alex Elder To: subashab@codeaurora.org, stranche@codeaurora.org, davem@davemloft.net, kuba@kernel.org Cc: bjorn.andersson@linaro.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH net-next 7/8] net: qualcomm: rmnet: drop some unary NOTs Date: Sat, 12 Jun 2021 09:37:35 -0500 Message-Id: <20210612143736.3498712-8-elder@linaro.org> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210612143736.3498712-1-elder@linaro.org> References: <20210612143736.3498712-1-elder@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org We compare a payload checksum with a pseudo checksum value for equality in rmnet_map_ipv4_dl_csum_trailer(). Both of those values are computed with a unary NOT (~) operation. The result of the comparison is the same if we omit that NOT for both values. Remove these operations in rmnet_map_ipv6_dl_csum_trailer() also. Signed-off-by: Alex Elder --- .../net/ethernet/qualcomm/rmnet/rmnet_map_data.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) -- 2.27.0 diff --git a/drivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c b/drivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c index 610c8b5a8f46a..ed4737d0043d6 100644 --- a/drivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c +++ b/drivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c @@ -87,11 +87,11 @@ rmnet_map_ipv4_dl_csum_trailer(struct sk_buff *skb, * header checksum value; it is already accounted for in the * checksum value found in the trailer. */ - ip_payload_csum = ~csum_trailer->csum_value; + ip_payload_csum = csum_trailer->csum_value; - pseudo_csum = ~csum_tcpudp_magic(ip4h->saddr, ip4h->daddr, - ntohs(ip4h->tot_len) - ip4h->ihl * 4, - ip4h->protocol, 0); + pseudo_csum = csum_tcpudp_magic(ip4h->saddr, ip4h->daddr, + ntohs(ip4h->tot_len) - ip4h->ihl * 4, + ip4h->protocol, 0); /* The cast is required to ensure only the low 16 bits are examined */ if (ip_payload_csum != (__sum16)~pseudo_csum) { @@ -132,13 +132,13 @@ rmnet_map_ipv6_dl_csum_trailer(struct sk_buff *skb, * checksum computed over the pseudo header. */ ip_header_csum = (__force __be16)ip_fast_csum(ip6h, sizeof(*ip6h) / 4); - ip6_payload_csum = ~csum16_sub(csum_trailer->csum_value, ip_header_csum); + ip6_payload_csum = csum16_sub(csum_trailer->csum_value, ip_header_csum); length = (ip6h->nexthdr == IPPROTO_UDP) ? ntohs(((struct udphdr *)txporthdr)->len) : ntohs(ip6h->payload_len); - pseudo_csum = ~csum_ipv6_magic(&ip6h->saddr, &ip6h->daddr, - length, ip6h->nexthdr, 0); + pseudo_csum = csum_ipv6_magic(&ip6h->saddr, &ip6h->daddr, + length, ip6h->nexthdr, 0); /* It's sufficient to compare the IP payload checksum with the * negated pseudo checksum to determine whether the packet From patchwork Sat Jun 12 14:37:36 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 459169 Delivered-To: patch@linaro.org Received: by 2002:a02:735a:0:0:0:0:0 with SMTP id a26csp1859927jae; Sat, 12 Jun 2021 07:39:46 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxikj6NR6tWdNVKzh5eTuOaLfPN0FGgo6I7xqTSKqOvtrdlZKiOtGBn1+FwQLskvCuD0hGu X-Received: by 2002:aa7:c40f:: with SMTP id j15mr8644824edq.169.1623508786541; Sat, 12 Jun 2021 07:39:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623508786; cv=none; d=google.com; s=arc-20160816; b=epl/LLVpjjKbM9djUnGDPBm9UqOocz3ycmNVoo+iz6VwLFDDA5pR/BQ89KyYdrYv/w x5rcE3UXu6qO+xseObUGejnLSzT6Sw6rkI8k0ALmhiao7GWN5W/+CncIYrizei4XYS5v Jmfc5BovgABWDXh1cbgzed30/ooijueuhueuoU2vWnK0UNSq1GU3vEHN+9GXsvc8obYn 6NiwwUHKbbWP/ZwOmUdOV5k6twVMLhJwO7y0ba0I+MCPshMpVpOy3sUiqa6ccaL4rAOd tvXWOHqsQ5kCfyqhglk489GU5IyhuvWGE+BJI3QFW3W0REEkVDXITwY2OSRQptghkFHB yN1g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=LC9SvpQ/Uxhg0GO1cMqQXuwzbE3v2RjkJ7G/fhbU/Z8=; b=YZ/1jl+akktVDviu0IJvxWlcr7uZOojNRCTuYAdb9weHvKUoJ7oBX98JI/Otj2DEF1 55QznOvASWZaeeDbcIyID2eKJ8zE9vDFY1WdNd2DClQbLUSRByd6YbU/QfC+bYPOLdS5 he8qAcBnggB2OignHVWs6KoorMpeux4WcUpJUQte6qwFEPeXxBnsbJamP+ZbNy9BjOUn ZP8QLAyPxCGxABBA5m2sUYPxkxpR1q++WELP0KwQh3EQQXwEguiqmNV2wMWDiVpjUWOv CJ5ZOw2ZejZOzihcjMPYA8lQ008FLNvEgiGdu3wRfEMHOOEZqmc9UtoEesWz1efQZeru 4MFQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=HRrIfU2N; spf=pass (google.com: domain of netdev-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=netdev-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id y21si7316454ejb.616.2021.06.12.07.39.46; Sat, 12 Jun 2021 07:39:46 -0700 (PDT) Received-SPF: pass (google.com: domain of netdev-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=HRrIfU2N; spf=pass (google.com: domain of netdev-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=netdev-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231572AbhFLOlU (ORCPT + 8 others); Sat, 12 Jun 2021 10:41:20 -0400 Received: from mail-io1-f42.google.com ([209.85.166.42]:41671 "EHLO mail-io1-f42.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231557AbhFLOlC (ORCPT ); Sat, 12 Jun 2021 10:41:02 -0400 Received: by mail-io1-f42.google.com with SMTP id p66so32861446iod.8 for ; Sat, 12 Jun 2021 07:38:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=LC9SvpQ/Uxhg0GO1cMqQXuwzbE3v2RjkJ7G/fhbU/Z8=; b=HRrIfU2NNwbt/T1Aemqlv+f2Xej+RwSv/MeoPgIqoPaMIOBE6iL1XEcTKsDfMgWeVu 5h2/usTr/2oL62fd6HaJuz/YeVB5PyQCW1CKGl4fkp6ODbjURk3nJam6Xf6FElB1LBr5 Ce3sSaKo6mzxz/deimuGU/UzsCcARcEz/RLCSb6m2n8pT/d1fbVDjD2eXEIJ8wtO8FGA UxLi9yKXxgUheSvoba3EZ5DZXgiYfK7hvGT0gJp4lBx9CG3umMi2/sRfNqrKBljM/hpr lfa9ljIggY8SzHCCGt4LuP0M0NzpvWlywmVHZg38qmTqawy+1NXscfkp7C+LkKh4HOo7 kDuA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=LC9SvpQ/Uxhg0GO1cMqQXuwzbE3v2RjkJ7G/fhbU/Z8=; b=LlOEuyhEcwhYpgS8M8MYiw1+LeLkIwImDgOe4duPmWEBBRyg3ZSLmiRoSEZblbd2Md 12/5pXFDgdsE27UUNI39P1qMJwIAmUYnlU+KmYTMHNGHhk8V1L4mIWxyxsh41H8CyPiP g+/PXx5QQBzXZovHSyFTXABfvLZR+u8rYDi4rcEv8TfnvI2rNCNURfuHahLthm2IEH8O RwiDChw7NbMekO83YIqJnCgMCdO8WTqSftvZ9/LO6gebXFJV3g0gXy0XVXC37oVldaxT DFOdY2pPr00/ZctGOq8DdG3az9gqvmnFH4x6B/iE2DnlWVuUiMBtlDjl7jLT9HGh/Vw2 W7Cg== X-Gm-Message-State: AOAM532+Hd+8IGPXhLECrQFF7MMjH2T024JCk4QmVeqI016aPXFMWuGr 1WCOsoQugtJCLsOnc30tBKXRlA== X-Received: by 2002:a5d:9916:: with SMTP id x22mr7217178iol.160.1623508666642; Sat, 12 Jun 2021 07:37:46 -0700 (PDT) Received: from presto.localdomain (c-73-185-129-58.hsd1.mn.comcast.net. [73.185.129.58]) by smtp.gmail.com with ESMTPSA id k4sm5126559ior.55.2021.06.12.07.37.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 12 Jun 2021 07:37:46 -0700 (PDT) From: Alex Elder To: subashab@codeaurora.org, stranche@codeaurora.org, davem@davemloft.net, kuba@kernel.org Cc: bjorn.andersson@linaro.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH net-next 8/8] net: qualcomm: rmnet: IPv6 payload length is simple Date: Sat, 12 Jun 2021 09:37:36 -0500 Message-Id: <20210612143736.3498712-9-elder@linaro.org> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210612143736.3498712-1-elder@linaro.org> References: <20210612143736.3498712-1-elder@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org We don't support any extension headers for IPv6 packets. Extension headers therefore contribute 0 bytes to the payload length. As a result we can just use the IPv6 payload length as the length used to compute the pseudo header checksum for both UDP and TCP messages. Signed-off-by: Alex Elder --- drivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) -- 2.27.0 diff --git a/drivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c b/drivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c index ed4737d0043d6..a6ce22f60a00c 100644 --- a/drivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c +++ b/drivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c @@ -114,7 +114,6 @@ rmnet_map_ipv6_dl_csum_trailer(struct sk_buff *skb, __sum16 *csum_field, pseudo_csum; __sum16 ip6_payload_csum; __be16 ip_header_csum; - u32 length; /* Checksum offload is only supported for UDP and TCP protocols; * the packet cannot include any IPv6 extension headers @@ -134,11 +133,9 @@ rmnet_map_ipv6_dl_csum_trailer(struct sk_buff *skb, ip_header_csum = (__force __be16)ip_fast_csum(ip6h, sizeof(*ip6h) / 4); ip6_payload_csum = csum16_sub(csum_trailer->csum_value, ip_header_csum); - length = (ip6h->nexthdr == IPPROTO_UDP) ? - ntohs(((struct udphdr *)txporthdr)->len) : - ntohs(ip6h->payload_len); pseudo_csum = csum_ipv6_magic(&ip6h->saddr, &ip6h->daddr, - length, ip6h->nexthdr, 0); + ntohs(ip6h->payload_len), + ip6h->nexthdr, 0); /* It's sufficient to compare the IP payload checksum with the * negated pseudo checksum to determine whether the packet