diff options
author | Hannes Frederic Sowa <hannes@stressinduktion.org> | 2013-03-08 02:07:16 +0000 |
---|---|---|
committer | Gabby Lee <galee@nvidia.com> | 2014-01-09 17:50:50 -0800 |
commit | 36a0aecac360a89a88306d22b7578d2ae14ba9be (patch) | |
tree | 0f2160f61ede78e1165d7725b2e69353ea32edf1 | |
parent | f08b3a1c970f72c6978979936d117b694ecaeba6 (diff) |
ipv6: introdcue __ipv6_addr_needs_scope_id and ipv6_iface_scope_id helper functions
[net-next commit b7ef213ef65256168df83ddfbb8131ed9adc10f9]
__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
Bug 1412141
Change-Id: I1788f1f2d3a6bd2b9e6a6afe74992d6d4a1385eb
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>
Signed-off-by: David S. Miller <davem@davemloft.net>
(cherry picked from commit 2c75b248e5243d0af7cc97522148db7415a70f8a)
Reviewed-on: http://git-master/r/336266
(cherry picked from commit dfd23e75d7f69863ec3903ea1300185a1474b56a)
Reviewed-on: http://git-master/r/353229
Reviewed-by: Nitin Bindal <nbindal@nvidia.com>
Tested-by: Nitin Bindal <nbindal@nvidia.com>
Reviewed-by: Bitan Biswas <bbiswas@nvidia.com>
Reviewed-by: Gabby Lee <galee@nvidia.com>
-rw-r--r-- | include/net/ipv6.h | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/include/net/ipv6.h b/include/net/ipv6.h index 12a1bd2e9879..155a84a98759 100644 --- a/include/net/ipv6.h +++ b/include/net/ipv6.h @@ -295,6 +295,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)); |