Skip to content

Commit 79a1f0c

Browse files
liuhangbindavem330
authored andcommitted
ipv6: fix IPV6_ADDRFORM operation logic
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 b6f6118 ("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 82c9ae4 ("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: 82c9ae4 ("ipv6: fix restrict IPV6_ADDRFORM operation") Signed-off-by: Hangbin Liu <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 4c21daa commit 79a1f0c

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

net/ipv6/ipv6_sockglue.c

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -218,14 +218,15 @@ static int do_ipv6_setsockopt(struct sock *sk, int level, int optname,
218218
retv = -EBUSY;
219219
break;
220220
}
221-
}
222-
if (sk->sk_protocol == IPPROTO_TCP &&
223-
sk->sk_prot != &tcpv6_prot) {
224-
retv = -EBUSY;
221+
} else if (sk->sk_protocol == IPPROTO_TCP) {
222+
if (sk->sk_prot != &tcpv6_prot) {
223+
retv = -EBUSY;
224+
break;
225+
}
226+
} else {
225227
break;
226228
}
227-
if (sk->sk_protocol != IPPROTO_TCP)
228-
break;
229+
229230
if (sk->sk_state != TCP_ESTABLISHED) {
230231
retv = -ENOTCONN;
231232
break;

0 commit comments

Comments
 (0)