From patchwork Thu Nov 8 10:12:50 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chris Mi X-Patchwork-Id: 994725 X-Patchwork-Delegate: horms@verge.net.au Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=openvswitch.org (client-ip=140.211.169.12; helo=mail.linuxfoundation.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=mellanox.com Received: from mail.linuxfoundation.org (mail.linuxfoundation.org [140.211.169.12]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 42rK5P5dKxz9sB7 for ; Thu, 8 Nov 2018 21:19:21 +1100 (AEDT) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id A8520941; Thu, 8 Nov 2018 10:19:18 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@mail.linuxfoundation.org Received: from smtp1.linuxfoundation.org (smtp1.linux-foundation.org [172.17.192.35]) by mail.linuxfoundation.org (Postfix) with ESMTPS id 42F4C7A9 for ; Thu, 8 Nov 2018 10:19:18 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mellanox.co.il (mail-il-dmz.mellanox.com [193.47.165.129]) by smtp1.linuxfoundation.org (Postfix) with ESMTP id 1BDE28B for ; Thu, 8 Nov 2018 10:19:16 +0000 (UTC) Received: from Internal Mail-Server by MTLPINE1 (envelope-from chrism@mellanox.com) with ESMTPS (AES256-SHA encrypted); 8 Nov 2018 12:18:25 +0200 Received: from dev-r630-04.mtbc.labs.mlnx (dev-r630-04.mtbc.labs.mlnx [10.12.205.14]) by labmailer.mlnx (8.13.8/8.13.8) with ESMTP id wA8ACvru027269; Thu, 8 Nov 2018 12:12:58 +0200 From: Chris Mi To: dev@openvswitch.org Date: Thu, 8 Nov 2018 05:12:50 -0500 Message-Id: <1541671970-28973-1-git-send-email-chrism@mellanox.com> X-Mailer: git-send-email 1.8.3.1 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_NONE, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on smtp1.linux-foundation.org Cc: simon.horman@netronome.com Subject: [ovs-dev] netdev-tc-offloads: Delete ufid tc mapping in the right place X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: ovs-dev-bounces@openvswitch.org Errors-To: ovs-dev-bounces@openvswitch.org Currently, the ufid tc mapping is deleted in add_ufid_tc_mapping(). But if tc_replace_flower() failed, the old ufid tc mapping will not be deleted. If another thread adds the same tc mapping successfully, then there will be multiple mappings for the same ifindex, handle and prio. Fixes: 9116730db ("netdev-tc-offloads: Add ufid to tc/netdev map") Signed-off-by: Chris Mi Reviewed-by: Roi Dayan --- lib/netdev-tc-offloads.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/lib/netdev-tc-offloads.c b/lib/netdev-tc-offloads.c index 6f1fbe6..27a40bf 100644 --- a/lib/netdev-tc-offloads.c +++ b/lib/netdev-tc-offloads.c @@ -163,8 +163,7 @@ del_ufid_tc_mapping(const ovs_u128 *ufid) ovs_mutex_unlock(&ufid_lock); } -/* Add ufid entry to ufid_tc hashmap. - * If entry exists already it will be replaced. */ +/* Add ufid entry to ufid_tc hashmap. */ static void add_ufid_tc_mapping(const ovs_u128 *ufid, int prio, int handle, struct netdev *netdev, int ifindex) @@ -173,8 +172,6 @@ add_ufid_tc_mapping(const ovs_u128 *ufid, int prio, int handle, size_t tc_hash = hash_int(hash_int(prio, handle), ifindex); struct ufid_tc_data *new_data = xzalloc(sizeof *new_data); - del_ufid_tc_mapping(ufid); - new_data->ufid = *ufid; new_data->prio = prio; new_data->handle = handle; @@ -1303,6 +1300,7 @@ netdev_tc_flow_put(struct netdev *netdev, struct match *match, if (handle && prio) { VLOG_DBG_RL(&rl, "updating old handle: %d prio: %d", handle, prio); tc_del_filter(ifindex, prio, handle, block_id); + del_ufid_tc_mapping(ufid); } if (!prio) {