]>
Commit | Line | Data |
---|---|---|
1da177e4 LT |
1 | /* |
2 | * IP Virtual Server | |
3 | * data structure and functionality definitions | |
4 | */ | |
5 | ||
bc4768eb JV |
6 | #ifndef _NET_IP_VS_H |
7 | #define _NET_IP_VS_H | |
1da177e4 | 8 | |
bc4768eb | 9 | #include <linux/ip_vs.h> /* definitions shared with userland */ |
1da177e4 | 10 | |
bc4768eb | 11 | /* old ipvsadm versions still include this file directly */ |
1da177e4 LT |
12 | #ifdef __KERNEL__ |
13 | ||
bc4768eb JV |
14 | #include <asm/types.h> /* for __uXX types */ |
15 | ||
16 | #include <linux/sysctl.h> /* for ctl_path */ | |
1da177e4 LT |
17 | #include <linux/list.h> /* for struct list_head */ |
18 | #include <linux/spinlock.h> /* for struct rwlock_t */ | |
1da177e4 | 19 | #include <asm/atomic.h> /* for struct atomic_t */ |
1da177e4 | 20 | #include <linux/compiler.h> |
14c85021 | 21 | #include <linux/timer.h> |
1da177e4 | 22 | |
14c85021 | 23 | #include <net/checksum.h> |
e7ade46a | 24 | #include <linux/netfilter.h> /* for union nf_inet_addr */ |
1668e010 | 25 | #include <linux/ip.h> |
e7ade46a JV |
26 | #include <linux/ipv6.h> /* for struct ipv6hdr */ |
27 | #include <net/ipv6.h> /* for ipv6_addr_copy */ | |
f4bc17cd JA |
28 | #ifdef CONFIG_IP_VS_NFCT |
29 | #include <net/netfilter/nf_conntrack.h> | |
30 | #endif | |
6f7edb48 CB |
31 | |
32 | /* Connections' size value needed by ip_vs_ctl.c */ | |
33 | extern int ip_vs_conn_tab_size; | |
34 | ||
35 | ||
64aae3cb JV |
36 | struct ip_vs_iphdr { |
37 | int len; | |
38 | __u8 protocol; | |
39 | union nf_inet_addr saddr; | |
40 | union nf_inet_addr daddr; | |
41 | }; | |
42 | ||
43 | static inline void | |
44 | ip_vs_fill_iphdr(int af, const void *nh, struct ip_vs_iphdr *iphdr) | |
45 | { | |
46 | #ifdef CONFIG_IP_VS_IPV6 | |
47 | if (af == AF_INET6) { | |
48 | const struct ipv6hdr *iph = nh; | |
49 | iphdr->len = sizeof(struct ipv6hdr); | |
50 | iphdr->protocol = iph->nexthdr; | |
51 | ipv6_addr_copy(&iphdr->saddr.in6, &iph->saddr); | |
52 | ipv6_addr_copy(&iphdr->daddr.in6, &iph->daddr); | |
53 | } else | |
54 | #endif | |
55 | { | |
56 | const struct iphdr *iph = nh; | |
57 | iphdr->len = iph->ihl * 4; | |
58 | iphdr->protocol = iph->protocol; | |
59 | iphdr->saddr.ip = iph->saddr; | |
60 | iphdr->daddr.ip = iph->daddr; | |
61 | } | |
62 | } | |
63 | ||
64 | static inline void ip_vs_addr_copy(int af, union nf_inet_addr *dst, | |
65 | const union nf_inet_addr *src) | |
66 | { | |
67 | #ifdef CONFIG_IP_VS_IPV6 | |
68 | if (af == AF_INET6) | |
69 | ipv6_addr_copy(&dst->in6, &src->in6); | |
70 | else | |
71 | #endif | |
72 | dst->ip = src->ip; | |
73 | } | |
74 | ||
75 | static inline int ip_vs_addr_equal(int af, const union nf_inet_addr *a, | |
76 | const union nf_inet_addr *b) | |
77 | { | |
78 | #ifdef CONFIG_IP_VS_IPV6 | |
79 | if (af == AF_INET6) | |
80 | return ipv6_addr_equal(&a->in6, &b->in6); | |
81 | #endif | |
82 | return a->ip == b->ip; | |
83 | } | |
84 | ||
1da177e4 | 85 | #ifdef CONFIG_IP_VS_DEBUG |
14c85021 ACM |
86 | #include <linux/net.h> |
87 | ||
1da177e4 | 88 | extern int ip_vs_get_debug_level(void); |
c842a3ad JV |
89 | |
90 | static inline const char *ip_vs_dbg_addr(int af, char *buf, size_t buf_len, | |
91 | const union nf_inet_addr *addr, | |
92 | int *idx) | |
93 | { | |
94 | int len; | |
95 | #ifdef CONFIG_IP_VS_IPV6 | |
96 | if (af == AF_INET6) | |
5b095d98 | 97 | len = snprintf(&buf[*idx], buf_len - *idx, "[%pI6]", |
0c6ce78a | 98 | &addr->in6) + 1; |
c842a3ad JV |
99 | else |
100 | #endif | |
3685f25d HH |
101 | len = snprintf(&buf[*idx], buf_len - *idx, "%pI4", |
102 | &addr->ip) + 1; | |
c842a3ad JV |
103 | |
104 | *idx += len; | |
105 | BUG_ON(*idx > buf_len + 1); | |
106 | return &buf[*idx - len]; | |
107 | } | |
108 | ||
9aada7ac HE |
109 | #define IP_VS_DBG_BUF(level, msg, ...) \ |
110 | do { \ | |
111 | char ip_vs_dbg_buf[160]; \ | |
112 | int ip_vs_dbg_idx = 0; \ | |
113 | if (level <= ip_vs_get_debug_level()) \ | |
114 | printk(KERN_DEBUG pr_fmt(msg), ##__VA_ARGS__); \ | |
115 | } while (0) | |
116 | #define IP_VS_ERR_BUF(msg...) \ | |
117 | do { \ | |
118 | char ip_vs_dbg_buf[160]; \ | |
119 | int ip_vs_dbg_idx = 0; \ | |
120 | pr_err(msg); \ | |
121 | } while (0) | |
c842a3ad JV |
122 | |
123 | /* Only use from within IP_VS_DBG_BUF() or IP_VS_ERR_BUF macros */ | |
9aada7ac HE |
124 | #define IP_VS_DBG_ADDR(af, addr) \ |
125 | ip_vs_dbg_addr(af, ip_vs_dbg_buf, \ | |
126 | sizeof(ip_vs_dbg_buf), addr, \ | |
127 | &ip_vs_dbg_idx) | |
128 | ||
129 | #define IP_VS_DBG(level, msg, ...) \ | |
130 | do { \ | |
131 | if (level <= ip_vs_get_debug_level()) \ | |
132 | printk(KERN_DEBUG pr_fmt(msg), ##__VA_ARGS__); \ | |
133 | } while (0) | |
134 | #define IP_VS_DBG_RL(msg, ...) \ | |
135 | do { \ | |
136 | if (net_ratelimit()) \ | |
137 | printk(KERN_DEBUG pr_fmt(msg), ##__VA_ARGS__); \ | |
138 | } while (0) | |
139 | #define IP_VS_DBG_PKT(level, pp, skb, ofs, msg) \ | |
140 | do { \ | |
141 | if (level <= ip_vs_get_debug_level()) \ | |
142 | pp->debug_packet(pp, skb, ofs, msg); \ | |
143 | } while (0) | |
144 | #define IP_VS_DBG_RL_PKT(level, pp, skb, ofs, msg) \ | |
145 | do { \ | |
146 | if (level <= ip_vs_get_debug_level() && \ | |
147 | net_ratelimit()) \ | |
148 | pp->debug_packet(pp, skb, ofs, msg); \ | |
149 | } while (0) | |
1da177e4 | 150 | #else /* NO DEBUGGING at ALL */ |
c842a3ad JV |
151 | #define IP_VS_DBG_BUF(level, msg...) do {} while (0) |
152 | #define IP_VS_ERR_BUF(msg...) do {} while (0) | |
1da177e4 LT |
153 | #define IP_VS_DBG(level, msg...) do {} while (0) |
154 | #define IP_VS_DBG_RL(msg...) do {} while (0) | |
155 | #define IP_VS_DBG_PKT(level, pp, skb, ofs, msg) do {} while (0) | |
156 | #define IP_VS_DBG_RL_PKT(level, pp, skb, ofs, msg) do {} while (0) | |
157 | #endif | |
158 | ||
159 | #define IP_VS_BUG() BUG() | |
1e3e238e | 160 | #define IP_VS_ERR_RL(msg, ...) \ |
9aada7ac HE |
161 | do { \ |
162 | if (net_ratelimit()) \ | |
1e3e238e | 163 | pr_err(msg, ##__VA_ARGS__); \ |
9aada7ac | 164 | } while (0) |
1da177e4 LT |
165 | |
166 | #ifdef CONFIG_IP_VS_DEBUG | |
167 | #define EnterFunction(level) \ | |
9aada7ac HE |
168 | do { \ |
169 | if (level <= ip_vs_get_debug_level()) \ | |
170 | printk(KERN_DEBUG \ | |
171 | pr_fmt("Enter: %s, %s line %i\n"), \ | |
172 | __func__, __FILE__, __LINE__); \ | |
173 | } while (0) | |
174 | #define LeaveFunction(level) \ | |
175 | do { \ | |
176 | if (level <= ip_vs_get_debug_level()) \ | |
177 | printk(KERN_DEBUG \ | |
178 | pr_fmt("Leave: %s, %s line %i\n"), \ | |
179 | __func__, __FILE__, __LINE__); \ | |
180 | } while (0) | |
1da177e4 LT |
181 | #else |
182 | #define EnterFunction(level) do {} while (0) | |
183 | #define LeaveFunction(level) do {} while (0) | |
184 | #endif | |
185 | ||
186 | #define IP_VS_WAIT_WHILE(expr) while (expr) { cpu_relax(); } | |
187 | ||
188 | ||
189 | /* | |
190 | * The port number of FTP service (in network order). | |
191 | */ | |
f3a7c66b HH |
192 | #define FTPPORT cpu_to_be16(21) |
193 | #define FTPDATA cpu_to_be16(20) | |
1da177e4 | 194 | |
1da177e4 LT |
195 | /* |
196 | * TCP State Values | |
197 | */ | |
198 | enum { | |
199 | IP_VS_TCP_S_NONE = 0, | |
200 | IP_VS_TCP_S_ESTABLISHED, | |
201 | IP_VS_TCP_S_SYN_SENT, | |
202 | IP_VS_TCP_S_SYN_RECV, | |
203 | IP_VS_TCP_S_FIN_WAIT, | |
204 | IP_VS_TCP_S_TIME_WAIT, | |
205 | IP_VS_TCP_S_CLOSE, | |
206 | IP_VS_TCP_S_CLOSE_WAIT, | |
207 | IP_VS_TCP_S_LAST_ACK, | |
208 | IP_VS_TCP_S_LISTEN, | |
209 | IP_VS_TCP_S_SYNACK, | |
210 | IP_VS_TCP_S_LAST | |
211 | }; | |
212 | ||
213 | /* | |
214 | * UDP State Values | |
215 | */ | |
216 | enum { | |
217 | IP_VS_UDP_S_NORMAL, | |
218 | IP_VS_UDP_S_LAST, | |
219 | }; | |
220 | ||
221 | /* | |
222 | * ICMP State Values | |
223 | */ | |
224 | enum { | |
225 | IP_VS_ICMP_S_NORMAL, | |
226 | IP_VS_ICMP_S_LAST, | |
227 | }; | |
228 | ||
2906f66a VMR |
229 | /* |
230 | * SCTP State Values | |
231 | */ | |
232 | enum ip_vs_sctp_states { | |
233 | IP_VS_SCTP_S_NONE, | |
234 | IP_VS_SCTP_S_INIT_CLI, | |
235 | IP_VS_SCTP_S_INIT_SER, | |
236 | IP_VS_SCTP_S_INIT_ACK_CLI, | |
237 | IP_VS_SCTP_S_INIT_ACK_SER, | |
238 | IP_VS_SCTP_S_ECHO_CLI, | |
239 | IP_VS_SCTP_S_ECHO_SER, | |
240 | IP_VS_SCTP_S_ESTABLISHED, | |
241 | IP_VS_SCTP_S_SHUT_CLI, | |
242 | IP_VS_SCTP_S_SHUT_SER, | |
243 | IP_VS_SCTP_S_SHUT_ACK_CLI, | |
244 | IP_VS_SCTP_S_SHUT_ACK_SER, | |
245 | IP_VS_SCTP_S_CLOSED, | |
246 | IP_VS_SCTP_S_LAST | |
247 | }; | |
248 | ||
1da177e4 LT |
249 | /* |
250 | * Delta sequence info structure | |
251 | * Each ip_vs_conn has 2 (output AND input seq. changes). | |
252 | * Only used in the VS/NAT. | |
253 | */ | |
254 | struct ip_vs_seq { | |
255 | __u32 init_seq; /* Add delta from this seq */ | |
256 | __u32 delta; /* Delta in sequence numbers */ | |
257 | __u32 previous_delta; /* Delta in sequence numbers | |
258 | before last resized pkt */ | |
259 | }; | |
260 | ||
261 | ||
262 | /* | |
3a14a313 | 263 | * IPVS statistics objects |
1da177e4 | 264 | */ |
3a14a313 SW |
265 | struct ip_vs_estimator { |
266 | struct list_head list; | |
267 | ||
268 | u64 last_inbytes; | |
269 | u64 last_outbytes; | |
270 | u32 last_conns; | |
271 | u32 last_inpkts; | |
272 | u32 last_outpkts; | |
273 | ||
274 | u32 cps; | |
275 | u32 inpps; | |
276 | u32 outpps; | |
277 | u32 inbps; | |
278 | u32 outbps; | |
279 | }; | |
280 | ||
fd2c3ef7 | 281 | struct ip_vs_stats { |
e9c0ce23 SW |
282 | struct ip_vs_stats_user ustats; /* statistics */ |
283 | struct ip_vs_estimator est; /* estimator */ | |
3a14a313 | 284 | |
1da177e4 LT |
285 | spinlock_t lock; /* spin lock */ |
286 | }; | |
287 | ||
14c85021 ACM |
288 | struct dst_entry; |
289 | struct iphdr; | |
1da177e4 LT |
290 | struct ip_vs_conn; |
291 | struct ip_vs_app; | |
14c85021 | 292 | struct sk_buff; |
1da177e4 LT |
293 | |
294 | struct ip_vs_protocol { | |
295 | struct ip_vs_protocol *next; | |
296 | char *name; | |
2ad17def JA |
297 | u16 protocol; |
298 | u16 num_states; | |
1da177e4 LT |
299 | int dont_defrag; |
300 | atomic_t appcnt; /* counter of proto app incs */ | |
301 | int *timeout_table; /* protocol timeout table */ | |
302 | ||
303 | void (*init)(struct ip_vs_protocol *pp); | |
304 | ||
305 | void (*exit)(struct ip_vs_protocol *pp); | |
306 | ||
51ef348b | 307 | int (*conn_schedule)(int af, struct sk_buff *skb, |
1da177e4 LT |
308 | struct ip_vs_protocol *pp, |
309 | int *verdict, struct ip_vs_conn **cpp); | |
310 | ||
311 | struct ip_vs_conn * | |
51ef348b JV |
312 | (*conn_in_get)(int af, |
313 | const struct sk_buff *skb, | |
1da177e4 | 314 | struct ip_vs_protocol *pp, |
51ef348b | 315 | const struct ip_vs_iphdr *iph, |
1da177e4 LT |
316 | unsigned int proto_off, |
317 | int inverse); | |
318 | ||
319 | struct ip_vs_conn * | |
51ef348b JV |
320 | (*conn_out_get)(int af, |
321 | const struct sk_buff *skb, | |
1da177e4 | 322 | struct ip_vs_protocol *pp, |
51ef348b | 323 | const struct ip_vs_iphdr *iph, |
1da177e4 LT |
324 | unsigned int proto_off, |
325 | int inverse); | |
326 | ||
3db05fea | 327 | int (*snat_handler)(struct sk_buff *skb, |
1da177e4 LT |
328 | struct ip_vs_protocol *pp, struct ip_vs_conn *cp); |
329 | ||
3db05fea | 330 | int (*dnat_handler)(struct sk_buff *skb, |
1da177e4 LT |
331 | struct ip_vs_protocol *pp, struct ip_vs_conn *cp); |
332 | ||
51ef348b JV |
333 | int (*csum_check)(int af, struct sk_buff *skb, |
334 | struct ip_vs_protocol *pp); | |
1da177e4 LT |
335 | |
336 | const char *(*state_name)(int state); | |
337 | ||
338 | int (*state_transition)(struct ip_vs_conn *cp, int direction, | |
339 | const struct sk_buff *skb, | |
340 | struct ip_vs_protocol *pp); | |
341 | ||
342 | int (*register_app)(struct ip_vs_app *inc); | |
343 | ||
344 | void (*unregister_app)(struct ip_vs_app *inc); | |
345 | ||
346 | int (*app_conn_bind)(struct ip_vs_conn *cp); | |
347 | ||
348 | void (*debug_packet)(struct ip_vs_protocol *pp, | |
349 | const struct sk_buff *skb, | |
350 | int offset, | |
351 | const char *msg); | |
352 | ||
353 | void (*timeout_change)(struct ip_vs_protocol *pp, int flags); | |
354 | ||
355 | int (*set_state_timeout)(struct ip_vs_protocol *pp, char *sname, int to); | |
356 | }; | |
357 | ||
358 | extern struct ip_vs_protocol * ip_vs_proto_get(unsigned short proto); | |
359 | ||
360 | /* | |
361 | * IP_VS structure allocated for each dynamically scheduled connection | |
362 | */ | |
363 | struct ip_vs_conn { | |
364 | struct list_head c_list; /* hashed list heads */ | |
365 | ||
366 | /* Protocol, addresses and port numbers */ | |
e7ade46a JV |
367 | u16 af; /* address family */ |
368 | union nf_inet_addr caddr; /* client address */ | |
369 | union nf_inet_addr vaddr; /* virtual address */ | |
370 | union nf_inet_addr daddr; /* destination address */ | |
3575792e | 371 | volatile __u32 flags; /* status flags */ |
014d730d AV |
372 | __be16 cport; |
373 | __be16 vport; | |
374 | __be16 dport; | |
1da177e4 LT |
375 | __u16 protocol; /* Which protocol (TCP/UDP) */ |
376 | ||
377 | /* counter and timer */ | |
378 | atomic_t refcnt; /* reference count */ | |
379 | struct timer_list timer; /* Expiration timer */ | |
380 | volatile unsigned long timeout; /* timeout */ | |
381 | ||
382 | /* Flags and state transition */ | |
383 | spinlock_t lock; /* lock for state transition */ | |
1da177e4 | 384 | volatile __u16 state; /* state info */ |
efac5276 RB |
385 | volatile __u16 old_state; /* old state, to be used for |
386 | * state transition triggerd | |
387 | * synchronization | |
388 | */ | |
1da177e4 LT |
389 | |
390 | /* Control members */ | |
391 | struct ip_vs_conn *control; /* Master control connection */ | |
392 | atomic_t n_control; /* Number of controlled ones */ | |
393 | struct ip_vs_dest *dest; /* real server */ | |
394 | atomic_t in_pkts; /* incoming packet counter */ | |
395 | ||
396 | /* packet transmitter for different forwarding methods. If it | |
397 | mangles the packet, it must return NF_DROP or better NF_STOLEN, | |
398 | otherwise this must be changed to a sk_buff **. | |
399 | */ | |
400 | int (*packet_xmit)(struct sk_buff *skb, struct ip_vs_conn *cp, | |
401 | struct ip_vs_protocol *pp); | |
402 | ||
403 | /* Note: we can group the following members into a structure, | |
404 | in order to save more space, and the following members are | |
405 | only used in VS/NAT anyway */ | |
406 | struct ip_vs_app *app; /* bound ip_vs_app object */ | |
407 | void *app_data; /* Application private data */ | |
408 | struct ip_vs_seq in_seq; /* incoming seq. struct */ | |
409 | struct ip_vs_seq out_seq; /* outgoing seq. struct */ | |
410 | }; | |
411 | ||
412 | ||
c860c6b1 JV |
413 | /* |
414 | * Extended internal versions of struct ip_vs_service_user and | |
415 | * ip_vs_dest_user for IPv6 support. | |
416 | * | |
417 | * We need these to conveniently pass around service and destination | |
418 | * options, but unfortunately, we also need to keep the old definitions to | |
419 | * maintain userspace backwards compatibility for the setsockopt interface. | |
420 | */ | |
421 | struct ip_vs_service_user_kern { | |
422 | /* virtual service addresses */ | |
423 | u16 af; | |
424 | u16 protocol; | |
425 | union nf_inet_addr addr; /* virtual ip address */ | |
426 | u16 port; | |
427 | u32 fwmark; /* firwall mark of service */ | |
428 | ||
429 | /* virtual service options */ | |
430 | char *sched_name; | |
431 | unsigned flags; /* virtual service flags */ | |
432 | unsigned timeout; /* persistent timeout in sec */ | |
433 | u32 netmask; /* persistent netmask */ | |
434 | }; | |
435 | ||
436 | ||
437 | struct ip_vs_dest_user_kern { | |
438 | /* destination server address */ | |
439 | union nf_inet_addr addr; | |
440 | u16 port; | |
441 | ||
442 | /* real server options */ | |
443 | unsigned conn_flags; /* connection flags */ | |
444 | int weight; /* destination weight */ | |
445 | ||
446 | /* thresholds for active connections */ | |
447 | u32 u_threshold; /* upper threshold */ | |
448 | u32 l_threshold; /* lower threshold */ | |
449 | }; | |
450 | ||
451 | ||
1da177e4 LT |
452 | /* |
453 | * The information about the virtual service offered to the net | |
454 | * and the forwarding entries | |
455 | */ | |
456 | struct ip_vs_service { | |
457 | struct list_head s_list; /* for normal service table */ | |
458 | struct list_head f_list; /* for fwmark-based service table */ | |
459 | atomic_t refcnt; /* reference counter */ | |
460 | atomic_t usecnt; /* use counter */ | |
461 | ||
e7ade46a | 462 | u16 af; /* address family */ |
1da177e4 | 463 | __u16 protocol; /* which protocol (TCP/UDP) */ |
e7ade46a | 464 | union nf_inet_addr addr; /* IP address for virtual service */ |
014d730d | 465 | __be16 port; /* port number for the service */ |
1da177e4 LT |
466 | __u32 fwmark; /* firewall mark of the service */ |
467 | unsigned flags; /* service status flags */ | |
468 | unsigned timeout; /* persistent timeout in ticks */ | |
014d730d | 469 | __be32 netmask; /* grouping granularity */ |
1da177e4 LT |
470 | |
471 | struct list_head destinations; /* real server d-linked list */ | |
472 | __u32 num_dests; /* number of servers */ | |
473 | struct ip_vs_stats stats; /* statistics for the service */ | |
474 | struct ip_vs_app *inc; /* bind conns to this app inc */ | |
475 | ||
476 | /* for scheduling */ | |
477 | struct ip_vs_scheduler *scheduler; /* bound scheduler object */ | |
478 | rwlock_t sched_lock; /* lock sched_data */ | |
479 | void *sched_data; /* scheduler application data */ | |
480 | }; | |
481 | ||
482 | ||
483 | /* | |
484 | * The real server destination forwarding entry | |
485 | * with ip address, port number, and so on. | |
486 | */ | |
487 | struct ip_vs_dest { | |
488 | struct list_head n_list; /* for the dests in the service */ | |
489 | struct list_head d_list; /* for table with all the dests */ | |
490 | ||
e7ade46a JV |
491 | u16 af; /* address family */ |
492 | union nf_inet_addr addr; /* IP address of the server */ | |
014d730d | 493 | __be16 port; /* port number of the server */ |
1da177e4 LT |
494 | volatile unsigned flags; /* dest status flags */ |
495 | atomic_t conn_flags; /* flags to copy to conn */ | |
496 | atomic_t weight; /* server weight */ | |
497 | ||
498 | atomic_t refcnt; /* reference counter */ | |
499 | struct ip_vs_stats stats; /* statistics */ | |
500 | ||
501 | /* connection counters and thresholds */ | |
502 | atomic_t activeconns; /* active connections */ | |
503 | atomic_t inactconns; /* inactive connections */ | |
504 | atomic_t persistconns; /* persistent connections */ | |
505 | __u32 u_threshold; /* upper threshold */ | |
506 | __u32 l_threshold; /* lower threshold */ | |
507 | ||
508 | /* for destination cache */ | |
509 | spinlock_t dst_lock; /* lock of dst_cache */ | |
510 | struct dst_entry *dst_cache; /* destination cache entry */ | |
511 | u32 dst_rtos; /* RT_TOS(tos) for dst */ | |
512 | ||
513 | /* for virtual service */ | |
514 | struct ip_vs_service *svc; /* service it belongs to */ | |
515 | __u16 protocol; /* which protocol (TCP/UDP) */ | |
e7ade46a | 516 | union nf_inet_addr vaddr; /* virtual IP address */ |
014d730d | 517 | __be16 vport; /* virtual port number */ |
1da177e4 LT |
518 | __u32 vfwmark; /* firewall mark of service */ |
519 | }; | |
520 | ||
521 | ||
522 | /* | |
523 | * The scheduler object | |
524 | */ | |
525 | struct ip_vs_scheduler { | |
526 | struct list_head n_list; /* d-linked list head */ | |
527 | char *name; /* scheduler name */ | |
528 | atomic_t refcnt; /* reference counter */ | |
529 | struct module *module; /* THIS_MODULE/NULL */ | |
530 | ||
531 | /* scheduler initializing service */ | |
532 | int (*init_service)(struct ip_vs_service *svc); | |
533 | /* scheduling service finish */ | |
534 | int (*done_service)(struct ip_vs_service *svc); | |
535 | /* scheduler updating service */ | |
536 | int (*update_service)(struct ip_vs_service *svc); | |
537 | ||
538 | /* selecting a server from the given service */ | |
539 | struct ip_vs_dest* (*schedule)(struct ip_vs_service *svc, | |
540 | const struct sk_buff *skb); | |
541 | }; | |
542 | ||
543 | ||
544 | /* | |
545 | * The application module object (a.k.a. app incarnation) | |
546 | */ | |
fd2c3ef7 | 547 | struct ip_vs_app { |
1da177e4 LT |
548 | struct list_head a_list; /* member in app list */ |
549 | int type; /* IP_VS_APP_TYPE_xxx */ | |
550 | char *name; /* application module name */ | |
551 | __u16 protocol; | |
552 | struct module *module; /* THIS_MODULE/NULL */ | |
553 | struct list_head incs_list; /* list of incarnations */ | |
554 | ||
555 | /* members for application incarnations */ | |
556 | struct list_head p_list; /* member in proto app list */ | |
557 | struct ip_vs_app *app; /* its real application */ | |
014d730d | 558 | __be16 port; /* port number in net order */ |
1da177e4 LT |
559 | atomic_t usecnt; /* usage counter */ |
560 | ||
561 | /* output hook: return false if can't linearize. diff set for TCP. */ | |
562 | int (*pkt_out)(struct ip_vs_app *, struct ip_vs_conn *, | |
3db05fea | 563 | struct sk_buff *, int *diff); |
1da177e4 LT |
564 | |
565 | /* input hook: return false if can't linearize. diff set for TCP. */ | |
566 | int (*pkt_in)(struct ip_vs_app *, struct ip_vs_conn *, | |
3db05fea | 567 | struct sk_buff *, int *diff); |
1da177e4 LT |
568 | |
569 | /* ip_vs_app initializer */ | |
570 | int (*init_conn)(struct ip_vs_app *, struct ip_vs_conn *); | |
571 | ||
572 | /* ip_vs_app finish */ | |
573 | int (*done_conn)(struct ip_vs_app *, struct ip_vs_conn *); | |
574 | ||
575 | ||
576 | /* not used now */ | |
577 | int (*bind_conn)(struct ip_vs_app *, struct ip_vs_conn *, | |
578 | struct ip_vs_protocol *); | |
579 | ||
580 | void (*unbind_conn)(struct ip_vs_app *, struct ip_vs_conn *); | |
581 | ||
582 | int * timeout_table; | |
583 | int * timeouts; | |
584 | int timeouts_size; | |
585 | ||
586 | int (*conn_schedule)(struct sk_buff *skb, struct ip_vs_app *app, | |
587 | int *verdict, struct ip_vs_conn **cpp); | |
588 | ||
589 | struct ip_vs_conn * | |
590 | (*conn_in_get)(const struct sk_buff *skb, struct ip_vs_app *app, | |
591 | const struct iphdr *iph, unsigned int proto_off, | |
592 | int inverse); | |
593 | ||
594 | struct ip_vs_conn * | |
595 | (*conn_out_get)(const struct sk_buff *skb, struct ip_vs_app *app, | |
596 | const struct iphdr *iph, unsigned int proto_off, | |
597 | int inverse); | |
598 | ||
599 | int (*state_transition)(struct ip_vs_conn *cp, int direction, | |
600 | const struct sk_buff *skb, | |
601 | struct ip_vs_app *app); | |
602 | ||
603 | void (*timeout_change)(struct ip_vs_app *app, int flags); | |
604 | }; | |
605 | ||
606 | ||
607 | /* | |
608 | * IPVS core functions | |
609 | * (from ip_vs_core.c) | |
610 | */ | |
611 | extern const char *ip_vs_proto_name(unsigned proto); | |
612 | extern void ip_vs_init_hash_table(struct list_head *table, int rows); | |
afdd6140 | 613 | #define IP_VS_INIT_HASH_TABLE(t) ip_vs_init_hash_table((t), ARRAY_SIZE((t))) |
1da177e4 | 614 | |
1da177e4 LT |
615 | #define IP_VS_APP_TYPE_FTP 1 |
616 | ||
617 | /* | |
618 | * ip_vs_conn handling functions | |
619 | * (from ip_vs_conn.c) | |
620 | */ | |
621 | ||
1da177e4 LT |
622 | enum { |
623 | IP_VS_DIR_INPUT = 0, | |
624 | IP_VS_DIR_OUTPUT, | |
625 | IP_VS_DIR_INPUT_ONLY, | |
626 | IP_VS_DIR_LAST, | |
627 | }; | |
628 | ||
629 | extern struct ip_vs_conn *ip_vs_conn_in_get | |
28364a59 JV |
630 | (int af, int protocol, const union nf_inet_addr *s_addr, __be16 s_port, |
631 | const union nf_inet_addr *d_addr, __be16 d_port); | |
632 | ||
87375ab4 | 633 | extern struct ip_vs_conn *ip_vs_ct_in_get |
28364a59 JV |
634 | (int af, int protocol, const union nf_inet_addr *s_addr, __be16 s_port, |
635 | const union nf_inet_addr *d_addr, __be16 d_port); | |
636 | ||
5c0d2374 SH |
637 | struct ip_vs_conn * ip_vs_conn_in_get_proto(int af, const struct sk_buff *skb, |
638 | struct ip_vs_protocol *pp, | |
639 | const struct ip_vs_iphdr *iph, | |
640 | unsigned int proto_off, | |
641 | int inverse); | |
642 | ||
1da177e4 | 643 | extern struct ip_vs_conn *ip_vs_conn_out_get |
28364a59 JV |
644 | (int af, int protocol, const union nf_inet_addr *s_addr, __be16 s_port, |
645 | const union nf_inet_addr *d_addr, __be16 d_port); | |
1da177e4 | 646 | |
5c0d2374 SH |
647 | struct ip_vs_conn * ip_vs_conn_out_get_proto(int af, const struct sk_buff *skb, |
648 | struct ip_vs_protocol *pp, | |
649 | const struct ip_vs_iphdr *iph, | |
650 | unsigned int proto_off, | |
651 | int inverse); | |
652 | ||
1da177e4 LT |
653 | /* put back the conn without restarting its timer */ |
654 | static inline void __ip_vs_conn_put(struct ip_vs_conn *cp) | |
655 | { | |
656 | atomic_dec(&cp->refcnt); | |
657 | } | |
658 | extern void ip_vs_conn_put(struct ip_vs_conn *cp); | |
014d730d | 659 | extern void ip_vs_conn_fill_cport(struct ip_vs_conn *cp, __be16 cport); |
1da177e4 LT |
660 | |
661 | extern struct ip_vs_conn * | |
28364a59 JV |
662 | ip_vs_conn_new(int af, int proto, const union nf_inet_addr *caddr, __be16 cport, |
663 | const union nf_inet_addr *vaddr, __be16 vport, | |
664 | const union nf_inet_addr *daddr, __be16 dport, unsigned flags, | |
1da177e4 LT |
665 | struct ip_vs_dest *dest); |
666 | extern void ip_vs_conn_expire_now(struct ip_vs_conn *cp); | |
667 | ||
668 | extern const char * ip_vs_state_name(__u16 proto, int state); | |
669 | ||
670 | extern void ip_vs_tcp_conn_listen(struct ip_vs_conn *cp); | |
671 | extern int ip_vs_check_template(struct ip_vs_conn *ct); | |
1da177e4 LT |
672 | extern void ip_vs_random_dropentry(void); |
673 | extern int ip_vs_conn_init(void); | |
674 | extern void ip_vs_conn_cleanup(void); | |
675 | ||
676 | static inline void ip_vs_control_del(struct ip_vs_conn *cp) | |
677 | { | |
678 | struct ip_vs_conn *ctl_cp = cp->control; | |
679 | if (!ctl_cp) { | |
cfc78c5a JV |
680 | IP_VS_ERR_BUF("request control DEL for uncontrolled: " |
681 | "%s:%d to %s:%d\n", | |
682 | IP_VS_DBG_ADDR(cp->af, &cp->caddr), | |
683 | ntohs(cp->cport), | |
684 | IP_VS_DBG_ADDR(cp->af, &cp->vaddr), | |
685 | ntohs(cp->vport)); | |
686 | ||
1da177e4 LT |
687 | return; |
688 | } | |
689 | ||
cfc78c5a JV |
690 | IP_VS_DBG_BUF(7, "DELeting control for: " |
691 | "cp.dst=%s:%d ctl_cp.dst=%s:%d\n", | |
692 | IP_VS_DBG_ADDR(cp->af, &cp->caddr), | |
693 | ntohs(cp->cport), | |
694 | IP_VS_DBG_ADDR(cp->af, &ctl_cp->caddr), | |
695 | ntohs(ctl_cp->cport)); | |
1da177e4 LT |
696 | |
697 | cp->control = NULL; | |
698 | if (atomic_read(&ctl_cp->n_control) == 0) { | |
cfc78c5a JV |
699 | IP_VS_ERR_BUF("BUG control DEL with n=0 : " |
700 | "%s:%d to %s:%d\n", | |
701 | IP_VS_DBG_ADDR(cp->af, &cp->caddr), | |
702 | ntohs(cp->cport), | |
703 | IP_VS_DBG_ADDR(cp->af, &cp->vaddr), | |
704 | ntohs(cp->vport)); | |
705 | ||
1da177e4 LT |
706 | return; |
707 | } | |
708 | atomic_dec(&ctl_cp->n_control); | |
709 | } | |
710 | ||
711 | static inline void | |
712 | ip_vs_control_add(struct ip_vs_conn *cp, struct ip_vs_conn *ctl_cp) | |
713 | { | |
714 | if (cp->control) { | |
cfc78c5a JV |
715 | IP_VS_ERR_BUF("request control ADD for already controlled: " |
716 | "%s:%d to %s:%d\n", | |
717 | IP_VS_DBG_ADDR(cp->af, &cp->caddr), | |
718 | ntohs(cp->cport), | |
719 | IP_VS_DBG_ADDR(cp->af, &cp->vaddr), | |
720 | ntohs(cp->vport)); | |
721 | ||
1da177e4 LT |
722 | ip_vs_control_del(cp); |
723 | } | |
724 | ||
cfc78c5a JV |
725 | IP_VS_DBG_BUF(7, "ADDing control for: " |
726 | "cp.dst=%s:%d ctl_cp.dst=%s:%d\n", | |
727 | IP_VS_DBG_ADDR(cp->af, &cp->caddr), | |
728 | ntohs(cp->cport), | |
729 | IP_VS_DBG_ADDR(cp->af, &ctl_cp->caddr), | |
730 | ntohs(ctl_cp->cport)); | |
1da177e4 LT |
731 | |
732 | cp->control = ctl_cp; | |
733 | atomic_inc(&ctl_cp->n_control); | |
734 | } | |
735 | ||
736 | ||
737 | /* | |
738 | * IPVS application functions | |
739 | * (from ip_vs_app.c) | |
740 | */ | |
741 | #define IP_VS_APP_MAX_PORTS 8 | |
742 | extern int register_ip_vs_app(struct ip_vs_app *app); | |
743 | extern void unregister_ip_vs_app(struct ip_vs_app *app); | |
744 | extern int ip_vs_bind_app(struct ip_vs_conn *cp, struct ip_vs_protocol *pp); | |
745 | extern void ip_vs_unbind_app(struct ip_vs_conn *cp); | |
746 | extern int | |
747 | register_ip_vs_app_inc(struct ip_vs_app *app, __u16 proto, __u16 port); | |
748 | extern int ip_vs_app_inc_get(struct ip_vs_app *inc); | |
749 | extern void ip_vs_app_inc_put(struct ip_vs_app *inc); | |
750 | ||
3db05fea HX |
751 | extern int ip_vs_app_pkt_out(struct ip_vs_conn *, struct sk_buff *skb); |
752 | extern int ip_vs_app_pkt_in(struct ip_vs_conn *, struct sk_buff *skb); | |
1da177e4 LT |
753 | extern int ip_vs_app_init(void); |
754 | extern void ip_vs_app_cleanup(void); | |
755 | ||
756 | ||
757 | /* | |
758 | * IPVS protocol functions (from ip_vs_proto.c) | |
759 | */ | |
760 | extern int ip_vs_protocol_init(void); | |
761 | extern void ip_vs_protocol_cleanup(void); | |
762 | extern void ip_vs_protocol_timeout_change(int flags); | |
763 | extern int *ip_vs_create_timeout_table(int *table, int size); | |
764 | extern int | |
36cbd3dc JE |
765 | ip_vs_set_state_timeout(int *table, int num, const char *const *names, |
766 | const char *name, int to); | |
1da177e4 LT |
767 | extern void |
768 | ip_vs_tcpudp_debug_packet(struct ip_vs_protocol *pp, const struct sk_buff *skb, | |
769 | int offset, const char *msg); | |
770 | ||
771 | extern struct ip_vs_protocol ip_vs_protocol_tcp; | |
772 | extern struct ip_vs_protocol ip_vs_protocol_udp; | |
773 | extern struct ip_vs_protocol ip_vs_protocol_icmp; | |
774 | extern struct ip_vs_protocol ip_vs_protocol_esp; | |
775 | extern struct ip_vs_protocol ip_vs_protocol_ah; | |
2906f66a | 776 | extern struct ip_vs_protocol ip_vs_protocol_sctp; |
1da177e4 LT |
777 | |
778 | /* | |
779 | * Registering/unregistering scheduler functions | |
780 | * (from ip_vs_sched.c) | |
781 | */ | |
782 | extern int register_ip_vs_scheduler(struct ip_vs_scheduler *scheduler); | |
783 | extern int unregister_ip_vs_scheduler(struct ip_vs_scheduler *scheduler); | |
784 | extern int ip_vs_bind_scheduler(struct ip_vs_service *svc, | |
785 | struct ip_vs_scheduler *scheduler); | |
786 | extern int ip_vs_unbind_scheduler(struct ip_vs_service *svc); | |
787 | extern struct ip_vs_scheduler *ip_vs_scheduler_get(const char *sched_name); | |
788 | extern void ip_vs_scheduler_put(struct ip_vs_scheduler *scheduler); | |
789 | extern struct ip_vs_conn * | |
790 | ip_vs_schedule(struct ip_vs_service *svc, const struct sk_buff *skb); | |
791 | extern int ip_vs_leave(struct ip_vs_service *svc, struct sk_buff *skb, | |
792 | struct ip_vs_protocol *pp); | |
793 | ||
794 | ||
795 | /* | |
796 | * IPVS control data and functions (from ip_vs_ctl.c) | |
797 | */ | |
798 | extern int sysctl_ip_vs_cache_bypass; | |
799 | extern int sysctl_ip_vs_expire_nodest_conn; | |
800 | extern int sysctl_ip_vs_expire_quiescent_template; | |
801 | extern int sysctl_ip_vs_sync_threshold[2]; | |
802 | extern int sysctl_ip_vs_nat_icmp_send; | |
f4bc17cd | 803 | extern int sysctl_ip_vs_conntrack; |
8a803040 | 804 | extern int sysctl_ip_vs_snat_reroute; |
1da177e4 | 805 | extern struct ip_vs_stats ip_vs_stats; |
5587da55 | 806 | extern const struct ctl_path net_vs_ctl_path[]; |
1da177e4 LT |
807 | |
808 | extern struct ip_vs_service * | |
3c2e0505 JV |
809 | ip_vs_service_get(int af, __u32 fwmark, __u16 protocol, |
810 | const union nf_inet_addr *vaddr, __be16 vport); | |
1da177e4 LT |
811 | |
812 | static inline void ip_vs_service_put(struct ip_vs_service *svc) | |
813 | { | |
814 | atomic_dec(&svc->usecnt); | |
815 | } | |
816 | ||
817 | extern struct ip_vs_dest * | |
7937df15 JV |
818 | ip_vs_lookup_real_service(int af, __u16 protocol, |
819 | const union nf_inet_addr *daddr, __be16 dport); | |
820 | ||
1da177e4 LT |
821 | extern int ip_vs_use_count_inc(void); |
822 | extern void ip_vs_use_count_dec(void); | |
823 | extern int ip_vs_control_init(void); | |
824 | extern void ip_vs_control_cleanup(void); | |
1e356f9c | 825 | extern struct ip_vs_dest * |
7937df15 JV |
826 | ip_vs_find_dest(int af, const union nf_inet_addr *daddr, __be16 dport, |
827 | const union nf_inet_addr *vaddr, __be16 vport, __u16 protocol); | |
1e356f9c | 828 | extern struct ip_vs_dest *ip_vs_try_bind_dest(struct ip_vs_conn *cp); |
1da177e4 LT |
829 | |
830 | ||
831 | /* | |
832 | * IPVS sync daemon data and function prototypes | |
833 | * (from ip_vs_sync.c) | |
834 | */ | |
835 | extern volatile int ip_vs_sync_state; | |
836 | extern volatile int ip_vs_master_syncid; | |
837 | extern volatile int ip_vs_backup_syncid; | |
838 | extern char ip_vs_master_mcast_ifn[IP_VS_IFNAME_MAXLEN]; | |
839 | extern char ip_vs_backup_mcast_ifn[IP_VS_IFNAME_MAXLEN]; | |
840 | extern int start_sync_thread(int state, char *mcast_ifn, __u8 syncid); | |
841 | extern int stop_sync_thread(int state); | |
842 | extern void ip_vs_sync_conn(struct ip_vs_conn *cp); | |
843 | ||
844 | ||
845 | /* | |
846 | * IPVS rate estimator prototypes (from ip_vs_est.c) | |
847 | */ | |
a919cf4b SW |
848 | extern int ip_vs_estimator_init(void); |
849 | extern void ip_vs_estimator_cleanup(void); | |
3a14a313 | 850 | extern void ip_vs_new_estimator(struct ip_vs_stats *stats); |
1da177e4 LT |
851 | extern void ip_vs_kill_estimator(struct ip_vs_stats *stats); |
852 | extern void ip_vs_zero_estimator(struct ip_vs_stats *stats); | |
853 | ||
854 | /* | |
855 | * Various IPVS packet transmitters (from ip_vs_xmit.c) | |
856 | */ | |
857 | extern int ip_vs_null_xmit | |
858 | (struct sk_buff *skb, struct ip_vs_conn *cp, struct ip_vs_protocol *pp); | |
859 | extern int ip_vs_bypass_xmit | |
860 | (struct sk_buff *skb, struct ip_vs_conn *cp, struct ip_vs_protocol *pp); | |
861 | extern int ip_vs_nat_xmit | |
862 | (struct sk_buff *skb, struct ip_vs_conn *cp, struct ip_vs_protocol *pp); | |
863 | extern int ip_vs_tunnel_xmit | |
864 | (struct sk_buff *skb, struct ip_vs_conn *cp, struct ip_vs_protocol *pp); | |
865 | extern int ip_vs_dr_xmit | |
866 | (struct sk_buff *skb, struct ip_vs_conn *cp, struct ip_vs_protocol *pp); | |
867 | extern int ip_vs_icmp_xmit | |
868 | (struct sk_buff *skb, struct ip_vs_conn *cp, struct ip_vs_protocol *pp, int offset); | |
869 | extern void ip_vs_dst_reset(struct ip_vs_dest *dest); | |
870 | ||
b3cdd2a7 JV |
871 | #ifdef CONFIG_IP_VS_IPV6 |
872 | extern int ip_vs_bypass_xmit_v6 | |
873 | (struct sk_buff *skb, struct ip_vs_conn *cp, struct ip_vs_protocol *pp); | |
874 | extern int ip_vs_nat_xmit_v6 | |
875 | (struct sk_buff *skb, struct ip_vs_conn *cp, struct ip_vs_protocol *pp); | |
876 | extern int ip_vs_tunnel_xmit_v6 | |
877 | (struct sk_buff *skb, struct ip_vs_conn *cp, struct ip_vs_protocol *pp); | |
878 | extern int ip_vs_dr_xmit_v6 | |
879 | (struct sk_buff *skb, struct ip_vs_conn *cp, struct ip_vs_protocol *pp); | |
880 | extern int ip_vs_icmp_xmit_v6 | |
881 | (struct sk_buff *skb, struct ip_vs_conn *cp, struct ip_vs_protocol *pp, | |
882 | int offset); | |
883 | #endif | |
1da177e4 LT |
884 | |
885 | /* | |
886 | * This is a simple mechanism to ignore packets when | |
887 | * we are loaded. Just set ip_vs_drop_rate to 'n' and | |
888 | * we start to drop 1/rate of the packets | |
889 | */ | |
890 | extern int ip_vs_drop_rate; | |
891 | extern int ip_vs_drop_counter; | |
892 | ||
893 | static __inline__ int ip_vs_todrop(void) | |
894 | { | |
895 | if (!ip_vs_drop_rate) return 0; | |
896 | if (--ip_vs_drop_counter > 0) return 0; | |
897 | ip_vs_drop_counter = ip_vs_drop_rate; | |
898 | return 1; | |
899 | } | |
900 | ||
901 | /* | |
902 | * ip_vs_fwd_tag returns the forwarding tag of the connection | |
903 | */ | |
904 | #define IP_VS_FWD_METHOD(cp) (cp->flags & IP_VS_CONN_F_FWD_MASK) | |
905 | ||
732db659 | 906 | static inline char ip_vs_fwd_tag(struct ip_vs_conn *cp) |
1da177e4 LT |
907 | { |
908 | char fwd; | |
909 | ||
910 | switch (IP_VS_FWD_METHOD(cp)) { | |
911 | case IP_VS_CONN_F_MASQ: | |
912 | fwd = 'M'; break; | |
913 | case IP_VS_CONN_F_LOCALNODE: | |
914 | fwd = 'L'; break; | |
915 | case IP_VS_CONN_F_TUNNEL: | |
916 | fwd = 'T'; break; | |
917 | case IP_VS_CONN_F_DROUTE: | |
918 | fwd = 'R'; break; | |
919 | case IP_VS_CONN_F_BYPASS: | |
920 | fwd = 'B'; break; | |
921 | default: | |
922 | fwd = '?'; break; | |
923 | } | |
924 | return fwd; | |
925 | } | |
926 | ||
1da177e4 | 927 | extern void ip_vs_nat_icmp(struct sk_buff *skb, struct ip_vs_protocol *pp, |
b3cdd2a7 JV |
928 | struct ip_vs_conn *cp, int dir); |
929 | ||
930 | #ifdef CONFIG_IP_VS_IPV6 | |
931 | extern void ip_vs_nat_icmp_v6(struct sk_buff *skb, struct ip_vs_protocol *pp, | |
932 | struct ip_vs_conn *cp, int dir); | |
933 | #endif | |
1da177e4 | 934 | |
b1550f22 | 935 | extern __sum16 ip_vs_checksum_complete(struct sk_buff *skb, int offset); |
1da177e4 | 936 | |
f9214b26 | 937 | static inline __wsum ip_vs_check_diff4(__be32 old, __be32 new, __wsum oldsum) |
1da177e4 | 938 | { |
f9214b26 | 939 | __be32 diff[2] = { ~old, new }; |
1da177e4 | 940 | |
07f0757a | 941 | return csum_partial(diff, sizeof(diff), oldsum); |
f9214b26 AV |
942 | } |
943 | ||
0bbdd42b JV |
944 | #ifdef CONFIG_IP_VS_IPV6 |
945 | static inline __wsum ip_vs_check_diff16(const __be32 *old, const __be32 *new, | |
946 | __wsum oldsum) | |
947 | { | |
948 | __be32 diff[8] = { ~old[3], ~old[2], ~old[1], ~old[0], | |
949 | new[3], new[2], new[1], new[0] }; | |
950 | ||
07f0757a | 951 | return csum_partial(diff, sizeof(diff), oldsum); |
0bbdd42b JV |
952 | } |
953 | #endif | |
954 | ||
f9214b26 AV |
955 | static inline __wsum ip_vs_check_diff2(__be16 old, __be16 new, __wsum oldsum) |
956 | { | |
957 | __be16 diff[2] = { ~old, new }; | |
958 | ||
07f0757a | 959 | return csum_partial(diff, sizeof(diff), oldsum); |
1da177e4 LT |
960 | } |
961 | ||
f4bc17cd JA |
962 | #ifdef CONFIG_IP_VS_NFCT |
963 | /* | |
964 | * Netfilter connection tracking | |
965 | * (from ip_vs_nfct.c) | |
966 | */ | |
967 | static inline int ip_vs_conntrack_enabled(void) | |
968 | { | |
969 | return sysctl_ip_vs_conntrack; | |
970 | } | |
971 | ||
6523ce15 JA |
972 | extern void ip_vs_update_conntrack(struct sk_buff *skb, struct ip_vs_conn *cp, |
973 | int outin); | |
f4bc17cd JA |
974 | extern int ip_vs_confirm_conntrack(struct sk_buff *skb, struct ip_vs_conn *cp); |
975 | extern void ip_vs_nfct_expect_related(struct sk_buff *skb, struct nf_conn *ct, | |
976 | struct ip_vs_conn *cp, u_int8_t proto, | |
977 | const __be16 port, int from_rs); | |
978 | extern void ip_vs_conn_drop_conntrack(struct ip_vs_conn *cp); | |
979 | ||
980 | #else | |
981 | ||
982 | static inline int ip_vs_conntrack_enabled(void) | |
983 | { | |
984 | return 0; | |
985 | } | |
986 | ||
987 | static inline void ip_vs_update_conntrack(struct sk_buff *skb, | |
988 | struct ip_vs_conn *cp, int outin) | |
989 | { | |
990 | } | |
991 | ||
992 | static inline int ip_vs_confirm_conntrack(struct sk_buff *skb, | |
993 | struct ip_vs_conn *cp) | |
994 | { | |
995 | return NF_ACCEPT; | |
996 | } | |
997 | ||
998 | static inline void ip_vs_conn_drop_conntrack(struct ip_vs_conn *cp) | |
999 | { | |
1000 | } | |
1001 | /* CONFIG_IP_VS_NFCT */ | |
1002 | #endif | |
6523ce15 | 1003 | |
1da177e4 LT |
1004 | #endif /* __KERNEL__ */ |
1005 | ||
bc4768eb | 1006 | #endif /* _NET_IP_VS_H */ |