• Hangbin Liu's avatar
    ipv6: fix IPV6_ADDRFORM operation logic · 79a1f0cc
    Hangbin Liu authored
    Socket option IPV6_ADDRFORM supports UDP/UDPLITE and TCP at present.
    Previously the checking logic looks like:
    if (sk->sk_protocol == IPPROTO_UDP || sk->sk_protocol == IPPROTO_UDPLITE)
    	do_some_check;
    else if (sk->sk_protocol != IPPROTO_TCP)
    	break;
    
    After commit b6f61189 ("ipv6: restrict IPV6_ADDRFORM operation"), TCP
    was blocked as the logic changed to:
    if (sk->sk_protocol == IPPROTO_UDP || sk->sk_protocol == IPPROTO_UDPLITE)
    	do_some_check;
    else if (sk->sk_protocol == IPPROTO_TCP)
    	do_some_check;
    	break;
    else
    	break;
    
    Then after commit 82c9ae44 ("ipv6: fix restrict IPV6_ADDRFORM operation")
    UDP/UDPLITE were blocked as the logic changed to:
    if (sk->sk_protocol == IPPROTO_UDP || sk->sk_protocol == IPPROTO_UDPLITE)
    	do_some_check;
    if (sk->sk_protocol == IPPROTO_TCP)
    	do_some_check;
    
    if (sk->sk_protocol != IPPROTO_TCP)
    	break;
    
    Fix it by using Eric's code and simply remove the break in TCP check, which
    looks like:
    if (sk->sk_protocol == IPPROTO_UDP || sk->sk_protocol == IPPROTO_UDPLITE)
    	do_some_check;
    else if (sk->sk_protocol == IPPROTO_TCP)
    	do_some_check;
    else
    	break;
    
    Fixes: 82c9ae44 ("ipv6: fix restrict IPV6_ADDRFORM operation")
    Signed-off-by: default avatarHangbin Liu <liuhangbin@gmail.com>
    Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
    79a1f0cc
ipv6_sockglue.c 33.1 KB