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