Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

openvswitch: export get_dp() API.

Later patches will invoke get_dp() outside of datapath.c. Export it.

Signed-off-by: Andy Zhou <azhou@ovn.org>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Andy Zhou and committed by
David S. Miller
9602c01e 57940406

+31 -29
-29
net/openvswitch/datapath.c
··· 142 142 const struct dp_upcall_info *, 143 143 uint32_t cutlen); 144 144 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 - 174 145 /* Must be called with rcu_read_lock or ovs_mutex. */ 175 146 const char *ovs_dp_name(const struct datapath *dp) 176 147 {
+31
net/openvswitch/datapath.h
··· 30 30 #include "conntrack.h" 31 31 #include "flow.h" 32 32 #include "flow_table.h" 33 + #include "vport-internal_dev.h" 33 34 34 35 #define DP_MAX_PORTS USHRT_MAX 35 36 #define DP_VPORT_HASH_BUCKETS 1024 ··· 189 188 { 190 189 ASSERT_OVSL(); 191 190 return ovs_lookup_vport(dp, port_no); 191 + } 192 + 193 + /* Must be called with rcu_read_lock. */ 194 + static inline struct datapath *get_dp_rcu(struct net *net, int dp_ifindex) 195 + { 196 + struct net_device *dev = dev_get_by_index_rcu(net, dp_ifindex); 197 + 198 + if (dev) { 199 + struct vport *vport = ovs_internal_dev_get_vport(dev); 200 + 201 + if (vport) 202 + return vport->dp; 203 + } 204 + 205 + return NULL; 206 + } 207 + 208 + /* The caller must hold either ovs_mutex or rcu_read_lock to keep the 209 + * returned dp pointer valid. 210 + */ 211 + static inline struct datapath *get_dp(struct net *net, int dp_ifindex) 212 + { 213 + struct datapath *dp; 214 + 215 + WARN_ON_ONCE(!rcu_read_lock_held() && !lockdep_ovsl_is_held()); 216 + rcu_read_lock(); 217 + dp = get_dp_rcu(net, dp_ifindex); 218 + rcu_read_unlock(); 219 + 220 + return dp; 192 221 } 193 222 194 223 extern struct notifier_block ovs_dp_device_notifier;