summaryrefslogtreecommitdiff
path: root/net/batman-adv/hard-interface.h
diff options
context:
space:
mode:
authorDavid S. Miller <davem@davemloft.net>2011-05-02 15:04:46 -0700
committerDavid S. Miller <davem@davemloft.net>2011-05-02 15:04:46 -0700
commitdcfd9cdc1222f14d6180514e533289493a0716fb (patch)
tree8a60386e7e55c44fc08c02506380989a3c83a166 /net/batman-adv/hard-interface.h
parent5615787257742aab42ecf17c11e3244d9536a48d (diff)
parent32ae9b221e788413ce68feaae2ca39e406211a0a (diff)
downloadlinux-next-dcfd9cdc1222f14d6180514e533289493a0716fb.tar.gz
Merge branch 'batman-adv/next' of git://git.open-mesh.org/ecsv/linux-merge
Diffstat (limited to 'net/batman-adv/hard-interface.h')
-rw-r--r--net/batman-adv/hard-interface.h18
1 files changed, 18 insertions, 0 deletions
diff --git a/net/batman-adv/hard-interface.h b/net/batman-adv/hard-interface.h
index a9ddf36e51c8..64265991460b 100644
--- a/net/batman-adv/hard-interface.h
+++ b/net/batman-adv/hard-interface.h
@@ -45,4 +45,22 @@ static inline void hardif_free_ref(struct hard_iface *hard_iface)
call_rcu(&hard_iface->rcu, hardif_free_rcu);
}
+static inline struct hard_iface *primary_if_get_selected(
+ struct bat_priv *bat_priv)
+{
+ struct hard_iface *hard_iface;
+
+ rcu_read_lock();
+ hard_iface = rcu_dereference(bat_priv->primary_if);
+ if (!hard_iface)
+ goto out;
+
+ if (!atomic_inc_not_zero(&hard_iface->refcount))
+ hard_iface = NULL;
+
+out:
+ rcu_read_unlock();
+ return hard_iface;
+}
+
#endif /* _NET_BATMAN_ADV_HARD_INTERFACE_H_ */