diff options
author | Hannes Frederic Sowa <hannes@stressinduktion.org> | 2013-03-08 02:07:16 +0000 |
---|---|---|
committer | Manish Tuteja <mtuteja@nvidia.com> | 2014-04-01 03:10:22 -0700 |
commit | 37a81c1e93fd95b20977d40915711462e309f6ec (patch) | |
tree | 575b9fb49ded76ad438a2d441a41a3dd9cf1c52d /include | |
parent | d51c18a8ae5da9ab9755df5acf58a0f417842409 (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/350982
(cherry picked from commit edc5676cb9a9136f88db4685feb11bb87ed359cf)
Reviewed-on: http://git-master/r/390633
Reviewed-by: Jun Su <juns@nvidia.com>
Reviewed-by: Om Prakash Singh <omp@nvidia.com>
Reviewed-by: Liangcai Li <liangcail@nvidia.com>
Tested-by: Liangcai Li <liangcail@nvidia.com>
Reviewed-by: Manish Tuteja <mtuteja@nvidia.com>
Diffstat (limited to 'include')
-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 e4170a22fc6f..32f9cb9c97d6 100644 --- a/include/net/ipv6.h +++ b/include/net/ipv6.h @@ -294,6 +294,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)); |