Received: by 2002:ab2:6c55:0:b0:1fd:c486:4f03 with SMTP id v21csp108996lqp; Tue, 11 Jun 2024 16:56:11 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXRdons9vsJyQDVtxun8Fdn5FEP5oQ4RhrW27PPxzlIIaa3yU+tJjWD3gcmqt1lca/Y82otO8xiE0Q6RZeAYpZWyVbfm/uR8w9NFopOEQ== X-Google-Smtp-Source: AGHT+IGbX/iGef6S8WqC+vHdwGgV5F3cEbjmUL3HBbwuIVLFv4cTZNzBB9SUno8XTfyqxRGwNByh X-Received: by 2002:a05:6214:488e:b0:6b0:664e:2390 with SMTP id 6a1803df08f44-6b1a62a3aa4mr1725846d6.38.1718150171514; Tue, 11 Jun 2024 16:56:11 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1718150171; cv=pass; d=google.com; s=arc-20160816; b=ZM26Vo2vY4M4OX8ftNHFofvXh2LAXXG/ASTp6srku4j7OOehMZnuvf11bDJEmJbQmq X2weu1UbrOdFvurXk2R32XY/oE+L5FVKVw8gZBmJdtj7q7vArxTabBVJ4/HM1cTsnIE8 W2/rmMFmn4s9u8Nee/QEFYSQmBeptgp38YzonqikbUSLUFhYo3wdrOtmBtK1+KRaSITW Xb2NKLXiZO65zNmPw3Rmf/QZ50gJhUVQiZg0y6dtzpOSbImvK9/p7uclleiL/gpIu7Cn e8xVnConk4BD8D6bUyeJo2czlUjKyqt6OmT6I+GzQmlH12GAheLQH3HRqTVLPXL3lq+v Codg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=uYHUxwVROWcCDMMznLRsPbuNwTYICXFJzFM01gZbZFs=; fh=frjvUbsquGPigjV6mdI2Sw3TyI8amMB5MY8lXlm26fI=; b=hlGYItUFuf9UguPtmpGLjnNYOyiSDw1eyVTwPHtZWDm9utxYCefDXpuPB1gWT8U1UN OfngH6veT4ATT7vJPb4CtiNytfML9qI4VP3YrGKQ0YuVOxYbcQLB6rrj0roDz3c+bZUD ETmLsK7Aaj0uNDCqSSbJeH2PcUENusA+xSKFLSZmoyjR0rms5TBDHtnoUTBd9rVYiNTB 4THtO2FYzl7CcRyNH5K/+1Fi+LSHQHLs0j6kH0mgTO7gLjVT+MolSTxCf2hokJtGbEze syQxX4cMBRVl5quoJvCVi9x/bU3+7t4QG5YeYrSGZTnJzRTKMKOwGNv0XanliDf2EW3Z QpHg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@fiberby.net header.s=202008 header.b=cXhXVGdh; arc=pass (i=1 spf=pass spfdomain=fiberby.net dkim=pass dkdomain=fiberby.net dmarc=pass fromdomain=fiberby.net); spf=pass (google.com: domain of linux-kernel+bounces-210720-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-210720-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=fiberby.net Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id 6a1803df08f44-6b066dce42asi102443326d6.260.2024.06.11.16.56.11 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 11 Jun 2024 16:56:11 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-210720-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@fiberby.net header.s=202008 header.b=cXhXVGdh; arc=pass (i=1 spf=pass spfdomain=fiberby.net dkim=pass dkdomain=fiberby.net dmarc=pass fromdomain=fiberby.net); spf=pass (google.com: domain of linux-kernel+bounces-210720-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-210720-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=fiberby.net Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 3E0A61C21FE5 for ; Tue, 11 Jun 2024 23:56:11 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 90A85158215; Tue, 11 Jun 2024 23:54:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=fiberby.net header.i=@fiberby.net header.b="cXhXVGdh" Received: from mail1.fiberby.net (mail1.fiberby.net [193.104.135.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E243F156F26; Tue, 11 Jun 2024 23:54:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.104.135.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718150069; cv=none; b=KiiKkedSRGXQexlK093QDBVIbaMEm9ermCR67TEau7QhqAhIAQ0tuSYi3ySwHBSKRibOJ/azs3UOH8d4Gf/rRoPN7rPQ8r1acRp3XcHAgiEA/6cYMXMe/8yVcI3G2DM9EgcmDLoJYgPbrPsBQicTm5kOCg0sjkFvUgOLinu3Ey0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718150069; c=relaxed/simple; bh=zATe/2n/zWdwcgm2mIZEJ9zy1kGHBOn2WYZ49kih8ms=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=NLYti073XduFqBViSd2NWUK5EFFb92kChOXpQtikENbu9XpS50QAnCwnutL4gdAwf5KjsA/oW22zkSv/WluqFVSiTJP94AIzclp8OZyspsuKQj0lW64wX9zvb1ESmJeySR4SynmSvAWGClnRm9RqYDJUBlXQVCI3x6npDI41tRc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=fiberby.net; spf=pass smtp.mailfrom=fiberby.net; dkim=pass (2048-bit key) header.d=fiberby.net header.i=@fiberby.net header.b=cXhXVGdh; arc=none smtp.client-ip=193.104.135.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=fiberby.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=fiberby.net DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=fiberby.net; s=202008; t=1718150060; bh=zATe/2n/zWdwcgm2mIZEJ9zy1kGHBOn2WYZ49kih8ms=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=cXhXVGdhYaLiGkQqorl0NYe68qgmF+N05ooKZjvjIfQkX6NvHJWjT/tPlH/luVj+Z XZ6RxTYuKNVXnlwZnjntVSt5mEjSa2B4iLmXlQVJCt4jq+b/vdqMzDDtwpdpzvPzMH II+ptZOJ/9iBJReV9gcsNFhxo7ZznwRBcGVk+lb4xZkwb9cNoTEhjPZeFXGSloTupY DkyrE3Czfo1AEkMp6m3bNj05YcsTNIX7pQ5/JP4x60ZC20F9Z/sskLPx4pkMw4Lq47 KGYxWsvMc+7ja63NmIerdf8b9IwHnL7WNj64WhDVruLq20JojswFc1kEfXwyIHlZmt WOqGSldHmd41A== Received: from x201s (193-104-135-243.ip4.fiberby.net [193.104.135.243]) by mail1.fiberby.net (Postfix) with ESMTPSA id 505DE6009C; Tue, 11 Jun 2024 23:54:17 +0000 (UTC) Received: by x201s (Postfix, from userid 1000) id 665A9202C29; Tue, 11 Jun 2024 23:54:00 +0000 (UTC) From: =?UTF-8?q?Asbj=C3=B8rn=20Sloth=20T=C3=B8nnesen?= To: Davide Caratti , Ilya Maximets , Jamal Hadi Salim , Cong Wang , Jiri Pirko Cc: =?UTF-8?q?Asbj=C3=B8rn=20Sloth=20T=C3=B8nnesen?= , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , David Ahern , Simon Horman , netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [RFC PATCH net-next 2/9] net/sched: cls_flower: prepare fl_{set,dump}_key_flags() for ENC_FLAGS Date: Tue, 11 Jun 2024 23:53:35 +0000 Message-ID: <20240611235355.177667-3-ast@fiberby.net> X-Mailer: git-send-email 2.45.1 In-Reply-To: <20240611235355.177667-1-ast@fiberby.net> References: <20240611235355.177667-1-ast@fiberby.net> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Prepare fl_set_key_flags/fl_dump_key_flags() for use with TCA_FLOWER_KEY_ENC_FLAGS{,_MASK}. This patch adds an encap argument, similar to fl_set_key_ip/ fl_dump_key_ip(), and determine the flower keys based on the encap argument, and use them in the rest of the two functions. Since these functions are so far, only called with encap set false, then there is no functional change. Signed-off-by: Asbjørn Sloth Tønnesen --- net/sched/cls_flower.c | 40 ++++++++++++++++++++++++++++++---------- 1 file changed, 30 insertions(+), 10 deletions(-) diff --git a/net/sched/cls_flower.c b/net/sched/cls_flower.c index eef570c577ac7..6a5cecfd95619 100644 --- a/net/sched/cls_flower.c +++ b/net/sched/cls_flower.c @@ -1166,19 +1166,28 @@ static void fl_set_key_flag(u32 flower_key, u32 flower_mask, } } -static int fl_set_key_flags(struct nlattr **tb, u32 *flags_key, +static int fl_set_key_flags(struct nlattr **tb, bool encap, u32 *flags_key, u32 *flags_mask, struct netlink_ext_ack *extack) { + int fl_key, fl_mask; u32 key, mask; + if (encap) { + fl_key = TCA_FLOWER_KEY_ENC_FLAGS; + fl_mask = TCA_FLOWER_KEY_ENC_FLAGS_MASK; + } else { + fl_key = TCA_FLOWER_KEY_FLAGS; + fl_mask = TCA_FLOWER_KEY_FLAGS_MASK; + } + /* mask is mandatory for flags */ - if (!tb[TCA_FLOWER_KEY_FLAGS_MASK]) { + if (NL_REQ_ATTR_CHECK(extack, NULL, tb, fl_mask)) { NL_SET_ERR_MSG(extack, "Missing flags mask"); return -EINVAL; } - key = be32_to_cpu(nla_get_be32(tb[TCA_FLOWER_KEY_FLAGS])); - mask = be32_to_cpu(nla_get_be32(tb[TCA_FLOWER_KEY_FLAGS_MASK])); + key = be32_to_cpu(nla_get_be32(tb[fl_key])); + mask = be32_to_cpu(nla_get_be32(tb[fl_mask])); *flags_key = 0; *flags_mask = 0; @@ -2086,7 +2095,7 @@ static int fl_set_key(struct net *net, struct nlattr **tb, return ret; if (tb[TCA_FLOWER_KEY_FLAGS]) { - ret = fl_set_key_flags(tb, &key->control.flags, + ret = fl_set_key_flags(tb, false, &key->control.flags, &mask->control.flags, extack); if (ret) return ret; @@ -3084,12 +3093,22 @@ static void fl_get_key_flag(u32 dissector_key, u32 dissector_mask, } } -static int fl_dump_key_flags(struct sk_buff *skb, u32 flags_key, u32 flags_mask) +static int fl_dump_key_flags(struct sk_buff *skb, bool encap, + u32 flags_key, u32 flags_mask) { - u32 key, mask; + int fl_key, fl_mask; __be32 _key, _mask; + u32 key, mask; int err; + if (encap) { + fl_key = TCA_FLOWER_KEY_ENC_FLAGS; + fl_mask = TCA_FLOWER_KEY_ENC_FLAGS_MASK; + } else { + fl_key = TCA_FLOWER_KEY_FLAGS; + fl_mask = TCA_FLOWER_KEY_FLAGS_MASK; + } + if (!memchr_inv(&flags_mask, 0, sizeof(flags_mask))) return 0; @@ -3105,11 +3124,11 @@ static int fl_dump_key_flags(struct sk_buff *skb, u32 flags_key, u32 flags_mask) _key = cpu_to_be32(key); _mask = cpu_to_be32(mask); - err = nla_put(skb, TCA_FLOWER_KEY_FLAGS, 4, &_key); + err = nla_put(skb, fl_key, 4, &_key); if (err) return err; - return nla_put(skb, TCA_FLOWER_KEY_FLAGS_MASK, 4, &_mask); + return nla_put(skb, fl_mask, 4, &_mask); } static int fl_dump_key_geneve_opt(struct sk_buff *skb, @@ -3632,7 +3651,8 @@ static int fl_dump_key(struct sk_buff *skb, struct net *net, if (fl_dump_key_ct(skb, &key->ct, &mask->ct)) goto nla_put_failure; - if (fl_dump_key_flags(skb, key->control.flags, mask->control.flags)) + if (fl_dump_key_flags(skb, false, key->control.flags, + mask->control.flags)) goto nla_put_failure; if (fl_dump_key_val(skb, &key->hash.hash, TCA_FLOWER_KEY_HASH, -- 2.45.1