shortcut-fe: use correct API to get master of bridge port
CRs-Fixed: 808126
Change-Id: I49f3961250c70752bc85c57383bf5bf19aa5728e
Signed-off-by: Xiaoping Fan <xfan@codeaurora.org>
diff --git a/shortcut-fe/sfe_backport.h b/shortcut-fe/sfe_backport.h
index 58e4477..b7f7928 100644
--- a/shortcut-fe/sfe_backport.h
+++ b/shortcut-fe/sfe_backport.h
@@ -40,11 +40,27 @@
int (*OKFN)(struct sk_buff *))
#endif
+/*
+ * sfe_dev_get_master
+ * get master of bridge port, and hold it
+ */
+static inline struct net_device *sfe_dev_get_master(struct net_device *dev)
+{
+ struct net_device *master;
#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 9, 0)
-#define SFE_DEV_MASTER(DEV) netdev_master_upper_dev_get(DEV)
+ rcu_read_lock();
+ master = netdev_master_upper_dev_get_rcu(dev);
+ if (master)
+ dev_hold(master);
+
+ rcu_read_unlock();
#else
-#define SFE_DEV_MASTER(DEV) ((DEV)->master)
+ master = dev->master;
+ if (master)
+ dev_hold(master);
#endif
+ return master;
+}
#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 13, 0)
#define SFE_NF_CONN_ACCT(NM) struct nf_conn_acct *NM