Received: by 2002:a05:7412:3784:b0:e2:908c:2ebd with SMTP id jk4csp2904351rdb; Wed, 4 Oct 2023 15:38:07 -0700 (PDT) X-Google-Smtp-Source: AGHT+IF+nxniEImVNKgMNrbXVy3fI+Jqvfxlsv80Yofb3f/l8xKhKDjbeRH0CBXvIKrhE+YJYjgZ X-Received: by 2002:a05:6a20:3252:b0:140:6d68:ce07 with SMTP id hm18-20020a056a20325200b001406d68ce07mr3444140pzc.52.1696459086873; Wed, 04 Oct 2023 15:38:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696459086; cv=none; d=google.com; s=arc-20160816; b=jbS+YM+XHM3WxfWVvsmVfM+Mzcs2gdpeADxTLvGSkKM1v4hKpmS7GB4r9aySljy46Z iQGJFZl9HzZgnEhKA68vFG6AGgyJXv2QQG3zvBeY3/WnMAJoBCLsjUEFAe0S3261wGmO k5oAFnE79zS13G/qYVapjJIqui4m3mazlK4JV7DUaKsepwX0H6RTplrklguwm23Y2gbO 16EwhU05wW0lCMlB1oBIZjimnd4YEa6DLupCdKJlImgcdyTLWu5+xbdDxj/WHMSc8kCl gFXBgwH9rlD13wzyRUz599/c+ocr1R2ozwlc9TIV8OWQ6KW29BXPazFoeJl6V+vp2XkL ercw== 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=VwmXVNm//ys9qfpF+UjN5wQql5zv/i0Wub8zAOrLQUF9KOfPtZ0csAxYAg7wP1o1gG 4ZxdbunJ33O9B+fsk5oVn4cXLEZDxMnWnfNKPu/lh8V+RJOl/vCpB8sT7DwPNFk08w/I e1QBESwhgBJ0eGLV6ntpffcrISNUqrWnbm3GvuYm+lIXMBhrPMEKKl8xECbGotwz7cPd oKFG9Uc9CtP4zQFboOBa4eZ5IbjfFjBUGUSyir2ruOrXiP+eatcjVQJX99ehyKQvPK67 RYilgv6DyUWinIerWd0EYVKFf2elw8SWXjT75AgPupyKfioQ8FMJ/qiyMBxt3ZvF9m8l io+A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@arista.com header.s=google header.b=AcT0k6EQ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 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 howler.vger.email (howler.vger.email. [23.128.96.34]) by mx.google.com with ESMTPS id fi9-20020a056a00398900b0068bc0b772d8si75471pfb.194.2023.10.04.15.38.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Oct 2023 15:38:06 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) client-ip=23.128.96.34; Authentication-Results: mx.google.com; dkim=pass header.i=@arista.com header.s=google header.b=AcT0k6EQ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 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 howler.vger.email (Postfix) with ESMTP id 6FAAA850FAFA; Wed, 4 Oct 2023 15:38:05 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236529AbjJDWiB (ORCPT + 99 others); Wed, 4 Oct 2023 18:38:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41224 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236558AbjJDWhi (ORCPT ); Wed, 4 Oct 2023 18:37:38 -0400 Received: from mail-wm1-x32c.google.com (mail-wm1-x32c.google.com [IPv6:2a00:1450:4864:20::32c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 34685171C for ; Wed, 4 Oct 2023 15:37:09 -0700 (PDT) Received: by mail-wm1-x32c.google.com with SMTP id 5b1f17b1804b1-406402933edso2976695e9.2 for ; Wed, 04 Oct 2023 15:37:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=arista.com; s=google; t=1696459027; x=1697063827; 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=AcT0k6EQIXRaNuj7ZYGkDJ/+yP4RyxCx8dZPnbiq7nQgklt1/ZsgyDWd2l0nBD4umI bG4Rfs3qV1VBPxKXj+wMTZT55D4zZLDVEjjkC57++tmpyV67gnRkG4KgMLnSWHVvIbEh QZCPNOrnUB//AG5LrVt8FtdBxZnTDRQ0D5llSWm/U8frzUgg0NxME5JTjRW3yiGP1xNX YyyPTPB6dHUlUpIQCTbP7roP77JuSsLbe7iM8n1duLw8ZTtROUTwu3TEv5KTuvh/V1rq 9soECjCwytxYDq3ubSGv3nci8ScFM+eB2IdlKpZkbtqJ+fd1ZZyC0KQxfzUgpUJCQCZU fYkw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696459027; x=1697063827; 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=LBUKReBIQA760fwhmq6eUIAHIqdjJ8flhCDTXZHRKiafoVsmJ4YI6Jb33DCKPMhTVN g9p2eM7wL6WwcGS5/CVRnieGgo+Qmnt05Jkl5ZaVowzEfkWnpocMvHSHRotXBZgrr8Jc 5jAxfOnG6j3InCebsm20i6ebHvyYMGJvffHPnlZmYRBfw/dbfUJOUJOHCwQKWsmuXKDZ FX7MOg1sz1iNsbJ+0UTNGD3YruFxuiUF8IT9xpPMLrVfDAwsRHe9gYjcKIPnKVitImGn dR7rg5Eic3FJ4PgIkV4CRosONmbENptePqHDuoW4j5xaaPxixByIPgsEpp0rnn5ZO+pJ HdIg== X-Gm-Message-State: AOJu0Yx7r8j46stm9GDG035W4iuRdJd6tUig7qke9SMGQfjW/8MW7wMo t5NfEHXHpMznA7n39onH4s0VRA== X-Received: by 2002:a05:600c:b4b:b0:405:3b1f:968b with SMTP id k11-20020a05600c0b4b00b004053b1f968bmr3386589wmr.21.1696459027172; Wed, 04 Oct 2023 15:37:07 -0700 (PDT) Received: from Mindolluin.ire.aristanetworks.com ([217.173.96.166]) by smtp.gmail.com with ESMTPSA id z11-20020a5d4d0b000000b0031ff89af0e4sm181412wrt.99.2023.10.04.15.37.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Oct 2023 15:37:06 -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 v13 net-next 17/23] net/tcp: Add option for TCP-AO to (not) hash header Date: Wed, 4 Oct 2023 23:36:21 +0100 Message-ID: <20231004223629.166300-18-dima@arista.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231004223629.166300-1-dima@arista.com> References: <20231004223629.166300-1-dima@arista.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_NONE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net 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 (howler.vger.email [0.0.0.0]); Wed, 04 Oct 2023 15:38:06 -0700 (PDT) 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