Whamcloud - gitweb
LU-14690 kernel: new kernel [RHEL 8.4 4.18.0-305.3.1.el8_4]
[fs/lustre-release.git] / libcfs / include / libcfs / linux / linux-net.h
1 /*
2  * GPL HEADER START
3  *
4  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License version 2 only,
8  * as published by the Free Software Foundation.
9  *
10  * This program is distributed in the hope that it will be useful, but
11  * WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13  * General Public License version 2 for more details (a copy is included
14  * in the LICENSE file that accompanied this code).
15  *
16  * You should have received a copy of the GNU General Public License
17  * version 2 along with this program; If not, see
18  * http://www.gnu.org/licenses/gpl-2.0.html
19  *
20  * GPL HEADER END
21  */
22
23 #ifndef __LIBCFS_LINUX_NET_H__
24 #define __LIBCFS_LINUX_NET_H__
25
26 #ifdef HAVE_KERNEL_SETSOCKOPT
27
28 #include <net/tcp.h>
29
30 static inline void tcp_sock_set_quickack(struct sock *sk, int opt)
31 {
32         struct socket *sock = sk->sk_socket;
33
34         kernel_setsockopt(sock, SOL_TCP, TCP_QUICKACK,
35                           (char *)&opt, sizeof(opt));
36 }
37
38 #if !defined(HAVE_TCP_SOCK_SET_NODELAY)
39 static inline void tcp_sock_set_nodelay(struct sock *sk)
40 {
41         int opt = 1;
42         struct socket *sock = sk->sk_socket;
43
44         kernel_setsockopt(sock, SOL_TCP, TCP_NODELAY,
45                           (char *)&opt, sizeof(opt));
46 }
47 #endif /* HAVE_TCP_SOCK_SET_NODELAY */
48
49 #if !defined(HAVE_TCP_SOCK_SET_KEEPIDLE)
50 static inline int tcp_sock_set_keepidle(struct sock *sk, int opt)
51 {
52         struct socket *sock = sk->sk_socket;
53
54         return kernel_setsockopt(sock, SOL_TCP, TCP_KEEPIDLE,
55                                  (char *)&opt, sizeof(opt));
56 }
57 #endif /* HAVE_TCP_SOCK_SET_KEEPIDLE */
58
59 static inline int tcp_sock_set_keepintvl(struct sock *sk, int opt)
60 {
61         struct socket *sock = sk->sk_socket;
62
63         return kernel_setsockopt(sock, SOL_TCP, TCP_KEEPINTVL,
64                                  (char *)&opt, sizeof(opt));
65 }
66
67 static inline int tcp_sock_set_keepcnt(struct sock *sk, int opt)
68 {
69         struct socket *sock = sk->sk_socket;
70
71         return kernel_setsockopt(sock, SOL_TCP, TCP_KEEPCNT,
72                                  (char *)&opt, sizeof(opt));
73 }
74 #endif /* HAVE_KERNEL_SETSOCKOPT */
75
76 #endif /* __LIBCFS_LINUX_NET_H__ */