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)  * INET		An implementation of the TCP/IP protocol suite for the LINUX
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   4)  *		operating system.  INET is implemented using the  BSD Socket
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   5)  *		interface as the means of communication with the user level.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   6)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   7)  *		Definitions for a generic INET TIMEWAIT sock
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   8)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   9)  *		From code originally in net/tcp.h
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  10)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  11) #ifndef _INET_TIMEWAIT_SOCK_
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  12) #define _INET_TIMEWAIT_SOCK_
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  13) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  14) #include <linux/list.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  15) #include <linux/timer.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  16) #include <linux/types.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  17) #include <linux/workqueue.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  18) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  19) #include <net/inet_sock.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  20) #include <net/sock.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21) #include <net/tcp_states.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22) #include <net/timewait_sock.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24) #include <linux/atomic.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  25) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  26) struct inet_bind_bucket;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  27) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29)  * This is a TIME_WAIT sock. It works around the memory consumption
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30)  * problems of sockets in such a state on heavily loaded servers, but
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31)  * without violating the protocol specification.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33) struct inet_timewait_sock {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35) 	 * Now struct sock also uses sock_common, so please just
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36) 	 * don't add nothing before this first member (__tw_common) --acme
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38) 	struct sock_common	__tw_common;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39) #define tw_family		__tw_common.skc_family
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40) #define tw_state		__tw_common.skc_state
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41) #define tw_reuse		__tw_common.skc_reuse
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42) #define tw_reuseport		__tw_common.skc_reuseport
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43) #define tw_ipv6only		__tw_common.skc_ipv6only
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44) #define tw_bound_dev_if		__tw_common.skc_bound_dev_if
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45) #define tw_node			__tw_common.skc_nulls_node
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46) #define tw_bind_node		__tw_common.skc_bind_node
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47) #define tw_refcnt		__tw_common.skc_refcnt
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  48) #define tw_hash			__tw_common.skc_hash
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49) #define tw_prot			__tw_common.skc_prot
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50) #define tw_net			__tw_common.skc_net
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51) #define tw_daddr        	__tw_common.skc_daddr
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52) #define tw_v6_daddr		__tw_common.skc_v6_daddr
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53) #define tw_rcv_saddr    	__tw_common.skc_rcv_saddr
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54) #define tw_v6_rcv_saddr    	__tw_common.skc_v6_rcv_saddr
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55) #define tw_dport		__tw_common.skc_dport
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56) #define tw_num			__tw_common.skc_num
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57) #define tw_cookie		__tw_common.skc_cookie
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58) #define tw_dr			__tw_common.skc_tw_dr
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  60) 	__u32			tw_mark;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  61) 	volatile unsigned char	tw_substate;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  62) 	unsigned char		tw_rcv_wscale;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  63) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  64) 	/* Socket demultiplex comparisons on incoming packets. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  65) 	/* these three are in inet_sock */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  66) 	__be16			tw_sport;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67) 	/* And these are ours. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68) 	unsigned int		tw_kill		: 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  69) 				tw_transparent  : 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  70) 				tw_flowlabel	: 20,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71) 				tw_pad		: 2,	/* 2 bits hole */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72) 				tw_tos		: 8;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73) 	u32			tw_txhash;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  74) 	u32			tw_priority;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  75) 	struct timer_list	tw_timer;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  76) 	struct inet_bind_bucket	*tw_tb;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  77) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78) #define tw_tclass tw_tos
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80) static inline struct inet_timewait_sock *inet_twsk(const struct sock *sk)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  81) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  82) 	return (struct inet_timewait_sock *)sk;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  83) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  84) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85) void inet_twsk_free(struct inet_timewait_sock *tw);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86) void inet_twsk_put(struct inet_timewait_sock *tw);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88) void inet_twsk_bind_unhash(struct inet_timewait_sock *tw,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89) 			   struct inet_hashinfo *hashinfo);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91) struct inet_timewait_sock *inet_twsk_alloc(const struct sock *sk,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  92) 					   struct inet_timewait_death_row *dr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93) 					   const int state);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95) void inet_twsk_hashdance(struct inet_timewait_sock *tw, struct sock *sk,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96) 			 struct inet_hashinfo *hashinfo);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98) void __inet_twsk_schedule(struct inet_timewait_sock *tw, int timeo,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  99) 			  bool rearm);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) static inline void inet_twsk_schedule(struct inet_timewait_sock *tw, int timeo)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) 	__inet_twsk_schedule(tw, timeo, false);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) static inline void inet_twsk_reschedule(struct inet_timewait_sock *tw, int timeo)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) 	__inet_twsk_schedule(tw, timeo, true);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) void inet_twsk_deschedule_put(struct inet_timewait_sock *tw);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) void inet_twsk_purge(struct inet_hashinfo *hashinfo, int family);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) static inline
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) struct net *twsk_net(const struct inet_timewait_sock *twsk)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) 	return read_pnet(&twsk->tw_net);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) static inline
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) void twsk_net_set(struct inet_timewait_sock *twsk, struct net *net)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) 	write_pnet(&twsk->tw_net, net);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) #endif	/* _INET_TIMEWAIT_SOCK_ */