* [PATCH net-next v4 1/4] ipv6: introdcue __ipv6_addr_needs_scope_id and ipv6_iface_scope_id helper functions
@ 2013-03-08 12:07 Hannes Frederic Sowa
2013-03-08 16:28 ` YOSHIFUJI Hideaki
0 siblings, 1 reply; 3+ messages in thread
From: Hannes Frederic Sowa @ 2013-03-08 12:07 UTC (permalink / raw)
To: netdev; +Cc: yoshfuji
__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
Suggested-by: YOSHIFUJI Hideaki <yoshfuji@linux-ipv6.org>
Cc: YOSHIFUJI Hideaki <yoshfuji@linux-ipv6.org>
Acked-by: YOSHIFUJI Hideaki <yoshfuji@linux-ipv6.org>
Signed-off-by: Hannes Frederic Sowa <hannes@stressinduktion.org>
---
include/net/ipv6.h | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/include/net/ipv6.h b/include/net/ipv6.h
index 988c9f2..42ef6ab 100644
--- a/include/net/ipv6.h
+++ b/include/net/ipv6.h
@@ -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));
--
1.8.1.4
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH net-next v4 1/4] ipv6: introdcue __ipv6_addr_needs_scope_id and ipv6_iface_scope_id helper functions
2013-03-08 12:07 [PATCH net-next v4 1/4] ipv6: introdcue __ipv6_addr_needs_scope_id and ipv6_iface_scope_id helper functions Hannes Frederic Sowa
@ 2013-03-08 16:28 ` YOSHIFUJI Hideaki
2013-03-08 17:29 ` David Miller
0 siblings, 1 reply; 3+ messages in thread
From: YOSHIFUJI Hideaki @ 2013-03-08 16:28 UTC (permalink / raw)
To: netdev, David Miller; +Cc: YOSHIFUJI Hideaki
Hannes Frederic Sowa wrote:
> __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
>
> Suggested-by: YOSHIFUJI Hideaki <yoshfuji@linux-ipv6.org>
> Cc: YOSHIFUJI Hideaki <yoshfuji@linux-ipv6.org>
> Acked-by: YOSHIFUJI Hideaki <yoshfuji@linux-ipv6.org>
> Signed-off-by: Hannes Frederic Sowa <hannes@stressinduktion.org>
> ---
> include/net/ipv6.h | 12 ++++++++++++
> 1 file changed, 12 insertions(+)
>
> diff --git a/include/net/ipv6.h b/include/net/ipv6.h
> index 988c9f2..42ef6ab 100644
> --- a/include/net/ipv6.h
> +++ b/include/net/ipv6.h
> @@ -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));
>
Acked-by: YOSHIFUJI Hideaki <yoshfuji@linux-ipv6.org>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH net-next v4 1/4] ipv6: introdcue __ipv6_addr_needs_scope_id and ipv6_iface_scope_id helper functions
2013-03-08 16:28 ` YOSHIFUJI Hideaki
@ 2013-03-08 17:29 ` David Miller
0 siblings, 0 replies; 3+ messages in thread
From: David Miller @ 2013-03-08 17:29 UTC (permalink / raw)
To: yoshfuji; +Cc: netdev
From: YOSHIFUJI Hideaki <yoshfuji@linux-ipv6.org>
Date: Sat, 09 Mar 2013 01:28:56 +0900
> Hannes Frederic Sowa wrote:
>> __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
>>
>> Suggested-by: YOSHIFUJI Hideaki <yoshfuji@linux-ipv6.org>
>> Cc: YOSHIFUJI Hideaki <yoshfuji@linux-ipv6.org>
>> Acked-by: YOSHIFUJI Hideaki <yoshfuji@linux-ipv6.org>
>> Signed-off-by: Hannes Frederic Sowa <hannes@stressinduktion.org>
...
> Acked-by: YOSHIFUJI Hideaki <yoshfuji@linux-ipv6.org>
Applied.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2013-03-08 17:29 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-03-08 12:07 [PATCH net-next v4 1/4] ipv6: introdcue __ipv6_addr_needs_scope_id and ipv6_iface_scope_id helper functions Hannes Frederic Sowa
2013-03-08 16:28 ` YOSHIFUJI Hideaki
2013-03-08 17:29 ` David Miller
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).