Received: by 2002:a05:6358:7058:b0:131:369:b2a3 with SMTP id 24csp8688576rwp; Wed, 19 Jul 2023 13:49:41 -0700 (PDT) X-Google-Smtp-Source: APBJJlFr7rJvkj10ThEahhSmKaWx7s7Hd2a5mEDvZLLp8TJC/GXCYzbwZhnTj8FfXSDVCQp6FRga X-Received: by 2002:a05:6358:33a1:b0:133:6bcc:ae9d with SMTP id i33-20020a05635833a100b001336bccae9dmr36793rwd.17.1689799780618; Wed, 19 Jul 2023 13:49:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689799780; cv=none; d=google.com; s=arc-20160816; b=DlweUGvdeXu4kFsDZeUUklbz6EhgpViwVFgMNH8mwpvIc4BQMlzqM2nSjbpTDwBtNf D7Y5dKqUgE3MfQpJu16GeqHI6Z5jAVYtbMVlAOiqsmIAS10sEU+R46DeCE/ztvrnIckF 76uaH3Sf2b+pR5wAvaOynd1XXirOOpRue7eSxJaJOY499b01G0RMZlntyHwx8jSpt2zT z9doB+6smIgeL1Ag2kP/ibbjQLrED1aXE2yigdaqNhUPPbSqPiD30GPLEUY1EW9ZfO1E yz+Tmn1hdQ4Ixsh0zFM1C/TWl0Hw9HAVYeXCbaafcwJCs1xVOIQ8aABLuN7c/ternMS+ 7M9Q== 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=g//yS07dhHSKeyyRj/J57DFtZtZ+cyyolllpbeSyUP8=; fh=+1v2wpWL3SwC67MevmNFbsOkJ0jlpe0KMhkxFTuop+s=; b=ow/c3YqK2eiz4E8R5mV/V9xxYm9FFeWuJh775y3OTQuxoInie/SvkGOP+IyHfdm4zK kU1+4f7g5vzrhKKJf/A20ynphNsLR4GabnebUq9GOmmqxsMCWFzQK8+wdILeHXMZBWN7 DYkPQiteRMNQ5crTo/s4WeRzeGIczat/dFTcddqUzJNIgwRQZcqN0Q0mjrOZvBe3pL8a s96B1jua87awrbaZUYhNrGHdCGHqD1hE9x7tIqi1zfq9hTQ8Uo6Fn9Bs/werYKnOheZZ TVo2SZAwmSOhXaji7Zx2JL8lupddVrOvsXNQWpNFKSsFNDveK/1cE47Rz5VTJQiGNJQe r/hQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@arista.com header.s=google header.b=KUX8DaZ+; 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 q123-20020a632a81000000b0055ae20ada77si3876936pgq.591.2023.07.19.13.49.27; Wed, 19 Jul 2023 13:49:40 -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=KUX8DaZ+; 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 S231269AbjGSU2b (ORCPT + 99 others); Wed, 19 Jul 2023 16:28:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58318 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231486AbjGSU1x (ORCPT ); Wed, 19 Jul 2023 16:27:53 -0400 Received: from mail-wm1-x335.google.com (mail-wm1-x335.google.com [IPv6:2a00:1450:4864:20::335]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A60DE2720 for ; Wed, 19 Jul 2023 13:27:09 -0700 (PDT) Received: by mail-wm1-x335.google.com with SMTP id 5b1f17b1804b1-3fbea14700bso227655e9.3 for ; Wed, 19 Jul 2023 13:27:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=arista.com; s=google; t=1689798427; x=1692390427; 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=g//yS07dhHSKeyyRj/J57DFtZtZ+cyyolllpbeSyUP8=; b=KUX8DaZ+/2Qf4JrXfq1ey1LA9k95/uuZfblgE8kr1k7hsGdZtKFsgj7xNtuts/VsqV IHHyFnbbe+LQf2DprQ+kP81iutRuULH4sFkAqoEPJsCaTsPeQ9TXWZOgiyyiZOc6/oKK ltk1EUex1Qgww5wm6j9BepynUtvYL9Me9D477OeupHb6SPa41gEnlQwGl7l8KM2O1fxo HSn+f0fa/QL37lrvngn6hnnINevioCtpcM+L3m1wjb65VXCe8RBAss/AY1OW7q5trp2i 61hNb7t6jRO4YRExo5DdWzw9QQzqRziw0DQri9gtMd5QEHlJM19mH27VXBrkhNU0MpKu iclA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689798427; x=1692390427; 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=g//yS07dhHSKeyyRj/J57DFtZtZ+cyyolllpbeSyUP8=; b=MnA/vO1ujDNB+VDwHfTrVHbciecyd4anu6a6t/phbQHICyphFtdW4VdC3pf8WDknlm 4/ukzjqs6BmCtFkDsGPnydRcF8ClH/ZC4IsecaYTmVpWqEmkonYgGIJjJwHp0nFZNy7g /0U+LsCaZ+Mzr6HiVq7qtGkD6mfqKAk4ng8ES8JOgVRaQVcIkj5HQ4AfuV/Q18L1NXNT /+/fn+0tPv0DcR3lYE8I3EKvIPHAXvOjw5u4BmRm3H7m1fNPocyI5Wn9Aiaf/qxBYc3u PrN3AJkMo5ZeZO1Q0y3nvrPBiOs78pRV9LbwBRizf8SuKBEuL6BWSuIbiYJq++ZvCn/5 SxSA== X-Gm-Message-State: ABy/qLZuoEGnp/8Kog0WXy1EdGoqNzkMOLmwnP8I9gPHBYp18fzzSQ/Z hdR7aVorAUQRj2wh/qGDXHj+cQ== X-Received: by 2002:a1c:f30b:0:b0:3f8:c9a4:4998 with SMTP id q11-20020a1cf30b000000b003f8c9a44998mr303950wmq.28.1689798427229; Wed, 19 Jul 2023 13:27:07 -0700 (PDT) Received: from Mindolluin.ire.aristanetworks.com ([217.173.96.166]) by smtp.gmail.com with ESMTPSA id 3-20020a05600c234300b003fc04d13242sm2432319wmq.0.2023.07.19.13.27.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 19 Jul 2023 13:27: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 , Salam Noureddine , "Tetreault, Francois" , netdev@vger.kernel.org Subject: [PATCH v8 17/23] net/tcp: Add option for TCP-AO to (not) hash header Date: Wed, 19 Jul 2023 21:26:22 +0100 Message-ID: <20230719202631.472019-18-dima@arista.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230719202631.472019-1-dima@arista.com> References: <20230719202631.472019-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_NONE, 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 --- 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 4bde58ede63a..4fabd3ec5c71 100644 --- a/net/ipv4/tcp_ao.c +++ b/net/ipv4/tcp_ao.c @@ -567,7 +567,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); @@ -615,7 +616,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)) @@ -1430,7 +1432,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