blob: 4ad47d9f9d271fcf8bb3c9d88ef2a602bdeffa54 [file] [log] [blame]
Thomas Gleixner2874c5f2019-05-27 08:55:01 +02001/* SPDX-License-Identifier: GPL-2.0-or-later */
Arnaldo Carvalho de Melo463c84b2005-08-09 20:10:42 -07002/*
3 * NET Generic infrastructure for INET connection oriented protocols.
4 *
5 * Definitions for inet_connection_sock
6 *
7 * Authors: Many people, see the TCP sources
8 *
9 * From code originally in TCP
Arnaldo Carvalho de Melo463c84b2005-08-09 20:10:42 -070010 */
11#ifndef _INET_CONNECTION_SOCK_H
12#define _INET_CONNECTION_SOCK_H
13
Arnaldo Carvalho de Melo8292a172005-12-13 23:15:52 -080014#include <linux/compiler.h>
Arnaldo Carvalho de Melo3f421ba2005-08-09 20:11:08 -070015#include <linux/string.h>
Arnaldo Carvalho de Melo463c84b2005-08-09 20:10:42 -070016#include <linux/timer.h>
Al Virobd01f842006-10-19 17:23:57 -040017#include <linux/poll.h>
Nick Desaulniers96d18d82018-08-01 14:57:59 -070018#include <linux/kernel.h>
Christoph Hellwiga7b75c52020-07-23 08:09:07 +020019#include <linux/sockptr.h>
Arnaldo Carvalho de Melo14c85022005-12-27 02:43:12 -020020
21#include <net/inet_sock.h>
Arnaldo Carvalho de Melo463c84b2005-08-09 20:10:42 -070022#include <net/request_sock.h>
23
Arnaldo Carvalho de Melo3f421ba2005-08-09 20:11:08 -070024/* Cancel timers, when they are not required. */
25#undef INET_CSK_CLEAR_TIMERS
26
Arnaldo Carvalho de Melo463c84b2005-08-09 20:10:42 -070027struct inet_bind_bucket;
Arnaldo Carvalho de Melo6687e982005-08-10 04:03:31 -030028struct tcp_congestion_ops;
Arnaldo Carvalho de Melo463c84b2005-08-09 20:10:42 -070029
Arnaldo Carvalho de Melo8292a172005-12-13 23:15:52 -080030/*
31 * Pointers to address related TCP functions
32 * (i.e. things that depend on the address family)
33 */
34struct inet_connection_sock_af_ops {
Eric Dumazetb0270e92014-04-15 12:58:34 -040035 int (*queue_xmit)(struct sock *sk, struct sk_buff *skb, struct flowi *fl);
Herbert Xubb296242010-04-11 02:15:55 +000036 void (*send_check)(struct sock *sk, struct sk_buff *skb);
Arnaldo Carvalho de Melo8292a172005-12-13 23:15:52 -080037 int (*rebuild_header)(struct sock *sk);
Eric Dumazet5d299f32012-08-06 05:09:33 +000038 void (*sk_rx_dst_set)(struct sock *sk, const struct sk_buff *skb);
Arnaldo Carvalho de Melo8292a172005-12-13 23:15:52 -080039 int (*conn_request)(struct sock *sk, struct sk_buff *skb);
Eric Dumazet0c271712015-09-29 07:42:48 -070040 struct sock *(*syn_recv_sock)(const struct sock *sk, struct sk_buff *skb,
Arnaldo Carvalho de Melo8292a172005-12-13 23:15:52 -080041 struct request_sock *req,
Eric Dumazet5e0724d2015-10-22 08:20:46 -070042 struct dst_entry *dst,
43 struct request_sock *req_unhash,
44 bool *own_req);
Arnaldo Carvalho de Melo850db6b2006-11-27 17:56:43 -020045 u16 net_header_len;
Eric Dumazet67469602012-04-24 07:37:38 +000046 u16 net_frag_header_len;
Arnaldo Carvalho de Melo850db6b2006-11-27 17:56:43 -020047 u16 sockaddr_len;
Stephen Hemminger82695b32018-02-27 15:48:21 -080048 int (*setsockopt)(struct sock *sk, int level, int optname,
Christoph Hellwiga7b75c52020-07-23 08:09:07 +020049 sockptr_t optval, unsigned int optlen);
Stephen Hemminger82695b32018-02-27 15:48:21 -080050 int (*getsockopt)(struct sock *sk, int level, int optname,
Arnaldo Carvalho de Melo8292a172005-12-13 23:15:52 -080051 char __user *optval, int __user *optlen);
52 void (*addr2sockaddr)(struct sock *sk, struct sockaddr *);
Neal Cardwell4fab9072014-08-14 12:40:05 -040053 void (*mtu_reduced)(struct sock *sk);
Arnaldo Carvalho de Melo8292a172005-12-13 23:15:52 -080054};
55
Arnaldo Carvalho de Melo463c84b2005-08-09 20:10:42 -070056/** inet_connection_sock - INET connection oriented sock
57 *
Stephen Hemminger82695b32018-02-27 15:48:21 -080058 * @icsk_accept_queue: FIFO of established children
Arnaldo Carvalho de Melo463c84b2005-08-09 20:10:42 -070059 * @icsk_bind_hash: Bind node
60 * @icsk_timeout: Timeout
61 * @icsk_retransmit_timer: Resend (no ack)
62 * @icsk_rto: Retransmit timeout
Arnaldo Carvalho de Melod83d8462005-12-13 23:26:10 -080063 * @icsk_pmtu_cookie Last pmtu seen by socket
Arnaldo Carvalho de Melo6687e982005-08-10 04:03:31 -030064 * @icsk_ca_ops Pluggable congestion control hook
Arnaldo Carvalho de Melo8292a172005-12-13 23:15:52 -080065 * @icsk_af_ops Operations which are AF_INET{4,6} specific
Dave Watson734942c2017-06-14 11:37:14 -070066 * @icsk_ulp_ops Pluggable ULP control hook
67 * @icsk_ulp_data ULP private data
Ilya Lesokhin6dac1522018-04-30 10:16:10 +030068 * @icsk_clean_acked Clean acked data hook
Martin KaFai Lau61b7c692017-12-01 12:52:31 -080069 * @icsk_listen_portaddr_node hash to the portaddr listener hashtable
Arnaldo Carvalho de Melo6687e982005-08-10 04:03:31 -030070 * @icsk_ca_state: Congestion control state
Arnaldo Carvalho de Melo463c84b2005-08-09 20:10:42 -070071 * @icsk_retransmits: Number of unrecovered [RTO] timeouts
72 * @icsk_pending: Scheduled timer event
73 * @icsk_backoff: Backoff
74 * @icsk_syn_retries: Number of allowed SYN (or equivalent) retries
Arnaldo Carvalho de Melo6687e982005-08-10 04:03:31 -030075 * @icsk_probes_out: unanswered 0 window probes
Arnaldo Carvalho de Melod83d8462005-12-13 23:26:10 -080076 * @icsk_ext_hdr_len: Network protocol overhead (IP/IPv6 options)
Arnaldo Carvalho de Melo463c84b2005-08-09 20:10:42 -070077 * @icsk_ack: Delayed ACK control data
John Heffner5d424d52006-03-20 17:53:41 -080078 * @icsk_mtup; MTU probing control data
Enke Chen9d9b1ee2021-01-15 14:30:58 -080079 * @icsk_probes_tstamp: Probe timestamp (cleared by non-zero window ack)
80 * @icsk_user_timeout: TCP_USER_TIMEOUT value
Arnaldo Carvalho de Melo463c84b2005-08-09 20:10:42 -070081 */
82struct inet_connection_sock {
83 /* inet_sock has to be the first member! */
84 struct inet_sock icsk_inet;
85 struct request_sock_queue icsk_accept_queue;
86 struct inet_bind_bucket *icsk_bind_hash;
87 unsigned long icsk_timeout;
88 struct timer_list icsk_retransmit_timer;
89 struct timer_list icsk_delack_timer;
90 __u32 icsk_rto;
Martin KaFai Lauca584ba2020-08-20 12:00:27 -070091 __u32 icsk_rto_min;
Martin KaFai Lau2b8ee4f2020-08-20 12:00:21 -070092 __u32 icsk_delack_max;
Arnaldo Carvalho de Melod83d8462005-12-13 23:26:10 -080093 __u32 icsk_pmtu_cookie;
Stephen Hemminger770cfbc2006-01-09 15:56:09 -080094 const struct tcp_congestion_ops *icsk_ca_ops;
95 const struct inet_connection_sock_af_ops *icsk_af_ops;
Dave Watson734942c2017-06-14 11:37:14 -070096 const struct tcp_ulp_ops *icsk_ulp_ops;
Jakub Kicinski15a7dea2019-08-30 12:25:47 +020097 void __rcu *icsk_ulp_data;
Ilya Lesokhin6dac1522018-04-30 10:16:10 +030098 void (*icsk_clean_acked)(struct sock *sk, u32 acked_seq);
Martin KaFai Lau61b7c692017-12-01 12:52:31 -080099 struct hlist_node icsk_listen_portaddr_node;
Arnaldo Carvalho de Melod83d8462005-12-13 23:26:10 -0800100 unsigned int (*icsk_sync_mss)(struct sock *sk, u32 pmtu);
Neal Cardwell8919a9b2020-09-10 15:35:32 -0400101 __u8 icsk_ca_state:5,
102 icsk_ca_initialized:1,
Neal Cardwell9f950412015-05-29 13:47:07 -0400103 icsk_ca_setsockopt:1,
Daniel Borkmannc5c6a8a2015-01-05 23:57:46 +0100104 icsk_ca_dst_locked:1;
Arnaldo Carvalho de Melo463c84b2005-08-09 20:10:42 -0700105 __u8 icsk_retransmits;
106 __u8 icsk_pending;
107 __u8 icsk_backoff;
108 __u8 icsk_syn_retries;
Arnaldo Carvalho de Melo6687e982005-08-10 04:03:31 -0300109 __u8 icsk_probes_out;
Arnaldo Carvalho de Melod83d8462005-12-13 23:26:10 -0800110 __u16 icsk_ext_hdr_len;
Arnaldo Carvalho de Melo463c84b2005-08-09 20:10:42 -0700111 struct {
112 __u8 pending; /* ACK is pending */
113 __u8 quick; /* Scheduled number of quick acks */
114 __u8 pingpong; /* The session is interactive */
Eric Dumazeta37c2132020-09-30 05:54:57 -0700115 __u8 retry; /* Number of attempts */
Arnaldo Carvalho de Melo463c84b2005-08-09 20:10:42 -0700116 __u32 ato; /* Predicted tick of soft clock */
117 unsigned long timeout; /* Currently scheduled timeout */
118 __u32 lrcvtime; /* timestamp of last received data packet */
119 __u16 last_seg_size; /* Size of last incoming segment */
Stephen Hemminger82695b32018-02-27 15:48:21 -0800120 __u16 rcv_mss; /* MSS used for delayed ACK decisions */
Arnaldo Carvalho de Melo463c84b2005-08-09 20:10:42 -0700121 } icsk_ack;
John Heffner5d424d52006-03-20 17:53:41 -0800122 struct {
John Heffner5d424d52006-03-20 17:53:41 -0800123 /* Range of MTUs to search */
124 int search_high;
125 int search_low;
126
127 /* Information on the current probe. */
Neal Cardwell14e8e0f2021-01-29 13:54:38 -0500128 u32 probe_size:31,
129 /* Is the MTUP feature enabled for this connection? */
130 enabled:1;
Fan Du05cbc0d2015-03-06 11:18:24 +0800131
132 u32 probe_timestamp;
John Heffner5d424d52006-03-20 17:53:41 -0800133 } icsk_mtup;
Enke Chen9d9b1ee2021-01-15 14:30:58 -0800134 u32 icsk_probes_tstamp;
Jerry Chudca43c72010-08-27 19:13:28 +0000135 u32 icsk_user_timeout;
Eric Dumazetb5d721d2015-05-18 17:06:14 -0700136
Priyaranjan Jha78dc70e2019-01-23 12:04:54 -0800137 u64 icsk_ca_priv[104 / sizeof(u64)];
Eric Dumazet3f8ad502021-06-29 06:53:14 -0700138#define ICSK_CA_PRIV_SIZE sizeof_field(struct inet_connection_sock, icsk_ca_priv)
Arnaldo Carvalho de Melo463c84b2005-08-09 20:10:42 -0700139};
140
Arnaldo Carvalho de Melo3f421ba2005-08-09 20:11:08 -0700141#define ICSK_TIME_RETRANS 1 /* Retransmit timer */
142#define ICSK_TIME_DACK 2 /* Delayed ack timer */
143#define ICSK_TIME_PROBE0 3 /* Zero window probe timer */
Nandita Dukkipati6ba8a3b2013-03-11 10:00:43 +0000144#define ICSK_TIME_LOSS_PROBE 5 /* Tail loss probe timer */
Yuchung Cheng57dde7f2017-01-12 22:11:33 -0800145#define ICSK_TIME_REO_TIMEOUT 6 /* Reordering timer */
Arnaldo Carvalho de Melo3f421ba2005-08-09 20:11:08 -0700146
Arnaldo Carvalho de Melo463c84b2005-08-09 20:10:42 -0700147static inline struct inet_connection_sock *inet_csk(const struct sock *sk)
148{
149 return (struct inet_connection_sock *)sk;
150}
151
Arnaldo Carvalho de Melo6687e982005-08-10 04:03:31 -0300152static inline void *inet_csk_ca(const struct sock *sk)
153{
154 return (void *)inet_csk(sk)->icsk_ca_priv;
155}
156
Joe Perches1fd51152013-09-21 10:22:41 -0700157struct sock *inet_csk_clone_lock(const struct sock *sk,
158 const struct request_sock *req,
159 const gfp_t priority);
Arnaldo Carvalho de Melo9f1d2602005-08-09 20:11:24 -0700160
Arnaldo Carvalho de Melo3f421ba2005-08-09 20:11:08 -0700161enum inet_csk_ack_state_t {
162 ICSK_ACK_SCHED = 1,
163 ICSK_ACK_TIMER = 2,
Alexey Kuznetsov1ef96962006-09-19 12:52:50 -0700164 ICSK_ACK_PUSHED = 4,
Yuchung Cheng466466d2018-08-09 09:38:09 -0700165 ICSK_ACK_PUSHED2 = 8,
166 ICSK_ACK_NOW = 16 /* Send the next ACK immediately (once) */
Arnaldo Carvalho de Melo3f421ba2005-08-09 20:11:08 -0700167};
168
Joe Perches1fd51152013-09-21 10:22:41 -0700169void inet_csk_init_xmit_timers(struct sock *sk,
Kees Cook59f379f2017-10-16 17:29:19 -0700170 void (*retransmit_handler)(struct timer_list *),
171 void (*delack_handler)(struct timer_list *),
172 void (*keepalive_handler)(struct timer_list *));
Joe Perches1fd51152013-09-21 10:22:41 -0700173void inet_csk_clear_xmit_timers(struct sock *sk);
Arnaldo Carvalho de Melo463c84b2005-08-09 20:10:42 -0700174
Arnaldo Carvalho de Melo3f421ba2005-08-09 20:11:08 -0700175static inline void inet_csk_schedule_ack(struct sock *sk)
176{
177 inet_csk(sk)->icsk_ack.pending |= ICSK_ACK_SCHED;
178}
179
180static inline int inet_csk_ack_scheduled(const struct sock *sk)
181{
182 return inet_csk(sk)->icsk_ack.pending & ICSK_ACK_SCHED;
183}
184
185static inline void inet_csk_delack_init(struct sock *sk)
186{
187 memset(&inet_csk(sk)->icsk_ack, 0, sizeof(inet_csk(sk)->icsk_ack));
188}
189
Joe Perches1fd51152013-09-21 10:22:41 -0700190void inet_csk_delete_keepalive_timer(struct sock *sk);
191void inet_csk_reset_keepalive_timer(struct sock *sk, unsigned long timeout);
Arnaldo Carvalho de Melo3f421ba2005-08-09 20:11:08 -0700192
Arnaldo Carvalho de Melo3f421ba2005-08-09 20:11:08 -0700193static inline void inet_csk_clear_xmit_timer(struct sock *sk, const int what)
194{
195 struct inet_connection_sock *icsk = inet_csk(sk);
Stephen Hemminger82695b32018-02-27 15:48:21 -0800196
Arnaldo Carvalho de Melo3f421ba2005-08-09 20:11:08 -0700197 if (what == ICSK_TIME_RETRANS || what == ICSK_TIME_PROBE0) {
198 icsk->icsk_pending = 0;
199#ifdef INET_CSK_CLEAR_TIMERS
200 sk_stop_timer(sk, &icsk->icsk_retransmit_timer);
201#endif
202 } else if (what == ICSK_TIME_DACK) {
Eric Dumazetb6b6d652020-09-30 05:54:56 -0700203 icsk->icsk_ack.pending = 0;
Eric Dumazeta37c2132020-09-30 05:54:57 -0700204 icsk->icsk_ack.retry = 0;
Arnaldo Carvalho de Melo3f421ba2005-08-09 20:11:08 -0700205#ifdef INET_CSK_CLEAR_TIMERS
206 sk_stop_timer(sk, &icsk->icsk_delack_timer);
207#endif
Joe Perches03bdfc02018-05-09 23:24:07 -0700208 } else {
209 pr_debug("inet_csk BUG: unknown timer value\n");
Arnaldo Carvalho de Melo3f421ba2005-08-09 20:11:08 -0700210 }
Arnaldo Carvalho de Melo3f421ba2005-08-09 20:11:08 -0700211}
212
213/*
214 * Reset the retransmission timer
215 */
216static inline void inet_csk_reset_xmit_timer(struct sock *sk, const int what,
217 unsigned long when,
218 const unsigned long max_when)
219{
220 struct inet_connection_sock *icsk = inet_csk(sk);
221
222 if (when > max_when) {
Arnaldo Carvalho de Melo3f421ba2005-08-09 20:11:08 -0700223 pr_debug("reset_xmit_timer: sk=%p %d when=0x%lx, caller=%p\n",
Nick Desaulniers96d18d82018-08-01 14:57:59 -0700224 sk, what, when, (void *)_THIS_IP_);
Arnaldo Carvalho de Melo3f421ba2005-08-09 20:11:08 -0700225 when = max_when;
226 }
227
Nandita Dukkipati6ba8a3b2013-03-11 10:00:43 +0000228 if (what == ICSK_TIME_RETRANS || what == ICSK_TIME_PROBE0 ||
Pengcheng Yanga05a7282021-01-21 22:31:13 +0800229 what == ICSK_TIME_LOSS_PROBE || what == ICSK_TIME_REO_TIMEOUT) {
Arnaldo Carvalho de Melo3f421ba2005-08-09 20:11:08 -0700230 icsk->icsk_pending = what;
231 icsk->icsk_timeout = jiffies + when;
232 sk_reset_timer(sk, &icsk->icsk_retransmit_timer, icsk->icsk_timeout);
233 } else if (what == ICSK_TIME_DACK) {
234 icsk->icsk_ack.pending |= ICSK_ACK_TIMER;
235 icsk->icsk_ack.timeout = jiffies + when;
236 sk_reset_timer(sk, &icsk->icsk_delack_timer, icsk->icsk_ack.timeout);
Joe Perches03bdfc02018-05-09 23:24:07 -0700237 } else {
238 pr_debug("inet_csk BUG: unknown timer value\n");
Arnaldo Carvalho de Melo3f421ba2005-08-09 20:11:08 -0700239 }
Arnaldo Carvalho de Melo3f421ba2005-08-09 20:11:08 -0700240}
241
Eric Dumazetfcdd1cf2014-09-22 13:19:44 -0700242static inline unsigned long
243inet_csk_rto_backoff(const struct inet_connection_sock *icsk,
244 unsigned long max_when)
245{
246 u64 when = (u64)icsk->icsk_rto << icsk->icsk_backoff;
247
248 return (unsigned long)min_t(u64, when, max_when);
249}
250
David Howellscdfbabf2017-03-09 08:09:05 +0000251struct sock *inet_csk_accept(struct sock *sk, int flags, int *err, bool kern);
Arnaldo Carvalho de Melo3f421ba2005-08-09 20:11:08 -0700252
Joe Perches1fd51152013-09-21 10:22:41 -0700253int inet_csk_get_port(struct sock *sk, unsigned short snum);
Arnaldo Carvalho de Melo463c84b2005-08-09 20:10:42 -0700254
Eric Dumazete5895bc2015-09-25 07:39:11 -0700255struct dst_entry *inet_csk_route_req(const struct sock *sk, struct flowi4 *fl4,
Joe Perches1fd51152013-09-21 10:22:41 -0700256 const struct request_sock *req);
Eric Dumazeta2432c42015-09-29 07:42:43 -0700257struct dst_entry *inet_csk_route_child_sock(const struct sock *sk,
258 struct sock *newsk,
David S. Millerba3f7f02012-07-17 14:02:46 -0700259 const struct request_sock *req);
Arnaldo Carvalho de Melo463c84b2005-08-09 20:10:42 -0700260
Eric Dumazet77166822016-02-18 05:39:18 -0800261struct sock *inet_csk_reqsk_queue_add(struct sock *sk,
262 struct request_sock *req,
263 struct sock *child);
Joe Perches1fd51152013-09-21 10:22:41 -0700264void inet_csk_reqsk_queue_hash_add(struct sock *sk, struct request_sock *req,
265 unsigned long timeout);
Eric Dumazet5e0724d2015-10-22 08:20:46 -0700266struct sock *inet_csk_complete_hashdance(struct sock *sk, struct sock *child,
267 struct request_sock *req,
268 bool own_req);
Arnaldo Carvalho de Melo3f421ba2005-08-09 20:11:08 -0700269
Eric Dumazet2feda342015-10-02 11:43:31 -0700270static inline void inet_csk_reqsk_queue_added(struct sock *sk)
Arnaldo Carvalho de Melo3f421ba2005-08-09 20:11:08 -0700271{
Eric Dumazetfa76ce732015-03-19 19:04:20 -0700272 reqsk_queue_added(&inet_csk(sk)->icsk_accept_queue);
Arnaldo Carvalho de Melo3f421ba2005-08-09 20:11:08 -0700273}
274
275static inline int inet_csk_reqsk_queue_len(const struct sock *sk)
276{
277 return reqsk_queue_len(&inet_csk(sk)->icsk_accept_queue);
278}
279
Arnaldo Carvalho de Melo3f421ba2005-08-09 20:11:08 -0700280static inline int inet_csk_reqsk_queue_is_full(const struct sock *sk)
281{
Eric Dumazetef547f22015-10-02 11:43:37 -0700282 return inet_csk_reqsk_queue_len(sk) >= sk->sk_max_ack_backlog;
Arnaldo Carvalho de Melo3f421ba2005-08-09 20:11:08 -0700283}
284
Alexander Ovechkin7233da82021-03-15 14:05:45 +0300285bool inet_csk_reqsk_queue_drop(struct sock *sk, struct request_sock *req);
Eric Dumazetf03f2e12015-10-14 11:16:27 -0700286void inet_csk_reqsk_queue_drop_and_put(struct sock *sk, struct request_sock *req);
Arnaldo Carvalho de Melo3f421ba2005-08-09 20:11:08 -0700287
Paolo Abeni2f8a3972020-05-15 19:22:16 +0200288static inline void inet_csk_prepare_for_destroy_sock(struct sock *sk)
289{
290 /* The below has to be done to allow calling inet_csk_destroy_sock */
291 sock_set_flag(sk, SOCK_DEAD);
Eric Dumazet19757ce2021-10-14 06:41:26 -0700292 this_cpu_inc(*sk->sk_prot->orphan_count);
Paolo Abeni2f8a3972020-05-15 19:22:16 +0200293}
294
Joe Perches1fd51152013-09-21 10:22:41 -0700295void inet_csk_destroy_sock(struct sock *sk);
296void inet_csk_prepare_forced_close(struct sock *sk);
Arnaldo Carvalho de Melodc40c7b2005-08-23 21:52:58 -0700297
298/*
299 * LISTEN is a special case for poll..
300 */
Al Viroade994f2017-07-03 00:01:49 -0400301static inline __poll_t inet_csk_listen_poll(const struct sock *sk)
Arnaldo Carvalho de Melodc40c7b2005-08-23 21:52:58 -0700302{
303 return !reqsk_queue_empty(&inet_csk(sk)->icsk_accept_queue) ?
Linus Torvaldsa9a08842018-02-11 14:34:03 -0800304 (EPOLLIN | EPOLLRDNORM) : 0;
Arnaldo Carvalho de Melodc40c7b2005-08-23 21:52:58 -0700305}
306
Kuniyuki Iwashimae7049392021-11-22 19:16:21 +0900307int inet_csk_listen_start(struct sock *sk);
Joe Perches1fd51152013-09-21 10:22:41 -0700308void inet_csk_listen_stop(struct sock *sk);
Arnaldo Carvalho de Melo295f7322005-08-09 20:11:56 -0700309
Joe Perches1fd51152013-09-21 10:22:41 -0700310void inet_csk_addr2sockaddr(struct sock *sk, struct sockaddr *uaddr);
Arnaldo Carvalho de Meloaf05dc92005-12-13 23:16:04 -0800311
Tim Froidcoeur62ffc582020-08-11 20:33:23 +0200312/* update the fast reuse flag when adding a socket */
313void inet_csk_update_fastreuse(struct inet_bind_bucket *tb,
314 struct sock *sk);
315
Joe Perches1fd51152013-09-21 10:22:41 -0700316struct dst_entry *inet_csk_update_pmtu(struct sock *sk, u32 mtu);
Wei Wang31954cd2019-01-25 10:53:19 -0800317
Wei Wang4a41f452019-01-25 10:53:20 -0800318#define TCP_PINGPONG_THRESH 3
Wei Wang31954cd2019-01-25 10:53:19 -0800319
320static inline void inet_csk_enter_pingpong_mode(struct sock *sk)
321{
322 inet_csk(sk)->icsk_ack.pingpong = TCP_PINGPONG_THRESH;
323}
324
325static inline void inet_csk_exit_pingpong_mode(struct sock *sk)
326{
327 inet_csk(sk)->icsk_ack.pingpong = 0;
328}
329
330static inline bool inet_csk_in_pingpong_mode(struct sock *sk)
331{
332 return inet_csk(sk)->icsk_ack.pingpong >= TCP_PINGPONG_THRESH;
333}
Wei Wang4a41f452019-01-25 10:53:20 -0800334
335static inline void inet_csk_inc_pingpong_cnt(struct sock *sk)
336{
337 struct inet_connection_sock *icsk = inet_csk(sk);
338
339 if (icsk->icsk_ack.pingpong < U8_MAX)
340 icsk->icsk_ack.pingpong++;
341}
Lorenz Bauer7b709732020-03-09 11:12:32 +0000342
343static inline bool inet_csk_has_ulp(struct sock *sk)
344{
345 return inet_sk(sk)->is_icsk && !!inet_csk(sk)->icsk_ulp_ops;
346}
347
Arnaldo Carvalho de Melo463c84b2005-08-09 20:10:42 -0700348#endif /* _INET_CONNECTION_SOCK_H */