]> git.baikalelectronics.ru Git - kernel.git/commitdiff
bpf: Add SO_TXREHASH setsockopt
authorAkhmat Karakotov <hmukos@yandex-team.ru>
Mon, 31 Jan 2022 13:31:24 +0000 (16:31 +0300)
committerDavid S. Miller <davem@davemloft.net>
Mon, 31 Jan 2022 15:05:25 +0000 (15:05 +0000)
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>
net/core/filter.c

index a06931c27eebe3f0d9a0232c4d9bf1ce9a69f092..9615ae1ab530a9735e3d862b1ddf12b1b1f55060 100644 (file)
@@ -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;
                }
@@ -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;
                }