hc
2024-05-10 23fa18eaa71266feff7ba8d83022d9e1cc83c65a
kernel/include/net/inet_connection_sock.h
....@@ -1,3 +1,4 @@
1
+/* SPDX-License-Identifier: GPL-2.0-or-later */
12 /*
23 * NET Generic infrastructure for INET connection oriented protocols.
34 *
....@@ -6,11 +7,6 @@
67 * Authors: Many people, see the TCP sources
78 *
89 * From code originally in TCP
9
- *
10
- * This program is free software; you can redistribute it and/or
11
- * modify it under the terms of the GNU General Public License
12
- * as published by the Free Software Foundation; either version
13
- * 2 of the License, or (at your option) any later version.
1410 */
1511 #ifndef _INET_CONNECTION_SOCK_H
1612 #define _INET_CONNECTION_SOCK_H
....@@ -20,6 +16,8 @@
2016 #include <linux/timer.h>
2117 #include <linux/poll.h>
2218 #include <linux/kernel.h>
19
+#include <linux/sockptr.h>
20
+#include <linux/android_kabi.h>
2321
2422 #include <net/inet_sock.h>
2523 #include <net/request_sock.h>
....@@ -49,19 +47,13 @@
4947 u16 net_frag_header_len;
5048 u16 sockaddr_len;
5149 int (*setsockopt)(struct sock *sk, int level, int optname,
52
- char __user *optval, unsigned int optlen);
50
+ sockptr_t optval, unsigned int optlen);
5351 int (*getsockopt)(struct sock *sk, int level, int optname,
5452 char __user *optval, int __user *optlen);
55
-#ifdef CONFIG_COMPAT
56
- int (*compat_setsockopt)(struct sock *sk,
57
- int level, int optname,
58
- char __user *optval, unsigned int optlen);
59
- int (*compat_getsockopt)(struct sock *sk,
60
- int level, int optname,
61
- char __user *optval, int __user *optlen);
62
-#endif
6353 void (*addr2sockaddr)(struct sock *sk, struct sockaddr *);
6454 void (*mtu_reduced)(struct sock *sk);
55
+
56
+ ANDROID_KABI_RESERVE(1);
6557 };
6658
6759 /** inet_connection_sock - INET connection oriented sock
....@@ -87,6 +79,8 @@
8779 * @icsk_ext_hdr_len: Network protocol overhead (IP/IPv6 options)
8880 * @icsk_ack: Delayed ACK control data
8981 * @icsk_mtup; MTU probing control data
82
+ * @icsk_probes_tstamp: Probe timestamp (cleared by non-zero window ack)
83
+ * @icsk_user_timeout: TCP_USER_TIMEOUT value
9084 */
9185 struct inet_connection_sock {
9286 /* inet_sock has to be the first member! */
....@@ -97,15 +91,18 @@
9791 struct timer_list icsk_retransmit_timer;
9892 struct timer_list icsk_delack_timer;
9993 __u32 icsk_rto;
94
+ __u32 icsk_rto_min;
95
+ __u32 icsk_delack_max;
10096 __u32 icsk_pmtu_cookie;
10197 const struct tcp_congestion_ops *icsk_ca_ops;
10298 const struct inet_connection_sock_af_ops *icsk_af_ops;
10399 const struct tcp_ulp_ops *icsk_ulp_ops;
104
- void *icsk_ulp_data;
100
+ void __rcu *icsk_ulp_data;
105101 void (*icsk_clean_acked)(struct sock *sk, u32 acked_seq);
106102 struct hlist_node icsk_listen_portaddr_node;
107103 unsigned int (*icsk_sync_mss)(struct sock *sk, u32 pmtu);
108
- __u8 icsk_ca_state:6,
104
+ __u8 icsk_ca_state:5,
105
+ icsk_ca_initialized:1,
109106 icsk_ca_setsockopt:1,
110107 icsk_ca_dst_locked:1;
111108 __u8 icsk_retransmits;
....@@ -118,7 +115,7 @@
118115 __u8 pending; /* ACK is pending */
119116 __u8 quick; /* Scheduled number of quick acks */
120117 __u8 pingpong; /* The session is interactive */
121
- __u8 blocked; /* Delayed ACK was blocked by socket lock */
118
+ __u8 retry; /* Number of attempts */
122119 __u32 ato; /* Predicted tick of soft clock */
123120 unsigned long timeout; /* Currently scheduled timeout */
124121 __u32 lrcvtime; /* timestamp of last received data packet */
....@@ -137,7 +134,10 @@
137134
138135 u32 probe_timestamp;
139136 } icsk_mtup;
137
+ u32 icsk_probes_tstamp;
140138 u32 icsk_user_timeout;
139
+
140
+ ANDROID_KABI_RESERVE(1);
141141
142142 u64 icsk_ca_priv[104 / sizeof(u64)];
143143 #define ICSK_CA_PRIV_SIZE (13 * sizeof(u64))
....@@ -206,7 +206,8 @@
206206 sk_stop_timer(sk, &icsk->icsk_retransmit_timer);
207207 #endif
208208 } else if (what == ICSK_TIME_DACK) {
209
- icsk->icsk_ack.blocked = icsk->icsk_ack.pending = 0;
209
+ icsk->icsk_ack.pending = 0;
210
+ icsk->icsk_ack.retry = 0;
210211 #ifdef INET_CSK_CLEAR_TIMERS
211212 sk_stop_timer(sk, &icsk->icsk_delack_timer);
212213 #endif
....@@ -291,6 +292,13 @@
291292 bool inet_csk_reqsk_queue_drop(struct sock *sk, struct request_sock *req);
292293 void inet_csk_reqsk_queue_drop_and_put(struct sock *sk, struct request_sock *req);
293294
295
+static inline void inet_csk_prepare_for_destroy_sock(struct sock *sk)
296
+{
297
+ /* The below has to be done to allow calling inet_csk_destroy_sock */
298
+ sock_set_flag(sk, SOCK_DEAD);
299
+ percpu_counter_inc(sk->sk_prot->orphan_count);
300
+}
301
+
294302 void inet_csk_destroy_sock(struct sock *sk);
295303 void inet_csk_prepare_forced_close(struct sock *sk);
296304
....@@ -308,14 +316,32 @@
308316
309317 void inet_csk_addr2sockaddr(struct sock *sk, struct sockaddr *uaddr);
310318
311
-int inet_csk_compat_getsockopt(struct sock *sk, int level, int optname,
312
- char __user *optval, int __user *optlen);
313
-int inet_csk_compat_setsockopt(struct sock *sk, int level, int optname,
314
- char __user *optval, unsigned int optlen);
315
-
316319 /* update the fast reuse flag when adding a socket */
317320 void inet_csk_update_fastreuse(struct inet_bind_bucket *tb,
318321 struct sock *sk);
319322
320323 struct dst_entry *inet_csk_update_pmtu(struct sock *sk, u32 mtu);
324
+
325
+#define TCP_PINGPONG_THRESH 1
326
+
327
+static inline void inet_csk_enter_pingpong_mode(struct sock *sk)
328
+{
329
+ inet_csk(sk)->icsk_ack.pingpong = TCP_PINGPONG_THRESH;
330
+}
331
+
332
+static inline void inet_csk_exit_pingpong_mode(struct sock *sk)
333
+{
334
+ inet_csk(sk)->icsk_ack.pingpong = 0;
335
+}
336
+
337
+static inline bool inet_csk_in_pingpong_mode(struct sock *sk)
338
+{
339
+ return inet_csk(sk)->icsk_ack.pingpong >= TCP_PINGPONG_THRESH;
340
+}
341
+
342
+static inline bool inet_csk_has_ulp(struct sock *sk)
343
+{
344
+ return inet_sk(sk)->is_icsk && !!inet_csk(sk)->icsk_ulp_ops;
345
+}
346
+
321347 #endif /* _INET_CONNECTION_SOCK_H */