Skip to content

Commit 9602c01

Browse files
azhou-niciradavem330
authored andcommitted
openvswitch: export get_dp() API.
Later patches will invoke get_dp() outside of datapath.c. Export it. Signed-off-by: Andy Zhou <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 5794040 commit 9602c01

File tree

2 files changed

+31
-29
lines changed

2 files changed

+31
-29
lines changed

net/openvswitch/datapath.c

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -142,35 +142,6 @@ static int queue_userspace_packet(struct datapath *dp, struct sk_buff *,
142142
const struct dp_upcall_info *,
143143
uint32_t cutlen);
144144

145-
/* Must be called with rcu_read_lock. */
146-
static struct datapath *get_dp_rcu(struct net *net, int dp_ifindex)
147-
{
148-
struct net_device *dev = dev_get_by_index_rcu(net, dp_ifindex);
149-
150-
if (dev) {
151-
struct vport *vport = ovs_internal_dev_get_vport(dev);
152-
if (vport)
153-
return vport->dp;
154-
}
155-
156-
return NULL;
157-
}
158-
159-
/* The caller must hold either ovs_mutex or rcu_read_lock to keep the
160-
* returned dp pointer valid.
161-
*/
162-
static inline struct datapath *get_dp(struct net *net, int dp_ifindex)
163-
{
164-
struct datapath *dp;
165-
166-
WARN_ON_ONCE(!rcu_read_lock_held() && !lockdep_ovsl_is_held());
167-
rcu_read_lock();
168-
dp = get_dp_rcu(net, dp_ifindex);
169-
rcu_read_unlock();
170-
171-
return dp;
172-
}
173-
174145
/* Must be called with rcu_read_lock or ovs_mutex. */
175146
const char *ovs_dp_name(const struct datapath *dp)
176147
{

net/openvswitch/datapath.h

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
#include "conntrack.h"
3131
#include "flow.h"
3232
#include "flow_table.h"
33+
#include "vport-internal_dev.h"
3334

3435
#define DP_MAX_PORTS USHRT_MAX
3536
#define DP_VPORT_HASH_BUCKETS 1024
@@ -190,6 +191,36 @@ static inline struct vport *ovs_vport_ovsl(const struct datapath *dp, int port_n
190191
return ovs_lookup_vport(dp, port_no);
191192
}
192193

194+
/* Must be called with rcu_read_lock. */
195+
static inline struct datapath *get_dp_rcu(struct net *net, int dp_ifindex)
196+
{
197+
struct net_device *dev = dev_get_by_index_rcu(net, dp_ifindex);
198+
199+
if (dev) {
200+
struct vport *vport = ovs_internal_dev_get_vport(dev);
201+
202+
if (vport)
203+
return vport->dp;
204+
}
205+
206+
return NULL;
207+
}
208+
209+
/* The caller must hold either ovs_mutex or rcu_read_lock to keep the
210+
* returned dp pointer valid.
211+
*/
212+
static inline struct datapath *get_dp(struct net *net, int dp_ifindex)
213+
{
214+
struct datapath *dp;
215+
216+
WARN_ON_ONCE(!rcu_read_lock_held() && !lockdep_ovsl_is_held());
217+
rcu_read_lock();
218+
dp = get_dp_rcu(net, dp_ifindex);
219+
rcu_read_unlock();
220+
221+
return dp;
222+
}
223+
193224
extern struct notifier_block ovs_dp_device_notifier;
194225
extern struct genl_family dp_vport_genl_family;
195226

0 commit comments

Comments
 (0)