From patchwork Thu Jun 6 00:58:19 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Safonov via B4 Relay X-Patchwork-Id: 13687741 X-Patchwork-Delegate: kuba@kernel.org Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 436EACA6F; Thu, 6 Jun 2024 00:58:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717635511; cv=none; b=P4jzcYtyrY5FLBHkuCcwONLrtYxEbbf0Hyni79d50Rhz9Bz8PH59J+cUmXo1hqR+j0xrhl/qv9nO6RGkwXsdKFKhaUcUNKw/vK/UYS4HI2uQamVDih+/jlNW7VB3Zt6VB5YfIdl61aOnCKWrLwDiFn7RKaUM4IQ97mvjWToBO60= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717635511; c=relaxed/simple; bh=m1ODjAZVIal9y8K9wO0qbhWp8y4HHguHQ1q4lW0dScU=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=kHvPr4YNEjbFJiNs5hZPeHtw9a5zCdetYOZN7qSbNz+DM26RZnrGWKbt8vzhRNXDi1nCuSUSdHPUR8DDnVMEltuTHkXhwPxzWmbKEM9j0rDyfV5bGOf0xc/ysNR/3u2mJ/4Bby1q584HqMRQoM26cKzGXQNVL4rZyBRTt4Yj0q0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=EYBpFy/R; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="EYBpFy/R" Received: by smtp.kernel.org (Postfix) with ESMTPS id B3846C4AF08; Thu, 6 Jun 2024 00:58:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1717635510; bh=m1ODjAZVIal9y8K9wO0qbhWp8y4HHguHQ1q4lW0dScU=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=EYBpFy/ReR255lYkxKgXO3cJUiteqvhDzWL5sk/4KN162F8hgNqAbWaQVzHp3JhDx WyFm7nJaZDX+NVYoALbsbUYTtR8eZQoUg2BozQZtHwoaaIpxvFQH89IKTvXEkb+7AZ L6UIqOg1A1DYaErrVeqfMvhpcqhpx6ZLW2fERC/NwcQbVyuvmHkSITi8oFL/e0eh+A vkeZ4muQICDJPlawAWFalaBcWnSqu93kHPNvWl9tR4AYwWIdqnP+Z+BubmQfAdOQWi K/mXf4RibUfbIV2qjkqTTAOJkdqbb6e+DFJXbj6az65Fph70snpcOlI8tYStSQ0H3I 8M1Y0AXHqKpkg== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9CB8EC27C5F; Thu, 6 Jun 2024 00:58:30 +0000 (UTC) From: Dmitry Safonov via B4 Relay Date: Thu, 06 Jun 2024 01:58:19 +0100 Subject: [PATCH net-next v3 2/6] net/tcp: Add a helper tcp_ao_hdr_maclen() Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240606-tcp_ao-tracepoints-v3-2-13621988c09f@gmail.com> References: <20240606-tcp_ao-tracepoints-v3-0-13621988c09f@gmail.com> In-Reply-To: <20240606-tcp_ao-tracepoints-v3-0-13621988c09f@gmail.com> To: Eric Dumazet , "David S. Miller" , Jakub Kicinski , Paolo Abeni , David Ahern , Steven Rostedt , Masami Hiramatsu , Mathieu Desnoyers , Jonathan Corbet Cc: Mohammad Nassiri , Simon Horman , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, linux-doc@vger.kernel.org, Dmitry Safonov <0x7f454c46@gmail.com> X-Mailer: b4 0.12.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1717635508; l=1228; i=0x7f454c46@gmail.com; s=20240410; h=from:subject:message-id; bh=3r0GUti1sbRL2DmiJwhtJuQ4wZfREpceQasirqqFZEo=; b=CQ0LdFqzJrO1PgTov6mN9djdrLg5x4/LZXb466Qlyk6W8wybb7HWvhrWy3gUyCTv+g5jZQzDy/Ml mjcdbQsSDD66rdlUluNAiirWV6c98jWuyOKlRgWqRbMUdReXpkck X-Developer-Key: i=0x7f454c46@gmail.com; a=ed25519; pk=cFSWovqtkx0HrT5O9jFCEC/Cef4DY8a2FPeqP4THeZQ= X-Endpoint-Received: by B4 Relay for 0x7f454c46@gmail.com/20240410 with auth_id=152 X-Original-From: Dmitry Safonov <0x7f454c46@gmail.com> Reply-To: 0x7f454c46@gmail.com X-Patchwork-Delegate: kuba@kernel.org From: Dmitry Safonov <0x7f454c46@gmail.com> It's going to be used more in TCP-AO tracepoints. Signed-off-by: Dmitry Safonov <0x7f454c46@gmail.com> Reviewed-by: Eric Dumazet --- include/net/tcp_ao.h | 5 +++++ net/ipv4/tcp_ao.c | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/include/net/tcp_ao.h b/include/net/tcp_ao.h index 471e177362b4..6501ed1dfa1e 100644 --- a/include/net/tcp_ao.h +++ b/include/net/tcp_ao.h @@ -19,6 +19,11 @@ struct tcp_ao_hdr { u8 rnext_keyid; }; +static inline u8 tcp_ao_hdr_maclen(const struct tcp_ao_hdr *aoh) +{ + return aoh->length - sizeof(struct tcp_ao_hdr); +} + struct tcp_ao_counters { atomic64_t pkt_good; atomic64_t pkt_bad; diff --git a/net/ipv4/tcp_ao.c b/net/ipv4/tcp_ao.c index 781b67a52571..7c9e90e531e3 100644 --- a/net/ipv4/tcp_ao.c +++ b/net/ipv4/tcp_ao.c @@ -884,8 +884,8 @@ tcp_ao_verify_hash(const struct sock *sk, const struct sk_buff *skb, const struct tcp_ao_hdr *aoh, struct tcp_ao_key *key, u8 *traffic_key, u8 *phash, u32 sne, int l3index) { - u8 maclen = aoh->length - sizeof(struct tcp_ao_hdr); const struct tcphdr *th = tcp_hdr(skb); + u8 maclen = tcp_ao_hdr_maclen(aoh); void *hash_buf = NULL; if (maclen != tcp_ao_maclen(key)) {