[ovs-dev] [PATCH 2/5] datapath: Take advantage of IFF_OVS_DATAPATH.
Jesse Gross
jesse at nicira.com
Fri Dec 10 20:42:54 UTC 2010
Starting in 2.6.37 we have our own unique identifier to be able
to find ports attached to OVS. Take advantage of it to avoid
ugly workarounds.
Signed-off-by: Jesse Gross <jesse at nicira.com>
---
datapath/vport-netdev.c | 17 +++++++++--------
1 files changed, 9 insertions(+), 8 deletions(-)
diff --git a/datapath/vport-netdev.c b/datapath/vport-netdev.c
index dfeccac..ba90a31 100644
--- a/datapath/vport-netdev.c
+++ b/datapath/vport-netdev.c
@@ -273,15 +273,16 @@ static int netdev_send(struct vport *vport, struct sk_buff *skb)
/* Returns null if this device is not attached to a datapath. */
struct vport *netdev_get_vport(struct net_device *dev)
{
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,36)
- /* XXX: The bridge code may have registered the data.
- * So check that the handler pointer is the datapath's.
- * Once the merge is done and IFF_OVS_DATAPATH stops
- * being the same value as IFF_BRIDGE_PORT the check can
- * simply be netdev_vport->dev->priv_flags & IFF_OVS_DATAPATH. */
- if (rcu_dereference(dev->rx_handler) != netdev_frame_hook)
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,37)
+ if (likely(dev->priv_flags & IFF_OVS_DATAPATH))
+ return (struct vport *)rcu_dereference(dev->rx_handler_data);
+ else
+ return NULL;
+#elif LINUX_VERSION_CODE == KERNEL_VERSION(2,6,36)
+ if (likely(rcu_dereference(dev->rx_handler) == netdev_frame_hook))
+ return (struct vport *)rcu_dereference(dev->rx_handler_data);
+ else
return NULL;
- return (struct vport *)rcu_dereference(dev->rx_handler_data);
#else
return (struct vport *)rcu_dereference(dev->br_port);
#endif
--
1.7.1
More information about the dev
mailing list