Skip to content

Commit

Permalink
net: lockless SO_{TYPE|PROTOCOL|DOMAIN|ERROR } setsockopt()
Browse files Browse the repository at this point in the history
This options can not be set and return -ENOPROTOOPT,
no need to acqure socket lock.

Signed-off-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Eric Dumazet authored and David S. Miller committed Oct 1, 2023
1 parent 8ebfb6d commit b120251
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions net/core/sock.c
Original file line number Diff line number Diff line change
Expand Up @@ -1135,6 +1135,11 @@ int sk_setsockopt(struct sock *sk, int level, int optname,
case SO_PASSPIDFD:
assign_bit(SOCK_PASSPIDFD, &sock->flags, valbool);
return 0;
case SO_TYPE:
case SO_PROTOCOL:
case SO_DOMAIN:
case SO_ERROR:
return -ENOPROTOOPT;
}

sockopt_lock_sock(sk);
Expand All @@ -1152,12 +1157,6 @@ int sk_setsockopt(struct sock *sk, int level, int optname,
case SO_REUSEPORT:
sk->sk_reuseport = valbool;
break;
case SO_TYPE:
case SO_PROTOCOL:
case SO_DOMAIN:
case SO_ERROR:
ret = -ENOPROTOOPT;
break;
case SO_DONTROUTE:
sock_valbool_flag(sk, SOCK_LOCALROUTE, valbool);
sk_dst_reset(sk);
Expand Down

0 comments on commit b120251

Please sign in to comment.