[Devel] [PATCH vz7] net: Skip IP_FREEBIND for ipv6 SOCK_RAW sockets

Andrei Vagin avagin at virtuozzo.com
Wed Mar 21 02:18:09 MSK 2018


On Tue, Mar 20, 2018 at 02:07:51PM +0300, Kirill Tkhai wrote:
> IP_FREEBIND is not supported for SOCK_RAW ipv6 sockets.
> See kernel rawv6_setsockopt() for the details.

inet_bind() can fail for ipv6 addresses without this option:

/*
 * ipv6 addresses go through a “tentative” phase and
 * sockets could not be bound to them in this moment
 * without setting IP_FREEBIND.
 */

Maybe we need to add support of this option for raw socket in the kernel?

> 
> JFI:
> For the rest of sockets, where they begin to support it:
> the actual magic happens in do_ipv6_setsockopt(), and
> IPV6_ADDRFORM optname changes sk->sk_prot to refer
> to tcp_prot, udp_prot and udplite_prot, which contains
> link to ip_setsockopt().
> 
> Signed-off-by: Kirill Tkhai <ktkhai at virtuozzo.com>
> ---
>  criu/sk-inet.c |    2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/criu/sk-inet.c b/criu/sk-inet.c
> index 941de1863..4fccda48c 100644
> --- a/criu/sk-inet.c
> +++ b/criu/sk-inet.c
> @@ -813,7 +813,7 @@ int inet_bind(int sk, struct inet_sk_info *ii)
>  	 * sockets could not be bound to them in this moment
>  	 * without setting IP_FREEBIND.
>  	 */
> -	if (ii->ie->family == AF_INET6 && ii->ie->proto != IPPROTO_RAW) {
> +	if (ii->ie->family == AF_INET6 && ii->ie->type != SOCK_RAW) {
>  		int yes = 1;
>  
>  		if (restore_opt(sk, SOL_IP, IP_FREEBIND, &yes))
> 
> _______________________________________________
> Devel mailing list
> Devel at openvz.org
> https://lists.openvz.org/mailman/listinfo/devel


More information about the Devel mailing list