]> git.baikalelectronics.ru Git - kernel.git/commitdiff
tcp: add tcp_sock_set_quickack
authorChristoph Hellwig <hch@lst.de>
Thu, 28 May 2020 05:12:20 +0000 (07:12 +0200)
committerDavid S. Miller <davem@davemloft.net>
Thu, 28 May 2020 18:11:45 +0000 (11:11 -0700)
Add a helper to directly set the TCP_QUICKACK sockopt from kernel space
without going through a fake uaccess.  Cleanup the callers to avoid
pointless wrappers now that this is a simple function call.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/block/drbd/drbd_int.h
drivers/block/drbd/drbd_receiver.c
include/linux/tcp.h
net/ipv4/tcp.c

index e24bba87c8e0258a3457432969c29e72bf47f44d..14345a87c7cc56fa6cfc5dd06d6beb14d0628a3a 100644 (file)
@@ -1570,13 +1570,6 @@ extern void drbd_set_recv_tcq(struct drbd_device *device, int tcq_enabled);
 extern void _drbd_clear_done_ee(struct drbd_device *device, struct list_head *to_be_freed);
 extern int drbd_connected(struct drbd_peer_device *);
 
-static inline void drbd_tcp_quickack(struct socket *sock)
-{
-       int val = 2;
-       (void) kernel_setsockopt(sock, SOL_TCP, TCP_QUICKACK,
-                       (char*)&val, sizeof(val));
-}
-
 /* sets the number of 512 byte sectors of our virtual device */
 void drbd_set_my_capacity(struct drbd_device *device, sector_t size);
 
index 20a5e94494acddb27ed145706bb4c2360eaa493b..3a3f2b6a821f394302228d1bbb18bb1ed6e6cfb6 100644 (file)
@@ -1223,7 +1223,7 @@ static int drbd_recv_header_maybe_unplug(struct drbd_connection *connection, str
                 * quickly as possible, and let remote TCP know what we have
                 * received so far. */
                if (err == -EAGAIN) {
-                       drbd_tcp_quickack(connection->data.socket);
+                       tcp_sock_set_quickack(connection->data.socket->sk, 2);
                        drbd_unplug_all_devices(connection);
                }
                if (err > 0) {
@@ -4959,8 +4959,7 @@ static int receive_UnplugRemote(struct drbd_connection *connection, struct packe
 {
        /* Make sure we've acked all the TCP data associated
         * with the data requests being unplugged */
-       drbd_tcp_quickack(connection->data.socket);
-
+       tcp_sock_set_quickack(connection->data.socket->sk, 2);
        return 0;
 }
 
index 9e42c7fe50a8b531a1bef0afd8ca84d19c4e64d4..2eaf8320b9db05ac9ffe89f644f2021562882cd6 100644 (file)
@@ -499,5 +499,6 @@ int tcp_skb_shift(struct sk_buff *to, struct sk_buff *from, int pcount,
 
 void tcp_sock_set_cork(struct sock *sk, bool on);
 void tcp_sock_set_nodelay(struct sock *sk);
+void tcp_sock_set_quickack(struct sock *sk, int val);
 
 #endif /* _LINUX_TCP_H */
index a65f293a19fac20b0a7430d35813d014b0cf5380..27b5e7a4e2ef9451cefde43038a444f08bce22b3 100644 (file)
@@ -2856,6 +2856,31 @@ void tcp_sock_set_nodelay(struct sock *sk)
 }
 EXPORT_SYMBOL(tcp_sock_set_nodelay);
 
+static void __tcp_sock_set_quickack(struct sock *sk, int val)
+{
+       if (!val) {
+               inet_csk_enter_pingpong_mode(sk);
+               return;
+       }
+
+       inet_csk_exit_pingpong_mode(sk);
+       if ((1 << sk->sk_state) & (TCPF_ESTABLISHED | TCPF_CLOSE_WAIT) &&
+           inet_csk_ack_scheduled(sk)) {
+               inet_csk(sk)->icsk_ack.pending |= ICSK_ACK_PUSHED;
+               tcp_cleanup_rbuf(sk, 1);
+               if (!(val & 1))
+                       inet_csk_enter_pingpong_mode(sk);
+       }
+}
+
+void tcp_sock_set_quickack(struct sock *sk, int val)
+{
+       lock_sock(sk);
+       __tcp_sock_set_quickack(sk, val);
+       release_sock(sk);
+}
+EXPORT_SYMBOL(tcp_sock_set_quickack);
+
 /*
  *     Socket option code for TCP.
  */
@@ -3096,19 +3121,7 @@ static int do_tcp_setsockopt(struct sock *sk, int level,
                break;
 
        case TCP_QUICKACK:
-               if (!val) {
-                       inet_csk_enter_pingpong_mode(sk);
-               } else {
-                       inet_csk_exit_pingpong_mode(sk);
-                       if ((1 << sk->sk_state) &
-                           (TCPF_ESTABLISHED | TCPF_CLOSE_WAIT) &&
-                           inet_csk_ack_scheduled(sk)) {
-                               icsk->icsk_ack.pending |= ICSK_ACK_PUSHED;
-                               tcp_cleanup_rbuf(sk, 1);
-                               if (!(val & 1))
-                                       inet_csk_enter_pingpong_mode(sk);
-                       }
-               }
+               __tcp_sock_set_quickack(sk, val);
                break;
 
 #ifdef CONFIG_TCP_MD5SIG