]> Pileus Git - ~andy/linux/blobdiff - include/net/ipv6.h
ipv6: introdcue __ipv6_addr_needs_scope_id and ipv6_iface_scope_id helper functions
[~andy/linux] / include / net / ipv6.h
index 64d12e77719afd26b95333a8a145b50301cef440..42ef6abf25c3dba413e2f7eb2fb16e8ba0f41728 100644 (file)
@@ -217,7 +217,7 @@ struct ipv6_txoptions {
 };
 
 struct ip6_flowlabel {
-       struct ip6_flowlabel    *next;
+       struct ip6_flowlabel __rcu *next;
        __be32                  label;
        atomic_t                users;
        struct in6_addr         dst;
@@ -238,9 +238,9 @@ struct ip6_flowlabel {
 #define IPV6_FLOWLABEL_MASK    cpu_to_be32(0x000FFFFF)
 
 struct ipv6_fl_socklist {
-       struct ipv6_fl_socklist *next;
-       struct ip6_flowlabel    *fl;
-       struct rcu_head         rcu;
+       struct ipv6_fl_socklist __rcu   *next;
+       struct ip6_flowlabel            *fl;
+       struct rcu_head                 rcu;
 };
 
 extern struct ip6_flowlabel    *fl6_sock_lookup(struct sock *sk, __be32 label);
@@ -320,6 +320,18 @@ static inline int ipv6_addr_src_scope(const struct in6_addr *addr)
        return __ipv6_addr_src_scope(__ipv6_addr_type(addr));
 }
 
+static inline bool __ipv6_addr_needs_scope_id(int type)
+{
+       return type & IPV6_ADDR_LINKLOCAL ||
+              (type & IPV6_ADDR_MULTICAST &&
+               (type & (IPV6_ADDR_LOOPBACK|IPV6_ADDR_LINKLOCAL)));
+}
+
+static inline __u32 ipv6_iface_scope_id(const struct in6_addr *addr, int iface)
+{
+       return __ipv6_addr_needs_scope_id(__ipv6_addr_type(addr)) ? iface : 0;
+}
+
 static inline int ipv6_addr_cmp(const struct in6_addr *a1, const struct in6_addr *a2)
 {
        return memcmp(a1, a2, sizeof(struct in6_addr));