Received: by 2002:a05:6358:700f:b0:131:369:b2a3 with SMTP id 15csp1368049rwo; Wed, 2 Aug 2023 12:55:51 -0700 (PDT) X-Google-Smtp-Source: APBJJlFJCdouwmhoTgRPv3bbyBjCiakMGFEEWW649HvoellRGCj6wJN3tX+aErCWIKVG0w2Sdvre X-Received: by 2002:aa7:d94d:0:b0:522:38f9:e64e with SMTP id l13-20020aa7d94d000000b0052238f9e64emr6402189eds.1.1691006151499; Wed, 02 Aug 2023 12:55:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691006151; cv=none; d=google.com; s=arc-20160816; b=TFcgwZWgyLpQ3j3IC8gUGltDyT55GkOamgQiGPox6vVV8JzqeaHZN8Cp2zBpM/dGuR 5lOPr3NKXGUSQUODrC2OnYGqG0U7FTQBQy23n2SQxUubfGqk8BaibiTBXZj+ByiQcEzH FlhG7AqBqIEIE6Lp7693Y0R+HgqLu2ut+KdgOJrRX3+7DQ8Wewv0B5f1KLZOlAHuzycW 3WeLNohV5qBcp4OYJC1vC6o1Io9+m7tQbv1AhxbrpThvyQBUrgnxmfCVNhebUKaQezC5 GIBEVrNZa8RTRr5S0jYwaZBn+bnrH9A1RssJcaFDyJg85XA7rK8Zvb87YWm6DuJY3HXW 93gw== 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=T5ELzyVk/XA1aCrZBrMuYOfiLZ2aUjuTj3gKgPsL214=; fh=+1v2wpWL3SwC67MevmNFbsOkJ0jlpe0KMhkxFTuop+s=; b=uxMdJSrjAyREHLgderFa0eTDCvfRdcooN9LMFB6QkD4WHg+KJSMUtOk2egLxp2ybG2 QX0kkRu0cfeKwiLTKli6N1p6W/EPBE9L6T4q0d8fWnLNjHpJN0C2url4icTayoFq21ww WCv0oHvi4fsZdSIEhtoljKhBKHCGUtiLmPbjGHswE8Zo1qsps17XUtlEZnajVWJqhBBE ezBnDoQ4zYv8b4oKka063au59TdN5d0T4LyAljOyVkjWXExbuY5zh2rEziKmoVohhYWf H6LFY1tTVWjGniH2eu6JMkI4KD1WfPcISB/iMtyQcVwy3D+cRtpcYUUKOXMa4PuWC3YO 6F6w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@arista.com header.s=google header.b=VeF8Nquy; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id i25-20020aa7c719000000b005222780b1c4si10713894edq.600.2023.08.02.12.55.25; Wed, 02 Aug 2023 12:55:51 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-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; dkim=pass header.i=@arista.com header.s=google header.b=VeF8Nquy; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=arista.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229664AbjHBR3Y (ORCPT + 99 others); Wed, 2 Aug 2023 13:29:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49194 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233444AbjHBR2C (ORCPT ); Wed, 2 Aug 2023 13:28:02 -0400 Received: from mail-wm1-x336.google.com (mail-wm1-x336.google.com [IPv6:2a00:1450:4864:20::336]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F05C13A93 for ; Wed, 2 Aug 2023 10:27:35 -0700 (PDT) Received: by mail-wm1-x336.google.com with SMTP id 5b1f17b1804b1-3fba8e2aa52so1066295e9.1 for ; Wed, 02 Aug 2023 10:27:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=arista.com; s=google; t=1690997253; x=1691602053; 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=T5ELzyVk/XA1aCrZBrMuYOfiLZ2aUjuTj3gKgPsL214=; b=VeF8NquyO/p8eu707GC3eeuT3FhjPxlFNBsZOLoqNk8jLkUffJ1tsfYmp+ow/lHf7K ESahpK8ztx8ZlrCe9s4869mbyBq+SP46GwwWLoIRA8hIRCtPcs97CtumxnFkRWf8BxqU FQzZeUS6FDAt/y7NS4VNFsJC0Odn3lfmnnu1N/lfA2AXhAps67PUpSp4q0/R3zTCfi/S HUw3yG8dcmFnwqURZZKObjty6tDJtxQUajjalgIlar0kec92Z4TKVUvlX5I7uA3ZzqqP 3sVZjUfRolQbaikcdAMJ0spIaUgW/09G7i4ZvbZJSOGaRxc/pjk8Gb6fbUwWjKzdRa7y B9bw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690997253; x=1691602053; 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=T5ELzyVk/XA1aCrZBrMuYOfiLZ2aUjuTj3gKgPsL214=; b=c6JD34fdMRjmOBNlJ5HT/nr6EcoFbytsW3gS/5GKYXXddEOJRbTWKlvcR5kDC3ond0 DzDdy1RT8hClSjBBvwUXruT45I9wGDTvH/Ol/nZPd/2mtyCnHniCWkDW/oXP1h6jyo+o qbnhLc6P13fHgLg1FDXhQOYeDKYYebGp4DK6rTxnydCDSA0C+rVbqPGNyFVbr7ojb6kj 6YuX5uTdi0fhY+tVpiqXRAMibWijsklbErIDUe82emwZ/EHHeNGmvDyKh/k8e1pMRdiQ /v5lMpii2w00OSmWXjNJJ9cm4jHrY7AqYKogT5mSHINpfF5t//rL2Y2H/4eNR8+BBPrz HzPA== X-Gm-Message-State: ABy/qLap0bKdLuJHfb3uAiMUX+ovxcKbUUr+4HjDuBgf9ISnQlXaaFrC fnJekqGOtjKQY0hpBrrRF/WM4g== X-Received: by 2002:a1c:f202:0:b0:3fa:97b3:7ce0 with SMTP id s2-20020a1cf202000000b003fa97b37ce0mr5160054wmc.26.1690997253630; Wed, 02 Aug 2023 10:27:33 -0700 (PDT) Received: from Mindolluin.ire.aristanetworks.com ([217.173.96.166]) by smtp.gmail.com with ESMTPSA id q5-20020a1ce905000000b003fbc0a49b57sm2221770wmc.6.2023.08.02.10.27.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Aug 2023 10:27:33 -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 , Salam Noureddine , "Tetreault, Francois" , netdev@vger.kernel.org Subject: [PATCH v9 net-next 17/23] net/tcp: Add option for TCP-AO to (not) hash header Date: Wed, 2 Aug 2023 18:26:44 +0100 Message-ID: <20230802172654.1467777-18-dima@arista.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230802172654.1467777-1-dima@arista.com> References: <20230802172654.1467777-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,T_SCC_BODY_TEXT_LINE, 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 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 ca7ed18ce67b..3275ade3293a 100644 --- a/include/uapi/linux/tcp.h +++ b/include/uapi/linux/tcp.h @@ -354,6 +354,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 236c8cd1a0c7..0d10b437b0f9 100644 --- a/net/ipv4/tcp_ao.c +++ b/net/ipv4/tcp_ao.c @@ -565,7 +565,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); @@ -613,7 +614,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)) @@ -1407,7 +1409,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.41.0