From patchwork Sat Mar 21 06:53:30 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: wenxu X-Patchwork-Id: 1259294 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 48krwN1ZBWz9sPR for ; Sat, 21 Mar 2020 17:54:10 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by hemlock.osuosl.org (Postfix) with ESMTP id E8BC989418; Sat, 21 Mar 2020 06:54:08 +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 KnvUIk7303V4; Sat, 21 Mar 2020 06:54:07 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by hemlock.osuosl.org (Postfix) with ESMTP id E37BD89383; Sat, 21 Mar 2020 06:54:07 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id C5969C089F; Sat, 21 Mar 2020 06:54:07 +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 C86BDC07FF for ; Sat, 21 Mar 2020 06:54:04 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by whitealder.osuosl.org (Postfix) with ESMTP id AFDD5886A7 for ; Sat, 21 Mar 2020 06:54:04 +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 XgzJUk7TGrZZ for ; Sat, 21 Mar 2020 06:54:03 +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 94A678861E for ; Sat, 21 Mar 2020 06:53:59 +0000 (UTC) Received: from localhost.localdomain (unknown [123.59.132.129]) by m9784.mail.qiye.163.com (Hmail) with ESMTPA id 9AD3341610; Sat, 21 Mar 2020 14:53:30 +0800 (CST) From: wenxu@ucloud.cn To: simon.horman@netronome.com Date: Sat, 21 Mar 2020 14:53:30 +0800 Message-Id: <1584773610-6814-1-git-send-email-wenxu@ucloud.cn> X-Mailer: git-send-email 1.8.3.1 X-HM-Spam-Status: e1kfGhgUHx5ZQUtXWQgYFAkeWUFZSVVMQk9CQkJDSExDTE5ITFlXWShZQU lCN1dZLVlBSVdZCQ4XHghZQVk1NCk2OjckKS43PlkG X-HM-Sender-Digest: e1kMHhlZQR0aFwgeV1kSHx4VD1lBWUc6OjY6ORw4STg#TxMpEzhKIxQB KxwKCTFVSlVKTkNPTExITUpLTUNJVTMWGhIXVQweFQMOOw4YFxQOH1UYFUVZV1kSC1lBWUpJSFVO QlVKSElVSklCWVdZCAFZQUhOQkg3Bg++ X-HM-Tid: 0a70fbde3c932086kuqy9ad3341610 Cc: dev@openvswitch.org Subject: [ovs-dev] [PATCH branch-2.9, branch-2.8] 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 ab04482..13f2fdc 100644 --- a/lib/dpif-netlink.c +++ b/lib/dpif-netlink.c @@ -2029,6 +2029,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, @@ -2060,7 +2061,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 13a5aa9..8d73a61 100644 --- a/lib/netdev-tc-offloads.c +++ b/lib/netdev-tc-offloads.c @@ -1042,8 +1042,12 @@ netdev_tc_flow_put(struct netdev *netdev, struct match *match, 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, ufid); + flow_deleted = !del_filter_and_ufid_mapping(ifindex, prio, + handle, ufid); + info->tc_modify_flow_deleted = flow_deleted; } if (!prio) { diff --git a/lib/netdev.h b/lib/netdev.h index ff1b604..c8b38e5 100644 --- a/lib/netdev.h +++ b/lib/netdev.h @@ -188,6 +188,9 @@ void netdev_send_wait(struct netdev *, int qid); struct offload_info { const struct dpif_class *dpif_class; ovs_be16 tp_dst_port; /* Destination port for tunnel in SET action */ + + bool tc_modify_flow_deleted; /* Indicate the tc modify flow put success + * to delete the original flow. */ }; struct dpif_class; struct netdev_flow_dump;