Received: by 2002:a05:7412:31a9:b0:e2:908c:2ebd with SMTP id et41csp2945526rdb; Tue, 12 Sep 2023 18:15:41 -0700 (PDT) X-Google-Smtp-Source: AGHT+IE8g+CeDDA6WRzOdNO3VOFHY374gm1FQJ145y7jrI5dvDBjbEqP6WEU07KhB/saYrbmAGpO X-Received: by 2002:a05:6a20:430f:b0:157:76c5:8f3e with SMTP id h15-20020a056a20430f00b0015776c58f3emr1171191pzk.45.1694567740993; Tue, 12 Sep 2023 18:15:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694567740; cv=none; d=google.com; s=arc-20160816; b=BOg8nlfnwh7iQqRbTmStFPRZjv8vELEaAsjxlhAD4SRMMsbu/WxU4Gy4Z9HqaZGS1H Vg15+MssT6WeX9V5JHsrAQWpKeRIPS55hiVVRQly7Q7ajSkCO7X31I7l40uVhWgxxOOn LHB0PU80KUp9vXZI9FmgvHsjqRy7RhCO+uRywRmLLx6DOReVCirtTA3jYZE/Puk/0wC3 TO/3vtnBvy7/sT4qsXuyrzIZuaKmH91Grt0xe1/zVUaCm6ePrXqBNepCGgLwzz5yTV97 QMSj302ST8DvPng62SOhrjuFaVQFlu/5y27p5ml6yg14wTxwCRsQnxOsBuXE6OzAKlTb BKIA== 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=F7ofryTO54K0jr1JOGhBSnyWqNvjMzPqbVktwP81LfI=; fh=58X8Twod/aefd4Yph/F0FPyIOMSYi96Sqi5HmPAz0To=; b=DamJtxL+fWbhIC4FUabRhmuOLoIBBXg+0MgBaOxghK3A7l94unMn7iC694bZIZ3R3C 3kWBd5fuVACL2TLezy1v/bWvWohMknEca/Yub2O5rqnjDEAtUxdmNKItyA07e2AeDMN9 EqcbUo0kiklwBIG5RQsfCYKeijHnGJsiGQ9VxUTe8i1iSzEDO8x4ZEgV5tLWSCLI2+ms AaPNyprpt3AxDjm/RJwOANzC/SQ0HqGbISBbiE74jtgWUOICzOiWZRtULeOwETwJN3Xr SU8I5y1oy5xwZHS+BZtxxRGH0C8xVMQltk/fruIsbhLZSNqdTk8Fn/LkORO4htxF4pC/ iBnA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@arista.com header.s=google header.b=ZFxgMiH+; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 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 snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id s1-20020a17090aad8100b002465d98f18csi448510pjq.170.2023.09.12.18.15.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Sep 2023 18:15:40 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; dkim=pass header.i=@arista.com header.s=google header.b=ZFxgMiH+; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 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 snail.vger.email (Postfix) with ESMTP id 609DD835D82F; Mon, 11 Sep 2023 21:47:03 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.8 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241583AbjILDEV (ORCPT + 99 others); Mon, 11 Sep 2023 23:04:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57066 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241704AbjILDEA (ORCPT ); Mon, 11 Sep 2023 23:04:00 -0400 Received: from mail-wm1-x329.google.com (mail-wm1-x329.google.com [IPv6:2a00:1450:4864:20::329]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4F12119047 for ; Mon, 11 Sep 2023 18:38:33 -0700 (PDT) Received: by mail-wm1-x329.google.com with SMTP id 5b1f17b1804b1-403012f27e1so30555155e9.1 for ; Mon, 11 Sep 2023 18:38:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=arista.com; s=google; t=1694482711; x=1695087511; 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=F7ofryTO54K0jr1JOGhBSnyWqNvjMzPqbVktwP81LfI=; b=ZFxgMiH+8bbjeOda0ChsXopEVlAIs4+mHNU7ycfPxQu6omKv5KwxCuwW7dPsq6rX57 OP/hs5TQBMkkBbtZ1E8o8px4tiNg12Ap2OdXpyuE42BQ0+rsWRLciuT8/kuj3A/nreZK VaEXn0OUKxm7YZ9SZ6qhTSdzvffJyM4JWTamx8OLkM5c0wlbuEO67SfCUADpmVNYBdXl xL6pOg2lThNxorQ1PZ5S3WACxHK6rNdyf7wEILR2I5TmXqqBKVVeAq2ZAUeBzYrgmipe JCbmC6zOY/5dJvvYOEZrL9NF+VkYn4FFfk37Ky5tArffOrSHQgTrORjuOKJqPiyt5Fhi qTVw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694482711; x=1695087511; 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=F7ofryTO54K0jr1JOGhBSnyWqNvjMzPqbVktwP81LfI=; b=DgySH3YN0lbDS1jFB0Hkg89UZcUWsfhJk+gXYBnk3v9YW02w+OO/nguT0zAq/rWmNo h3V3+/3f7B9euZg1Zt/rNSqTf+HNY30SCz6wVDsJaiK4OkNfOTzynNPDUBzi2EvgoS5l ksiEVBG+yMNtBsPqPZ5QrTWRfNKWi7JaarPRkOtw8guI+pCRgC/b2al0Iw/JX/8A7P9w Ij8HTxv439IcIOKSkz8DAWrOsxMjUxFqH+zCeloJ7sPRQs0fwXqIinReNEQENoPfzY4B qwowg/lYy5S+FGGutR1d9BS79Ud5o2/OgN+9ZIL5mtU1hLg6b94Jv/W/XByda96JTRX/ w1qA== X-Gm-Message-State: AOJu0YxDd/QROudn1Z7MGuTbjqUthl4I9glSymNJ4RaEfkszXRlqmVZh fTdFO8nOjgwHS7a+1u0YOj2ZNHwjb0cPQwNnZE8= X-Received: by 2002:a05:600c:228f:b0:401:c338:ab94 with SMTP id 15-20020a05600c228f00b00401c338ab94mr9730439wmf.29.1694466266443; Mon, 11 Sep 2023 14:04:26 -0700 (PDT) Received: from Mindolluin.ire.aristanetworks.com ([217.173.96.166]) by smtp.gmail.com with ESMTPSA id z20-20020a1c4c14000000b00402e942561fsm14261699wmf.38.2023.09.11.14.04.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Sep 2023 14:04:26 -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 v11 net-next 17/23] net/tcp: Add option for TCP-AO to (not) hash header Date: Mon, 11 Sep 2023 22:03:37 +0100 Message-ID: <20230911210346.301750-18-dima@arista.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230911210346.301750-1-dima@arista.com> References: <20230911210346.301750-1-dima@arista.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 (snail.vger.email [0.0.0.0]); Mon, 11 Sep 2023 21:47:03 -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 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 a8af93972ee5..ecbf2e217f29 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)) @@ -1403,7 +1405,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