Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   1) /* SPDX-License-Identifier: GPL-2.0-or-later */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   3)  * NET		Generic infrastructure for INET connection oriented protocols.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   4)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   5)  *		Definitions for inet_connection_sock 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   6)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   7)  * Authors:	Many people, see the TCP sources
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   8)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   9)  * 		From code originally in TCP
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  10)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  11) #ifndef _INET_CONNECTION_SOCK_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  12) #define _INET_CONNECTION_SOCK_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  13) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  14) #include <linux/compiler.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  15) #include <linux/string.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  16) #include <linux/timer.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  17) #include <linux/poll.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  18) #include <linux/kernel.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  19) #include <linux/sockptr.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  20) #include <linux/android_kabi.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22) #include <net/inet_sock.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23) #include <net/request_sock.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  25) /* Cancel timers, when they are not required. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  26) #undef INET_CSK_CLEAR_TIMERS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  27) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28) struct inet_bind_bucket;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29) struct tcp_congestion_ops;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32)  * Pointers to address related TCP functions
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33)  * (i.e. things that depend on the address family)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35) struct inet_connection_sock_af_ops {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36) 	int	    (*queue_xmit)(struct sock *sk, struct sk_buff *skb, struct flowi *fl);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37) 	void	    (*send_check)(struct sock *sk, struct sk_buff *skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38) 	int	    (*rebuild_header)(struct sock *sk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39) 	void	    (*sk_rx_dst_set)(struct sock *sk, const struct sk_buff *skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40) 	int	    (*conn_request)(struct sock *sk, struct sk_buff *skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41) 	struct sock *(*syn_recv_sock)(const struct sock *sk, struct sk_buff *skb,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42) 				      struct request_sock *req,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43) 				      struct dst_entry *dst,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44) 				      struct request_sock *req_unhash,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45) 				      bool *own_req);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46) 	u16	    net_header_len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47) 	u16	    net_frag_header_len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  48) 	u16	    sockaddr_len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49) 	int	    (*setsockopt)(struct sock *sk, int level, int optname,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50) 				  sockptr_t optval, unsigned int optlen);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51) 	int	    (*getsockopt)(struct sock *sk, int level, int optname,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52) 				  char __user *optval, int __user *optlen);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53) 	void	    (*addr2sockaddr)(struct sock *sk, struct sockaddr *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54) 	void	    (*mtu_reduced)(struct sock *sk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56) 	ANDROID_KABI_RESERVE(1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59) /** inet_connection_sock - INET connection oriented sock
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  60)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  61)  * @icsk_accept_queue:	   FIFO of established children
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  62)  * @icsk_bind_hash:	   Bind node
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  63)  * @icsk_timeout:	   Timeout
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  64)  * @icsk_retransmit_timer: Resend (no ack)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  65)  * @icsk_rto:		   Retransmit timeout
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  66)  * @icsk_pmtu_cookie	   Last pmtu seen by socket
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67)  * @icsk_ca_ops		   Pluggable congestion control hook
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68)  * @icsk_af_ops		   Operations which are AF_INET{4,6} specific
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  69)  * @icsk_ulp_ops	   Pluggable ULP control hook
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  70)  * @icsk_ulp_data	   ULP private data
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71)  * @icsk_clean_acked	   Clean acked data hook
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72)  * @icsk_listen_portaddr_node	hash to the portaddr listener hashtable
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73)  * @icsk_ca_state:	   Congestion control state
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  74)  * @icsk_retransmits:	   Number of unrecovered [RTO] timeouts
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  75)  * @icsk_pending:	   Scheduled timer event
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  76)  * @icsk_backoff:	   Backoff
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  77)  * @icsk_syn_retries:      Number of allowed SYN (or equivalent) retries
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78)  * @icsk_probes_out:	   unanswered 0 window probes
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79)  * @icsk_ext_hdr_len:	   Network protocol overhead (IP/IPv6 options)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80)  * @icsk_ack:		   Delayed ACK control data
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  81)  * @icsk_mtup;		   MTU probing control data
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  82)  * @icsk_probes_tstamp:    Probe timestamp (cleared by non-zero window ack)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  83)  * @icsk_user_timeout:	   TCP_USER_TIMEOUT value
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  84)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85) struct inet_connection_sock {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86) 	/* inet_sock has to be the first member! */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87) 	struct inet_sock	  icsk_inet;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88) 	struct request_sock_queue icsk_accept_queue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89) 	struct inet_bind_bucket	  *icsk_bind_hash;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90) 	unsigned long		  icsk_timeout;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91)  	struct timer_list	  icsk_retransmit_timer;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  92)  	struct timer_list	  icsk_delack_timer;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93) 	__u32			  icsk_rto;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94) 	__u32                     icsk_rto_min;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95) 	__u32                     icsk_delack_max;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96) 	__u32			  icsk_pmtu_cookie;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97) 	const struct tcp_congestion_ops *icsk_ca_ops;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98) 	const struct inet_connection_sock_af_ops *icsk_af_ops;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  99) 	const struct tcp_ulp_ops  *icsk_ulp_ops;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) 	void __rcu		  *icsk_ulp_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) 	void (*icsk_clean_acked)(struct sock *sk, u32 acked_seq);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) 	struct hlist_node         icsk_listen_portaddr_node;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) 	unsigned int		  (*icsk_sync_mss)(struct sock *sk, u32 pmtu);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) 	__u8			  icsk_ca_state:5,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) 				  icsk_ca_initialized:1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) 				  icsk_ca_setsockopt:1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) 				  icsk_ca_dst_locked:1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) 	__u8			  icsk_retransmits;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) 	__u8			  icsk_pending;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) 	__u8			  icsk_backoff;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) 	__u8			  icsk_syn_retries;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) 	__u8			  icsk_probes_out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) 	__u16			  icsk_ext_hdr_len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) 	struct {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) 		__u8		  pending;	 /* ACK is pending			   */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) 		__u8		  quick;	 /* Scheduled number of quick acks	   */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) 		__u8		  pingpong;	 /* The session is interactive		   */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) 		__u8		  retry;	 /* Number of attempts			   */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) 		__u32		  ato;		 /* Predicted tick of soft clock	   */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) 		unsigned long	  timeout;	 /* Currently scheduled timeout		   */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) 		__u32		  lrcvtime;	 /* timestamp of last received data packet */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) 		__u16		  last_seg_size; /* Size of last incoming segment	   */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) 		__u16		  rcv_mss;	 /* MSS used for delayed ACK decisions	   */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) 	} icsk_ack;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) 	struct {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) 		int		  enabled;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) 		/* Range of MTUs to search */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) 		int		  search_high;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) 		int		  search_low;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) 		/* Information on the current probe. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) 		int		  probe_size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) 		u32		  probe_timestamp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) 	} icsk_mtup;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) 	u32			  icsk_probes_tstamp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) 	u32			  icsk_user_timeout;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) 	ANDROID_KABI_RESERVE(1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) 	u64			  icsk_ca_priv[104 / sizeof(u64)];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) #define ICSK_CA_PRIV_SIZE      (13 * sizeof(u64))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) #define ICSK_TIME_RETRANS	1	/* Retransmit timer */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) #define ICSK_TIME_DACK		2	/* Delayed ack timer */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) #define ICSK_TIME_PROBE0	3	/* Zero window probe timer */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) #define ICSK_TIME_EARLY_RETRANS 4	/* Early retransmit timer */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) #define ICSK_TIME_LOSS_PROBE	5	/* Tail loss probe timer */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) #define ICSK_TIME_REO_TIMEOUT	6	/* Reordering timer */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) static inline struct inet_connection_sock *inet_csk(const struct sock *sk)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) 	return (struct inet_connection_sock *)sk;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) static inline void *inet_csk_ca(const struct sock *sk)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) 	return (void *)inet_csk(sk)->icsk_ca_priv;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) struct sock *inet_csk_clone_lock(const struct sock *sk,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) 				 const struct request_sock *req,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) 				 const gfp_t priority);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) enum inet_csk_ack_state_t {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) 	ICSK_ACK_SCHED	= 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) 	ICSK_ACK_TIMER  = 2,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) 	ICSK_ACK_PUSHED = 4,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) 	ICSK_ACK_PUSHED2 = 8,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) 	ICSK_ACK_NOW = 16	/* Send the next ACK immediately (once) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) void inet_csk_init_xmit_timers(struct sock *sk,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) 			       void (*retransmit_handler)(struct timer_list *),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) 			       void (*delack_handler)(struct timer_list *),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) 			       void (*keepalive_handler)(struct timer_list *));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) void inet_csk_clear_xmit_timers(struct sock *sk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) static inline void inet_csk_schedule_ack(struct sock *sk)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) 	inet_csk(sk)->icsk_ack.pending |= ICSK_ACK_SCHED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) static inline int inet_csk_ack_scheduled(const struct sock *sk)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) 	return inet_csk(sk)->icsk_ack.pending & ICSK_ACK_SCHED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) static inline void inet_csk_delack_init(struct sock *sk)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) 	memset(&inet_csk(sk)->icsk_ack, 0, sizeof(inet_csk(sk)->icsk_ack));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) void inet_csk_delete_keepalive_timer(struct sock *sk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) void inet_csk_reset_keepalive_timer(struct sock *sk, unsigned long timeout);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) static inline void inet_csk_clear_xmit_timer(struct sock *sk, const int what)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) 	struct inet_connection_sock *icsk = inet_csk(sk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) 	if (what == ICSK_TIME_RETRANS || what == ICSK_TIME_PROBE0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) 		icsk->icsk_pending = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) #ifdef INET_CSK_CLEAR_TIMERS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) 		sk_stop_timer(sk, &icsk->icsk_retransmit_timer);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) 	} else if (what == ICSK_TIME_DACK) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) 		icsk->icsk_ack.pending = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) 		icsk->icsk_ack.retry = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) #ifdef INET_CSK_CLEAR_TIMERS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) 		sk_stop_timer(sk, &icsk->icsk_delack_timer);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) 	} else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) 		pr_debug("inet_csk BUG: unknown timer value\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220)  *	Reset the retransmission timer
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) static inline void inet_csk_reset_xmit_timer(struct sock *sk, const int what,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) 					     unsigned long when,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) 					     const unsigned long max_when)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) 	struct inet_connection_sock *icsk = inet_csk(sk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) 	if (when > max_when) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) 		pr_debug("reset_xmit_timer: sk=%p %d when=0x%lx, caller=%p\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) 			 sk, what, when, (void *)_THIS_IP_);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) 		when = max_when;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) 	if (what == ICSK_TIME_RETRANS || what == ICSK_TIME_PROBE0 ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) 	    what == ICSK_TIME_EARLY_RETRANS || what == ICSK_TIME_LOSS_PROBE ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) 	    what == ICSK_TIME_REO_TIMEOUT) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) 		icsk->icsk_pending = what;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) 		icsk->icsk_timeout = jiffies + when;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) 		sk_reset_timer(sk, &icsk->icsk_retransmit_timer, icsk->icsk_timeout);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) 	} else if (what == ICSK_TIME_DACK) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) 		icsk->icsk_ack.pending |= ICSK_ACK_TIMER;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) 		icsk->icsk_ack.timeout = jiffies + when;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) 		sk_reset_timer(sk, &icsk->icsk_delack_timer, icsk->icsk_ack.timeout);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) 	} else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) 		pr_debug("inet_csk BUG: unknown timer value\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) static inline unsigned long
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) inet_csk_rto_backoff(const struct inet_connection_sock *icsk,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) 		     unsigned long max_when)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253)         u64 when = (u64)icsk->icsk_rto << icsk->icsk_backoff;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255)         return (unsigned long)min_t(u64, when, max_when);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) struct sock *inet_csk_accept(struct sock *sk, int flags, int *err, bool kern);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) int inet_csk_get_port(struct sock *sk, unsigned short snum);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) struct dst_entry *inet_csk_route_req(const struct sock *sk, struct flowi4 *fl4,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263) 				     const struct request_sock *req);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264) struct dst_entry *inet_csk_route_child_sock(const struct sock *sk,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265) 					    struct sock *newsk,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266) 					    const struct request_sock *req);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268) struct sock *inet_csk_reqsk_queue_add(struct sock *sk,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269) 				      struct request_sock *req,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270) 				      struct sock *child);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271) void inet_csk_reqsk_queue_hash_add(struct sock *sk, struct request_sock *req,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272) 				   unsigned long timeout);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273) struct sock *inet_csk_complete_hashdance(struct sock *sk, struct sock *child,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274) 					 struct request_sock *req,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275) 					 bool own_req);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277) static inline void inet_csk_reqsk_queue_added(struct sock *sk)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 278) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 279) 	reqsk_queue_added(&inet_csk(sk)->icsk_accept_queue);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 280) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 281) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 282) static inline int inet_csk_reqsk_queue_len(const struct sock *sk)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 283) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 284) 	return reqsk_queue_len(&inet_csk(sk)->icsk_accept_queue);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 285) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 286) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 287) static inline int inet_csk_reqsk_queue_is_full(const struct sock *sk)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 288) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 289) 	return inet_csk_reqsk_queue_len(sk) >= sk->sk_max_ack_backlog;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 290) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 291) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 292) bool inet_csk_reqsk_queue_drop(struct sock *sk, struct request_sock *req);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 293) void inet_csk_reqsk_queue_drop_and_put(struct sock *sk, struct request_sock *req);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 294) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 295) static inline void inet_csk_prepare_for_destroy_sock(struct sock *sk)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 296) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 297) 	/* The below has to be done to allow calling inet_csk_destroy_sock */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 298) 	sock_set_flag(sk, SOCK_DEAD);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 299) 	percpu_counter_inc(sk->sk_prot->orphan_count);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 300) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 301) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 302) void inet_csk_destroy_sock(struct sock *sk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 303) void inet_csk_prepare_forced_close(struct sock *sk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 304) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 305) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 306)  * LISTEN is a special case for poll..
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 307)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 308) static inline __poll_t inet_csk_listen_poll(const struct sock *sk)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 309) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 310) 	return !reqsk_queue_empty(&inet_csk(sk)->icsk_accept_queue) ?
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 311) 			(EPOLLIN | EPOLLRDNORM) : 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 312) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 313) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 314) int inet_csk_listen_start(struct sock *sk, int backlog);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 315) void inet_csk_listen_stop(struct sock *sk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 316) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 317) void inet_csk_addr2sockaddr(struct sock *sk, struct sockaddr *uaddr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 318) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 319) /* update the fast reuse flag when adding a socket */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 320) void inet_csk_update_fastreuse(struct inet_bind_bucket *tb,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 321) 			       struct sock *sk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 322) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 323) struct dst_entry *inet_csk_update_pmtu(struct sock *sk, u32 mtu);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 324) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 325) #define TCP_PINGPONG_THRESH	3
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 326) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 327) static inline void inet_csk_enter_pingpong_mode(struct sock *sk)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 328) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 329) 	inet_csk(sk)->icsk_ack.pingpong = TCP_PINGPONG_THRESH;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 330) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 331) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 332) static inline void inet_csk_exit_pingpong_mode(struct sock *sk)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 333) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 334) 	inet_csk(sk)->icsk_ack.pingpong = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 335) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 336) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 337) static inline bool inet_csk_in_pingpong_mode(struct sock *sk)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 338) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 339) 	return inet_csk(sk)->icsk_ack.pingpong >= TCP_PINGPONG_THRESH;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 340) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 341) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 342) static inline void inet_csk_inc_pingpong_cnt(struct sock *sk)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 343) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 344) 	struct inet_connection_sock *icsk = inet_csk(sk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 345) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 346) 	if (icsk->icsk_ack.pingpong < U8_MAX)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 347) 		icsk->icsk_ack.pingpong++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 348) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 349) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 350) static inline bool inet_csk_has_ulp(struct sock *sk)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 351) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 352) 	return inet_sk(sk)->is_icsk && !!inet_csk(sk)->icsk_ulp_ops;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 353) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 354) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 355) #endif /* _INET_CONNECTION_SOCK_H */