From: Liping Zhang <liping.zh...@spreadtrum.com> We can use IPV6_PKTINFO to specify the ipv6 source address when call sendmsg() to send packet, but if the address is not available, call will fail and EINVAL is returned. This error code is not very appropriate, it failed maybe just because of a temporary network problem, i.e. when the network recovery, sendmsg() call will become ok. Also RFC3542, section 6.6 describe an example in error scenario that returns EADDRNOTAVAIL: "ipi6_ifindex specifies an interface but the address ipi6_addr is not available for use on that interface.". So return EADDRNOTAVAIL instead of EINVAL here.
Signed-off-by: Liping Zhang <liping.zh...@spreadtrum.com> --- net/ipv6/datagram.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/ipv6/datagram.c b/net/ipv6/datagram.c index a73d701..20a968b 100644 --- a/net/ipv6/datagram.c +++ b/net/ipv6/datagram.c @@ -753,7 +753,7 @@ int ip6_datagram_send_ctl(struct net *net, struct sock *sk, strict ? dev : NULL, 0) && !ipv6_chk_acast_addr_src(net, dev, &src_info->ipi6_addr)) - err = -EINVAL; + err = -EADDRNOTAVAIL; else fl6->saddr = src_info->ipi6_addr; } -- 1.7.9.5