Commit 7c90cc2d authored by FX Le Bail's avatar FX Le Bail Committed by David S. Miller

ipv6: enable anycast addresses as source addresses for datagrams

This change allows to consider an anycast address valid as source address
when given via an IPV6_PKTINFO or IPV6_2292PKTINFO ancillary data item.
So, when sending a datagram with ancillary data, the unicast and anycast
addresses are handled in the same way.

- Adds ipv6_chk_acast_addr_src() to check if an anycast address is link-local
  on given interface or is global.
- Uses it in ip6_datagram_send_ctl().
Signed-off-by: default avatarFrancois-Xavier Le Bail <fx.lebail@yahoo.com>
Acked-by: default avatarHannes Frederic Sowa <hannes@stressinduktion.org>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent eb97768a
...@@ -205,8 +205,9 @@ void ipv6_sock_ac_close(struct sock *sk); ...@@ -205,8 +205,9 @@ void ipv6_sock_ac_close(struct sock *sk);
int ipv6_dev_ac_inc(struct net_device *dev, const struct in6_addr *addr); int ipv6_dev_ac_inc(struct net_device *dev, const struct in6_addr *addr);
int __ipv6_dev_ac_dec(struct inet6_dev *idev, const struct in6_addr *addr); int __ipv6_dev_ac_dec(struct inet6_dev *idev, const struct in6_addr *addr);
bool ipv6_chk_acast_addr(struct net *net, struct net_device *dev, bool ipv6_chk_acast_addr(struct net *net, struct net_device *dev,
const struct in6_addr *addr); const struct in6_addr *addr);
bool ipv6_chk_acast_addr_src(struct net *net, struct net_device *dev,
const struct in6_addr *addr);
/* Device notifier */ /* Device notifier */
int register_inet6addr_notifier(struct notifier_block *nb); int register_inet6addr_notifier(struct notifier_block *nb);
......
...@@ -383,6 +383,17 @@ bool ipv6_chk_acast_addr(struct net *net, struct net_device *dev, ...@@ -383,6 +383,17 @@ bool ipv6_chk_acast_addr(struct net *net, struct net_device *dev,
return found; return found;
} }
/* check if this anycast address is link-local on given interface or
* is global
*/
bool ipv6_chk_acast_addr_src(struct net *net, struct net_device *dev,
const struct in6_addr *addr)
{
return ipv6_chk_acast_addr(net,
(ipv6_addr_type(addr) & IPV6_ADDR_LINKLOCAL ?
dev : NULL),
addr);
}
#ifdef CONFIG_PROC_FS #ifdef CONFIG_PROC_FS
struct ac6_iter_state { struct ac6_iter_state {
......
...@@ -699,7 +699,9 @@ int ip6_datagram_send_ctl(struct net *net, struct sock *sk, ...@@ -699,7 +699,9 @@ int ip6_datagram_send_ctl(struct net *net, struct sock *sk,
int strict = __ipv6_addr_src_scope(addr_type) <= IPV6_ADDR_SCOPE_LINKLOCAL; int strict = __ipv6_addr_src_scope(addr_type) <= IPV6_ADDR_SCOPE_LINKLOCAL;
if (!(inet_sk(sk)->freebind || inet_sk(sk)->transparent) && if (!(inet_sk(sk)->freebind || inet_sk(sk)->transparent) &&
!ipv6_chk_addr(net, &src_info->ipi6_addr, !ipv6_chk_addr(net, &src_info->ipi6_addr,
strict ? dev : NULL, 0)) strict ? dev : NULL, 0) &&
!ipv6_chk_acast_addr_src(net, dev,
&src_info->ipi6_addr))
err = -EINVAL; err = -EINVAL;
else else
fl6->saddr = src_info->ipi6_addr; fl6->saddr = src_info->ipi6_addr;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment