diff mbox

[net-next,RFC,v1,15/27] afnetns: add ipv6_get_ifaddr_afnetns_rcu

Message ID 20170312230151.5185-16-hannes@stressinduktion.org
State RFC, archived
Delegated to: David Miller
Headers show

Commit Message

Hannes Frederic Sowa March 12, 2017, 11:01 p.m. UTC
Signed-off-by: Hannes Frederic Sowa <hannes@stressinduktion.org>
---
 include/net/addrconf.h | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)
diff mbox

Patch

diff --git a/include/net/addrconf.h b/include/net/addrconf.h
index e3f1920ca57968..644fa68bb4ddef 100644
--- a/include/net/addrconf.h
+++ b/include/net/addrconf.h
@@ -104,6 +104,23 @@  int addrconf_prefix_rcv_add_addr(struct net *net, struct net_device *dev,
 				 u32 addr_flags, bool sllao, bool tokenized,
 				 __u32 valid_lft, u32 prefered_lft);
 
+static inline
+struct afnetns *ipv6_get_ifaddr_afnetns_rcu(struct net *net,
+					    const struct in6_addr *addr,
+					    struct net_device *dev)
+{
+#if IS_ENABLED(CONFIG_AFNETNS)
+	struct inet6_ifaddr *ifp;
+
+	ifp = ipv6_get_ifaddr(net, addr, dev, 1);
+	if (ifp)
+		return ifp->afnetns;
+	return net->afnet_ns;
+#else
+	return NULL;
+#endif
+}
+
 static inline int addrconf_ifid_eui48(u8 *eui, struct net_device *dev)
 {
 	if (dev->addr_len != ETH_ALEN)