Skip to content

Commit

Permalink
bpf: Add SO_TXREHASH setsockopt
Browse files Browse the repository at this point in the history
Add bpf socket option to override rehash behaviour from userspace or from bpf.

Signed-off-by: Akhmat Karakotov <hmukos@yandex-team.ru>
Reviewed-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Akhmat Karakotov authored and David S. Miller committed Jan 31, 2022
1 parent 2127324 commit e7b9bfd
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions net/core/filter.c
Original file line number Diff line number Diff line change
Expand Up @@ -5091,6 +5091,13 @@ static int _bpf_setsockopt(struct sock *sk, int level, int optname,
case SO_REUSEPORT:
sk->sk_reuseport = valbool;
break;
case SO_TXREHASH:
if (val < -1 || val > 1) {
ret = -EINVAL;
break;
}
sk->sk_txrehash = (u8)val;
break;
default:
ret = -EINVAL;
}
Expand Down Expand Up @@ -5269,6 +5276,9 @@ static int _bpf_getsockopt(struct sock *sk, int level, int optname,
case SO_REUSEPORT:
*((int *)optval) = sk->sk_reuseport;
break;
case SO_TXREHASH:
*((int *)optval) = sk->sk_txrehash;
break;
default:
goto err_clear;
}
Expand Down

0 comments on commit e7b9bfd

Please sign in to comment.