From patchwork Wed Sep 11 09:37:43 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ido Schimmel X-Patchwork-Id: 13800130 X-Patchwork-Delegate: kuba@kernel.org Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2086.outbound.protection.outlook.com [40.107.92.86]) (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 7F82417C7CA for ; Wed, 11 Sep 2024 09:38:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.92.86 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726047518; cv=fail; b=pwrTgQWYePgoAY6XCxXpIifZAVAr79I6ssv8a0HCKiXjQB7HIqpxDeMinVOzURuoh3dTZLlfthKIrhLY5pjPsXS4HfdqR0GbEpgJ8FUL+ZAhBSXl3tsfU7eexHsaTPfpMTOqJY5Qo+XLXYIdGmi3/gUvZfkT1HwX0ZD6IYFOavU= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726047518; c=relaxed/simple; bh=460hLHpl9Zz7UNh2JtjQGjqothUXaYVB6xDvr3qC7No=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=lejhjDFuSX1hWVQaa7i9wfFEMuSBKs03Ld+9bl+v8NG6914XMJr7L19rTmZe+rYU1uyVJdkLFuo30T5OexjgEqfe3fC1xxaGYSdUBI2XJg24zNAEjxFAA419RuJ6qCX6+O/hz/8GECiusx96EpLeIYfLvl/RbdtpSNNDHb4uqXY= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com; spf=fail smtp.mailfrom=nvidia.com; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b=ripSTK0K; arc=fail smtp.client-ip=40.107.92.86 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=nvidia.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b="ripSTK0K" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=Sl0hDYifyuK2IaA3rwJbryP7MBX9VjWQMe1+xR18x+Mfep0XmNNlPN12JYpFqcnzWTq2h4elT1A8c9xRYCPX2czaHdIQRNwZY8ghd8YxyMC9XA2fsOfO9Iy72yLph/118V4n/UYpOjQCykCBEQluJe+hR9VPJWNE4fO+GcitA+uUj1/zSNa4jKn9v6m6gzTmFtN6a3l0r2382joSlNHUYOUNAknSSrya7MlQjXQQzPNuonjLSrXMlCo2SyVckZcoxSdbVoBrEpDDQCdClSLupWSibjQ+Vq1b1FpV3zZ6O8IQ2JW7raNyrhw7ZvXq+gr74V1Reha4mkZhbHFgMey4+g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=yHHOF5VS+8rv4qPrXstPPcwy4PYrsM+LX6piabpaCLE=; b=d2Byp5pWDKTYvHKtOpIJv18udnJ7CUxyMlDB2kiRjN5I71qWEToVwuDdNpJinlTgyoD8hS53GIotLYQoS2V8+mNyj0bUVCC9HuHKYJO8QZ255VRa27v5o0fwIk/v3KrT65QS2andPvHjrwI+ipJYtdRcWeKC+UodP00pD7QLAWWrCvm4+zTyv80USPD1zHKjb/MDKlecnHOIB2zm28tcCUQG9BcAB2hmh5Z2pd3/A9XLUCL+0rn0S2c7Jk2MC+YpBNvU5crngUprYjy2cgnVecdWo/y5bXSzHdy56IxsstJce96BDCzIEy54yJJrkf0zOHLzTuhiJhJJ5yP87YAnvA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.160) smtp.rcpttodomain=vger.kernel.org smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=yHHOF5VS+8rv4qPrXstPPcwy4PYrsM+LX6piabpaCLE=; b=ripSTK0K66gtD1hcpgJh99dcCQ9blZMKN5IVnAVnISbyG33edbroA5lk9ZXXI+A8cP6v64pKLwz6I5//tQTdwlo1aduLqXo02WZC8WJlvhR+PgK+/pdHVZeYjXGXvN0Nnz9GSvsDMI+4aBX5Q7f84wkWT35BtSRR/PSyYJ0r1cOhpetqP2J8V1VB1PHOHY95MGBDnDH8SpqpWrwTYyCfUWwXEqwu1JAJDRsxPR/ONxwTeR+vbc9hePRvvhxXpbc1SkBAwp+0YPFVGj1UVPOgXknfch97AEKHMmUeZ2YczW7R6+70qoIdA2D8uBaOpxEnfi5G0p0a9bw0a5NXUPz3tw== Received: from MW4PR04CA0298.namprd04.prod.outlook.com (2603:10b6:303:89::33) by CYXPR12MB9337.namprd12.prod.outlook.com (2603:10b6:930:d8::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7918.20; Wed, 11 Sep 2024 09:38:30 +0000 Received: from MWH0EPF000A672F.namprd04.prod.outlook.com (2603:10b6:303:89:cafe::23) by MW4PR04CA0298.outlook.office365.com (2603:10b6:303:89::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7939.24 via Frontend Transport; Wed, 11 Sep 2024 09:38:30 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.160) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.117.160 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.160; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.160) by MWH0EPF000A672F.mail.protection.outlook.com (10.167.249.21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7918.13 via Frontend Transport; Wed, 11 Sep 2024 09:38:30 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by mail.nvidia.com (10.129.200.66) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Wed, 11 Sep 2024 02:38:14 -0700 Received: from shredder.lan (10.126.231.35) by rnnvmail201.nvidia.com (10.129.68.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Wed, 11 Sep 2024 02:38:10 -0700 From: Ido Schimmel To: CC: , , , , , , "Ido Schimmel" Subject: [PATCH net-next 1/6] net: fib_rules: Add DSCP selector attribute Date: Wed, 11 Sep 2024 12:37:43 +0300 Message-ID: <20240911093748.3662015-2-idosch@nvidia.com> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20240911093748.3662015-1-idosch@nvidia.com> References: <20240911093748.3662015-1-idosch@nvidia.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: rnnvmail202.nvidia.com (10.129.68.7) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MWH0EPF000A672F:EE_|CYXPR12MB9337:EE_ X-MS-Office365-Filtering-Correlation-Id: b6079ca1-45fb-4d08-1fe9-08dcd2457f09 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|36860700013|1800799024|82310400026; X-Microsoft-Antispam-Message-Info: cXChPQ6zK0Qw5cZgqHY6uti+F0fx+yVhUr8x+EUracLYMJP37xhLmi7/y8DI3ueera4x8UPyeBHLI7EvUWjTt56FxNe3vQBw/TC7YTFN45eAUfPv+CrU8YoxpXc/TkbjXgO/5uTpRcr19w7e7sfKc13Mt56tL2BQF5dPW4HrOOlWiwpQLf71I/TZ70FC+s3QMGzj0iggHkHZriAU5gEei/5MsKZcF3bTFl+11fmu2ZeXVx1KNsqsEt93KgzOKYE2tIh2HcjG0ycPG7yOgbi95guH42HjSxsDwrkX93LUPyhQmpPaAnjYJ1vQ5uG9VyX7GXKLiGQ8Fu1EAZcS3N5WGTe6AJ9DAbhJ24jyvz4o8sko5rUPUK4s0feLW+NjwboPgQLx4YzgC7PDRgENGZqtAqDbpIADfSFlBfUPTI3NQ2kMDqdB7cm18EJZhWFiHGc5EqZ+d6Ut/vIlSs7XbA1fm980veMybXmxeipGaI8R0YF+AgjMcd6BTlogx5YD5HxaTuuIO77RiiEMEotfdcDSUU/2FPmijue3CpxssDS3IQwXLG5B11ibkS28BH0YDN8wBy4VsTomhcyv/VkaD1BJ1mwDlaJk58XxKBrGftSHso+xtihWYVtqttEOTfkGlDAZuAtGIG71k26W2lCpcwwRvEdCg2f07Lm01OB4P6h1A5Yn1u2ICQOO1AGyg+LrendLmDkgXVo6pLIGx/Qqerxmtqk0ZTyzDsd7HqkwaPzO+e43CHoAFUVVk8vm03oyGhD3MH/TiiXeF4df3FjkLL6HQ+ae5npRGuby080e9eXW3G5VSOsA9eDV83z3s9hupzkXqhooqn7JBLmmZh4KkhtTUlGbiKw8EYi9Ym/+spRZ/dKjKt4DVnNaJWy8kNr7517BOFvTTRMHP6ruhgVHTsdmvHx7F9qZ62Ohmibiu4CGEvqqBGcPbx7ayboEBoWeJxQeDb3h+5ww5BqX7haqeyw68PfeJCHVK4O4pjAEzKeKxcfIi+r2oUov3pGQiVw8JrQdaQN3wPrAWs5DR8w5m8pEH9K5821i/vUDArIc3M9ZjktScN4Xq33hy3N8vOBs6BFTojFekU9N4aCaXinlRrT8BjfiddmP20z+oFHjHle8+71qGmIbiqpN+/K12ZvDI45rSUvlmczXF7tYiP+bvyYsiISuxagMjSpC7rHZFUT0Rhv1xQw+EFsQJaPrsM7N/rOnA65CA2as//HeF4UC88kAHYxkct07vuRpQcqu2yVAsLkok7jakUfJl6JcunGF+mMn49/vGVv+4RNkGOcRaleGSAF3/c8VDC1/PzhjxIuPdaLwHcBLqZ6UwJv1GevHzUpamSFote2RMeN9MHjSBgwPEmexGfakRUz0FJatlkDQCfy4v0Q9ptjNB3cAxSfH98StUsm/JIs9IlEZhcoF0NTZh7a/+J3udv/By8EnzUKNBIAjNtyZ9QhnowSdV0XnxkNs X-Forefront-Antispam-Report: CIP:216.228.117.160;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:dc6edge1.nvidia.com;CAT:NONE;SFS:(13230040)(376014)(36860700013)(1800799024)(82310400026);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Sep 2024 09:38:30.4711 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: b6079ca1-45fb-4d08-1fe9-08dcd2457f09 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.117.160];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: MWH0EPF000A672F.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CYXPR12MB9337 X-Patchwork-Delegate: kuba@kernel.org The FIB rule TOS selector is implemented differently between IPv4 and IPv6. In IPv4 it is used to match on the three "Type of Services" bits specified in RFC 791, while in IPv6 is it is used to match on the six DSCP bits specified in RFC 2474. Add a new FIB rule attribute to allow matching on DSCP. The attribute will be used to implement a 'dscp' selector in ip-rule with a consistent behavior between IPv4 and IPv6. For now, set the type of the attribute to 'NLA_REJECT' so that user space will not be able to configure it. This restriction will be lifted once both IPv4 and IPv6 support the new attribute. Signed-off-by: Ido Schimmel Reviewed-by: Guillaume Nault --- include/uapi/linux/fib_rules.h | 1 + net/core/fib_rules.c | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/include/uapi/linux/fib_rules.h b/include/uapi/linux/fib_rules.h index 232df14e1287..a6924dd3aff1 100644 --- a/include/uapi/linux/fib_rules.h +++ b/include/uapi/linux/fib_rules.h @@ -67,6 +67,7 @@ enum { FRA_IP_PROTO, /* ip proto */ FRA_SPORT_RANGE, /* sport */ FRA_DPORT_RANGE, /* dport */ + FRA_DSCP, /* dscp */ __FRA_MAX }; diff --git a/net/core/fib_rules.c b/net/core/fib_rules.c index 5a4eb744758c..df41c05f7234 100644 --- a/net/core/fib_rules.c +++ b/net/core/fib_rules.c @@ -766,7 +766,8 @@ static const struct nla_policy fib_rule_policy[FRA_MAX + 1] = { [FRA_PROTOCOL] = { .type = NLA_U8 }, [FRA_IP_PROTO] = { .type = NLA_U8 }, [FRA_SPORT_RANGE] = { .len = sizeof(struct fib_rule_port_range) }, - [FRA_DPORT_RANGE] = { .len = sizeof(struct fib_rule_port_range) } + [FRA_DPORT_RANGE] = { .len = sizeof(struct fib_rule_port_range) }, + [FRA_DSCP] = { .type = NLA_REJECT }, }; int fib_nl_newrule(struct sk_buff *skb, struct nlmsghdr *nlh, From patchwork Wed Sep 11 09:37:44 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ido Schimmel X-Patchwork-Id: 13800131 X-Patchwork-Delegate: kuba@kernel.org Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2080.outbound.protection.outlook.com [40.107.223.80]) (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 2F29539FF3 for ; Wed, 11 Sep 2024 09:38:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.223.80 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726047518; cv=fail; b=dN9oDFiOb1J5KxC6HJ7A4o0LNzxBygWkOQbAzrDHsWWWdqmLawXVKLZeqkMUbFJjuhk7I+HYtIWRBfeukEZxDYjrcn2hABcQwo7fyJeLyPEUBuFPvAjchZ3jPVVoYRFsVLoRSyDUEl3+d0bDGv5wlUyrjQDhaHaUjQ3uw7HCmq0= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726047518; c=relaxed/simple; bh=Af7KONBFvon/D5HMVVrkT3BIFFl4a1ZDMyGB3XQZmvI=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=fcOawU/I3fwqerGGUL/T77TYKK30vGjPzV9AzL+rx/8K57o60eHfWsDhejccQUZmS/Ti2pTJFiFOKHk9BTEipyN0Yh++Bl7VIXIYL399CyM9gIGBY6IrIfvlpNpxq+oIfEaiDXyxwPWisTCFe4/GEculZMyDkt4opKt5Xo+M4DI= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com; spf=fail smtp.mailfrom=nvidia.com; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b=oKw3yr04; arc=fail smtp.client-ip=40.107.223.80 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=nvidia.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b="oKw3yr04" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=jcfBqpdtySKOn4Rd5jDHwZMjVLOqAWpR+Aw2kWCYBNbKnBxwq3ucGMe7UW2BcL92UYETXK1YuO37pYJ63RPR+rDLoSwAu9xfhXYN7aDO+9VbJFyuv/K+nvacVTmvuhQgJyRW3tWTjxJRQT/kiXkuSUJFS5Lu0bqrG4w+RRoXfcZiOQFxs0mZI/CACg+GnUTPMHBlg4zslbEV8gt7r6T7ypKdsFvFjGTxDLi8TA3C4KoLR3myxCkk0cqtrADVYuVTiJT4ksoSd3UcOoqCMMg6HMg+XPvy8ozN524W2OQ9eyNi+/iRiPJ52deI4qn2t0/rD9UZzlky/p37FApznXjmDg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=5l5M7MNYkupqF3wT/36K79w15PSDgq/MBcgwnzNi75E=; b=osMbpVHXA8YgrcUySpKKAe5h63uFy/twyX2PZ2ZlMV0o1FLgTtGnNAqKn+6F4SRqzQeCUqztiBwWQql9iTqoW2UIoQkEiA7Py8dEw6VDGtIyhq1g2aZYNfB0Eg2RJpEMhH08wHb9YnqUUhHVdtlg/C5y35/k4c6T0H1IHv5HFdRrcxWB+P16Hp5sK5NJTLLCDIOs5/R51oHJz92sYW/AITUQzY1U8Xcwbf8tk+ugr/CX9tQsmVMPVid4CKfSJptPmEX5t1YzWRrDFgnw9EbTKRMxTjchiRHYsdKIqbAXTvZdcbBu/T0X6IOh9IRhY9D0V8ADQyPiH4VfMRPZqmT5kQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.160) smtp.rcpttodomain=vger.kernel.org smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=5l5M7MNYkupqF3wT/36K79w15PSDgq/MBcgwnzNi75E=; b=oKw3yr04BmVW+UU90T25IUREA+PxZYnguZXqRaI5HvklTVQgnMOHOnGJ9XSzhac2SyU/+u4scdBJ1dS4cwKgRDqr8bHmGOCODozCgRtPiTVMsRvl2tE4OFI//3jhDSQWWwgigTvSeIttpwHfwZvo43+RCJ3Nje+OriVpN2etrTU8uUEK0iwPSGOO5VWlJUhzczz2HMemCShDhD/p2igtrPeyxaUJe1pWHWPKfOputQZu9vlYhe87GmsyOeMPnvsYAAU1JtPxRQjeuZJVuCs38gs7Vw27dJ4hYdslD4rii7IjoF1GSDFBqrLxiNEMukCB4w+q0L9dBH6ariVLTV7LtA== Received: from PH8PR07CA0046.namprd07.prod.outlook.com (2603:10b6:510:2cf::24) by CY8PR12MB8194.namprd12.prod.outlook.com (2603:10b6:930:76::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7939.24; Wed, 11 Sep 2024 09:38:33 +0000 Received: from MWH0EPF000A6734.namprd04.prod.outlook.com (2603:10b6:510:2cf:cafe::45) by PH8PR07CA0046.outlook.office365.com (2603:10b6:510:2cf::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7939.24 via Frontend Transport; Wed, 11 Sep 2024 09:38:32 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.160) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.117.160 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.160; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.160) by MWH0EPF000A6734.mail.protection.outlook.com (10.167.249.26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7918.13 via Frontend Transport; Wed, 11 Sep 2024 09:38:32 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by mail.nvidia.com (10.129.200.66) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Wed, 11 Sep 2024 02:38:17 -0700 Received: from shredder.lan (10.126.231.35) by rnnvmail201.nvidia.com (10.129.68.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Wed, 11 Sep 2024 02:38:14 -0700 From: Ido Schimmel To: CC: , , , , , , "Ido Schimmel" Subject: [PATCH net-next 2/6] ipv4: fib_rules: Add DSCP selector support Date: Wed, 11 Sep 2024 12:37:44 +0300 Message-ID: <20240911093748.3662015-3-idosch@nvidia.com> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20240911093748.3662015-1-idosch@nvidia.com> References: <20240911093748.3662015-1-idosch@nvidia.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: rnnvmail202.nvidia.com (10.129.68.7) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MWH0EPF000A6734:EE_|CY8PR12MB8194:EE_ X-MS-Office365-Filtering-Correlation-Id: 29201721-123e-4c6c-b784-08dcd2458054 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|36860700013|376014|1800799024|82310400026; X-Microsoft-Antispam-Message-Info: LLvyZLhdUrmvTpDej2Qz3lBzIyit8ZSPWYN9JO1vRA3me3AgLeYQEdTVIjnWYQAkzQlfSj8K2lpZ4MpbnPd1UmW+kz5IPrE0Zk65wkhIPGCmSXJsbJbxGxfBI5c6cym/JHrvmSgKQTwxTqjIgO0kmiB3pitGUZf29m7TcBo0OxL1EqjV+1H+wVu9V291FqFZfqjmd8FEVAD93WTGgWJJJTl6mu2uaAnv5bFB/j9cr83EjXhPFK5n1a5VPYiAvqxrptil3Ag8brxbFl/mtlvN1qiTQqrCmUqeyIjWek2TyonIDdvdnubzqu1DJJgzBQ1cl49TQ9GpI2NQ8kzehnZBJj75uabi4689JmKB04iKExYNrCMwMaLYz00KNWh7JHAAmMTHzt530WYbZx1cNP18wmjClVTSK8NdE3MgokFZb9AWB2EcGZBGkpD1UVQwBrjKQTGQEjdcCvE+aMJpPsl6mbQkYtNOYnFrtlDBGwiJDW38q+8JsiERVb3ZTFWeQOykCgvXHMK9vel19pGP+vgJ8ht3geVGSCTwTKbvploGCJFluFwJbfc2RdXAjPzdT5o+ztDhicNDVSjZ/7fP9seqs0TjhwWrY0uje2EIlt4yuaro+DjDDj2nB0DGmM9MsVVEEMpqVB/juSucDpMSJdpDJeeTPAXicBbaSrQ3HeSQIJEMqi+v//NSebkb3PTvyWjq7gzyikdsVoPQqdquGzjXg5B7y0UjCrkoHCO6/XAAsMDxWjtgFOv06wsnogqD30cIopOcWqp9AAkc/gINZM6fqnfnKqKpbok81/xPt0DMPZCjj4ersa/jSCh4aiI2gwQtBmfgEk7I+wm7dq0WMPQqwU68VxW4jqippfib3tFdVLMW6KefBS+z/rd9qCu/1r7CBItgPlyOwLyapByvGY0hC5Nbwvp71kV8BMXVmOSLBctxz1uf3nGBc/ej2Z3jTtHAeJcHWiIb/IKcpGP7cbpCV6WSDhY3Bck3/dPiJLo40HlLmLoXVrF5jPq/XpdH4l0eo1E/lTpWLfDc5AABiSKxsK9lHh1vW1/gkUC3Cvj3YS2HNoY2yhVVsAYrVc8SJn/fXxRhPboTeNQxjCIVf6psfnv0rde4mIQGx8bI9sDO8NPRPO1KU/cpWtneTJrKU/no1YQUUlPBUfEPeHVEp3wzNs7WjjcDGBef3ZTU3XJf74yq0Pas2uAxC9ObThdS41ze8isd2tsJft14a+vevz/X0h8N8uvT7k5Scf/d4kCL/kPMF4ya+8Ie7U50Elk+Cohg6ZDs1evO/zQ+hpU7Cp8zVm9OH/B3Nu7ULV248GOP//DBbZqhLEq2bvza2Kp7J/mXwm96w7foUFx4fnO9V79pUwy0VPpvAdYvDmwW9TKL91U0+T9NVD5uiwXdY8Nzpams1BiLNVhaIALH8WO3rV3fB58e48CSovFJdB2OaIf+KxQ= X-Forefront-Antispam-Report: CIP:216.228.117.160;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:dc6edge1.nvidia.com;CAT:NONE;SFS:(13230040)(36860700013)(376014)(1800799024)(82310400026);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Sep 2024 09:38:32.6442 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 29201721-123e-4c6c-b784-08dcd2458054 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.117.160];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: MWH0EPF000A6734.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY8PR12MB8194 X-Patchwork-Delegate: kuba@kernel.org Implement support for the new DSCP selector that allows IPv4 FIB rules to match on the entire DSCP field, unlike the existing TOS selector that only matches on the three lower DSCP bits. Differentiate between both selectors by adding a new bit in the IPv4 FIB rule structure (in an existing one byte hole) that is only set when the 'FRA_DSCP' attribute is specified by user space. Reject rules that use both selectors. Signed-off-by: Ido Schimmel Reviewed-by: Guillaume Nault --- net/ipv4/fib_rules.c | 54 ++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 50 insertions(+), 4 deletions(-) diff --git a/net/ipv4/fib_rules.c b/net/ipv4/fib_rules.c index c26776b71e97..b07292d50ee7 100644 --- a/net/ipv4/fib_rules.c +++ b/net/ipv4/fib_rules.c @@ -37,6 +37,7 @@ struct fib4_rule { u8 dst_len; u8 src_len; dscp_t dscp; + u8 dscp_full:1; /* DSCP or TOS selector */ __be32 src; __be32 srcmask; __be32 dst; @@ -186,7 +187,15 @@ INDIRECT_CALLABLE_SCOPE int fib4_rule_match(struct fib_rule *rule, ((daddr ^ r->dst) & r->dstmask)) return 0; - if (r->dscp && !fib_dscp_masked_match(r->dscp, fl4)) + /* When DSCP selector is used we need to match on the entire DSCP field + * in the flow information structure. When TOS selector is used we need + * to mask the upper three DSCP bits prior to matching to maintain + * legacy behavior. + */ + if (r->dscp_full && r->dscp != inet_dsfield_to_dscp(fl4->flowi4_tos)) + return 0; + else if (!r->dscp_full && r->dscp && + !fib_dscp_masked_match(r->dscp, fl4)) return 0; if (rule->ip_proto && (rule->ip_proto != fl4->flowi4_proto)) @@ -217,6 +226,20 @@ static struct fib_table *fib_empty_table(struct net *net) return NULL; } +static int fib4_nl2rule_dscp(const struct nlattr *nla, struct fib4_rule *rule4, + struct netlink_ext_ack *extack) +{ + if (rule4->dscp) { + NL_SET_ERR_MSG(extack, "Cannot specify both TOS and DSCP"); + return -EINVAL; + } + + rule4->dscp = inet_dsfield_to_dscp(nla_get_u8(nla) << 2); + rule4->dscp_full = true; + + return 0; +} + static int fib4_rule_configure(struct fib_rule *rule, struct sk_buff *skb, struct fib_rule_hdr *frh, struct nlattr **tb, @@ -238,6 +261,10 @@ static int fib4_rule_configure(struct fib_rule *rule, struct sk_buff *skb, } rule4->dscp = inet_dsfield_to_dscp(frh->tos); + if (tb[FRA_DSCP] && + fib4_nl2rule_dscp(tb[FRA_DSCP], rule4, extack) < 0) + goto errout; + /* split local/main if they are not already split */ err = fib_unmerge(net); if (err) @@ -320,9 +347,19 @@ static int fib4_rule_compare(struct fib_rule *rule, struct fib_rule_hdr *frh, if (frh->dst_len && (rule4->dst_len != frh->dst_len)) return 0; - if (frh->tos && inet_dscp_to_dsfield(rule4->dscp) != frh->tos) + if (frh->tos && + (rule4->dscp_full || + inet_dscp_to_dsfield(rule4->dscp) != frh->tos)) return 0; + if (tb[FRA_DSCP]) { + dscp_t dscp; + + dscp = inet_dsfield_to_dscp(nla_get_u8(tb[FRA_DSCP]) << 2); + if (!rule4->dscp_full || rule4->dscp != dscp) + return 0; + } + #ifdef CONFIG_IP_ROUTE_CLASSID if (tb[FRA_FLOW] && (rule4->tclassid != nla_get_u32(tb[FRA_FLOW]))) return 0; @@ -344,7 +381,15 @@ static int fib4_rule_fill(struct fib_rule *rule, struct sk_buff *skb, frh->dst_len = rule4->dst_len; frh->src_len = rule4->src_len; - frh->tos = inet_dscp_to_dsfield(rule4->dscp); + + if (rule4->dscp_full) { + frh->tos = 0; + if (nla_put_u8(skb, FRA_DSCP, + inet_dscp_to_dsfield(rule4->dscp) >> 2)) + goto nla_put_failure; + } else { + frh->tos = inet_dscp_to_dsfield(rule4->dscp); + } if ((rule4->dst_len && nla_put_in_addr(skb, FRA_DST, rule4->dst)) || @@ -366,7 +411,8 @@ static size_t fib4_rule_nlmsg_payload(struct fib_rule *rule) { return nla_total_size(4) /* dst */ + nla_total_size(4) /* src */ - + nla_total_size(4); /* flow */ + + nla_total_size(4) /* flow */ + + nla_total_size(1); /* dscp */ } static void fib4_rule_flush_cache(struct fib_rules_ops *ops) From patchwork Wed Sep 11 09:37:45 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ido Schimmel X-Patchwork-Id: 13800129 X-Patchwork-Delegate: kuba@kernel.org Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2048.outbound.protection.outlook.com [40.107.93.48]) (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 3196E17BB0D for ; Wed, 11 Sep 2024 09:38:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.93.48 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726047515; cv=fail; b=MAUFaLZ95qcFlTuGxE6Ors6lXd09mnkkUkR8Q1e3K7m1F5+WPprGR/Yt6wtklwFk5t6ni+Hww/J9JnmI6rtCBzraKnmDi3ocR7xe3EgtaweOPe2jav3YWNfk/qSlS7MW1xG51DmqXN52TmEpjeamRgcEGUYzFfAeP3eAi6nNIss= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726047515; c=relaxed/simple; bh=yt4SmNf5hoi3KHwArIyKrRYIyNn1RlouTVs/Vjfebps=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=M1C/S8ZmMq0Kq8qIzp6dX0k12F2yP4CG7KGzLkVm0FrFHTih+yWvfaEgJD2zNmVvukLdn4m0Tyt4UMkI+DKHjCnTlAUXji24aO40x+tbVFPaE+IpZF9ClRF/apVrclNDe0neMZOuU+v1sajoRBVHlgt5yrghUV+5b0elSPl/Tp4= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com; spf=fail smtp.mailfrom=nvidia.com; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b=RwtHlKNf; arc=fail smtp.client-ip=40.107.93.48 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=nvidia.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b="RwtHlKNf" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=FSvzV23EMODatDUnQuL0JmRUKFs8pHfWWs8pMiOA5G0B6qZC5pDzOWVJyk5VFeDmevDEZtTTQ8cMbB8XCTEVrMYMerxzlxd6wr6+bnGWBG1oimXs98VukS8ktHe8eXYd/gar5xVXxjEJPO63ajssQtPF2GbBw7IpXR+fMTJKsrMBiuIrFoNJP0EKnzixPNRK1wWpsT0Z3P/CbEvJnF1GbrEh8JOpBgoX8icBpJ/TB0Co+eFc+m5oCp6MQxomRYuottg0reMLTn+f79+9d4SVIurobwwIEN4fXBYLFNZM0DZxMPexJiRggkPsSAcoSsv43rHTVkl8K4AV9x4zOt3lgQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=/khUBJyvSZlDwnsk71M+7WrbfUVT6+Q27PMLCPOKM3s=; b=YWI8E76xifcLGwWHhjWRZId07HB52YZAHXdfEq+JKwh6x1efsMMpkjCPfu+8LEldXjtTUfprNqKU8AZx+Dr/ie0AgrnDNfo/hnBWTx3hz2XQmjkKRVo/YjZ2gmlI00gUss0BA51m+clsRNdPT8+diCVUWocHW5InFjH2jYm1+UWS2s7kKo+MxrWeBKLDj5ofdlUM2ASIXPUt1Hfj2+j5Q28ilMa1yn2wrXsLQPHgVrrq58tIHtDdtVctLOoWH0arqu7JyBzk+YxAj+EkqbYKOlxra7Eo99BGuXV73ocEaO8FN/G4aW3pZlqm6I9PmoraiicGgGPSWLskvT9s/Z7LSA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.161) smtp.rcpttodomain=vger.kernel.org smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=/khUBJyvSZlDwnsk71M+7WrbfUVT6+Q27PMLCPOKM3s=; b=RwtHlKNffzhSHwku8Zmnf6O/UGuZk42Zax1ffg+D6z+Xs0crsM2w744wp7evugM16Qt4jJnJrVwmmGFfJgEYBHAtvnaVnbWDMsYr3io8YotMqWNWlahwAHPD8AasnE5jxE8PxudpG2zUGa3jEFZkJ09HY0xQoeXMw9cBnoVRyiT/3UfqOPPGNuNQwLFjcXy1RdASLWCUwfdcEHraGMOkjf6I5vdvnKI0vAr9GOIojccyH38ptU0oeZoZ+dvCO8T5i+lVOQH6JKmRbuUccCEqNLk2g9yPBflEN6gYlrEzPR5hQn+WmwxmvS3/gOB48P5MKMa2+w0vOYiBbV0dO3vcEg== Received: from CH2PR07CA0051.namprd07.prod.outlook.com (2603:10b6:610:5b::25) by SJ0PR12MB5663.namprd12.prod.outlook.com (2603:10b6:a03:42a::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7918.25; Wed, 11 Sep 2024 09:38:30 +0000 Received: from CH2PEPF0000013D.namprd02.prod.outlook.com (2603:10b6:610:5b:cafe::13) by CH2PR07CA0051.outlook.office365.com (2603:10b6:610:5b::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7939.24 via Frontend Transport; Wed, 11 Sep 2024 09:38:30 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.161) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.117.161 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.161; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.161) by CH2PEPF0000013D.mail.protection.outlook.com (10.167.244.69) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7918.13 via Frontend Transport; Wed, 11 Sep 2024 09:38:29 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by mail.nvidia.com (10.129.200.67) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Wed, 11 Sep 2024 02:38:20 -0700 Received: from shredder.lan (10.126.231.35) by rnnvmail201.nvidia.com (10.129.68.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Wed, 11 Sep 2024 02:38:17 -0700 From: Ido Schimmel To: CC: , , , , , , "Ido Schimmel" Subject: [PATCH net-next 3/6] ipv6: fib_rules: Add DSCP selector support Date: Wed, 11 Sep 2024 12:37:45 +0300 Message-ID: <20240911093748.3662015-4-idosch@nvidia.com> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20240911093748.3662015-1-idosch@nvidia.com> References: <20240911093748.3662015-1-idosch@nvidia.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: rnnvmail202.nvidia.com (10.129.68.7) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH2PEPF0000013D:EE_|SJ0PR12MB5663:EE_ X-MS-Office365-Filtering-Correlation-Id: 4bb6783c-00dc-41c0-f0ab-08dcd2457eb6 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|82310400026|36860700013|376014|1800799024; X-Microsoft-Antispam-Message-Info: r4zsCBMz0XqFZHvk7Z0iJQAQubquD41ISLPA7quRK4nm405Yi+RJM1VE22OHdzdjeGAa1t1Jcf7LlkzGZ5orj3vaHe4hxMakDC9FkhanHCwfS571DgQMmbFVTLoIUqoFJ7JFA6phFwkwMdqLOrx3l6+AIlGYXOmrLDzAWJLqzN8o+CEiAA1T8ohz5qnXx09YWk/mSkYwmGa8OdFSNarMdnw1isTiKEcbnUxXIOY8LXaNrHSFSDX2ooZIhhN7pWT8nsQtnc4dAiJc0S0JM4WmXBciMxahUycIK8ywk4Igp1OQCBnTY/KUTRWUVTHp5cs8Ritzaf/RLXnZbMUjRhWZtF76qND3MuCuRz3DnMkV7Fraovv1k2pqHNtVqq0p0VGBRetj+sv8iWUubJZSKAQVY+pTmGIqXQy4PEgLiM0ssblXHJF7Wn2j9fnR4Rs4kwmltzk2Cx6W2UAipYzxG9r9WpXTooWKQucYpz1jSErQB2oGzbnBM4oUeoYuOlocpmYn0PatMjCQ+WpQ1/V4cY/7YHN6ux4zlfYC2DSFG7hta8LOcehZIPuT5LWUhIJAz51MvS3zg9hJdgq9DutC2kODTvKmqnSoaWwVK9ZLdMn2oNAO8HkhCxr/A6RRVhrXvLlh3ezOHitCOKcANR+Woi6bJZjxM8O0eFqzbayzpHczJZORoBd75jgrqQT/VeyZFBHlZUClMA8F78uW5+waupn0dNiVr/bWMSPAk7yBdsqG66fhoetdTGu9vyG0+gTaFXFrhqYmV1vW3A59uWzPh0SYcTUSyJfS3XK7HwRMkTmDctaH+c4lMLHXKTZ8BY3lAXF+qhp/Gh37ImJep0JzAUGAbH7OwkHAQeLNNtTdzxoh6cOgfxlTuUDqj1PVTURyzizIZuA8s+6z6iapwkDs6V2YRRrkTfF3Q1sFBwJXRdZLDJLJWNw58GoHauDuLFjEgNuSBRdRR/hEF9LrmNWat9mEKN5BCh7mRfP4OSwzdx2Df6Vf9mOCN3SqLRMfrBmgJVXSSdgLMRyyhPLpTO0lkalNxfq5tE4d+LTiKUO75txMKfnizBynF1ZPxURFvTPcwjSduy5GYjtGWWy3o92u7FUWfxk8Bztz9PeZ9g84rgNIVWPUx9gfztf5Knqfkn/y66MwI5IxkylGAEmnqy4g3o6FyGL3oQoGsPLMVMTAyW9FgzM1xdIXj2BB6cgVDvaLMFq69BLpcjF0+O1+Ox9MXBCzU0K5m/ajWINDxcceJ2uGJqH3zcHK3WsAygP+jhTK9gqiPQzDD+uEi1Am3sQV8GQ5rMKSRsUzh9zpNt7w4v7asTcZ4c7K3p35cnPGuh2sd8ik/pr70IoZRsfb2JMYaQcn6Bt+NLMvZisWBZgfpxvgZMi9KwqLAP7/JByAQ1hgWgv6KREwG6ajUMirVU5BZBtNpxHRKwazIgXc8vL4oq9W93Gj74Pp7bp/qlTcTrTTyChr X-Forefront-Antispam-Report: CIP:216.228.117.161;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:dc6edge2.nvidia.com;CAT:NONE;SFS:(13230040)(82310400026)(36860700013)(376014)(1800799024);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Sep 2024 09:38:29.8700 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 4bb6783c-00dc-41c0-f0ab-08dcd2457eb6 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.117.161];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: CH2PEPF0000013D.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR12MB5663 X-Patchwork-Delegate: kuba@kernel.org Implement support for the new DSCP selector that allows IPv6 FIB rules to match on the entire DSCP field. This is done despite the fact that the above can be achieved using the existing TOS selector, so that user space program will be able to work with IPv4 and IPv6 rules in the same way. Differentiate between both selectors by adding a new bit in the IPv6 FIB rule structure that is only set when the 'FRA_DSCP' attribute is specified by user space. Reject rules that use both selectors. Signed-off-by: Ido Schimmel Reviewed-by: Guillaume Nault --- net/ipv6/fib6_rules.c | 43 ++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 40 insertions(+), 3 deletions(-) diff --git a/net/ipv6/fib6_rules.c b/net/ipv6/fib6_rules.c index 9e254de7462f..04a9ed5e8310 100644 --- a/net/ipv6/fib6_rules.c +++ b/net/ipv6/fib6_rules.c @@ -27,6 +27,7 @@ struct fib6_rule { struct rt6key src; struct rt6key dst; dscp_t dscp; + u8 dscp_full:1; /* DSCP or TOS selector */ }; static bool fib6_rule_matchall(const struct fib_rule *rule) @@ -345,6 +346,20 @@ INDIRECT_CALLABLE_SCOPE int fib6_rule_match(struct fib_rule *rule, return 1; } +static int fib6_nl2rule_dscp(const struct nlattr *nla, struct fib6_rule *rule6, + struct netlink_ext_ack *extack) +{ + if (rule6->dscp) { + NL_SET_ERR_MSG(extack, "Cannot specify both TOS and DSCP"); + return -EINVAL; + } + + rule6->dscp = inet_dsfield_to_dscp(nla_get_u8(nla) << 2); + rule6->dscp_full = true; + + return 0; +} + static int fib6_rule_configure(struct fib_rule *rule, struct sk_buff *skb, struct fib_rule_hdr *frh, struct nlattr **tb, @@ -361,6 +376,9 @@ static int fib6_rule_configure(struct fib_rule *rule, struct sk_buff *skb, } rule6->dscp = inet_dsfield_to_dscp(frh->tos); + if (tb[FRA_DSCP] && fib6_nl2rule_dscp(tb[FRA_DSCP], rule6, extack) < 0) + goto errout; + if (rule->action == FR_ACT_TO_TBL && !rule->l3mdev) { if (rule->table == RT6_TABLE_UNSPEC) { NL_SET_ERR_MSG(extack, "Invalid table"); @@ -413,9 +431,19 @@ static int fib6_rule_compare(struct fib_rule *rule, struct fib_rule_hdr *frh, if (frh->dst_len && (rule6->dst.plen != frh->dst_len)) return 0; - if (frh->tos && inet_dscp_to_dsfield(rule6->dscp) != frh->tos) + if (frh->tos && + (rule6->dscp_full || + inet_dscp_to_dsfield(rule6->dscp) != frh->tos)) return 0; + if (tb[FRA_DSCP]) { + dscp_t dscp; + + dscp = inet_dsfield_to_dscp(nla_get_u8(tb[FRA_DSCP]) << 2); + if (!rule6->dscp_full || rule6->dscp != dscp) + return 0; + } + if (frh->src_len && nla_memcmp(tb[FRA_SRC], &rule6->src.addr, sizeof(struct in6_addr))) return 0; @@ -434,7 +462,15 @@ static int fib6_rule_fill(struct fib_rule *rule, struct sk_buff *skb, frh->dst_len = rule6->dst.plen; frh->src_len = rule6->src.plen; - frh->tos = inet_dscp_to_dsfield(rule6->dscp); + + if (rule6->dscp_full) { + frh->tos = 0; + if (nla_put_u8(skb, FRA_DSCP, + inet_dscp_to_dsfield(rule6->dscp) >> 2)) + goto nla_put_failure; + } else { + frh->tos = inet_dscp_to_dsfield(rule6->dscp); + } if ((rule6->dst.plen && nla_put_in6_addr(skb, FRA_DST, &rule6->dst.addr)) || @@ -450,7 +486,8 @@ static int fib6_rule_fill(struct fib_rule *rule, struct sk_buff *skb, static size_t fib6_rule_nlmsg_payload(struct fib_rule *rule) { return nla_total_size(16) /* dst */ - + nla_total_size(16); /* src */ + + nla_total_size(16) /* src */ + + nla_total_size(1); /* dscp */ } static void fib6_rule_flush_cache(struct fib_rules_ops *ops) From patchwork Wed Sep 11 09:37:46 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ido Schimmel X-Patchwork-Id: 13800132 X-Patchwork-Delegate: kuba@kernel.org Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2061.outbound.protection.outlook.com [40.107.237.61]) (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 28717181BA8 for ; Wed, 11 Sep 2024 09:38:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.237.61 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726047528; cv=fail; b=PiHAVUHZ7Jc8w2zaaC9e1mEwqlqklhthfKJ0O4LwhpP3aKNWaj0+Tqd3ACHYjJ6Yx1eHvQPkS/ImM+kLJBRWVoxlKMJjk0sr2wdVTqD9+5H16MDIb0tquCg6SVBxRZh1OFzYwYL5yMk5YKS0qMUOUQppcB06djMl4MBw/O+fFpw= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726047528; c=relaxed/simple; bh=jOAiT0XhZuZlUVZZ+2lwK6oKrzLcZKoAMWa/1aBE6cQ=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=aHeAvpQRaCuXAjoaEpi+9K/90DmTiz0DcniOHv5q2dzZFbBN+n74J16kqxlZUWHYLfXzWfohjput8qI11FZF36cDuQOagGwoG7Sv5t8WnRKn/0H6bqSb/cl9ogRZM19q4L+GBOmwT5I1ukWDJ/PL+uhZvyfDNobv06S16i4kZhU= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com; spf=fail smtp.mailfrom=nvidia.com; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b=nX5a9UV9; arc=fail smtp.client-ip=40.107.237.61 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=nvidia.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b="nX5a9UV9" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=evLDvebyVQflUwcg7aEMMYhih/m2ChfdaMZU/Xs5sfckLqzIACxBAdDcusvKmESufZpNSPF4kh+0X/JdLVKkm3LAFFJ4JkeXxWlUw0eFsQp4LToBZbeWtp/VkkKepinQFkIfQ/k44ZouDzz9E50CjCMuWOYrmyFBZhwmUJVYD+7bEV3ZBg7/SLfWibk+2VE41MVP8+qVXOLoGYFXlJng6peDt6lQ1d6acnSzjH6BlKQ1eSPM0q+ZQwKMXF5OTq+B/k7URgfFlLKgXPIwik+TczSL8/ZhiBIW0ee9npf/crzTMgziYyip/Phiaha30o1DqG/lKftpT2bPt3qp6a447g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=ceLCkuHWInp6FzsVDZszeherwXuiU1lsIkyYtYZlX+k=; b=sZo7UmWPT/URiXAZuJ+K3hu/eP+yKOcattjGAvg5QQEIsYfVzXjs0yvhy0WcSOOiIkc8ufTH4EOclcGlA8vvqxnY8qbll3FUtsYmjqmO/3KwQKAbELe+hhb+XhZWxcsE0JDjy0gq6Csf+Lduozy4Oz0M5LM/+Oz9t2HIy+1u5n7NkJeUxPf53fIMyiB2pn20eiPf8QXWNDm+VCQsg/7Yf6lEX9LSApyOakFOnxdCLnQtQyncbaHkICpp5YwG0xIYDZKbOrS+c+PR26rNeZWGZKwg2QmiLyguv6DSbTdgRGDDi2PZLr9hk5esKW540OX189QB8hPmcST8r3J+zE1WAw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.160) smtp.rcpttodomain=vger.kernel.org smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=ceLCkuHWInp6FzsVDZszeherwXuiU1lsIkyYtYZlX+k=; b=nX5a9UV9Rdm5lcECwdtrIW0MfQJ+lBH7w86T3L+yzDThK0UbLFffO1uCmffSz87zcTKWvsk98rVG9pF+V/43wwJqeeihacLTiXmYq9+ikxbNmjgBuEZoD8lJ2MXSsFXWpY4xlX2Oe7Z8QuVdw6kcRedxDYQpz1NK8gC2q73/x6xh/Rd3el3IJTqGkU7dygjW71PZNdNv06cpJmU2FXA2AI2+62O7GINieecUDuwEaySACDjAjuT88un+YaYh0gkqrRPCT+0WT64Tk7/Y+wrmbyw9XABFXZnbNB87WnB31KmMHBjQA0P4gp5HdiNDsCJm4JATugA3/f79P1G1geZEzw== Received: from PH2PEPF00003857.namprd17.prod.outlook.com (2603:10b6:518:1::79) by CH3PR12MB9079.namprd12.prod.outlook.com (2603:10b6:610:1a1::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7962.17; Wed, 11 Sep 2024 09:38:40 +0000 Received: from MWH0EPF000A6732.namprd04.prod.outlook.com (2a01:111:f403:c91d::1) by PH2PEPF00003857.outlook.office365.com (2603:1036:903:48::3) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7918.24 via Frontend Transport; Wed, 11 Sep 2024 09:38:40 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.160) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.117.160 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.160; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.160) by MWH0EPF000A6732.mail.protection.outlook.com (10.167.249.24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7918.13 via Frontend Transport; Wed, 11 Sep 2024 09:38:40 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by mail.nvidia.com (10.129.200.66) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Wed, 11 Sep 2024 02:38:25 -0700 Received: from shredder.lan (10.126.231.35) by rnnvmail201.nvidia.com (10.129.68.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Wed, 11 Sep 2024 02:38:20 -0700 From: Ido Schimmel To: CC: , , , , , , "Ido Schimmel" Subject: [PATCH net-next 4/6] net: fib_rules: Enable DSCP selector usage Date: Wed, 11 Sep 2024 12:37:46 +0300 Message-ID: <20240911093748.3662015-5-idosch@nvidia.com> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20240911093748.3662015-1-idosch@nvidia.com> References: <20240911093748.3662015-1-idosch@nvidia.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: rnnvmail202.nvidia.com (10.129.68.7) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MWH0EPF000A6732:EE_|CH3PR12MB9079:EE_ X-MS-Office365-Filtering-Correlation-Id: b2dfe5b7-26f6-47a1-e855-08dcd24584d4 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|36860700013|376014|82310400026|1800799024; X-Microsoft-Antispam-Message-Info: wWwrDEz7OyhMv6lykXKQQy7E0V4dLDELz6hdnFknLismuFMBCpLCR3ml5JJVwaKA0x3uSpvTP5zkJx1J4DsTg22prqOrQPOtdqT6cSTnxt8xJc7Mcx2o9qLw9cneD9ZfQoaCwuKQ7hH4iHxZO/he82iLLFMJWbAB9CMLDZ8DRW7l1sFGHqdhfZGir5yCOs3fiarCP0sThD1lE0FYmtDUu0uZOG90rRFL0DPrer5TtI3kvMW1xmzJX4PL0Q3G3JM5Hj+2r8DZmneFdYooD2jyYBEjlJ+sGDAbKJhzBohzc41TcuUsgksubpuz6Gv9Bjt4ZBYns0W1SMR3qnzmxFDZbjgCFFR2IjcdYbUMPglypXYZcV8JrfnQHCo5JRyXzRo1011xxlUL6N9APxekQq26kdAmC5OvDCDQZytY876WW7mfCREDjOUshrWTgSJh1hyqmQ80IIWT5GmSbNoMzdA7mV+vnGpqCtPt55gZ7csDLnnbebXc8A0VDz+gxwY3sv+RFID29GxMbrzL20s4brf79bBxqetQVDAdYt6QUCfimk3svWL7a2Q3rMaHWPMDAlISBGxlLd356pSKzbiLrS7n9n3FFVL/oxtpP1iNxOuEPpO0RmY1kaIAM+O/IfW3zcfZ21KAZsQe9vYyQeMM7COHZdn/CMHlb6Ac2ABT14mSTxBv9J31QT6ZWmr2CH23hR79ox19UaBTMdmWFXMyg2aKG5jIJR6vS4d/Bggp9GRFRek+nLoXmFful2F5EmEKyqpLspgwS8z8dFFmlyEStWZm/92CQ1l7AY/UbMFUY9xpPz4WzqSB8Hlm+daRAgmO9ioG5UuyCBmIYWoUSTXElNzoXggVjn4mZ25lEaFuIDnlBxPQLBgeazMykGAp68LAWY7doXupi/3wn6dtdwL+GaWG1bZLnb1KcZ5pQL5vQnS21sV72xCDICUQVngEUkr4jNHFYThYj1i6CRP+gMWPCizC1Z9qwckJIxtv9la+GnSokkETkZsUPwWNeg+mH65/nAD4v8YopwxCWQqPl6D/ZvAN9B3xvWljgtGygDBwWs5diNp0JgZUUZ2bhWc1JZPjgNl4Bu9fMpaVGVDdF3bxO43aJIkLvTCWVjOfygIw5At6AP0mRWoSYoS3L6e8/kCFKmLnthibhBspwuywaOjQeHNHuL+EoxG5TIXQVFE9HzWrLUCqGEMt977N1VeLZECKEA7YNzTLG/WiL4+rknO/fSsXU5cYt7VE4g5hQ7gKOB7csfSd+0Z5NAzaLEZfRqWt3PTnT3IpLC1B/ITOv62WN05NX+gQ+mnkScd9lb7TPKzfVBx8wB26aQJ28DZI9DQzWc383AiYj2LC2Yu8mEgRDg1jD2QVgw8Y0m5k8k5nHnJaHZgSqDJqxjzu8XF6rQd64Gwa2hfxBNgZiyV8BAuTB8EWCy055fHDl+jOrr6gQcXqOUqlm5XsM6xAW3M5d+TuPunc X-Forefront-Antispam-Report: CIP:216.228.117.160;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:dc6edge1.nvidia.com;CAT:NONE;SFS:(13230040)(36860700013)(376014)(82310400026)(1800799024);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Sep 2024 09:38:40.2108 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: b2dfe5b7-26f6-47a1-e855-08dcd24584d4 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.117.160];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: MWH0EPF000A6732.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH3PR12MB9079 X-Patchwork-Delegate: kuba@kernel.org Now that both IPv4 and IPv6 support the new DSCP selector, enable user space to configure FIB rules that make use of it by changing the policy of the new DSCP attribute so that it accepts values in the range of [0, 63]. Use NLA_U8 rather than NLA_UINT as the field is of fixed size. Signed-off-by: Ido Schimmel Reviewed-by: Guillaume Nault --- net/core/fib_rules.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/net/core/fib_rules.c b/net/core/fib_rules.c index df41c05f7234..154a2681f55c 100644 --- a/net/core/fib_rules.c +++ b/net/core/fib_rules.c @@ -11,6 +11,7 @@ #include #include #include +#include #include #include #include @@ -767,7 +768,7 @@ static const struct nla_policy fib_rule_policy[FRA_MAX + 1] = { [FRA_IP_PROTO] = { .type = NLA_U8 }, [FRA_SPORT_RANGE] = { .len = sizeof(struct fib_rule_port_range) }, [FRA_DPORT_RANGE] = { .len = sizeof(struct fib_rule_port_range) }, - [FRA_DSCP] = { .type = NLA_REJECT }, + [FRA_DSCP] = NLA_POLICY_MAX(NLA_U8, INET_DSCP_MASK >> 2), }; int fib_nl_newrule(struct sk_buff *skb, struct nlmsghdr *nlh, From patchwork Wed Sep 11 09:37:47 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ido Schimmel X-Patchwork-Id: 13800133 X-Patchwork-Delegate: kuba@kernel.org Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2089.outbound.protection.outlook.com [40.107.243.89]) (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 D85A3176AC5 for ; Wed, 11 Sep 2024 09:38:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.243.89 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726047533; cv=fail; b=tbaLEcakb73LQ0fefssSaCt/JDwK7fVQc6S7nbmavYcBQbmgAlfi9fWfN4YOV9kWcIH+PMK8i6DlaIdCodgrXClRWapei9+dUd73IJ7XrZhM9IV18qksr6XoKoCMdJENfn29NH2VieT8XMB0DjO9z0BnOmbHkDabkKjfUDe7Nfo= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726047533; c=relaxed/simple; bh=mvcnCQIv7Bot9l35d5nrSDF1+L0C163/INu2hDitmgc=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=jnROfUGMWYeXTgD+dYC1CecFF2tuc67x1vW9sqCoyNzX6OJ8E1L2OWbZWY95lRUBVLUhhAibZR2nXG44/Ie+I9pqkaUVWVnaSJB41DwtfdQOzZcyc+6l3w/njXb6QlqKyD4HtF10gVMyf9wf/nFcRm1EpsWXz39gZrefOnD5qyI= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com; spf=fail smtp.mailfrom=nvidia.com; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b=p69pqr0w; arc=fail smtp.client-ip=40.107.243.89 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=nvidia.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b="p69pqr0w" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=EyOPfeZU75IP7B1/JUHQpgTeKkFvzZdjjo2PeAvLuNlcmOOtkfcSyQgvLwPRFSeQbuP6K45j9fghKJjmslmNPbbdSn+La7TuBZFVd50S689fLOMVfKoJuIRx7h+hb8gRMwURsRlyQI+O/hSqKFHHI0rkrXtWckjCs+94Nx2YJLSYssyWpG9fmY0QcnRkVfW0j6ePc82fCbKQ6m1kDwdUo9o1iyTXvShIDkRGGA8QROjhhMF5/JickhSqmFzkiOuynrthjuRzLWq5O5Un16g1uy02b1Uc3sVvZo+1GN4RoAafYrLrymqBEYb+TK9r+XOrp2b15o7TxVYm6jt62GDAmQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=li5CGoewwjlj2ejoOdFksKXFG0m4EexWo5PhUoZM8cM=; b=G1QF5Y9BFz1487Hle/CnVoecQBEVKdr5W+Rbis8DwpYgMvhNfF7zGXtFndN29+ulOeNPSyY3aWbSHa2pBaBHabKybXf9Y2GqRtQ38DHE1WNu+PMZP/XujoUbZPDjny4TDXH99FtIbaB0oeQFA7CqsItDYZfPwcOSpj6DUDm/QF9mhNibmimJuTIDVX3c9ZefuYjMTOhBdrCtvjNAxXQ5id58wtNC5BjJ9x+lNIVKVnzGtPHiT5Oz+5+0JstZgxc3dau7NA1eP6UFCLowaKZRHAwwcNVUO/4NeEYyvmfCe14sjlytbqFin2/E4jNZOfMCZCVLzYfXgsa8uFn+ZziqUw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.160) smtp.rcpttodomain=vger.kernel.org smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=li5CGoewwjlj2ejoOdFksKXFG0m4EexWo5PhUoZM8cM=; b=p69pqr0wAyNFvuajamKBnYSXcQahPl8bw7dCO4AOqAuJnmXA3CBrl/IdiDBtlVQ+xhwLNgxanCss9V24D4a+11Af5Dmz56OO19y70QUgF8+ml1/mfWwYe1r/15yaeXpWimwgSJE6bx6hI+oJmnEd4MNPRELsfSuIqYxMP0x00106BHSdIdYJ2Uc3gAtIGi+e4sz80nnvGhn4RqQuYwCQb+uL7lznW/wnhNs9rh4kZm2XrOwtLBnVMoILBW0mF749g3Dp7x5DZMgLsWKu5b4XS2UPFJkCs6o3kSV+2JkZpS7gzSx4Fhp3oT10FzYAZlVB7HWwbX0g/2a6gy4ernHXuA== Received: from PH8PR07CA0037.namprd07.prod.outlook.com (2603:10b6:510:2cf::17) by DM3PR12MB9435.namprd12.prod.outlook.com (2603:10b6:0:40::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7939.17; Wed, 11 Sep 2024 09:38:47 +0000 Received: from MWH0EPF000A6734.namprd04.prod.outlook.com (2603:10b6:510:2cf:cafe::1) by PH8PR07CA0037.outlook.office365.com (2603:10b6:510:2cf::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7939.24 via Frontend Transport; Wed, 11 Sep 2024 09:38:47 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.160) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.117.160 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.160; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.160) by MWH0EPF000A6734.mail.protection.outlook.com (10.167.249.26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7918.13 via Frontend Transport; Wed, 11 Sep 2024 09:38:47 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by mail.nvidia.com (10.129.200.66) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Wed, 11 Sep 2024 02:38:29 -0700 Received: from shredder.lan (10.126.231.35) by rnnvmail201.nvidia.com (10.129.68.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Wed, 11 Sep 2024 02:38:25 -0700 From: Ido Schimmel To: CC: , , , , , , "Ido Schimmel" Subject: [PATCH net-next 5/6] selftests: fib_rule_tests: Add DSCP selector match tests Date: Wed, 11 Sep 2024 12:37:47 +0300 Message-ID: <20240911093748.3662015-6-idosch@nvidia.com> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20240911093748.3662015-1-idosch@nvidia.com> References: <20240911093748.3662015-1-idosch@nvidia.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: rnnvmail202.nvidia.com (10.129.68.7) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MWH0EPF000A6734:EE_|DM3PR12MB9435:EE_ X-MS-Office365-Filtering-Correlation-Id: 9fd77258-7abc-4e81-ba9e-08dcd245890e X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|36860700013|82310400026|1800799024; X-Microsoft-Antispam-Message-Info: 1Exo/JjSyDOfyS5ELEE/9Dczm/NvtZhVFqhv36yvwGjGVdega0zjfH1iP4kYprwiWJfdueAwdWXtL4NBRtv3jtFUlp6r7Ph0Y7L6Ze/9IjMURY0o+M2w07nGJvQc9Rdvu2RrjPVG+AUUO8B/+u7OPAxaRXsZPim+vYxwNbKEtkitRqDrHaAD2BjyRmLuSravLs/veE/nUrfw4Nw1ND+5JBT3EI4k/wxHpVKUtgGAms1qVWCRIBvie3FUYx+5uiGJoeUM2TMVJ7UiZE5nu4mc9Qcol4aMfM+HLtWpzMyKNhCc5BghXsSR3leweXzBWxI3RHJpCowQV6NVfGxquenbfEAz4Jk7b6/e6kYler+PiQSgXK52g6U3GHWhqGmeGbXgE7dHw32xy2oy5sVzIsOdDMEOkG6AMxzx7PdgE0du/rtrwx4ue7Usq1xwXs/CHZrWEiT/0q/I1k2m0uX8Dav5wG2uaoqSw2nCsTulcOaPGQMHrl7rk/AIPCPJtqcrRSW7AESMRUfHKuoa+PM7pcONzLQJOHjWCUOMSl6p5wT+eOGy8N2nkPqQBEYK2WUR7x/VftdnQypmvFtnMR22iho5i7wbNaAbEQX7GDphke5GpwMBZrLb4dIKjnv36yy9Q7Bnk1l3jk59WbwgynmGuTQ5dJ+Khz3cNfydiu4DCz5NzeTh5Sh+86xBem/Y4vZzl0xI3rNFpWGOzUuv4PRXicBuFSS5OwI6LVl4VZflyw8MMuGkhl6hGFQQT+BfT9NBMUo+R6o7QneUKN6NfR4XDCNri2ZVr1bpAY6YViesgajY9m+b5+2aAAlpMcfKFMQHNB74uWrfmkE5YuMw1lnuO3lQgkKDl7ynA0FJ6dm764B7SYG/ZbGIGPxTiIcT4XAvJAKM6N4zSGLK0ZpdWgngMnwLbSj2jJH7pKktGp9BNNhqUZTBcT5x0Zz3ATJKsD527i70U9+a96T0yRMu9nhQWgJDtRDSroGKlBhwfcFiLV0lPos2L6bIwza9YcwUpyxnGK93gRPBXLUeQa70yPNkvRWQLiBVgzqVdap1Oi1TePUvkbQWq61hAgYcG+4b7JbcnJ1rk5QFKxFMW/NU1LWfhZ0O4XHcPoxofeDEIVH0izkd6s4LXdNVo6F9xGV8yUIxzWDJi1aA4nHJFleIJBkc2AXoEC57kk5G/l5bDPL34Q4FMaQhUSYoIc7FN5DR0zAaPPE3TrpyoQyh8JiGphB3mUUX2jGaq6eNWddZl8I757t7w5R0YpethBokVW8yzPFIji2bDBXb82WZc+VqA3P4WeVNDBlTysl9FAtP+WUvfeer7ciBw3kJfBdtGxJYpxgLsvG7/ezMrDlKgIlKtDX/Im8zfY89YQELKm7JgGYx+tQmWlqNkDnMfjM5r7Yv05qLYcvi0opAcZxsQacBK4gcVLhY+pM+kkl6RzONhifLDxN6i7bsDKlypYqWzjPJwat2prFl X-Forefront-Antispam-Report: CIP:216.228.117.160;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:dc6edge1.nvidia.com;CAT:NONE;SFS:(13230040)(376014)(36860700013)(82310400026)(1800799024);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Sep 2024 09:38:47.2850 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 9fd77258-7abc-4e81-ba9e-08dcd245890e X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.117.160];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: MWH0EPF000A6734.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM3PR12MB9435 X-Patchwork-Delegate: kuba@kernel.org Add tests for the new FIB rule DSCP selector. Test with both IPv4 and IPv6 and with both input and output routes. Signed-off-by: Ido Schimmel Reviewed-by: Guillaume Nault --- tools/testing/selftests/net/fib_rule_tests.sh | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/tools/testing/selftests/net/fib_rule_tests.sh b/tools/testing/selftests/net/fib_rule_tests.sh index 53c5c1ad437e..21d11d23fab7 100755 --- a/tools/testing/selftests/net/fib_rule_tests.sh +++ b/tools/testing/selftests/net/fib_rule_tests.sh @@ -274,6 +274,23 @@ fib_rule6_test() "$getnomatch" "ipproto ipv6-icmp match" \ "ipproto ipv6-tcp no match" fi + + fib_check_iproute_support "dscp" "tos" + if [ $? -eq 0 ]; then + match="dscp 0x3f" + getmatch="tos 0xfc" + getnomatch="tos 0xf4" + fib_rule6_test_match_n_redirect "$match" "$getmatch" \ + "$getnomatch" "dscp redirect to table" \ + "dscp no redirect to table" + + match="dscp 0x3f" + getmatch="from $SRC_IP6 iif $DEV tos 0xfc" + getnomatch="from $SRC_IP6 iif $DEV tos 0xf4" + fib_rule6_test_match_n_redirect "$match" "$getmatch" \ + "$getnomatch" "iif dscp redirect to table" \ + "iif dscp no redirect to table" + fi } fib_rule6_vrf_test() @@ -468,6 +485,23 @@ fib_rule4_test() "$getnomatch" "ipproto icmp match" \ "ipproto tcp no match" fi + + fib_check_iproute_support "dscp" "tos" + if [ $? -eq 0 ]; then + match="dscp 0x3f" + getmatch="tos 0xfc" + getnomatch="tos 0xf4" + fib_rule4_test_match_n_redirect "$match" "$getmatch" \ + "$getnomatch" "dscp redirect to table" \ + "dscp no redirect to table" + + match="dscp 0x3f" + getmatch="from $SRC_IP iif $DEV tos 0xfc" + getnomatch="from $SRC_IP iif $DEV tos 0xf4" + fib_rule4_test_match_n_redirect "$match" "$getmatch" \ + "$getnomatch" "iif dscp redirect to table" \ + "iif dscp no redirect to table" + fi } fib_rule4_vrf_test() From patchwork Wed Sep 11 09:37:48 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ido Schimmel X-Patchwork-Id: 13800134 X-Patchwork-Delegate: kuba@kernel.org Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on2056.outbound.protection.outlook.com [40.107.236.56]) (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 77844185936 for ; Wed, 11 Sep 2024 09:38:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.236.56 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726047536; cv=fail; b=mOJeNemA6ECfIo6MT53Rs33Dy9V5DgXklLfkcJeUzt8pxSKb5EY9+huMl8o5BBfCUxVW6e0xkWUVf/yNoYdnTaET/imW7cEmfUgKgSeYIWKfGytCqw0XbDvIn9MA65WXgqjQRFZE+pIuqfVHCS/qetkYvdSkacMpw6XtehfHrSE= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726047536; c=relaxed/simple; bh=FjvS3YsxC6EOn/OQhrIcX+fg+Rx5TDIhpAjE7XRKnG0=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=YsDpXNmq8ZP836kgX64q+qKBGfK5x4zdST8k6kToYVP1Av1Vn61q+nWau7C3EN6noDKaryGR0SWIS7FTLPa914JHTTztBQ4yJ+Dql6XoiY9iNDDcRG1iqlFLk9FKk5AhogKwZjze7VWpoBRADP72fsjiTFDrunPqQDGRo4Gh3Qs= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com; spf=fail smtp.mailfrom=nvidia.com; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b=nX0f4olZ; arc=fail smtp.client-ip=40.107.236.56 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=nvidia.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b="nX0f4olZ" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=U5FZ+kzs5QoVNY7L6DM5IccNb1y7NWrItyXFKN6MynGNGgJ+uLylCrjUmpUQmyusPm2DrXy0JaII3RSeKfBDxOISrZrugltOGH8MasQTBK0sH/Ct1PoTSJ2BmMug8A4bMSsUUEiwpkgE6RDrW0OTq0vCAF1gBt2418N4sYOSFaJzM3N03lBWzTVj2kDW/bQdBButEJ5pC5CNJ4BDIUKCcZ1xyTyp2PT8YS5v2lf4re3RSgVp5GA0z1CKGziLwSVOtLUdipn9Tb6XEhpfJCL6E2CiAt8Hx/+U6FFScDCOi5Q0oHsN7eXg31AgIUhwE2NtcV1aVekavTfmqARejMhDqQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=ly4GeywsXVWLfCWKV1E4FpddJHNk96y9a74uUL1IFMI=; b=y30CYMeN5DCn9JJI22/mHXcwDfwufYmDo6GR3cBJjfiDQPitVKD3c9l2ZXyOKXGBlE+y8mR+hIPeWAKX29bAgX21JkAb4GaOGUnFC6vmtRo/afcJyu/nXhO5OaVmiTAzAamdHLZ3iayA+4xwLK6jgMWD/TVgNn89JTplXy8jxThN5ne9j3ZjSKfp+m63pZPZ2TQsKpk4R92cT6ZFhnIs+awrYaPJbKZrr7KVtRTFF/lDgegzwqVJTHZLV5NIS0ptAK1HEyXku7U3Hwfruq7NujLPxGmlNTpdOxleb7elNVqM2+Nk2S0jiWWe+DcnvEee0fW/9Hwf/Ad89rtZLIEXIw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.160) smtp.rcpttodomain=vger.kernel.org smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=ly4GeywsXVWLfCWKV1E4FpddJHNk96y9a74uUL1IFMI=; b=nX0f4olZcdXHygawHFQENtC5ZPI4BerD6QlCjmV8WaelRdKR/dLxUrLrF4Ahu93T8cP2/YH6ArqFSIhhUsO5v/u6kaIAMwzuJtD9C4X0XXTxil9Ey27uBFXCJnUTIzpYPh7x1hFrYUqp+wZWHqNMdfkQzyLujvb9GoYIpW1na8cSuy7nY+2xdv1/yrF8C0E6/AH8iSYnu1aJiwaMm3SCx1AMNWaqxGSrazOZO8jKazlvb3gO1yeD2J/Jn1L1K69Z1M8QsA7A3TMhrXp7XRFFd5o7TrAk/WNvOm6xGuFNP49brLqnrIODJE8+yvNk29Cg7kkeDqNsAy4fVHzpwVOkMg== Received: from MW4PR04CA0295.namprd04.prod.outlook.com (2603:10b6:303:89::30) by DM4PR12MB6566.namprd12.prod.outlook.com (2603:10b6:8:8d::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7918.33; Wed, 11 Sep 2024 09:38:50 +0000 Received: from MWH0EPF000A672F.namprd04.prod.outlook.com (2603:10b6:303:89:cafe::ed) by MW4PR04CA0295.outlook.office365.com (2603:10b6:303:89::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7939.24 via Frontend Transport; Wed, 11 Sep 2024 09:38:50 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.160) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.117.160 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.160; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.160) by MWH0EPF000A672F.mail.protection.outlook.com (10.167.249.21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7918.13 via Frontend Transport; Wed, 11 Sep 2024 09:38:49 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by mail.nvidia.com (10.129.200.66) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Wed, 11 Sep 2024 02:38:33 -0700 Received: from shredder.lan (10.126.231.35) by rnnvmail201.nvidia.com (10.129.68.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Wed, 11 Sep 2024 02:38:29 -0700 From: Ido Schimmel To: CC: , , , , , , "Ido Schimmel" Subject: [PATCH net-next 6/6] selftests: fib_rule_tests: Add DSCP selector connect tests Date: Wed, 11 Sep 2024 12:37:48 +0300 Message-ID: <20240911093748.3662015-7-idosch@nvidia.com> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20240911093748.3662015-1-idosch@nvidia.com> References: <20240911093748.3662015-1-idosch@nvidia.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: rnnvmail202.nvidia.com (10.129.68.7) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MWH0EPF000A672F:EE_|DM4PR12MB6566:EE_ X-MS-Office365-Filtering-Correlation-Id: 3f22d90f-7efa-4d0a-7bb0-08dcd2458aa1 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|82310400026|36860700013|1800799024; X-Microsoft-Antispam-Message-Info: UxX0CPK1tpMsEmKaseLu4v0fwlQFsY7YNuyPmYOGnQmwPzz/o9rI+doWDuaHb2iGHIkfk/wn67el/T9ioniEcOcrHh6ayprVayxRxX+O6aSWze/kKGRL+NjdPhoMBMDSlE9Gxeqs2DmFx1h3dhenHOjdjUWvbfg0k5CI8Ms4OAcNiyEGBBGn8FoIoBvNXRZwbMrTWVPQ6l+N+j97EMmp203/lbwC4qDvcUooiU8+wXYXxHDoiWCEg+9y/tef+XeUfdEs6zm/KJ8bcZXutTUj+oWxXeNVh1TCMJyPnyURsOFiZgZUmda1MNrpoPeOXqaHU8DSFRkvA9QVRoJuB5bQpgW+gyuivISAmt67jrzG9Bt2ihZBxUaENnKNYQPjjIouF/jBQwjHfLEJSRAMu/5QITL8JK74bodZj/szRfdZv5MCJYa8jf99Jtw3uyCECL2lBNNEvQcFSTctmKgz3nZtRK/yL0n3CfaxagoiO2Nbr+hb0sIRuJY2rvJsCUTtUuAvIb5Mqoyb/9GgpBq8hIk29yUGGtZtsM7krNDzYtNBJImtL+mp56z9udaujKVqqgqUCID72lnCIe5JukEPlqLp6GzrwgGpIhRNgrKvFXwPPWsRXjUyoEVVUwlP6d44dWZsT8QRgquvMWuMWQPLSrxFkz0G8Q02dWxWAxrfvMT/WTXaeQnzZTyCvG8uhOcX55GNfXbZws2hKT/ZrM4dunG1RVQqEE5yw5loBJsveTdLcX4a95yptqwY2tbvSeMHwK+YU/Pzvnv84jKRyy1EOKVCRXyvIY0EsHu2Zh1iovYmp/ZKyDNPQXWh5V2bUO3RKSMBr8LewCH6/QI7Wh/g6gLKFGnnF3DYPSV3lBTBV4sVearJA/MPGWM/+kqULndRvq2rWDUxgdftTkQnTwsd+ekMnvkw+gZGu2RJAY3JSFYXcOXYwqLXqE43MiXA0QwCs+ObrOqEG4PHSS6bDgnN+CRlht+PFMImrc54x7R59J6hYhoES6rpCB8D5CZ/O0C+9wkeB4f85fK7axIGsxwqvePytpclUa9oebfLvJtBO+PQTgbayPcA0Q4wrzwcXpJnYcG8Gb4v8KZt+gOim8fSJndtVp38w9uPG0vvgxHzdolEl0DfNKrUaKqMCTo6ejLLKyVvBdZFh5lIm2qnrxdkZYjnHGQwt/qWxltmCGNS4sFdZ/W1cioLpeamJaTSDNiQM8pLooMQvnkjFAfODAa+sVQBi/HUjWgW451eijc8b/eOK9OiwJMBkuW3iEj29Tl0N1Rdvn6sabcjlYl8N5coK0g77nhAsXvCxAIkPWDoWlp1g+kqP/X+HDyXeyQ7XuvccrudV/7ASj/5A/90LsCCmgVSzgSPQUdt+3qVWFZilORKWLnMdYGZKWQrn0Y4XxoDcbJ9Jue1zpHv8jafllTZVAN1VUpsC+xkDNhVz1cU26Z77z7BDnQxeqmHhi7+UJ8eMJ7H X-Forefront-Antispam-Report: CIP:216.228.117.160;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:dc6edge1.nvidia.com;CAT:NONE;SFS:(13230040)(376014)(82310400026)(36860700013)(1800799024);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Sep 2024 09:38:49.9401 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 3f22d90f-7efa-4d0a-7bb0-08dcd2458aa1 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.117.160];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: MWH0EPF000A672F.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR12MB6566 X-Patchwork-Delegate: kuba@kernel.org Test that locally generated traffic from a socket that specifies a DS Field using the IP_TOS / IPV6_TCLASS socket options is correctly redirected using a FIB rule that matches on DSCP. Add negative tests to verify that the rule is not it when it should not. Test with both IPv4 and IPv6 and with both TCP and UDP sockets. Signed-off-by: Ido Schimmel Reviewed-by: Guillaume Nault --- tools/testing/selftests/net/fib_rule_tests.sh | 56 +++++++++++++++++++ 1 file changed, 56 insertions(+) diff --git a/tools/testing/selftests/net/fib_rule_tests.sh b/tools/testing/selftests/net/fib_rule_tests.sh index 21d11d23fab7..1d58b3b87465 100755 --- a/tools/testing/selftests/net/fib_rule_tests.sh +++ b/tools/testing/selftests/net/fib_rule_tests.sh @@ -336,6 +336,34 @@ fib_rule6_connect_test() log_test $? 1 "rule6 dsfield tcp no connect (dsfield 0x20)" $IP -6 rule del dsfield 0x04 table $RTABLE_PEER + + ip rule help 2>&1 | grep -q dscp + if [ $? -ne 0 ]; then + echo "SKIP: iproute2 iprule too old, missing dscp match" + cleanup_peer + return + fi + + $IP -6 rule add dscp 0x3f table $RTABLE_PEER + + nettest -q -6 -B -t 5 -N $testns -O $peerns -U -D -Q 0xfc \ + -l 2001:db8::1:11 -r 2001:db8::1:11 + log_test $? 0 "rule6 dscp udp connect" + + nettest -q -6 -B -t 5 -N $testns -O $peerns -Q 0xfc \ + -l 2001:db8::1:11 -r 2001:db8::1:11 + log_test $? 0 "rule6 dscp tcp connect" + + nettest -q -6 -B -t 5 -N $testns -O $peerns -U -D -Q 0xf4 \ + -l 2001:db8::1:11 -r 2001:db8::1:11 + log_test $? 1 "rule6 dscp udp no connect" + + nettest -q -6 -B -t 5 -N $testns -O $peerns -Q 0xf4 \ + -l 2001:db8::1:11 -r 2001:db8::1:11 + log_test $? 1 "rule6 dscp tcp no connect" + + $IP -6 rule del dscp 0x3f table $RTABLE_PEER + cleanup_peer } @@ -547,6 +575,34 @@ fib_rule4_connect_test() log_test $? 1 "rule4 dsfield tcp no connect (dsfield 0x20)" $IP -4 rule del dsfield 0x04 table $RTABLE_PEER + + ip rule help 2>&1 | grep -q dscp + if [ $? -ne 0 ]; then + echo "SKIP: iproute2 iprule too old, missing dscp match" + cleanup_peer + return + fi + + $IP -4 rule add dscp 0x3f table $RTABLE_PEER + + nettest -q -B -t 5 -N $testns -O $peerns -D -U -Q 0xfc \ + -l 198.51.100.11 -r 198.51.100.11 + log_test $? 0 "rule4 dscp udp connect" + + nettest -q -B -t 5 -N $testns -O $peerns -Q 0xfc \ + -l 198.51.100.11 -r 198.51.100.11 + log_test $? 0 "rule4 dscp tcp connect" + + nettest -q -B -t 5 -N $testns -O $peerns -D -U -Q 0xf4 \ + -l 198.51.100.11 -r 198.51.100.11 + log_test $? 1 "rule4 dscp udp no connect" + + nettest -q -B -t 5 -N $testns -O $peerns -Q 0xf4 \ + -l 198.51.100.11 -r 198.51.100.11 + log_test $? 1 "rule4 dscp tcp no connect" + + $IP -4 rule del dscp 0x3f table $RTABLE_PEER + cleanup_peer } ################################################################################