]> git.baikalelectronics.ru Git - kernel.git/commitdiff
net: bpf: Use the protocol's set_rcvlowat behavior if there is one
authorGao Feng <gfree.wind@gmail.com>
Thu, 4 Aug 2022 15:04:21 +0000 (23:04 +0800)
committerDavid S. Miller <davem@davemloft.net>
Mon, 8 Aug 2022 08:45:14 +0000 (09:45 +0100)
The commit 5c4e6e4923c1 ("tcp: fix SO_RCVLOWAT and RCVBUF autotuning")
add one new (struct proto_ops)->set_rcvlowat method so that a protocol
can override the default setsockopt(SO_RCVLOWAT) behavior.

The prior bpf codes don't check and invoke the protos's set_rcvlowat,
now correct it.

Signed-off-by: Gao Feng <gfree.wind@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/core/filter.c

index 5669248aff25b709e4ade9e3a60fab87509dd86a..e8508aaafd27d75c6cbf872eeeb60e608ecdcd6f 100644 (file)
@@ -5063,7 +5063,10 @@ static int __bpf_setsockopt(struct sock *sk, int level, int optname,
                case SO_RCVLOWAT:
                        if (val < 0)
                                val = INT_MAX;
-                       WRITE_ONCE(sk->sk_rcvlowat, val ? : 1);
+                       if (sk->sk_socket && sk->sk_socket->ops->set_rcvlowat)
+                               ret = sk->sk_socket->ops->set_rcvlowat(sk, val);
+                       else
+                               WRITE_ONCE(sk->sk_rcvlowat, val ? : 1);
                        break;
                case SO_MARK:
                        if (sk->sk_mark != val) {