From patchwork Sat Mar 21 06:55:18 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: wenxu X-Patchwork-Id: 1259297 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=openvswitch.org (client-ip=140.211.166.133; helo=hemlock.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=ucloud.cn Received: from hemlock.osuosl.org (smtp2.osuosl.org [140.211.166.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 48kry36vLgz9sPR for ; Sat, 21 Mar 2020 17:55:39 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by hemlock.osuosl.org (Postfix) with ESMTP id 49B968944F; Sat, 21 Mar 2020 06:55:38 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from hemlock.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id n93deSVL3sbx; Sat, 21 Mar 2020 06:55:35 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by hemlock.osuosl.org (Postfix) with ESMTP id 1778289383; Sat, 21 Mar 2020 06:55:35 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 0737DC089F; Sat, 21 Mar 2020 06:55:35 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from whitealder.osuosl.org (smtp1.osuosl.org [140.211.166.138]) by lists.linuxfoundation.org (Postfix) with ESMTP id B7A76C089F for ; Sat, 21 Mar 2020 06:55:33 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by whitealder.osuosl.org (Postfix) with ESMTP id 9FBBA886B2 for ; Sat, 21 Mar 2020 06:55:33 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from whitealder.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id gq2K+7x+ASNI for ; Sat, 21 Mar 2020 06:55:32 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from m9784.mail.qiye.163.com (m9784.mail.qiye.163.com [220.181.97.84]) by whitealder.osuosl.org (Postfix) with ESMTPS id 7A8588861E for ; Sat, 21 Mar 2020 06:55:32 +0000 (UTC) Received: from localhost.localdomain (unknown [123.59.132.129]) by m9784.mail.qiye.163.com (Hmail) with ESMTPA id CA6BE41610; Sat, 21 Mar 2020 14:55:18 +0800 (CST) From: wenxu@ucloud.cn To: simon.horman@netronome.com Date: Sat, 21 Mar 2020 14:55:18 +0800 Message-Id: <1584773718-6975-1-git-send-email-wenxu@ucloud.cn> X-Mailer: git-send-email 1.8.3.1 X-HM-Spam-Status: e1kfGhgUHx5ZQUtXWQgYFAkeWUFZSFVPSU1CQkJDS0xITkxMQllXWShZQU lCN1dZLVlBSVdZCQ4XHghZQVk1NCk2OjckKS43PlkG X-HM-Sender-Digest: e1kMHhlZQR0aFwgeV1kSHx4VD1lBWUc6PDY6NCo6GTgyAhM0AzgRHE5W PREaFBlVSlVKTkNPTExITEpDQklDVTMWGhIXVQweFQMOOw4YFxQOH1UYFUVZV1kSC1lBWUpJSFVO QlVKSElVSklCWVdZCAFZQUhOQks3Bg++ X-HM-Tid: 0a70fbdfe3382086kuqyca6be41610 Cc: dev@openvswitch.org Subject: [ovs-dev] [PATCH branch-2.10] dpif-netlink: avoid netlink modify flow put op failed after tc modify flow put op failed. X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: ovs-dev-bounces@openvswitch.org Sender: "dev" From: wenxu The tc modify flow put always delete the original flow first and then add the new flow. If the modfiy flow put operation failed, the flow put operation will change from modify to create if success to delete the original flow in tc (which will be always failed with ENOENT, the flow is already be deleted before add the new flow in tc). Finally, the modify flow put will failed to add in kernel datapath. Signed-off-by: wenxu --- lib/dpif-netlink.c | 7 ++++++- lib/netdev-tc-offloads.c | 6 +++++- lib/netdev.h | 3 +++ 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/lib/dpif-netlink.c b/lib/dpif-netlink.c index 08f0038..fff8833 100644 --- a/lib/dpif-netlink.c +++ b/lib/dpif-netlink.c @@ -2045,6 +2045,7 @@ parse_flow_put(struct dpif_netlink *dpif, struct dpif_flow_put *put) info.dpif_class = dpif_class; info.tp_dst_port = dst_port; + info.tc_modify_flow_deleted = false; err = netdev_flow_put(dev, &match, CONST_CAST(struct nlattr *, put->actions), put->actions_len, @@ -2076,7 +2077,11 @@ parse_flow_put(struct dpif_netlink *dpif, struct dpif_flow_put *put) out: if (err && err != EEXIST && (put->flags & DPIF_FP_MODIFY)) { /* Modified rule can't be offloaded, try and delete from HW */ - int del_err = netdev_flow_del(dev, put->ufid, put->stats); + int del_err = 0; + + if (!info.tc_modify_flow_deleted) { + del_err = netdev_flow_del(dev, put->ufid, put->stats); + } if (!del_err) { /* Delete from hw success, so old flow was offloaded. diff --git a/lib/netdev-tc-offloads.c b/lib/netdev-tc-offloads.c index 0a427a3..8e65418 100644 --- a/lib/netdev-tc-offloads.c +++ b/lib/netdev-tc-offloads.c @@ -1132,8 +1132,12 @@ netdev_tc_flow_put(struct netdev *netdev, struct match *match, block_id = get_block_id_from_netdev(netdev); handle = get_ufid_tc_mapping(ufid, &prio, NULL); if (handle && prio) { + bool flow_deleted; + VLOG_DBG_RL(&rl, "updating old handle: %d prio: %d", handle, prio); - del_filter_and_ufid_mapping(ifindex, prio, handle, block_id, ufid); + flow_deleted = !del_filter_and_ufid_mapping(ifindex, prio, handle, + block_id, ufid); + info->tc_modify_flow_deleted = flow_deleted; } if (!prio) { diff --git a/lib/netdev.h b/lib/netdev.h index 5566760..e0b73cb 100644 --- a/lib/netdev.h +++ b/lib/netdev.h @@ -207,6 +207,9 @@ struct offload_info { * it will be in the pkt meta data. */ uint32_t flow_mark; + + bool tc_modify_flow_deleted; /* Indicate the tc modify flow put success + * to delete the original flow. */ }; struct dpif_class; struct netdev_flow_dump;