From patchwork Wed Feb 7 15:49:51 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gregory Rose X-Patchwork-Id: 870442 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; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="V/99BrZg"; dkim-atps=neutral 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 3zc5QQ2XLSz9s7F for ; Thu, 8 Feb 2018 02:50:54 +1100 (AEDT) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id A5FFA11A3; Wed, 7 Feb 2018 15:50:09 +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 89D2F1158 for ; Wed, 7 Feb 2018 15:50:08 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.7.6 Received: from mail-pf0-f196.google.com (mail-pf0-f196.google.com [209.85.192.196]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id 0E8513C4 for ; Wed, 7 Feb 2018 15:50:07 +0000 (UTC) Received: by mail-pf0-f196.google.com with SMTP id l9so474692pfi.6 for ; Wed, 07 Feb 2018 07:50:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=mRiNrLzxIhzKog5iv6Nms1pw/rCOEeVI8IPG9PfTgIw=; b=V/99BrZgt7VGNyUW+nJ8P4Guuw4UkMS7sZWvAzf9uY1aEyTMtzg9CCRkN7BKJS1JkD hjrLpf20047wnCaKdw4XKsZOUbNMMIgrVcafRZZTpdzvZ/qBE0AQ/wJzF/QG3Shhmk4Z IgtOAKHUqt2bDV3Zjm1p1tNUrC9o+2yghr3v5hpX6LiGEUCGHHM+GZZHVU232VCemSAX 0IXeLCSvFHgxUTDAv0fIVn61oRyTy1k22+peA7feGNFrvGhGVtWoWc4iphZkGOwy2sRJ IG+Es+kX3Sy8WUGas2PR5kP+oYMNDe6vRYJsX/ps+fsHcMhnGeW0ke+E/ZPJM23ChRED 6vIg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=mRiNrLzxIhzKog5iv6Nms1pw/rCOEeVI8IPG9PfTgIw=; b=XuIX4Vo9SjBQQDAa0MBU21l2kRqeNePVMsXOQAO5oKzywOnDX3Y/KBE6qAYQfS3/+F RioqcAWWzlGVs9jlU4okAznQ7N8EhEPFAJUx1b93LUzJo+9uXgU8gIq7hkZROnbOhDw3 3rGd+wub1tXyDkMWRRmz36eSb9N7sdkh5maQ7F2qbIHQkWCO530nGGvLFqmbNIQloCEs LrGfAqNHSY0X8ATPa94/gPy+ink2IXO94QBzhG9X8Hh9WnIxMRjud5xQOu7NjJuSd20X lYcazWTM7ewAJ5nH+e4Uh7htqOPMSRtX68RLETvMJ9L1uFPEvAG2VaRLytdWgNsQqIwC a9Sw== X-Gm-Message-State: APf1xPAoYJjoq/ofE/5bbNlMj5uDGhDEbthWwgMKO8wUqE3Z2m03RMxi wS0XjLXPxEpF406NmWO0Zzo+ew== X-Google-Smtp-Source: AH8x227Bz1A3CaeN2RRByFk4jkQppAEvDJ9dlWTI+bPANixNSkd7g1VCIW3vKPqFPKWdPHPjn+y8HQ== X-Received: by 10.98.78.148 with SMTP id c142mr6401367pfb.153.1518018607105; Wed, 07 Feb 2018 07:50:07 -0800 (PST) Received: from gizo.domain (184-100-240-187.ptld.qwest.net. [184.100.240.187]) by smtp.gmail.com with ESMTPSA id x15sm4924096pff.55.2018.02.07.07.50.05 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 07 Feb 2018 07:50:06 -0800 (PST) From: Greg Rose To: dev@openvswitch.org Date: Wed, 7 Feb 2018 07:49:51 -0800 Message-Id: <1518018601-31980-2-git-send-email-gvrose8192@gmail.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1518018601-31980-1-git-send-email-gvrose8192@gmail.com> References: <1518018601-31980-1-git-send-email-gvrose8192@gmail.com> X-Spam-Status: No, score=-1.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_ENVFROM_END_DIGIT,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE autolearn=no version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on smtp1.linux-foundation.org Subject: [ovs-dev] [PATCH v2 01/11] datapath: export get_dp() API 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 From: Andy Zhou Upstream commit: commit 9602c01e57f7b868d748c2ba2aef0efa64b71ffc Author: Andy Zhou Date: Fri Nov 10 12:09:41 2017 -0800 openvswitch: export get_dp() API. Later patches will invoke get_dp() outside of datapath.c. Export it. Signed-off-by: Andy Zhou Signed-off-by: David S. Miller Cc: Andy Zhou Signed-off-by: Greg Rose --- datapath/datapath.c | 29 ----------------------------- datapath/datapath.h | 31 +++++++++++++++++++++++++++++++ 2 files changed, 31 insertions(+), 29 deletions(-) diff --git a/datapath/datapath.c b/datapath/datapath.c index 6ee507a..6a63a9c 100644 --- a/datapath/datapath.c +++ b/datapath/datapath.c @@ -145,35 +145,6 @@ static int queue_userspace_packet(struct datapath *dp, struct sk_buff *, const struct dp_upcall_info *, uint32_t cutlen); -/* Must be called with rcu_read_lock. */ -static struct datapath *get_dp_rcu(struct net *net, int dp_ifindex) -{ - struct net_device *dev = dev_get_by_index_rcu(net, dp_ifindex); - - if (dev) { - struct vport *vport = ovs_internal_dev_get_vport(dev); - if (vport) - return vport->dp; - } - - return NULL; -} - -/* The caller must hold either ovs_mutex or rcu_read_lock to keep the - * returned dp pointer valid. - */ -static inline struct datapath *get_dp(struct net *net, int dp_ifindex) -{ - struct datapath *dp; - - WARN_ON_ONCE(!rcu_read_lock_held() && !lockdep_ovsl_is_held()); - rcu_read_lock(); - dp = get_dp_rcu(net, dp_ifindex); - rcu_read_unlock(); - - return dp; -} - /* Must be called with rcu_read_lock or ovs_mutex. */ const char *ovs_dp_name(const struct datapath *dp) { diff --git a/datapath/datapath.h b/datapath/datapath.h index 70ad0ac..036f521 100644 --- a/datapath/datapath.h +++ b/datapath/datapath.h @@ -31,6 +31,7 @@ #include "compat.h" #include "flow.h" #include "flow_table.h" +#include "vport-internal_dev.h" #define DP_MAX_PORTS USHRT_MAX #define DP_VPORT_HASH_BUCKETS 1024 @@ -197,6 +198,36 @@ static inline struct vport *ovs_vport_ovsl(const struct datapath *dp, int port_n return ovs_lookup_vport(dp, port_no); } +/* Must be called with rcu_read_lock. */ +static inline struct datapath *get_dp_rcu(struct net *net, int dp_ifindex) +{ + struct net_device *dev = dev_get_by_index_rcu(net, dp_ifindex); + + if (dev) { + struct vport *vport = ovs_internal_dev_get_vport(dev); + + if (vport) + return vport->dp; + } + + return NULL; +} + +/* The caller must hold either ovs_mutex or rcu_read_lock to keep the + * returned dp pointer valid. + */ +static inline struct datapath *get_dp(struct net *net, int dp_ifindex) +{ + struct datapath *dp; + + WARN_ON_ONCE(!rcu_read_lock_held() && !lockdep_ovsl_is_held()); + rcu_read_lock(); + dp = get_dp_rcu(net, dp_ifindex); + rcu_read_unlock(); + + return dp; +} + extern struct notifier_block ovs_dp_device_notifier; extern struct genl_family dp_vport_genl_family; extern struct genl_multicast_group ovs_dp_vport_multicast_group;