Received: by 2002:a05:7412:da14:b0:e2:908c:2ebd with SMTP id fe20csp2185574rdb; Mon, 9 Oct 2023 16:10:38 -0700 (PDT) X-Google-Smtp-Source: AGHT+IF9GcC5YAvCPWvxvOrQD1pc392JuSD5b1AeF9SRCkSY2pqlWXo2KZDVkKFSM1bOLo2fZk7f X-Received: by 2002:a17:902:f68d:b0:1c7:61de:f25c with SMTP id l13-20020a170902f68d00b001c761def25cmr19708426plg.22.1696893038218; Mon, 09 Oct 2023 16:10:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696893038; cv=none; d=google.com; s=arc-20160816; b=w7mNNaftjv2Wpg2/xCsLXLMVgLspeeYp1Np7gfG4RpomTczi7dcougseeaJnLnuhDb /i/javaCKm78K0f87xil0LuvSXC8xk+4/ooJoZmeilfN7HgLnG1D7IU4zoE89Qt0rYga W2xdYFKWm31J6oGzpyWhSCAZvdVUaKun/tcLPMA6ms7okk+kT7GBe1J5Rbw7aCVbmQjb sm7EwWGwD/VurAM97ZU0+iFJQxvgWR7pNI6x5ppdLXSKtk/iY7w3DrvLjvS4ifXBKrup PUiSjy31+nateCCbAu5WPveR1Jozp4GSThOYjTRz8Lyw3x+Gk9AIsOD6vo7wIoV3tGl6 9ViQ== 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=/kek+IpSSyHROs5GlGdGf6GIiZ0a+NpAchKDoFinfg8=; fh=58X8Twod/aefd4Yph/F0FPyIOMSYi96Sqi5HmPAz0To=; b=zpWI4PMeLlmEbcRgdswyvM4zoqbyfZ3t+fwPFbIGw/Z2qDcrl0Ze+vycCJ32YsRRGw cdJnMfeDFI7xPc4PUfkgLgBHgaspFBmfAwxZ7kVSj85XZFwP+3rrL0AWwduzCF7yS20J lO3KeWkIU1TVtIo+Neb4a/Gxw4xKcn9S49c1ZT7AnDEpEvtq/cVboJHszbdIRhjL3cNF knD3JGnoPGozGT5D8VgHXjk7bRFfcXllqGp+DgKJiRjTR1Ts+0jCcYAP7NB0FOXYqO9w lzcI0rzFqpzhK3OOLz9gNn/O/iWdTtqInGT1GDeKmbAla+lOybheWlT8ZN9E/XFvQimG E0Cw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@arista.com header.s=google header.b=eLWWIyF0; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=arista.com Return-Path: Received: from groat.vger.email (groat.vger.email. [23.128.96.35]) by mx.google.com with ESMTPS id w12-20020a170902c78c00b001c465e1e219si10066647pla.30.2023.10.09.16.10.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Oct 2023 16:10:38 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) client-ip=23.128.96.35; Authentication-Results: mx.google.com; dkim=pass header.i=@arista.com header.s=google header.b=eLWWIyF0; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=arista.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id 2607F80BD5CE; Mon, 9 Oct 2023 16:10:16 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1379108AbjJIXJU (ORCPT + 99 others); Mon, 9 Oct 2023 19:09:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35808 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1379151AbjJIXI5 (ORCPT ); Mon, 9 Oct 2023 19:08:57 -0400 Received: from mail-wm1-x32d.google.com (mail-wm1-x32d.google.com [IPv6:2a00:1450:4864:20::32d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 27A02FC for ; Mon, 9 Oct 2023 16:08:03 -0700 (PDT) Received: by mail-wm1-x32d.google.com with SMTP id 5b1f17b1804b1-406618d0992so49457665e9.0 for ; Mon, 09 Oct 2023 16:08:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=arista.com; s=google; t=1696892875; x=1697497675; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=/kek+IpSSyHROs5GlGdGf6GIiZ0a+NpAchKDoFinfg8=; b=eLWWIyF0rUTpyZyuypZd1D6eCFlkN3EcB1eK0Kx/zLqspqgDQQ9CjQmchZSM4rlW+e 0b+1jtfDM3KdN+ZuV+uCvGuqR8az4r2S1waomiqZYFj/u9lcqJM9VCXyc4OBnzDKNfa5 suhYbf8JZ28qqWCvyxtjbcC3rmqIHQDUNiAyYn6JgBM/S4JjkEGSeUNzGC6UkjS+lZr7 Zp7RF7R6laG8YEEta4m21qWM/XdAH8SD5yzqV2KOlLZ13ysdBM9Vq4Xed38Nq/aMDuaV /KZlkblrIhiYrGUxk5q/vT/yBPjsYKOuPfgoDtFbB2AbVxjZHmgu6/wq356HjWq6pygc ZEOg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696892875; x=1697497675; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=/kek+IpSSyHROs5GlGdGf6GIiZ0a+NpAchKDoFinfg8=; b=j544sCpXKmPRnZPDl2Dbiz+kOOrHIJ3L0ghggI+RJ5pQqdjxWaBtfYKDeJHIq6b6zH KeMeizqY+C0A8XXAXmTLRV9JhgTNIbpCDLZeiAP/RDmqA1M24LgQuyA5kXoPads2nXU6 Wt4XpoIUI53MNy/vgmL7rTsFomnWehGsHlxPigED9Ypv7auoKMut3gkcm2PGc6ycHYOR CnMTGRxx3+ViIQLAw/A1ojAFsQXLqT9uIbaU3seJET3L/XtAOTvxt1hnvSDdiLdZSAaW L5Js0+fr+7SPV7t1O2R5QDgUhO5Sep7k91Md9xykAGOdOFsNY8WahhswmzLlvpLjSQmE u2Xw== X-Gm-Message-State: AOJu0Ywll9x2COUFvrfFN/VxuedsRfZoILIE/q9mscA7xCqKGNNS36GI V4AFz4T+Tse1EWFFIblFYqbDhg== X-Received: by 2002:a05:600c:21d1:b0:405:1c14:9227 with SMTP id x17-20020a05600c21d100b004051c149227mr14926186wmj.33.1696892875624; Mon, 09 Oct 2023 16:07:55 -0700 (PDT) Received: from Mindolluin.ire.aristanetworks.com ([217.173.96.166]) by smtp.gmail.com with ESMTPSA id t24-20020a7bc3d8000000b004042dbb8925sm14592104wmj.38.2023.10.09.16.07.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Oct 2023 16:07:55 -0700 (PDT) From: Dmitry Safonov To: David Ahern , Eric Dumazet , Paolo Abeni , Jakub Kicinski , "David S. Miller" Cc: linux-kernel@vger.kernel.org, Dmitry Safonov , Andy Lutomirski , Ard Biesheuvel , Bob Gilligan , Dan Carpenter , David Laight , Dmitry Safonov <0x7f454c46@gmail.com>, Donald Cassidy , Eric Biggers , "Eric W. Biederman" , Francesco Ruggeri , "Gaillardetz, Dominik" , Herbert Xu , Hideaki YOSHIFUJI , Ivan Delalande , Leonard Crestez , "Nassiri, Mohammad" , Salam Noureddine , Simon Horman , "Tetreault, Francois" , netdev@vger.kernel.org Subject: [PATCH v14 net-next 17/23] net/tcp: Add option for TCP-AO to (not) hash header Date: Tue, 10 Oct 2023 00:07:08 +0100 Message-ID: <20231009230722.76268-18-dima@arista.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231009230722.76268-1-dima@arista.com> References: <20231009230722.76268-1-dima@arista.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=2.7 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RCVD_IN_SBL_CSS,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (groat.vger.email [0.0.0.0]); Mon, 09 Oct 2023 16:10:16 -0700 (PDT) X-Spam-Level: ** Provide setsockopt() key flag that makes TCP-AO exclude hashing TCP header for peers that match the key. This is needed for interraction with middleboxes that may change TCP options, see RFC5925 (9.2). Co-developed-by: Francesco Ruggeri Signed-off-by: Francesco Ruggeri Co-developed-by: Salam Noureddine Signed-off-by: Salam Noureddine Signed-off-by: Dmitry Safonov Acked-by: David Ahern --- include/uapi/linux/tcp.h | 5 +++++ net/ipv4/tcp_ao.c | 8 +++++--- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/include/uapi/linux/tcp.h b/include/uapi/linux/tcp.h index e4ddca6178ca..7b9762ab4df8 100644 --- a/include/uapi/linux/tcp.h +++ b/include/uapi/linux/tcp.h @@ -366,6 +366,11 @@ struct tcp_diag_md5sig { #define TCP_AO_MAXKEYLEN 80 #define TCP_AO_KEYF_IFINDEX (1 << 0) /* L3 ifindex for VRF */ +#define TCP_AO_KEYF_EXCLUDE_OPT (1 << 1) /* "Indicates whether TCP + * options other than TCP-AO + * are included in the MAC + * calculation" + */ struct tcp_ao_add { /* setsockopt(TCP_AO_ADD_KEY) */ struct __kernel_sockaddr_storage addr; /* peer's address for the key */ diff --git a/net/ipv4/tcp_ao.c b/net/ipv4/tcp_ao.c index 168073cd1c89..ba13e85fcabd 100644 --- a/net/ipv4/tcp_ao.c +++ b/net/ipv4/tcp_ao.c @@ -562,7 +562,8 @@ int tcp_ao_hash_hdr(unsigned short int family, char *ao_hash, WARN_ON_ONCE(1); goto clear_hash; } - if (tcp_ao_hash_header(&hp, th, false, + if (tcp_ao_hash_header(&hp, th, + !!(key->keyflags & TCP_AO_KEYF_EXCLUDE_OPT), ao_hash, hash_offset, tcp_ao_maclen(key))) goto clear_hash; ahash_request_set_crypt(hp.req, NULL, hash_buf, 0); @@ -610,7 +611,8 @@ int tcp_ao_hash_skb(unsigned short int family, goto clear_hash; if (tcp_ao_hash_pseudoheader(family, sk, skb, &hp, skb->len)) goto clear_hash; - if (tcp_ao_hash_header(&hp, th, false, + if (tcp_ao_hash_header(&hp, th, + !!(key->keyflags & TCP_AO_KEYF_EXCLUDE_OPT), ao_hash, hash_offset, tcp_ao_maclen(key))) goto clear_hash; if (tcp_sigpool_hash_skb_data(&hp, skb, th->doff << 2)) @@ -1451,7 +1453,7 @@ static struct tcp_ao_info *setsockopt_ao_info(struct sock *sk) return ERR_PTR(-ESOCKTNOSUPPORT); } -#define TCP_AO_KEYF_ALL (0) +#define TCP_AO_KEYF_ALL (TCP_AO_KEYF_EXCLUDE_OPT) static struct tcp_ao_key *tcp_ao_key_alloc(struct sock *sk, struct tcp_ao_add *cmd) -- 2.42.0