xref: /OK3568_Linux_fs/kernel/Documentation/networking/ipvs-sysctl.rst (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun.. SPDX-License-Identifier: GPL-2.0
2*4882a593Smuzhiyun
3*4882a593Smuzhiyun===========
4*4882a593SmuzhiyunIPvs-sysctl
5*4882a593Smuzhiyun===========
6*4882a593Smuzhiyun
7*4882a593Smuzhiyun/proc/sys/net/ipv4/vs/* Variables:
8*4882a593Smuzhiyun==================================
9*4882a593Smuzhiyun
10*4882a593Smuzhiyunam_droprate - INTEGER
11*4882a593Smuzhiyun	default 10
12*4882a593Smuzhiyun
13*4882a593Smuzhiyun	It sets the always mode drop rate, which is used in the mode 3
14*4882a593Smuzhiyun	of the drop_rate defense.
15*4882a593Smuzhiyun
16*4882a593Smuzhiyunamemthresh - INTEGER
17*4882a593Smuzhiyun	default 1024
18*4882a593Smuzhiyun
19*4882a593Smuzhiyun	It sets the available memory threshold (in pages), which is
20*4882a593Smuzhiyun	used in the automatic modes of defense. When there is no
21*4882a593Smuzhiyun	enough available memory, the respective strategy will be
22*4882a593Smuzhiyun	enabled and the variable is automatically set to 2, otherwise
23*4882a593Smuzhiyun	the strategy is disabled and the variable is  set  to 1.
24*4882a593Smuzhiyun
25*4882a593Smuzhiyunbackup_only - BOOLEAN
26*4882a593Smuzhiyun	- 0 - disabled (default)
27*4882a593Smuzhiyun	- not 0 - enabled
28*4882a593Smuzhiyun
29*4882a593Smuzhiyun	If set, disable the director function while the server is
30*4882a593Smuzhiyun	in backup mode to avoid packet loops for DR/TUN methods.
31*4882a593Smuzhiyun
32*4882a593Smuzhiyunconn_reuse_mode - INTEGER
33*4882a593Smuzhiyun	1 - default
34*4882a593Smuzhiyun
35*4882a593Smuzhiyun	Controls how ipvs will deal with connections that are detected
36*4882a593Smuzhiyun	port reuse. It is a bitmap, with the values being:
37*4882a593Smuzhiyun
38*4882a593Smuzhiyun	0: disable any special handling on port reuse. The new
39*4882a593Smuzhiyun	connection will be delivered to the same real server that was
40*4882a593Smuzhiyun	servicing the previous connection.
41*4882a593Smuzhiyun
42*4882a593Smuzhiyun	bit 1: enable rescheduling of new connections when it is safe.
43*4882a593Smuzhiyun	That is, whenever expire_nodest_conn and for TCP sockets, when
44*4882a593Smuzhiyun	the connection is in TIME_WAIT state (which is only possible if
45*4882a593Smuzhiyun	you use NAT mode).
46*4882a593Smuzhiyun
47*4882a593Smuzhiyun	bit 2: it is bit 1 plus, for TCP connections, when connections
48*4882a593Smuzhiyun	are in FIN_WAIT state, as this is the last state seen by load
49*4882a593Smuzhiyun	balancer in Direct Routing mode. This bit helps on adding new
50*4882a593Smuzhiyun	real servers to a very busy cluster.
51*4882a593Smuzhiyun
52*4882a593Smuzhiyunconntrack - BOOLEAN
53*4882a593Smuzhiyun	- 0 - disabled (default)
54*4882a593Smuzhiyun	- not 0 - enabled
55*4882a593Smuzhiyun
56*4882a593Smuzhiyun	If set, maintain connection tracking entries for
57*4882a593Smuzhiyun	connections handled by IPVS.
58*4882a593Smuzhiyun
59*4882a593Smuzhiyun	This should be enabled if connections handled by IPVS are to be
60*4882a593Smuzhiyun	also handled by stateful firewall rules. That is, iptables rules
61*4882a593Smuzhiyun	that make use of connection tracking.  It is a performance
62*4882a593Smuzhiyun	optimisation to disable this setting otherwise.
63*4882a593Smuzhiyun
64*4882a593Smuzhiyun	Connections handled by the IPVS FTP application module
65*4882a593Smuzhiyun	will have connection tracking entries regardless of this setting.
66*4882a593Smuzhiyun
67*4882a593Smuzhiyun	Only available when IPVS is compiled with CONFIG_IP_VS_NFCT enabled.
68*4882a593Smuzhiyun
69*4882a593Smuzhiyuncache_bypass - BOOLEAN
70*4882a593Smuzhiyun	- 0 - disabled (default)
71*4882a593Smuzhiyun	- not 0 - enabled
72*4882a593Smuzhiyun
73*4882a593Smuzhiyun	If it is enabled, forward packets to the original destination
74*4882a593Smuzhiyun	directly when no cache server is available and destination
75*4882a593Smuzhiyun	address is not local (iph->daddr is RTN_UNICAST). It is mostly
76*4882a593Smuzhiyun	used in transparent web cache cluster.
77*4882a593Smuzhiyun
78*4882a593Smuzhiyundebug_level - INTEGER
79*4882a593Smuzhiyun	- 0          - transmission error messages (default)
80*4882a593Smuzhiyun	- 1          - non-fatal error messages
81*4882a593Smuzhiyun	- 2          - configuration
82*4882a593Smuzhiyun	- 3          - destination trash
83*4882a593Smuzhiyun	- 4          - drop entry
84*4882a593Smuzhiyun	- 5          - service lookup
85*4882a593Smuzhiyun	- 6          - scheduling
86*4882a593Smuzhiyun	- 7          - connection new/expire, lookup and synchronization
87*4882a593Smuzhiyun	- 8          - state transition
88*4882a593Smuzhiyun	- 9          - binding destination, template checks and applications
89*4882a593Smuzhiyun	- 10         - IPVS packet transmission
90*4882a593Smuzhiyun	- 11         - IPVS packet handling (ip_vs_in/ip_vs_out)
91*4882a593Smuzhiyun	- 12 or more - packet traversal
92*4882a593Smuzhiyun
93*4882a593Smuzhiyun	Only available when IPVS is compiled with CONFIG_IP_VS_DEBUG enabled.
94*4882a593Smuzhiyun
95*4882a593Smuzhiyun	Higher debugging levels include the messages for lower debugging
96*4882a593Smuzhiyun	levels, so setting debug level 2, includes level 0, 1 and 2
97*4882a593Smuzhiyun	messages. Thus, logging becomes more and more verbose the higher
98*4882a593Smuzhiyun	the level.
99*4882a593Smuzhiyun
100*4882a593Smuzhiyundrop_entry - INTEGER
101*4882a593Smuzhiyun	- 0  - disabled (default)
102*4882a593Smuzhiyun
103*4882a593Smuzhiyun	The drop_entry defense is to randomly drop entries in the
104*4882a593Smuzhiyun	connection hash table, just in order to collect back some
105*4882a593Smuzhiyun	memory for new connections. In the current code, the
106*4882a593Smuzhiyun	drop_entry procedure can be activated every second, then it
107*4882a593Smuzhiyun	randomly scans 1/32 of the whole and drops entries that are in
108*4882a593Smuzhiyun	the SYN-RECV/SYNACK state, which should be effective against
109*4882a593Smuzhiyun	syn-flooding attack.
110*4882a593Smuzhiyun
111*4882a593Smuzhiyun	The valid values of drop_entry are from 0 to 3, where 0 means
112*4882a593Smuzhiyun	that this strategy is always disabled, 1 and 2 mean automatic
113*4882a593Smuzhiyun	modes (when there is no enough available memory, the strategy
114*4882a593Smuzhiyun	is enabled and the variable is automatically set to 2,
115*4882a593Smuzhiyun	otherwise the strategy is disabled and the variable is set to
116*4882a593Smuzhiyun	1), and 3 means that the strategy is always enabled.
117*4882a593Smuzhiyun
118*4882a593Smuzhiyundrop_packet - INTEGER
119*4882a593Smuzhiyun	- 0  - disabled (default)
120*4882a593Smuzhiyun
121*4882a593Smuzhiyun	The drop_packet defense is designed to drop 1/rate packets
122*4882a593Smuzhiyun	before forwarding them to real servers. If the rate is 1, then
123*4882a593Smuzhiyun	drop all the incoming packets.
124*4882a593Smuzhiyun
125*4882a593Smuzhiyun	The value definition is the same as that of the drop_entry. In
126*4882a593Smuzhiyun	the automatic mode, the rate is determined by the follow
127*4882a593Smuzhiyun	formula: rate = amemthresh / (amemthresh - available_memory)
128*4882a593Smuzhiyun	when available memory is less than the available memory
129*4882a593Smuzhiyun	threshold. When the mode 3 is set, the always mode drop rate
130*4882a593Smuzhiyun	is controlled by the /proc/sys/net/ipv4/vs/am_droprate.
131*4882a593Smuzhiyun
132*4882a593Smuzhiyunexpire_nodest_conn - BOOLEAN
133*4882a593Smuzhiyun	- 0 - disabled (default)
134*4882a593Smuzhiyun	- not 0 - enabled
135*4882a593Smuzhiyun
136*4882a593Smuzhiyun	The default value is 0, the load balancer will silently drop
137*4882a593Smuzhiyun	packets when its destination server is not available. It may
138*4882a593Smuzhiyun	be useful, when user-space monitoring program deletes the
139*4882a593Smuzhiyun	destination server (because of server overload or wrong
140*4882a593Smuzhiyun	detection) and add back the server later, and the connections
141*4882a593Smuzhiyun	to the server can continue.
142*4882a593Smuzhiyun
143*4882a593Smuzhiyun	If this feature is enabled, the load balancer will expire the
144*4882a593Smuzhiyun	connection immediately when a packet arrives and its
145*4882a593Smuzhiyun	destination server is not available, then the client program
146*4882a593Smuzhiyun	will be notified that the connection is closed. This is
147*4882a593Smuzhiyun	equivalent to the feature some people requires to flush
148*4882a593Smuzhiyun	connections when its destination is not available.
149*4882a593Smuzhiyun
150*4882a593Smuzhiyunexpire_quiescent_template - BOOLEAN
151*4882a593Smuzhiyun	- 0 - disabled (default)
152*4882a593Smuzhiyun	- not 0 - enabled
153*4882a593Smuzhiyun
154*4882a593Smuzhiyun	When set to a non-zero value, the load balancer will expire
155*4882a593Smuzhiyun	persistent templates when the destination server is quiescent.
156*4882a593Smuzhiyun	This may be useful, when a user makes a destination server
157*4882a593Smuzhiyun	quiescent by setting its weight to 0 and it is desired that
158*4882a593Smuzhiyun	subsequent otherwise persistent connections are sent to a
159*4882a593Smuzhiyun	different destination server.  By default new persistent
160*4882a593Smuzhiyun	connections are allowed to quiescent destination servers.
161*4882a593Smuzhiyun
162*4882a593Smuzhiyun	If this feature is enabled, the load balancer will expire the
163*4882a593Smuzhiyun	persistence template if it is to be used to schedule a new
164*4882a593Smuzhiyun	connection and the destination server is quiescent.
165*4882a593Smuzhiyun
166*4882a593Smuzhiyunignore_tunneled - BOOLEAN
167*4882a593Smuzhiyun	- 0 - disabled (default)
168*4882a593Smuzhiyun	- not 0 - enabled
169*4882a593Smuzhiyun
170*4882a593Smuzhiyun	If set, ipvs will set the ipvs_property on all packets which are of
171*4882a593Smuzhiyun	unrecognized protocols.  This prevents us from routing tunneled
172*4882a593Smuzhiyun	protocols like ipip, which is useful to prevent rescheduling
173*4882a593Smuzhiyun	packets that have been tunneled to the ipvs host (i.e. to prevent
174*4882a593Smuzhiyun	ipvs routing loops when ipvs is also acting as a real server).
175*4882a593Smuzhiyun
176*4882a593Smuzhiyunnat_icmp_send - BOOLEAN
177*4882a593Smuzhiyun	- 0 - disabled (default)
178*4882a593Smuzhiyun	- not 0 - enabled
179*4882a593Smuzhiyun
180*4882a593Smuzhiyun	It controls sending icmp error messages (ICMP_DEST_UNREACH)
181*4882a593Smuzhiyun	for VS/NAT when the load balancer receives packets from real
182*4882a593Smuzhiyun	servers but the connection entries don't exist.
183*4882a593Smuzhiyun
184*4882a593Smuzhiyunpmtu_disc - BOOLEAN
185*4882a593Smuzhiyun	- 0 - disabled
186*4882a593Smuzhiyun	- not 0 - enabled (default)
187*4882a593Smuzhiyun
188*4882a593Smuzhiyun	By default, reject with FRAG_NEEDED all DF packets that exceed
189*4882a593Smuzhiyun	the PMTU, irrespective of the forwarding method. For TUN method
190*4882a593Smuzhiyun	the flag can be disabled to fragment such packets.
191*4882a593Smuzhiyun
192*4882a593Smuzhiyunsecure_tcp - INTEGER
193*4882a593Smuzhiyun	- 0  - disabled (default)
194*4882a593Smuzhiyun
195*4882a593Smuzhiyun	The secure_tcp defense is to use a more complicated TCP state
196*4882a593Smuzhiyun	transition table. For VS/NAT, it also delays entering the
197*4882a593Smuzhiyun	TCP ESTABLISHED state until the three way handshake is completed.
198*4882a593Smuzhiyun
199*4882a593Smuzhiyun	The value definition is the same as that of drop_entry and
200*4882a593Smuzhiyun	drop_packet.
201*4882a593Smuzhiyun
202*4882a593Smuzhiyunsync_threshold - vector of 2 INTEGERs: sync_threshold, sync_period
203*4882a593Smuzhiyun	default 3 50
204*4882a593Smuzhiyun
205*4882a593Smuzhiyun	It sets synchronization threshold, which is the minimum number
206*4882a593Smuzhiyun	of incoming packets that a connection needs to receive before
207*4882a593Smuzhiyun	the connection will be synchronized. A connection will be
208*4882a593Smuzhiyun	synchronized, every time the number of its incoming packets
209*4882a593Smuzhiyun	modulus sync_period equals the threshold. The range of the
210*4882a593Smuzhiyun	threshold is from 0 to sync_period.
211*4882a593Smuzhiyun
212*4882a593Smuzhiyun	When sync_period and sync_refresh_period are 0, send sync only
213*4882a593Smuzhiyun	for state changes or only once when pkts matches sync_threshold
214*4882a593Smuzhiyun
215*4882a593Smuzhiyunsync_refresh_period - UNSIGNED INTEGER
216*4882a593Smuzhiyun	default 0
217*4882a593Smuzhiyun
218*4882a593Smuzhiyun	In seconds, difference in reported connection timer that triggers
219*4882a593Smuzhiyun	new sync message. It can be used to avoid sync messages for the
220*4882a593Smuzhiyun	specified period (or half of the connection timeout if it is lower)
221*4882a593Smuzhiyun	if connection state is not changed since last sync.
222*4882a593Smuzhiyun
223*4882a593Smuzhiyun	This is useful for normal connections with high traffic to reduce
224*4882a593Smuzhiyun	sync rate. Additionally, retry sync_retries times with period of
225*4882a593Smuzhiyun	sync_refresh_period/8.
226*4882a593Smuzhiyun
227*4882a593Smuzhiyunsync_retries - INTEGER
228*4882a593Smuzhiyun	default 0
229*4882a593Smuzhiyun
230*4882a593Smuzhiyun	Defines sync retries with period of sync_refresh_period/8. Useful
231*4882a593Smuzhiyun	to protect against loss of sync messages. The range of the
232*4882a593Smuzhiyun	sync_retries is from 0 to 3.
233*4882a593Smuzhiyun
234*4882a593Smuzhiyunsync_qlen_max - UNSIGNED LONG
235*4882a593Smuzhiyun
236*4882a593Smuzhiyun	Hard limit for queued sync messages that are not sent yet. It
237*4882a593Smuzhiyun	defaults to 1/32 of the memory pages but actually represents
238*4882a593Smuzhiyun	number of messages. It will protect us from allocating large
239*4882a593Smuzhiyun	parts of memory when the sending rate is lower than the queuing
240*4882a593Smuzhiyun	rate.
241*4882a593Smuzhiyun
242*4882a593Smuzhiyunsync_sock_size - INTEGER
243*4882a593Smuzhiyun	default 0
244*4882a593Smuzhiyun
245*4882a593Smuzhiyun	Configuration of SNDBUF (master) or RCVBUF (slave) socket limit.
246*4882a593Smuzhiyun	Default value is 0 (preserve system defaults).
247*4882a593Smuzhiyun
248*4882a593Smuzhiyunsync_ports - INTEGER
249*4882a593Smuzhiyun	default 1
250*4882a593Smuzhiyun
251*4882a593Smuzhiyun	The number of threads that master and backup servers can use for
252*4882a593Smuzhiyun	sync traffic. Every thread will use single UDP port, thread 0 will
253*4882a593Smuzhiyun	use the default port 8848 while last thread will use port
254*4882a593Smuzhiyun	8848+sync_ports-1.
255*4882a593Smuzhiyun
256*4882a593Smuzhiyunsnat_reroute - BOOLEAN
257*4882a593Smuzhiyun	- 0 - disabled
258*4882a593Smuzhiyun	- not 0 - enabled (default)
259*4882a593Smuzhiyun
260*4882a593Smuzhiyun	If enabled, recalculate the route of SNATed packets from
261*4882a593Smuzhiyun	realservers so that they are routed as if they originate from the
262*4882a593Smuzhiyun	director. Otherwise they are routed as if they are forwarded by the
263*4882a593Smuzhiyun	director.
264*4882a593Smuzhiyun
265*4882a593Smuzhiyun	If policy routing is in effect then it is possible that the route
266*4882a593Smuzhiyun	of a packet originating from a director is routed differently to a
267*4882a593Smuzhiyun	packet being forwarded by the director.
268*4882a593Smuzhiyun
269*4882a593Smuzhiyun	If policy routing is not in effect then the recalculated route will
270*4882a593Smuzhiyun	always be the same as the original route so it is an optimisation
271*4882a593Smuzhiyun	to disable snat_reroute and avoid the recalculation.
272*4882a593Smuzhiyun
273*4882a593Smuzhiyunsync_persist_mode - INTEGER
274*4882a593Smuzhiyun	default 0
275*4882a593Smuzhiyun
276*4882a593Smuzhiyun	Controls the synchronisation of connections when using persistence
277*4882a593Smuzhiyun
278*4882a593Smuzhiyun	0: All types of connections are synchronised
279*4882a593Smuzhiyun
280*4882a593Smuzhiyun	1: Attempt to reduce the synchronisation traffic depending on
281*4882a593Smuzhiyun	the connection type. For persistent services avoid synchronisation
282*4882a593Smuzhiyun	for normal connections, do it only for persistence templates.
283*4882a593Smuzhiyun	In such case, for TCP and SCTP it may need enabling sloppy_tcp and
284*4882a593Smuzhiyun	sloppy_sctp flags on backup servers. For non-persistent services
285*4882a593Smuzhiyun	such optimization is not applied, mode 0 is assumed.
286*4882a593Smuzhiyun
287*4882a593Smuzhiyunsync_version - INTEGER
288*4882a593Smuzhiyun	default 1
289*4882a593Smuzhiyun
290*4882a593Smuzhiyun	The version of the synchronisation protocol used when sending
291*4882a593Smuzhiyun	synchronisation messages.
292*4882a593Smuzhiyun
293*4882a593Smuzhiyun	0 selects the original synchronisation protocol (version 0). This
294*4882a593Smuzhiyun	should be used when sending synchronisation messages to a legacy
295*4882a593Smuzhiyun	system that only understands the original synchronisation protocol.
296*4882a593Smuzhiyun
297*4882a593Smuzhiyun	1 selects the current synchronisation protocol (version 1). This
298*4882a593Smuzhiyun	should be used where possible.
299*4882a593Smuzhiyun
300*4882a593Smuzhiyun	Kernels with this sync_version entry are able to receive messages
301*4882a593Smuzhiyun	of both version 1 and version 2 of the synchronisation protocol.
302