netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Simon Horman <simon.horman@netronome.com>
To: netdev@vger.kernel.org, dev@openvswitch.org
Cc: Simon Horman <simon.horman@netronome.com>
Subject: [PATCH/RFC 10/12] openvswitch: make get_dp_rcu() available outside datapath.c
Date: Wed, 28 Sep 2016 14:43:00 +0200	[thread overview]
Message-ID: <1475066582-1971-11-git-send-email-simon.horman@netronome.com> (raw)
In-Reply-To: <1475066582-1971-1-git-send-email-simon.horman@netronome.com>

Make get_dp_rcu() available outside datapath.c and as a precaution add a
check to ensure that rcu_read_lock is held.

This is in preparation for calling get_dp_rcu() from other source files
which is in turn in preparation for prototyping allowing Open vSwitch to
program flows into hardware.

Signed-off-by: Simon Horman <simon.horman@netronome.com>
---
 net/openvswitch/datapath.c | 4 +++-
 net/openvswitch/datapath.h | 2 ++
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/net/openvswitch/datapath.c b/net/openvswitch/datapath.c
index 4d67ea856067..365d480031d3 100644
--- a/net/openvswitch/datapath.c
+++ b/net/openvswitch/datapath.c
@@ -145,10 +145,12 @@ static int queue_userspace_packet(struct datapath *dp, struct sk_buff *,
 				  uint32_t cutlen);
 
 /* Must be called with rcu_read_lock. */
-static struct datapath *get_dp_rcu(struct net *net, int dp_ifindex)
+struct datapath *get_dp_rcu(struct net *net, int dp_ifindex)
 {
 	struct net_device *dev = dev_get_by_index_rcu(net, dp_ifindex);
 
+	WARN_ON_ONCE(!rcu_read_lock_held());
+
 	if (dev) {
 		struct vport *vport = ovs_internal_dev_get_vport(dev);
 		if (vport)
diff --git a/net/openvswitch/datapath.h b/net/openvswitch/datapath.h
index ab85c1cae255..6094d912eaec 100644
--- a/net/openvswitch/datapath.h
+++ b/net/openvswitch/datapath.h
@@ -154,6 +154,8 @@ int lockdep_ovsl_is_held(void);
 #define lockdep_ovsl_is_held()	1
 #endif
 
+struct datapath *get_dp_rcu(struct net *net, int dp_ifindex);
+
 #define ASSERT_OVSL()		WARN_ON(!lockdep_ovsl_is_held())
 #define ovsl_dereference(p)					\
 	rcu_dereference_protected(p, lockdep_ovsl_is_held())
-- 
2.7.0.rc3.207.g0ac5344

  parent reply	other threads:[~2016-09-28 12:43 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-09-28 12:42 [PATCH/RFC 00/12] Programming Open vSwitch (-like) flows into hardware using SwitchDev Simon Horman
     [not found] ` <1475066582-1971-1-git-send-email-simon.horman-wFxRvT7yatFl57MIdRCFDg@public.gmane.org>
2016-09-28 12:42   ` [PATCH/RFC 01/12] sw_flow: make struct sw_flow_key available outside of net/openvswitch/ Simon Horman
2016-09-28 13:54   ` [PATCH/RFC 00/12] Programming Open vSwitch (-like) flows into hardware using SwitchDev Or Gerlitz
2016-09-29  8:09     ` Simon Horman
     [not found]       ` <20160929080904.GA24113-ucRxlxcrRFEsysjaEhV7d2ey4e3TpSOZIxS8c3vjKQDk1uMJSBkQmQ@public.gmane.org>
2016-09-30 22:12         ` pravin shelar
     [not found]           ` <CAOrHB_CG6wJ4t1zTaFZ8Uq5Ltoiqx+ctk-ZhqZ0sy3tF5-YXVQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2016-10-01  9:05             ` Or Gerlitz
2016-09-28 12:42 ` [PATCH/RFC 02/12] switchdev: Add Open vSwitch (-like) flow object support Simon Horman
2016-09-28 12:42 ` [PATCH/RFC 03/12] switchdev: Add support for getting port object details Simon Horman
2016-09-28 12:42 ` [PATCH/RFC 04/12] rocker: Add Open vSwitch (-like) flow support Simon Horman
2016-09-28 12:42 ` [PATCH/RFC 05/12] rocker: Support Open vSwitch (-like) flow stats Simon Horman
2016-09-28 12:42 ` [PATCH/RFC 06/12] rocker: Add helper to check ports belong to the same rocker switch Simon Horman
2016-09-28 12:42 ` [PATCH/RFC 07/12] rocker: switchdev Add Open vSwitch (-like) flow support to OF-DPA world Simon Horman
2016-09-28 12:42 ` [PATCH/RFC 08/12] rocker: Support Open vSwitch (-like) flow stats in " Simon Horman
2016-09-28 12:42 ` [PATCH/RFC 09/12] openvswitch: Add key_attrs to struct sw_flow_match Simon Horman
2016-09-28 12:43 ` Simon Horman [this message]
2016-09-28 12:43 ` [PATCH/RFC 11/12] openvswitch: Support programming of flows into hardware Simon Horman
2016-09-28 12:43 ` [PATCH/RFC 12/12] hack: rocker: no ip frag match Simon Horman

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1475066582-1971-11-git-send-email-simon.horman@netronome.com \
    --to=simon.horman@netronome.com \
    --cc=dev@openvswitch.org \
    --cc=netdev@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).