case RX_HANDLER_CONSUMED:
ret = NET_RX_SUCCESS;
goto unlock;
diff --git a/net/openvswitch/dp_notify.c b/net/openvswitch/dp_notify.c
index 5558350..5248f8e 100644
--- a/net/openvswitch/dp_notify.c
+++ b/net/openvswitch/dp_notify.c
@@ -32,7 +32,7 @@ static int dp_device_event(struct notifier_block
*unused, unsigned long event,
if (ovs_is_internal_dev(dev))
vport = ovs_internal_dev_get_vport(dev);
else
- vport = ovs_netdev_get_vport(dev);
+ vport = ovs_netdev_get_vport_rtnl(dev);
if (!vport)
return NOTIFY_DONE;
diff --git a/net/openvswitch/vport-netdev.c
b/net/openvswitch/vport-netdev.c
index 2130d61..0ff6aa1 100644
--- a/net/openvswitch/vport-netdev.c
+++ b/net/openvswitch/vport-netdev.c
/* Must be called with rcu_read_lock. */
static void netdev_port_receive(struct vport *vport, struct sk_buff
*skb)
{
- if (unlikely(!vport))
- goto error;
-
if (unlikely(skb_warn_if_lro(skb)))
goto error;
}
/* Called with rcu_read_lock and bottom-halves disabled. */
-static rx_handler_result_t netdev_frame_hook(struct sk_buff **pskb)
+static rx_handler_result_t
+netdev_frame_hook(struct sk_buff **pskb, struct netdev_rx_handler
*rx_handler)
{
struct sk_buff *skb = *pskb;
struct vport *vport;@@ -65,7 +63,7 @@ static rx_handler_result_t netdev_frame_hook(struct
sk_buff **pskb)
if (unlikely(skb->pkt_type == PACKET_LOOPBACK))
return RX_HANDLER_PASS;
- vport = ovs_netdev_get_vport(skb->dev);
+ vport = ovs_netdev_get_vport_by_rx_handler(rx_handler);
netdev_port_receive(vport, skb);
@@ -100,8 +98,8 @@ static struct vport *netdev_create(const struct
vport_parms *parms)
goto error_put;
}
- err = netdev_rx_handler_register(netdev_vport->dev,
netdev_frame_hook,
- vport);
+ netdev_rx_handler_init(&vport->rx_handler, netdev_frame_hook);
+ err = netdev_rx_handler_register(netdev_vport->dev,
&vport->rx_handler);
if (err)
goto error_put;
@@ -185,16 +183,6 @@ error:
return 0;
}
-/* Returns null if this device is not attached to a datapath. */
-struct vport *ovs_netdev_get_vport(struct net_device *dev)
-{
- if (likely(dev->priv_flags & IFF_OVS_DATAPATH))
- return (struct vport *)
- rcu_dereference_rtnl(dev->rx_handler_data);
- else
- return NULL;
-}
-
const struct vport_ops ovs_netdev_vport_ops = {
.type = OVS_VPORT_TYPE_NETDEV,
.create = netdev_create,diff --git a/net/openvswitch/vport-netdev.h
b/net/openvswitch/vport-netdev.h
index 6478079..d3f1471 100644
--- a/net/openvswitch/vport-netdev.h
+++ b/net/openvswitch/vport-netdev.h
#include "vport.h"
-struct vport *ovs_netdev_get_vport(struct net_device *dev);
+#define ovs_netdev_vport_exists(dev) (dev->priv_flags &
IFF_OVS_DATAPATH)
+
+static inline struct vport *
+ovs_netdev_get_vport_by_rx_handler(const struct netdev_rx_handler
*rx_handler)
+{
+ return container_of(rx_handler, struct vport, rx_handler);
+}
+
+static inline struct vport *
+ovs_netdev_get_vport_rtnl(const struct net_device *dev)
+{
+ if (!ovs_netdev_vport_exists(dev))
+ return NULL;
+ return
ovs_netdev_get_vport_by_rx_handler(rtnl_dereference(dev->rx_handler));
+}
struct netdev_vport {
struct rcu_head rcu;diff --git a/net/openvswitch/vport.h b/net/openvswitch/vport.h
index aee7d43..a7a07c0 100644
--- a/net/openvswitch/vport.h
+++ b/net/openvswitch/vport.h
@@ -67,6 +67,7 @@ struct vport_err_stats {
/**
* struct vport - one port within a datapath
+ * @rx_handler: RX handler structure.
* @rcu: RCU callback head for deferred destruction.
* @dp: Datapath to which this port belongs.
* @upcall_portid: The Netlink port to use for packets received on this
port that
@@ -80,6 +81,7 @@ struct vport_err_stats {
* @err_stats: Points to error statistics used and maintained by vport
*/struct vport {
+ struct netdev_rx_handler rx_handler;
struct rcu_head rcu;
struct datapath *dp;
u32 upcall_portid;