| .. | .. |
|---|
| 1 | +/* SPDX-License-Identifier: GPL-2.0-or-later */ |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | * NET Generic infrastructure for INET connection oriented protocols. |
|---|
| 3 | 4 | * |
|---|
| .. | .. |
|---|
| 6 | 7 | * Authors: Many people, see the TCP sources |
|---|
| 7 | 8 | * |
|---|
| 8 | 9 | * 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. |
|---|
| 14 | 10 | */ |
|---|
| 15 | 11 | #ifndef _INET_CONNECTION_SOCK_H |
|---|
| 16 | 12 | #define _INET_CONNECTION_SOCK_H |
|---|
| .. | .. |
|---|
| 20 | 16 | #include <linux/timer.h> |
|---|
| 21 | 17 | #include <linux/poll.h> |
|---|
| 22 | 18 | #include <linux/kernel.h> |
|---|
| 19 | +#include <linux/sockptr.h> |
|---|
| 20 | +#include <linux/android_kabi.h> |
|---|
| 23 | 21 | |
|---|
| 24 | 22 | #include <net/inet_sock.h> |
|---|
| 25 | 23 | #include <net/request_sock.h> |
|---|
| .. | .. |
|---|
| 49 | 47 | u16 net_frag_header_len; |
|---|
| 50 | 48 | u16 sockaddr_len; |
|---|
| 51 | 49 | int (*setsockopt)(struct sock *sk, int level, int optname, |
|---|
| 52 | | - char __user *optval, unsigned int optlen); |
|---|
| 50 | + sockptr_t optval, unsigned int optlen); |
|---|
| 53 | 51 | int (*getsockopt)(struct sock *sk, int level, int optname, |
|---|
| 54 | 52 | 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 |
|---|
| 63 | 53 | void (*addr2sockaddr)(struct sock *sk, struct sockaddr *); |
|---|
| 64 | 54 | void (*mtu_reduced)(struct sock *sk); |
|---|
| 55 | + |
|---|
| 56 | + ANDROID_KABI_RESERVE(1); |
|---|
| 65 | 57 | }; |
|---|
| 66 | 58 | |
|---|
| 67 | 59 | /** inet_connection_sock - INET connection oriented sock |
|---|
| .. | .. |
|---|
| 87 | 79 | * @icsk_ext_hdr_len: Network protocol overhead (IP/IPv6 options) |
|---|
| 88 | 80 | * @icsk_ack: Delayed ACK control data |
|---|
| 89 | 81 | * @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 |
|---|
| 90 | 84 | */ |
|---|
| 91 | 85 | struct inet_connection_sock { |
|---|
| 92 | 86 | /* inet_sock has to be the first member! */ |
|---|
| .. | .. |
|---|
| 97 | 91 | struct timer_list icsk_retransmit_timer; |
|---|
| 98 | 92 | struct timer_list icsk_delack_timer; |
|---|
| 99 | 93 | __u32 icsk_rto; |
|---|
| 94 | + __u32 icsk_rto_min; |
|---|
| 95 | + __u32 icsk_delack_max; |
|---|
| 100 | 96 | __u32 icsk_pmtu_cookie; |
|---|
| 101 | 97 | const struct tcp_congestion_ops *icsk_ca_ops; |
|---|
| 102 | 98 | const struct inet_connection_sock_af_ops *icsk_af_ops; |
|---|
| 103 | 99 | const struct tcp_ulp_ops *icsk_ulp_ops; |
|---|
| 104 | | - void *icsk_ulp_data; |
|---|
| 100 | + void __rcu *icsk_ulp_data; |
|---|
| 105 | 101 | void (*icsk_clean_acked)(struct sock *sk, u32 acked_seq); |
|---|
| 106 | 102 | struct hlist_node icsk_listen_portaddr_node; |
|---|
| 107 | 103 | 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, |
|---|
| 109 | 106 | icsk_ca_setsockopt:1, |
|---|
| 110 | 107 | icsk_ca_dst_locked:1; |
|---|
| 111 | 108 | __u8 icsk_retransmits; |
|---|
| .. | .. |
|---|
| 118 | 115 | __u8 pending; /* ACK is pending */ |
|---|
| 119 | 116 | __u8 quick; /* Scheduled number of quick acks */ |
|---|
| 120 | 117 | __u8 pingpong; /* The session is interactive */ |
|---|
| 121 | | - __u8 blocked; /* Delayed ACK was blocked by socket lock */ |
|---|
| 118 | + __u8 retry; /* Number of attempts */ |
|---|
| 122 | 119 | __u32 ato; /* Predicted tick of soft clock */ |
|---|
| 123 | 120 | unsigned long timeout; /* Currently scheduled timeout */ |
|---|
| 124 | 121 | __u32 lrcvtime; /* timestamp of last received data packet */ |
|---|
| .. | .. |
|---|
| 137 | 134 | |
|---|
| 138 | 135 | u32 probe_timestamp; |
|---|
| 139 | 136 | } icsk_mtup; |
|---|
| 137 | + u32 icsk_probes_tstamp; |
|---|
| 140 | 138 | u32 icsk_user_timeout; |
|---|
| 139 | + |
|---|
| 140 | + ANDROID_KABI_RESERVE(1); |
|---|
| 141 | 141 | |
|---|
| 142 | 142 | u64 icsk_ca_priv[104 / sizeof(u64)]; |
|---|
| 143 | 143 | #define ICSK_CA_PRIV_SIZE (13 * sizeof(u64)) |
|---|
| .. | .. |
|---|
| 206 | 206 | sk_stop_timer(sk, &icsk->icsk_retransmit_timer); |
|---|
| 207 | 207 | #endif |
|---|
| 208 | 208 | } 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; |
|---|
| 210 | 211 | #ifdef INET_CSK_CLEAR_TIMERS |
|---|
| 211 | 212 | sk_stop_timer(sk, &icsk->icsk_delack_timer); |
|---|
| 212 | 213 | #endif |
|---|
| .. | .. |
|---|
| 291 | 292 | bool inet_csk_reqsk_queue_drop(struct sock *sk, struct request_sock *req); |
|---|
| 292 | 293 | void inet_csk_reqsk_queue_drop_and_put(struct sock *sk, struct request_sock *req); |
|---|
| 293 | 294 | |
|---|
| 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 | + |
|---|
| 294 | 302 | void inet_csk_destroy_sock(struct sock *sk); |
|---|
| 295 | 303 | void inet_csk_prepare_forced_close(struct sock *sk); |
|---|
| 296 | 304 | |
|---|
| .. | .. |
|---|
| 308 | 316 | |
|---|
| 309 | 317 | void inet_csk_addr2sockaddr(struct sock *sk, struct sockaddr *uaddr); |
|---|
| 310 | 318 | |
|---|
| 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 | | - |
|---|
| 316 | 319 | /* update the fast reuse flag when adding a socket */ |
|---|
| 317 | 320 | void inet_csk_update_fastreuse(struct inet_bind_bucket *tb, |
|---|
| 318 | 321 | struct sock *sk); |
|---|
| 319 | 322 | |
|---|
| 320 | 323 | 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 | + |
|---|
| 321 | 347 | #endif /* _INET_CONNECTION_SOCK_H */ |
|---|