From patchwork Thu Aug 2 10:33:00 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matan Azrad X-Patchwork-Id: 43524 Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id B53191B46F; Thu, 2 Aug 2018 12:33:15 +0200 (CEST) Received: from mellanox.co.il (mail-il-dmz.mellanox.com [193.47.165.129]) by dpdk.org (Postfix) with ESMTP id 5D7B31B46D for ; Thu, 2 Aug 2018 12:33:14 +0200 (CEST) Received: from Internal Mail-Server by MTLPINE1 (envelope-from matan@mellanox.com) with ESMTPS (AES256-SHA encrypted); 2 Aug 2018 13:36:33 +0300 Received: from pegasus08.mtr.labs.mlnx (pegasus08.mtr.labs.mlnx [10.210.16.114]) by labmailer.mlnx (8.13.8/8.13.8) with ESMTP id w72AX8iS025865; Thu, 2 Aug 2018 13:33:08 +0300 From: Matan Azrad To: Keith Wiles Cc: Ophir Munk , dev@dpdk.org, stable@dpdk.org Date: Thu, 2 Aug 2018 10:33:00 +0000 Message-Id: <1533205980-7874-1-git-send-email-matan@mellanox.com> X-Mailer: git-send-email 2.7.4 Subject: [dpdk-dev] [PATCH] net/tap: fix zeroed flow mask configurations X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" The rte_flow meaning of zero flow mask configuration is to match all the range of the item value. For example, the flow eth / ipv4 dst spec 1.2.3.4 dst mask 0.0.0.0 should much all the ipv4 traffic from the rte_flow API perspective. From some kernel perspectives the above rule means to ignore all the ipv4 traffic (e.g. Ubuntu 16.04, 4.15.10). Due to the fact that the tap PMD should provide the rte_flow meaning, it is necessary to ignore the spec in case the mask is zero when it forwards such like flows to the kernel. So, the above rule should be translated to eth / ipv4 to get the correct meaning. Ignore spec configurations when the mask is zero. Fixes: de96fe68ae95 ("net/tap: add basic flow API patterns and actions") Cc: stable@dpdk.org Signed-off-by: Matan Azrad Acked-by: Keith Wiles --- drivers/net/tap/tap_flow.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/drivers/net/tap/tap_flow.c b/drivers/net/tap/tap_flow.c index 6b60e6d..993e6f6 100644 --- a/drivers/net/tap/tap_flow.c +++ b/drivers/net/tap/tap_flow.c @@ -537,7 +537,8 @@ tap_flow_create_eth(const struct rte_flow_item *item, void *data) if (!flow) return 0; msg = &flow->msg; - if (!is_zero_ether_addr(&spec->dst)) { + if (!is_zero_ether_addr(&spec->dst) && + !is_zero_ether_addr(&mask->dst)) { tap_nlattr_add(&msg->nh, TCA_FLOWER_KEY_ETH_DST, ETHER_ADDR_LEN, &spec->dst.addr_bytes); tap_nlattr_add(&msg->nh, @@ -651,13 +652,13 @@ tap_flow_create_ipv4(const struct rte_flow_item *item, void *data) info->eth_type = htons(ETH_P_IP); if (!spec) return 0; - if (spec->hdr.dst_addr) { + if (spec->hdr.dst_addr && mask->hdr.dst_addr) { tap_nlattr_add32(&msg->nh, TCA_FLOWER_KEY_IPV4_DST, spec->hdr.dst_addr); tap_nlattr_add32(&msg->nh, TCA_FLOWER_KEY_IPV4_DST_MASK, mask->hdr.dst_addr); } - if (spec->hdr.src_addr) { + if (spec->hdr.src_addr && mask->hdr.src_addr) { tap_nlattr_add32(&msg->nh, TCA_FLOWER_KEY_IPV4_SRC, spec->hdr.src_addr); tap_nlattr_add32(&msg->nh, TCA_FLOWER_KEY_IPV4_SRC_MASK, @@ -707,13 +708,15 @@ tap_flow_create_ipv6(const struct rte_flow_item *item, void *data) info->eth_type = htons(ETH_P_IPV6); if (!spec) return 0; - if (memcmp(spec->hdr.dst_addr, empty_addr, 16)) { + if (memcmp(spec->hdr.dst_addr, empty_addr, 16) && + memcmp(mask->hdr.dst_addr, empty_addr, 16)) { tap_nlattr_add(&msg->nh, TCA_FLOWER_KEY_IPV6_DST, sizeof(spec->hdr.dst_addr), &spec->hdr.dst_addr); tap_nlattr_add(&msg->nh, TCA_FLOWER_KEY_IPV6_DST_MASK, sizeof(mask->hdr.dst_addr), &mask->hdr.dst_addr); } - if (memcmp(spec->hdr.src_addr, empty_addr, 16)) { + if (memcmp(spec->hdr.src_addr, empty_addr, 16) && + memcmp(mask->hdr.src_addr, empty_addr, 16)) { tap_nlattr_add(&msg->nh, TCA_FLOWER_KEY_IPV6_SRC, sizeof(spec->hdr.src_addr), &spec->hdr.src_addr); tap_nlattr_add(&msg->nh, TCA_FLOWER_KEY_IPV6_SRC_MASK,