net: make ipv6 PKTINFO honour freebind
authorMaciej Żenczykowski <maze@google.com>
Mon, 7 Nov 2011 14:57:22 +0000 (14:57 +0000)
committerDavid S. Miller <davem@davemloft.net>
Tue, 8 Nov 2011 20:13:03 +0000 (15:13 -0500)
This just makes it possible to spoof source IPv6 address on a socket
without having to create and bind a new socket for every source IP
we wish to spoof.

Signed-off-by: Maciej Żenczykowski <maze@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/ipv6/datagram.c

index e2480691c220a16f93f602ce19266ffb2e7f017f..83037af4fa7b50ddaf680f8d2fa4c339422d863f 100644 (file)
@@ -654,7 +654,7 @@ int datagram_send_ctl(struct net *net, struct sock *sk,
 
                        if (addr_type != IPV6_ADDR_ANY) {
                                int strict = __ipv6_addr_src_scope(addr_type) <= IPV6_ADDR_SCOPE_LINKLOCAL;
-                               if (!inet_sk(sk)->transparent &&
+                               if (!(inet_sk(sk)->freebind || inet_sk(sk)->transparent) &&
                                    !ipv6_chk_addr(net, &src_info->ipi6_addr,
                                                   strict ? dev : NULL, 0))
                                        err = -EINVAL;