From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id DC78846056; Sun, 12 Jan 2025 08:52:14 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id DD74240265; Sun, 12 Jan 2025 08:52:13 +0100 (CET) Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2085.outbound.protection.outlook.com [40.107.94.85]) by mails.dpdk.org (Postfix) with ESMTP id 1C9044025D for ; Sun, 12 Jan 2025 08:52:12 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=fXdV/OUecfL8GgtPbYfUs0JO481LVsidqlw/jZt3ZXfq9JG3bspucMJsXH457WnYPeLtHgwqa+RuKpp/gtxHxza+pU3GeElAaJpQGwExB4INm3CWQstCQUayZnBowlOFLedsTMbCK07kIbsa2d+fkUoqq8q1+2rxBAlKa1GyZ3sMMkOmiFOS58JygcpX14WCJ7nVS33m7wAJzVbyAjruEFQEzN5AJB9Ft3hHd8jt88UShRIXJfhJCsUb7iqPKhv0ICt/+VVhpI160qfDm4ak+phkfLmEip9hK/5fjQM66wbZhOb/dSUS2GKU1WzUvZ5ykCj68SVBhwCxef1urHL88g== 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=0MW34bOxgG4+ItBE769KhyY2EVrCI/fF1kHBMDV8BCo=; b=K/fQjtyH9HRSncq3j/BKHQxObOqCW4i8TyGnnGLMqVgGY7S+v+nPBibCOWdvvz59XJpzhk+kpJRni2KgQ6j7EEryMRm++DOgdxMt8g1SNjPTIwuyJyVv2S2Rjp05IToaShX3moLC2sNHVDOW6EU1xLkfjmkPF6MNxCrWzpkFVDq9ggLgqb5RC4Btxf5AALldpQ4snwlHN+DDCS/C87xHPuf5zgCEhUns0u3Cn6EdymxGgJ+oenpjC3axwj/8tNgZWEdvuWWSI8PrakOzjmCf0v+NPotwL4ASmqAJK/zHSCCZMSvTUWoKhXVwgYzZz2COAuh43ha+jAkCXH5XOOUqEg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.118.232) smtp.rcpttodomain=dpdk.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=0MW34bOxgG4+ItBE769KhyY2EVrCI/fF1kHBMDV8BCo=; b=aAka9G1F7lzx27/i7DVVojeDbmgUpBgpX6omEyiKnlqFVS9X4BqaitOLcwedYHUyQFiFj8VU9cuE7RZU0UOdpVhklmHBzHUeckBERiot7pZ56SEhstwEe9+TIiTqkK4g+WNdpqd6fV3mOODWBUyk4ua4ZGiXePlP2CR3wk/YBOUylsiOREC4VhSQXLvk6SQBEhZ+b72RFvQSZREUBWA9HZxwwEtsuK3PUwmrpdeX1occIzOdAjnmJ5MznZghL1gNzVpJGlS3bOyr7uWJPOJNj7OW3sGA/ZIysmpnUkBaCvaGl0Bkp1UR86aZdxl63yzQ25pinkZaXeamO8QY20/jog== Received: from DS7PR05CA0024.namprd05.prod.outlook.com (2603:10b6:5:3b9::29) by DM4PR12MB6110.namprd12.prod.outlook.com (2603:10b6:8:ad::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8335.17; Sun, 12 Jan 2025 07:52:08 +0000 Received: from DS1PEPF0001709D.namprd05.prod.outlook.com (2603:10b6:5:3b9:cafe::6d) by DS7PR05CA0024.outlook.office365.com (2603:10b6:5:3b9::29) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8356.10 via Frontend Transport; Sun, 12 Jan 2025 07:52:08 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.118.232) 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.118.232 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.118.232; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.118.232) by DS1PEPF0001709D.mail.protection.outlook.com (10.167.18.107) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8356.11 via Frontend Transport; Sun, 12 Jan 2025 07:52:08 +0000 Received: from drhqmail203.nvidia.com (10.126.190.182) by mail.nvidia.com (10.127.129.5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Sat, 11 Jan 2025 23:52:06 -0800 Received: from drhqmail203.nvidia.com (10.126.190.182) by drhqmail203.nvidia.com (10.126.190.182) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Sat, 11 Jan 2025 23:52:06 -0800 Received: from nvidia.com (10.127.8.12) by mail.nvidia.com (10.126.190.182) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4 via Frontend Transport; Sat, 11 Jan 2025 23:52:05 -0800 From: Shani Peretz To: CC: , , Ori Kam , Stephen Hemminger Subject: [PATCH] examples/flow_filtering: fix destination IP mask Date: Sun, 12 Jan 2025 09:52:00 +0200 Message-ID: <20250112075200.5020-1-shperetz@nvidia.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-NV-OnPremToCloud: AnonymousSubmission X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS1PEPF0001709D:EE_|DM4PR12MB6110:EE_ X-MS-Office365-Filtering-Correlation-Id: 26133b95-eaef-4fff-0b5d-08dd32de03e8 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|376014|1800799024|36860700013|82310400026; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?GJQxuOMAa7tfy7c+MDVKVETSha+ggLv64BMU+3jC5D0oFhHR27Jy/Qj/fbkB?= =?us-ascii?Q?MusJL9VRY3/LVEqom9JJLYsOH5dJUuDu4IWpIYRpmF0vUB4vNCONRJ7ZFOKl?= =?us-ascii?Q?fNa9nUymfRzl4gFutHm2YXiqyLaF8wPySH7Gtf7K01e/cHFFEjGhbGr8ov8j?= =?us-ascii?Q?Oxn2e1FVxN6zvpp3d+oj8HrxBiq3xijXJ4EFJJNmXcYuwMH0f6PTKcXgiJIT?= =?us-ascii?Q?SvXUW4kmWED+VwJLhrX5J8vn7qOa0KEs+NWn8wTHSINSh9qQKMwwPMO/0xYM?= =?us-ascii?Q?XDYpfgPy2R5oP+ezC4djvOhG0PMpP1HwmQPK0BOXs3xKV6/2PGbCTGl26Q7S?= =?us-ascii?Q?rV/VOMqTrBxqWKAEgVrdoS+BHIG/Z+wsabmiKk4oicbLhOBgo9eKWtVGVfVG?= =?us-ascii?Q?c6cUyIbxRnk96a5QWBic2RMm6CNI4yFvBWyR5gkYE2C7CCh5QCK1nAonetHv?= =?us-ascii?Q?MwY6xqyOi+7+Ka4Yjqbdc380Eu/g2M74nseEDWATI2ce/mo/vyrNBpMaf4Iq?= =?us-ascii?Q?2GrRO/i0RqkQaFQGpbwlez0DRoVvuPbd9zbXBXT7oQRAdkCsj/ByIJa340lG?= =?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IyqXjjIANChpmdgXzJ9ZWWATjuipcN0?= =?us-ascii?Q?tfuUOZV1ouN91Qw=3D?= X-Forefront-Antispam-Report: CIP:216.228.118.232; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:dc7edge1.nvidia.com; CAT:NONE; SFS:(13230040)(376014)(1800799024)(36860700013)(82310400026); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Jan 2025 07:52:08.4739 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 26133b95-eaef-4fff-0b5d-08dd32de03e8 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[216.228.118.232]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: DS1PEPF0001709D.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR12MB6110 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org This patch corrects the destination IP address mask to restore the previous implementation's behavior. Also it fixes a misuse of rte_flow_item_tcp struct. Replace it with the appropriate rte_flow_item_ipv4 struct, as the code in this context filters ipv4 traffic. Fixes: 16158f349000 ("examples/flow_filtering: introduce use cases snippets") Signed-off-by: Shani Peretz --- examples/flow_filtering/snippets/snippet_match_ipv4.c | 10 +++++----- examples/flow_filtering/snippets/snippet_match_ipv4.h | 1 - 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/examples/flow_filtering/snippets/snippet_match_ipv4.c b/examples/flow_filtering/snippets/snippet_match_ipv4.c index 808208e7b0..d32f4ebfdc 100644 --- a/examples/flow_filtering/snippets/snippet_match_ipv4.c +++ b/examples/flow_filtering/snippets/snippet_match_ipv4.c @@ -55,7 +55,7 @@ snippet_ipv4_flow_create_patterns(struct rte_flow_item *patterns) fprintf(stderr, "Failed to allocate memory for ip_mask\n"); ip_spec->hdr.dst_addr = htonl(DEST_IP); /* The dest ip value to match the input packet. */ - ip_mask->hdr.dst_addr = DEST_MASK; /* The mask to apply to the dest ip. */ + ip_mask->hdr.dst_addr = FULL_MASK; /* The mask to apply to the dest ip. */ ip_spec->hdr.src_addr = htonl(SRC_IP); /* The src ip value to match the input packet. */ ip_mask->hdr.src_addr = EMPTY_MASK; /* The mask to apply to the src ip. */ patterns[1].spec = ip_spec; @@ -77,7 +77,7 @@ snippet_ipv4_flow_create_actions_template(uint16_t port_id, struct rte_flow_erro }; tactions[0].type = RTE_FLOW_ACTION_TYPE_QUEUE; - tactions[0].type = RTE_FLOW_ACTION_TYPE_END; + tactions[1].type = RTE_FLOW_ACTION_TYPE_END; /* This sets the masks to match the actions, indicating that all fields of the actions * should be considered as part of the template. @@ -93,7 +93,7 @@ static struct rte_flow_pattern_template * snippet_ipv4_flow_create_pattern_template(uint16_t port_id, struct rte_flow_error *error) { struct rte_flow_item titems[MAX_PATTERN_NUM] = {0}; - struct rte_flow_item_tcp ip_mask = {0}; + struct rte_flow_item_ipv4 ip_mask = {0}; struct rte_flow_pattern_template_attr attr = { .relaxed_matching = 1, @@ -102,8 +102,8 @@ snippet_ipv4_flow_create_pattern_template(uint16_t port_id, struct rte_flow_erro titems[0].type = RTE_FLOW_ITEM_TYPE_ETH; titems[1].type = RTE_FLOW_ITEM_TYPE_IPV4; - ip_mask.hdr.src_port = EMPTY_MASK; - ip_mask.hdr.dst_port = DEST_MASK; + ip_mask.hdr.src_addr = EMPTY_MASK; + ip_mask.hdr.dst_addr = FULL_MASK; titems[1].mask = &ip_mask; titems[2].type = RTE_FLOW_ITEM_TYPE_END; diff --git a/examples/flow_filtering/snippets/snippet_match_ipv4.h b/examples/flow_filtering/snippets/snippet_match_ipv4.h index 847784beef..597a1c954e 100644 --- a/examples/flow_filtering/snippets/snippet_match_ipv4.h +++ b/examples/flow_filtering/snippets/snippet_match_ipv4.h @@ -13,7 +13,6 @@ #define DEST_IP ((192<<24) + (168<<16) + (1<<8) + 1) /* dest ip = 192.168.1.1 */ #define FULL_MASK 0xffffffff /* full mask */ #define EMPTY_MASK 0x0 /* empty mask */ -#define DEST_MASK 0xffff /* full mask */ #define MAX_PATTERN_NUM 3 /* Maximal number of patterns for this example. */ #define MAX_ACTION_NUM 2 /* Maximal number of actions for this example. */ -- 2.34.1