Skip to contentSkip to conversation

ipv6: introdcue __ipv6_addr_needs_scope_id and ipv6_iface_scope_id helper functions

PATCH Applied Hannes Frederic Sowa 3 participants 3 messages Mar 8, 2013

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH v4 1/4 ipv6: introdcue __ipv6_addr_needs_scope_id and ipv6_iface_scope_id helper functions

__ipv6_addr_needs_scope_id checks if an ipv6 address needs to supply a 'sin6_scope_id != 0'. 'sin6_scope_id != 0' was enforced in case of link-local addresses. To support interface-local multicast these checks had to be enhanced and are now consolidated into these new helper functions.

v2:
a) migrated to struct ipv6_addr_props

v3:
a) reverted changes for ipv6_addr_props
b) test for address type instead of comparing scope

v4:
a) unchanged

---
 include/net/ipv6.h | 12 ++++++++++++
 1 file changed, 12 insertions(+)
include/net/ipv6.h +12 -0
index 988c9f2..42ef6ab 100644
@@ -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));
Signature · 1 line
1.8.1.4
Acked-by on v4 1/4
#1 lore raw
Quoted 38 lines · Hannes Frederic Sowa

__ipv6_addr_needs_scope_id checks if an ipv6 address needs to supply a 'sin6_scope_id != 0'. 'sin6_scope_id != 0' was enforced in case of link-local addresses. To support interface-local multicast these checks had to be enhanced and are now consolidated into these new helper functions.

v2:
a) migrated to struct ipv6_addr_props

v3:
a) reverted changes for ipv6_addr_props
b) test for address type instead of comparing scope

v4:
a) unchanged

---
 include/net/ipv6.h | 12 ++++++++++++
 1 file changed, 12 insertions(+)
include/net/ipv6.h +5 -0
index 988c9f2..42ef6ab 100644
@@ -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)));

include/net/ipv6.h static inline int ipv6_addr_src_scope(const struct in6_addr *addr) · line 337

Quoted 10 lines
include/net/ipv6.h +7 -0
+}
+
+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));
maintainer Applied
#2 lore raw

From: YOSHIFUJI Hideaki <[email protected]>
Date: Sat, 09 Mar 2013 01:28:56 +0900

Quoted 21 lines
Quoted 20 lines · Hannes Frederic Sowa

__ipv6_addr_needs_scope_id checks if an ipv6 address needs to supply a 'sin6_scope_id != 0'. 'sin6_scope_id != 0' was enforced in case of link-local addresses. To support interface-local multicast these checks had to be enhanced and are now consolidated into these new helper functions.

v2:
a) migrated to struct ipv6_addr_props

v3:
a) reverted changes for ipv6_addr_props
b) test for address type instead of comparing scope

v4:
a) unchanged

...

Quoted 1 line

Applied.