Received: by 2002:a05:7412:251c:b0:e2:908c:2ebd with SMTP id w28csp1433571rda; Mon, 23 Oct 2023 12:24:57 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHaRFqVdDEBNMPZyHfFgu9NHU094fdWAb+kkHfb8GsswvRcR/rYcMEKXkV2OGDuq061C6n8 X-Received: by 2002:a05:6a21:780a:b0:157:b453:dbb9 with SMTP id be10-20020a056a21780a00b00157b453dbb9mr476240pzc.6.1698089097528; Mon, 23 Oct 2023 12:24:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698089097; cv=none; d=google.com; s=arc-20160816; b=u9R/+4WkLaJ9gR7xylm8Jl20o0w1DSAnP3QQnbeBqpLMJ6tjzsVc4t9OSs0mF2OolU 9NgB+xFnaBMgSUiRj1+dNwjU/V8/xogcpsHYXIreMVHeFLvKA4PUCTCKpYKCA/Dut95+ zlCNyZNPwvNBm+RIBORnU+6mRS53+oPxTwk8F8pgSiU6gN2/e6RceBYpM8HvnY3kPM3b XLZ7CxykX/DUVxNcGBXAnZMfML34qvO7EnCFq/CBWvx0a1tuZMzn/txB8HGDbJ27V135 wKJHjiY3NgNYsKDpazIGXB8dMUSG4LeYY6YmlTHU1hm15XJJjoPSBCJ0PGIWjPB+7K3E CyYA== 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=7u8YCu2AD+GW6MAEiXwWdEdCsazbndy14jHPXm7rwEg=; fh=a8JK1LlV6fjkJ2GExjvEHYBwBHtgXArNx6ms6Kac6b4=; b=DD3Rl9XvxkpLpoiJ/X1xeXpFM7EqtHHTWa2PqL/zTjgq5VAG7YHgQrZ6eLQErtPA/I DNc7gutmk78xUldnzhKX9SsLIoSuwzD7tC5yIwtBxhZvMIaLqc3lfO+zb4/W+prSuXL8 Qld77N+QqKw8SC/ES/kmDOccDEny1WPywO8i29G3+B7zMFjx5E1b2fvhIZ7JcBS4vE2N gsoEbpH2lRZlzFA4mk1sh+sfSKEnH9nLO9ecKNbli1ZVBF5cBlgVut7YVco94rA+5ErZ y7M5oD0CJDKk2GU7Ut7eNk70hqv0TBchfL4v2Br8+KRs9SLEEfbhDS25IdP9H3sQg37m yQTA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@arista.com header.s=google header.b=cOttSYca; 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 j191-20020a6380c8000000b0059d48c43152si6661661pgd.40.2023.10.23.12.24.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Oct 2023 12:24:57 -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=cOttSYca; 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 582298066975; Mon, 23 Oct 2023 12:24:43 -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 S233121AbjJWTYM (ORCPT + 99 others); Mon, 23 Oct 2023 15:24:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57810 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231453AbjJWTXi (ORCPT ); Mon, 23 Oct 2023 15:23:38 -0400 Received: from mail-wm1-x331.google.com (mail-wm1-x331.google.com [IPv6:2a00:1450:4864:20::331]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9F2901739 for ; Mon, 23 Oct 2023 12:23:02 -0700 (PDT) Received: by mail-wm1-x331.google.com with SMTP id 5b1f17b1804b1-40859dee28cso18766965e9.0 for ; Mon, 23 Oct 2023 12:23:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=arista.com; s=google; t=1698088979; x=1698693779; 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=7u8YCu2AD+GW6MAEiXwWdEdCsazbndy14jHPXm7rwEg=; b=cOttSYcamX4i+PydWodyMxATiRjX+vbQlUvLNTdHvEIALf5W6xab85A0U9xJfBYVGY hdYeBymYYZItSjjbot4etAP242bdfnoSvD+jXwUUcWBJCNoN3yUSCgHvJ8XgcGw6ISaS 3ayo0VKY7aU+0OJiE37A6SCOd4L4FDcc84Ts3Ch0LGn4UQ3iQPBIzDN7kGm9v4qfL6ud +wmWoL9+GGnqCnjYuLPN+Woh6MkXDNJkFajktuXWfoHgCW7daZU3dLJTC9ixf373wapM VdqB+7o+MsZhRAOm7boWXePBUGqtH3zF9rSJS/ork01187vI3+78wghO+vABikGSgwH7 xhRw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698088979; x=1698693779; 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=7u8YCu2AD+GW6MAEiXwWdEdCsazbndy14jHPXm7rwEg=; b=vCI7IM5N1LfU3M046cZwvB9DRXMFRCYjH/7MXIF5jc/PsULGQIYXE0uzukRBuWXg38 6M+meJ/EOYneAGQMfZKA8WQMlsCxOg7mDYAyaXFR22dHOFEnNsbsjzsL4PAn91VBcGgX GvY3k+nyasrhI940KeXlZc3B6hD6AuVcci4fYZ1Xg4HNADVEKAGgXAq5W1r6Mza2z6Jy 43UBZgM2N/eXC+EXWYVxQflhsxvrvWUJLA/Mk7wB0mbyNv7vHh2hb3AZtB8wU6fH94N0 LvFzzB0InjsZPZgEuuynFPx4RK5U6i+wHD5ivU4JH2ihVAmaGt51vXrttee5C8NI8cmE ysBQ== X-Gm-Message-State: AOJu0YyzBqwldpHJBsWjFDEVh84hiVG9L46DtBF3ObPsOOwVwKqV6pAf XxeRLJIsAykPSkM1F8hPsZ+20w== X-Received: by 2002:a05:600c:1d22:b0:408:4475:8cc1 with SMTP id l34-20020a05600c1d2200b0040844758cc1mr8453490wms.35.1698088978886; Mon, 23 Oct 2023 12:22:58 -0700 (PDT) Received: from Mindolluin.ire.aristanetworks.com ([217.173.96.166]) by smtp.gmail.com with ESMTPSA id ay20-20020a05600c1e1400b00407460234f9sm10142088wmb.21.2023.10.23.12.22.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Oct 2023 12:22:58 -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 v16 net-next 17/23] net/tcp: Add option for TCP-AO to (not) hash header Date: Mon, 23 Oct 2023 20:22:09 +0100 Message-ID: <20231023192217.426455-18-dima@arista.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231023192217.426455-1-dima@arista.com> References: <20231023192217.426455-1-dima@arista.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable 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, 23 Oct 2023 12:24:43 -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 d8b2ea23f12a..320aab010f9a 100644 --- a/include/uapi/linux/tcp.h +++ b/include/uapi/linux/tcp.h @@ -367,6 +367,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 223af5c9eaf3..10cc6be4d537 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)) @@ -1454,7 +1456,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