diff options
Diffstat (limited to 'include/net/ip_vs.h')
-rw-r--r-- | include/net/ip_vs.h | 278 |
1 files changed, 210 insertions, 68 deletions
diff --git a/include/net/ip_vs.h b/include/net/ip_vs.h index d858264217ba..b23bea62f708 100644 --- a/include/net/ip_vs.h +++ b/include/net/ip_vs.h | |||
@@ -28,6 +28,80 @@ | |||
28 | #if defined(CONFIG_NF_CONNTRACK) || defined(CONFIG_NF_CONNTRACK_MODULE) | 28 | #if defined(CONFIG_NF_CONNTRACK) || defined(CONFIG_NF_CONNTRACK_MODULE) |
29 | #include <net/netfilter/nf_conntrack.h> | 29 | #include <net/netfilter/nf_conntrack.h> |
30 | #endif | 30 | #endif |
31 | #include <net/net_namespace.h> /* Netw namespace */ | ||
32 | |||
33 | /* | ||
34 | * Generic access of ipvs struct | ||
35 | */ | ||
36 | static inline struct netns_ipvs *net_ipvs(struct net* net) | ||
37 | { | ||
38 | return net->ipvs; | ||
39 | } | ||
40 | /* | ||
41 | * Get net ptr from skb in traffic cases | ||
42 | * use skb_sknet when call is from userland (ioctl or netlink) | ||
43 | */ | ||
44 | static inline struct net *skb_net(const 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 | |||
72 | static inline struct net *skb_sknet(const 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 | } | ||
93 | /* | ||
94 | * This one needed for single_open_net since net is stored directly in | ||
95 | * private not as a struct i.e. seq_file_net cant be used. | ||
96 | */ | ||
97 | static inline struct net *seq_file_single_net(struct seq_file *seq) | ||
98 | { | ||
99 | #ifdef CONFIG_NET_NS | ||
100 | return (struct net *)seq->private; | ||
101 | #else | ||
102 | return &init_net; | ||
103 | #endif | ||
104 | } | ||
31 | 105 | ||
32 | /* Connections' size value needed by ip_vs_ctl.c */ | 106 | /* Connections' size value needed by ip_vs_ctl.c */ |
33 | extern int ip_vs_conn_tab_size; | 107 | extern int ip_vs_conn_tab_size; |
@@ -258,6 +332,23 @@ struct ip_vs_seq { | |||
258 | before last resized pkt */ | 332 | before last resized pkt */ |
259 | }; | 333 | }; |
260 | 334 | ||
335 | /* | ||
336 | * counters per cpu | ||
337 | */ | ||
338 | struct ip_vs_counters { | ||
339 | __u32 conns; /* connections scheduled */ | ||
340 | __u32 inpkts; /* incoming packets */ | ||
341 | __u32 outpkts; /* outgoing packets */ | ||
342 | __u64 inbytes; /* incoming bytes */ | ||
343 | __u64 outbytes; /* outgoing bytes */ | ||
344 | }; | ||
345 | /* | ||
346 | * Stats per cpu | ||
347 | */ | ||
348 | struct ip_vs_cpu_stats { | ||
349 | struct ip_vs_counters ustats; | ||
350 | struct u64_stats_sync syncp; | ||
351 | }; | ||
261 | 352 | ||
262 | /* | 353 | /* |
263 | * IPVS statistics objects | 354 | * IPVS statistics objects |
@@ -279,17 +370,34 @@ struct ip_vs_estimator { | |||
279 | }; | 370 | }; |
280 | 371 | ||
281 | struct ip_vs_stats { | 372 | struct ip_vs_stats { |
282 | struct ip_vs_stats_user ustats; /* statistics */ | 373 | struct ip_vs_stats_user ustats; /* statistics */ |
283 | struct ip_vs_estimator est; /* estimator */ | 374 | struct ip_vs_estimator est; /* estimator */ |
284 | 375 | struct ip_vs_cpu_stats *cpustats; /* per cpu counters */ | |
285 | spinlock_t lock; /* spin lock */ | 376 | spinlock_t lock; /* spin lock */ |
286 | }; | 377 | }; |
287 | 378 | ||
379 | /* | ||
380 | * Helper Macros for per cpu | ||
381 | * ipvs->tot_stats->ustats.count | ||
382 | */ | ||
383 | #define IPVS_STAT_INC(ipvs, count) \ | ||
384 | __this_cpu_inc((ipvs)->ustats->count) | ||
385 | |||
386 | #define IPVS_STAT_ADD(ipvs, count, value) \ | ||
387 | do {\ | ||
388 | write_seqcount_begin(per_cpu_ptr((ipvs)->ustats_seq, \ | ||
389 | raw_smp_processor_id())); \ | ||
390 | __this_cpu_add((ipvs)->ustats->count, value); \ | ||
391 | write_seqcount_end(per_cpu_ptr((ipvs)->ustats_seq, \ | ||
392 | raw_smp_processor_id())); \ | ||
393 | } while (0) | ||
394 | |||
288 | struct dst_entry; | 395 | struct dst_entry; |
289 | struct iphdr; | 396 | struct iphdr; |
290 | struct ip_vs_conn; | 397 | struct ip_vs_conn; |
291 | struct ip_vs_app; | 398 | struct ip_vs_app; |
292 | struct sk_buff; | 399 | struct sk_buff; |
400 | struct ip_vs_proto_data; | ||
293 | 401 | ||
294 | struct ip_vs_protocol { | 402 | struct ip_vs_protocol { |
295 | struct ip_vs_protocol *next; | 403 | struct ip_vs_protocol *next; |
@@ -297,21 +405,22 @@ struct ip_vs_protocol { | |||
297 | u16 protocol; | 405 | u16 protocol; |
298 | u16 num_states; | 406 | u16 num_states; |
299 | int dont_defrag; | 407 | int dont_defrag; |
300 | atomic_t appcnt; /* counter of proto app incs */ | ||
301 | int *timeout_table; /* protocol timeout table */ | ||
302 | 408 | ||
303 | void (*init)(struct ip_vs_protocol *pp); | 409 | void (*init)(struct ip_vs_protocol *pp); |
304 | 410 | ||
305 | void (*exit)(struct ip_vs_protocol *pp); | 411 | void (*exit)(struct ip_vs_protocol *pp); |
306 | 412 | ||
413 | void (*init_netns)(struct net *net, struct ip_vs_proto_data *pd); | ||
414 | |||
415 | void (*exit_netns)(struct net *net, struct ip_vs_proto_data *pd); | ||
416 | |||
307 | int (*conn_schedule)(int af, struct sk_buff *skb, | 417 | int (*conn_schedule)(int af, struct sk_buff *skb, |
308 | struct ip_vs_protocol *pp, | 418 | struct ip_vs_proto_data *pd, |
309 | int *verdict, struct ip_vs_conn **cpp); | 419 | int *verdict, struct ip_vs_conn **cpp); |
310 | 420 | ||
311 | struct ip_vs_conn * | 421 | struct ip_vs_conn * |
312 | (*conn_in_get)(int af, | 422 | (*conn_in_get)(int af, |
313 | const struct sk_buff *skb, | 423 | const struct sk_buff *skb, |
314 | struct ip_vs_protocol *pp, | ||
315 | const struct ip_vs_iphdr *iph, | 424 | const struct ip_vs_iphdr *iph, |
316 | unsigned int proto_off, | 425 | unsigned int proto_off, |
317 | int inverse); | 426 | int inverse); |
@@ -319,7 +428,6 @@ struct ip_vs_protocol { | |||
319 | struct ip_vs_conn * | 428 | struct ip_vs_conn * |
320 | (*conn_out_get)(int af, | 429 | (*conn_out_get)(int af, |
321 | const struct sk_buff *skb, | 430 | const struct sk_buff *skb, |
322 | struct ip_vs_protocol *pp, | ||
323 | const struct ip_vs_iphdr *iph, | 431 | const struct ip_vs_iphdr *iph, |
324 | unsigned int proto_off, | 432 | unsigned int proto_off, |
325 | int inverse); | 433 | int inverse); |
@@ -337,11 +445,11 @@ struct ip_vs_protocol { | |||
337 | 445 | ||
338 | int (*state_transition)(struct ip_vs_conn *cp, int direction, | 446 | int (*state_transition)(struct ip_vs_conn *cp, int direction, |
339 | const struct sk_buff *skb, | 447 | const struct sk_buff *skb, |
340 | struct ip_vs_protocol *pp); | 448 | struct ip_vs_proto_data *pd); |
341 | 449 | ||
342 | int (*register_app)(struct ip_vs_app *inc); | 450 | int (*register_app)(struct net *net, struct ip_vs_app *inc); |
343 | 451 | ||
344 | void (*unregister_app)(struct ip_vs_app *inc); | 452 | void (*unregister_app)(struct net *net, struct ip_vs_app *inc); |
345 | 453 | ||
346 | int (*app_conn_bind)(struct ip_vs_conn *cp); | 454 | int (*app_conn_bind)(struct ip_vs_conn *cp); |
347 | 455 | ||
@@ -350,14 +458,26 @@ struct ip_vs_protocol { | |||
350 | int offset, | 458 | int offset, |
351 | const char *msg); | 459 | const char *msg); |
352 | 460 | ||
353 | void (*timeout_change)(struct ip_vs_protocol *pp, int flags); | 461 | void (*timeout_change)(struct ip_vs_proto_data *pd, int flags); |
462 | }; | ||
354 | 463 | ||
355 | int (*set_state_timeout)(struct ip_vs_protocol *pp, char *sname, int to); | 464 | /* |
465 | * protocol data per netns | ||
466 | */ | ||
467 | struct ip_vs_proto_data { | ||
468 | struct ip_vs_proto_data *next; | ||
469 | struct ip_vs_protocol *pp; | ||
470 | int *timeout_table; /* protocol timeout table */ | ||
471 | atomic_t appcnt; /* counter of proto app incs. */ | ||
472 | struct tcp_states_t *tcp_state_table; | ||
356 | }; | 473 | }; |
357 | 474 | ||
358 | extern struct ip_vs_protocol * ip_vs_proto_get(unsigned short proto); | 475 | extern struct ip_vs_protocol *ip_vs_proto_get(unsigned short proto); |
476 | extern struct ip_vs_proto_data *ip_vs_proto_data_get(struct net *net, | ||
477 | unsigned short proto); | ||
359 | 478 | ||
360 | struct ip_vs_conn_param { | 479 | struct ip_vs_conn_param { |
480 | struct net *net; | ||
361 | const union nf_inet_addr *caddr; | 481 | const union nf_inet_addr *caddr; |
362 | const union nf_inet_addr *vaddr; | 482 | const union nf_inet_addr *vaddr; |
363 | __be16 cport; | 483 | __be16 cport; |
@@ -375,17 +495,19 @@ struct ip_vs_conn_param { | |||
375 | */ | 495 | */ |
376 | struct ip_vs_conn { | 496 | struct ip_vs_conn { |
377 | struct list_head c_list; /* hashed list heads */ | 497 | struct list_head c_list; /* hashed list heads */ |
378 | 498 | #ifdef CONFIG_NET_NS | |
499 | struct net *net; /* Name space */ | ||
500 | #endif | ||
379 | /* Protocol, addresses and port numbers */ | 501 | /* Protocol, addresses and port numbers */ |
380 | u16 af; /* address family */ | 502 | u16 af; /* address family */ |
381 | union nf_inet_addr caddr; /* client address */ | 503 | __be16 cport; |
382 | union nf_inet_addr vaddr; /* virtual address */ | 504 | __be16 vport; |
383 | union nf_inet_addr daddr; /* destination address */ | 505 | __be16 dport; |
384 | volatile __u32 flags; /* status flags */ | 506 | __u32 fwmark; /* Fire wall mark from skb */ |
385 | __u32 fwmark; /* Fire wall mark from skb */ | 507 | union nf_inet_addr caddr; /* client address */ |
386 | __be16 cport; | 508 | union nf_inet_addr vaddr; /* virtual address */ |
387 | __be16 vport; | 509 | union nf_inet_addr daddr; /* destination address */ |
388 | __be16 dport; | 510 | volatile __u32 flags; /* status flags */ |
389 | __u16 protocol; /* Which protocol (TCP/UDP) */ | 511 | __u16 protocol; /* Which protocol (TCP/UDP) */ |
390 | 512 | ||
391 | /* counter and timer */ | 513 | /* counter and timer */ |
@@ -428,6 +550,33 @@ struct ip_vs_conn { | |||
428 | __u8 pe_data_len; | 550 | __u8 pe_data_len; |
429 | }; | 551 | }; |
430 | 552 | ||
553 | /* | ||
554 | * To save some memory in conn table when name space is disabled. | ||
555 | */ | ||
556 | static inline struct net *ip_vs_conn_net(const struct ip_vs_conn *cp) | ||
557 | { | ||
558 | #ifdef CONFIG_NET_NS | ||
559 | return cp->net; | ||
560 | #else | ||
561 | return &init_net; | ||
562 | #endif | ||
563 | } | ||
564 | static inline void ip_vs_conn_net_set(struct ip_vs_conn *cp, struct net *net) | ||
565 | { | ||
566 | #ifdef CONFIG_NET_NS | ||
567 | cp->net = net; | ||
568 | #endif | ||
569 | } | ||
570 | |||
571 | static inline int ip_vs_conn_net_eq(const struct ip_vs_conn *cp, | ||
572 | struct net *net) | ||
573 | { | ||
574 | #ifdef CONFIG_NET_NS | ||
575 | return cp->net == net; | ||
576 | #else | ||
577 | return 1; | ||
578 | #endif | ||
579 | } | ||
431 | 580 | ||
432 | /* | 581 | /* |
433 | * Extended internal versions of struct ip_vs_service_user and | 582 | * Extended internal versions of struct ip_vs_service_user and |
@@ -487,6 +636,7 @@ struct ip_vs_service { | |||
487 | unsigned flags; /* service status flags */ | 636 | unsigned flags; /* service status flags */ |
488 | unsigned timeout; /* persistent timeout in ticks */ | 637 | unsigned timeout; /* persistent timeout in ticks */ |
489 | __be32 netmask; /* grouping granularity */ | 638 | __be32 netmask; /* grouping granularity */ |
639 | struct net *net; | ||
490 | 640 | ||
491 | struct list_head destinations; /* real server d-linked list */ | 641 | struct list_head destinations; /* real server d-linked list */ |
492 | __u32 num_dests; /* number of servers */ | 642 | __u32 num_dests; /* number of servers */ |
@@ -512,8 +662,8 @@ struct ip_vs_dest { | |||
512 | struct list_head d_list; /* for table with all the dests */ | 662 | struct list_head d_list; /* for table with all the dests */ |
513 | 663 | ||
514 | u16 af; /* address family */ | 664 | u16 af; /* address family */ |
515 | union nf_inet_addr addr; /* IP address of the server */ | ||
516 | __be16 port; /* port number of the server */ | 665 | __be16 port; /* port number of the server */ |
666 | union nf_inet_addr addr; /* IP address of the server */ | ||
517 | volatile unsigned flags; /* dest status flags */ | 667 | volatile unsigned flags; /* dest status flags */ |
518 | atomic_t conn_flags; /* flags to copy to conn */ | 668 | atomic_t conn_flags; /* flags to copy to conn */ |
519 | atomic_t weight; /* server weight */ | 669 | atomic_t weight; /* server weight */ |
@@ -540,8 +690,8 @@ struct ip_vs_dest { | |||
540 | /* for virtual service */ | 690 | /* for virtual service */ |
541 | struct ip_vs_service *svc; /* service it belongs to */ | 691 | struct ip_vs_service *svc; /* service it belongs to */ |
542 | __u16 protocol; /* which protocol (TCP/UDP) */ | 692 | __u16 protocol; /* which protocol (TCP/UDP) */ |
543 | union nf_inet_addr vaddr; /* virtual IP address */ | ||
544 | __be16 vport; /* virtual port number */ | 693 | __be16 vport; /* virtual port number */ |
694 | union nf_inet_addr vaddr; /* virtual IP address */ | ||
545 | __u32 vfwmark; /* firewall mark of service */ | 695 | __u32 vfwmark; /* firewall mark of service */ |
546 | }; | 696 | }; |
547 | 697 | ||
@@ -676,13 +826,14 @@ enum { | |||
676 | IP_VS_DIR_LAST, | 826 | IP_VS_DIR_LAST, |
677 | }; | 827 | }; |
678 | 828 | ||
679 | static inline void ip_vs_conn_fill_param(int af, int protocol, | 829 | static inline void ip_vs_conn_fill_param(struct net *net, int af, int protocol, |
680 | const union nf_inet_addr *caddr, | 830 | const union nf_inet_addr *caddr, |
681 | __be16 cport, | 831 | __be16 cport, |
682 | const union nf_inet_addr *vaddr, | 832 | const union nf_inet_addr *vaddr, |
683 | __be16 vport, | 833 | __be16 vport, |
684 | struct ip_vs_conn_param *p) | 834 | struct ip_vs_conn_param *p) |
685 | { | 835 | { |
836 | p->net = net; | ||
686 | p->af = af; | 837 | p->af = af; |
687 | p->protocol = protocol; | 838 | p->protocol = protocol; |
688 | p->caddr = caddr; | 839 | p->caddr = caddr; |
@@ -697,7 +848,6 @@ struct ip_vs_conn *ip_vs_conn_in_get(const struct ip_vs_conn_param *p); | |||
697 | struct ip_vs_conn *ip_vs_ct_in_get(const struct ip_vs_conn_param *p); | 848 | struct ip_vs_conn *ip_vs_ct_in_get(const struct ip_vs_conn_param *p); |
698 | 849 | ||
699 | struct ip_vs_conn * ip_vs_conn_in_get_proto(int af, const struct sk_buff *skb, | 850 | struct ip_vs_conn * ip_vs_conn_in_get_proto(int af, const struct sk_buff *skb, |
700 | struct ip_vs_protocol *pp, | ||
701 | const struct ip_vs_iphdr *iph, | 851 | const struct ip_vs_iphdr *iph, |
702 | unsigned int proto_off, | 852 | unsigned int proto_off, |
703 | int inverse); | 853 | int inverse); |
@@ -705,7 +855,6 @@ struct ip_vs_conn * ip_vs_conn_in_get_proto(int af, const struct sk_buff *skb, | |||
705 | struct ip_vs_conn *ip_vs_conn_out_get(const struct ip_vs_conn_param *p); | 855 | struct ip_vs_conn *ip_vs_conn_out_get(const struct ip_vs_conn_param *p); |
706 | 856 | ||
707 | struct ip_vs_conn * ip_vs_conn_out_get_proto(int af, const struct sk_buff *skb, | 857 | struct ip_vs_conn * ip_vs_conn_out_get_proto(int af, const struct sk_buff *skb, |
708 | struct ip_vs_protocol *pp, | ||
709 | const struct ip_vs_iphdr *iph, | 858 | const struct ip_vs_iphdr *iph, |
710 | unsigned int proto_off, | 859 | unsigned int proto_off, |
711 | int inverse); | 860 | int inverse); |
@@ -726,9 +875,9 @@ extern void ip_vs_conn_expire_now(struct ip_vs_conn *cp); | |||
726 | 875 | ||
727 | extern const char * ip_vs_state_name(__u16 proto, int state); | 876 | extern const char * ip_vs_state_name(__u16 proto, int state); |
728 | 877 | ||
729 | extern void ip_vs_tcp_conn_listen(struct ip_vs_conn *cp); | 878 | extern void ip_vs_tcp_conn_listen(struct net *net, struct ip_vs_conn *cp); |
730 | extern int ip_vs_check_template(struct ip_vs_conn *ct); | 879 | extern int ip_vs_check_template(struct ip_vs_conn *ct); |
731 | extern void ip_vs_random_dropentry(void); | 880 | extern void ip_vs_random_dropentry(struct net *net); |
732 | extern int ip_vs_conn_init(void); | 881 | extern int ip_vs_conn_init(void); |
733 | extern void ip_vs_conn_cleanup(void); | 882 | extern void ip_vs_conn_cleanup(void); |
734 | 883 | ||
@@ -798,12 +947,12 @@ ip_vs_control_add(struct ip_vs_conn *cp, struct ip_vs_conn *ctl_cp) | |||
798 | * (from ip_vs_app.c) | 947 | * (from ip_vs_app.c) |
799 | */ | 948 | */ |
800 | #define IP_VS_APP_MAX_PORTS 8 | 949 | #define IP_VS_APP_MAX_PORTS 8 |
801 | extern int register_ip_vs_app(struct ip_vs_app *app); | 950 | extern int register_ip_vs_app(struct net *net, struct ip_vs_app *app); |
802 | extern void unregister_ip_vs_app(struct ip_vs_app *app); | 951 | extern void unregister_ip_vs_app(struct net *net, struct ip_vs_app *app); |
803 | extern int ip_vs_bind_app(struct ip_vs_conn *cp, struct ip_vs_protocol *pp); | 952 | extern int ip_vs_bind_app(struct ip_vs_conn *cp, struct ip_vs_protocol *pp); |
804 | extern void ip_vs_unbind_app(struct ip_vs_conn *cp); | 953 | extern void ip_vs_unbind_app(struct ip_vs_conn *cp); |
805 | extern int | 954 | extern int register_ip_vs_app_inc(struct net *net, struct ip_vs_app *app, |
806 | register_ip_vs_app_inc(struct ip_vs_app *app, __u16 proto, __u16 port); | 955 | __u16 proto, __u16 port); |
807 | extern int ip_vs_app_inc_get(struct ip_vs_app *inc); | 956 | extern int ip_vs_app_inc_get(struct ip_vs_app *inc); |
808 | extern void ip_vs_app_inc_put(struct ip_vs_app *inc); | 957 | extern void ip_vs_app_inc_put(struct ip_vs_app *inc); |
809 | 958 | ||
@@ -836,7 +985,7 @@ static inline void ip_vs_pe_put(const struct ip_vs_pe *pe) | |||
836 | */ | 985 | */ |
837 | extern int ip_vs_protocol_init(void); | 986 | extern int ip_vs_protocol_init(void); |
838 | extern void ip_vs_protocol_cleanup(void); | 987 | extern void ip_vs_protocol_cleanup(void); |
839 | extern void ip_vs_protocol_timeout_change(int flags); | 988 | extern void ip_vs_protocol_timeout_change(struct netns_ipvs *ipvs, int flags); |
840 | extern int *ip_vs_create_timeout_table(int *table, int size); | 989 | extern int *ip_vs_create_timeout_table(int *table, int size); |
841 | extern int | 990 | extern int |
842 | ip_vs_set_state_timeout(int *table, int num, const char *const *names, | 991 | ip_vs_set_state_timeout(int *table, int num, const char *const *names, |
@@ -866,28 +1015,21 @@ extern struct ip_vs_scheduler *ip_vs_scheduler_get(const char *sched_name); | |||
866 | extern void ip_vs_scheduler_put(struct ip_vs_scheduler *scheduler); | 1015 | extern void ip_vs_scheduler_put(struct ip_vs_scheduler *scheduler); |
867 | extern struct ip_vs_conn * | 1016 | extern struct ip_vs_conn * |
868 | ip_vs_schedule(struct ip_vs_service *svc, struct sk_buff *skb, | 1017 | ip_vs_schedule(struct ip_vs_service *svc, struct sk_buff *skb, |
869 | struct ip_vs_protocol *pp, int *ignored); | 1018 | struct ip_vs_proto_data *pd, int *ignored); |
870 | extern int ip_vs_leave(struct ip_vs_service *svc, struct sk_buff *skb, | 1019 | extern int ip_vs_leave(struct ip_vs_service *svc, struct sk_buff *skb, |
871 | struct ip_vs_protocol *pp); | 1020 | struct ip_vs_proto_data *pd); |
872 | 1021 | ||
873 | 1022 | ||
874 | /* | 1023 | /* |
875 | * IPVS control data and functions (from ip_vs_ctl.c) | 1024 | * IPVS control data and functions (from ip_vs_ctl.c) |
876 | */ | 1025 | */ |
877 | extern int sysctl_ip_vs_cache_bypass; | ||
878 | extern int sysctl_ip_vs_expire_nodest_conn; | ||
879 | extern int sysctl_ip_vs_expire_quiescent_template; | ||
880 | extern int sysctl_ip_vs_sync_threshold[2]; | ||
881 | extern int sysctl_ip_vs_nat_icmp_send; | ||
882 | extern int sysctl_ip_vs_conntrack; | ||
883 | extern int sysctl_ip_vs_snat_reroute; | ||
884 | extern struct ip_vs_stats ip_vs_stats; | 1026 | extern struct ip_vs_stats ip_vs_stats; |
885 | extern const struct ctl_path net_vs_ctl_path[]; | 1027 | extern const struct ctl_path net_vs_ctl_path[]; |
886 | extern int sysctl_ip_vs_sync_ver; | 1028 | extern int sysctl_ip_vs_sync_ver; |
887 | 1029 | ||
888 | extern void ip_vs_sync_switch_mode(int mode); | 1030 | extern void ip_vs_sync_switch_mode(struct net *net, int mode); |
889 | extern struct ip_vs_service * | 1031 | extern struct ip_vs_service * |
890 | ip_vs_service_get(int af, __u32 fwmark, __u16 protocol, | 1032 | ip_vs_service_get(struct net *net, int af, __u32 fwmark, __u16 protocol, |
891 | const union nf_inet_addr *vaddr, __be16 vport); | 1033 | const union nf_inet_addr *vaddr, __be16 vport); |
892 | 1034 | ||
893 | static inline void ip_vs_service_put(struct ip_vs_service *svc) | 1035 | static inline void ip_vs_service_put(struct ip_vs_service *svc) |
@@ -896,7 +1038,7 @@ static inline void ip_vs_service_put(struct ip_vs_service *svc) | |||
896 | } | 1038 | } |
897 | 1039 | ||
898 | extern struct ip_vs_dest * | 1040 | extern struct ip_vs_dest * |
899 | ip_vs_lookup_real_service(int af, __u16 protocol, | 1041 | ip_vs_lookup_real_service(struct net *net, int af, __u16 protocol, |
900 | const union nf_inet_addr *daddr, __be16 dport); | 1042 | const union nf_inet_addr *daddr, __be16 dport); |
901 | 1043 | ||
902 | extern int ip_vs_use_count_inc(void); | 1044 | extern int ip_vs_use_count_inc(void); |
@@ -904,9 +1046,9 @@ extern void ip_vs_use_count_dec(void); | |||
904 | extern int ip_vs_control_init(void); | 1046 | extern int ip_vs_control_init(void); |
905 | extern void ip_vs_control_cleanup(void); | 1047 | extern void ip_vs_control_cleanup(void); |
906 | extern struct ip_vs_dest * | 1048 | extern struct ip_vs_dest * |
907 | ip_vs_find_dest(int af, const union nf_inet_addr *daddr, __be16 dport, | 1049 | ip_vs_find_dest(struct net *net, int af, const union nf_inet_addr *daddr, |
908 | const union nf_inet_addr *vaddr, __be16 vport, __u16 protocol, | 1050 | __be16 dport, const union nf_inet_addr *vaddr, __be16 vport, |
909 | __u32 fwmark); | 1051 | __u16 protocol, __u32 fwmark); |
910 | extern struct ip_vs_dest *ip_vs_try_bind_dest(struct ip_vs_conn *cp); | 1052 | extern struct ip_vs_dest *ip_vs_try_bind_dest(struct ip_vs_conn *cp); |
911 | 1053 | ||
912 | 1054 | ||
@@ -914,14 +1056,12 @@ extern struct ip_vs_dest *ip_vs_try_bind_dest(struct ip_vs_conn *cp); | |||
914 | * IPVS sync daemon data and function prototypes | 1056 | * IPVS sync daemon data and function prototypes |
915 | * (from ip_vs_sync.c) | 1057 | * (from ip_vs_sync.c) |
916 | */ | 1058 | */ |
917 | extern volatile int ip_vs_sync_state; | 1059 | extern int start_sync_thread(struct net *net, int state, char *mcast_ifn, |
918 | extern volatile int ip_vs_master_syncid; | 1060 | __u8 syncid); |
919 | extern volatile int ip_vs_backup_syncid; | 1061 | extern int stop_sync_thread(struct net *net, int state); |
920 | extern char ip_vs_master_mcast_ifn[IP_VS_IFNAME_MAXLEN]; | 1062 | extern void ip_vs_sync_conn(struct net *net, struct ip_vs_conn *cp); |
921 | extern char ip_vs_backup_mcast_ifn[IP_VS_IFNAME_MAXLEN]; | 1063 | extern int ip_vs_sync_init(void); |
922 | extern int start_sync_thread(int state, char *mcast_ifn, __u8 syncid); | 1064 | extern void ip_vs_sync_cleanup(void); |
923 | extern int stop_sync_thread(int state); | ||
924 | extern void ip_vs_sync_conn(struct ip_vs_conn *cp); | ||
925 | 1065 | ||
926 | 1066 | ||
927 | /* | 1067 | /* |
@@ -929,8 +1069,8 @@ extern void ip_vs_sync_conn(struct ip_vs_conn *cp); | |||
929 | */ | 1069 | */ |
930 | extern int ip_vs_estimator_init(void); | 1070 | extern int ip_vs_estimator_init(void); |
931 | extern void ip_vs_estimator_cleanup(void); | 1071 | extern void ip_vs_estimator_cleanup(void); |
932 | extern void ip_vs_new_estimator(struct ip_vs_stats *stats); | 1072 | extern void ip_vs_new_estimator(struct net *net, struct ip_vs_stats *stats); |
933 | extern void ip_vs_kill_estimator(struct ip_vs_stats *stats); | 1073 | extern void ip_vs_kill_estimator(struct net *net, struct ip_vs_stats *stats); |
934 | extern void ip_vs_zero_estimator(struct ip_vs_stats *stats); | 1074 | extern void ip_vs_zero_estimator(struct ip_vs_stats *stats); |
935 | 1075 | ||
936 | /* | 1076 | /* |
@@ -972,11 +1112,13 @@ extern int ip_vs_icmp_xmit_v6 | |||
972 | extern int ip_vs_drop_rate; | 1112 | extern int ip_vs_drop_rate; |
973 | extern int ip_vs_drop_counter; | 1113 | extern int ip_vs_drop_counter; |
974 | 1114 | ||
975 | static __inline__ int ip_vs_todrop(void) | 1115 | static inline int ip_vs_todrop(struct netns_ipvs *ipvs) |
976 | { | 1116 | { |
977 | if (!ip_vs_drop_rate) return 0; | 1117 | if (!ipvs->drop_rate) |
978 | if (--ip_vs_drop_counter > 0) return 0; | 1118 | return 0; |
979 | ip_vs_drop_counter = ip_vs_drop_rate; | 1119 | if (--ipvs->drop_counter > 0) |
1120 | return 0; | ||
1121 | ipvs->drop_counter = ipvs->drop_rate; | ||
980 | return 1; | 1122 | return 1; |
981 | } | 1123 | } |
982 | 1124 | ||
@@ -1064,9 +1206,9 @@ static inline void ip_vs_notrack(struct sk_buff *skb) | |||
1064 | * Netfilter connection tracking | 1206 | * Netfilter connection tracking |
1065 | * (from ip_vs_nfct.c) | 1207 | * (from ip_vs_nfct.c) |
1066 | */ | 1208 | */ |
1067 | static inline int ip_vs_conntrack_enabled(void) | 1209 | static inline int ip_vs_conntrack_enabled(struct netns_ipvs *ipvs) |
1068 | { | 1210 | { |
1069 | return sysctl_ip_vs_conntrack; | 1211 | return ipvs->sysctl_conntrack; |
1070 | } | 1212 | } |
1071 | 1213 | ||
1072 | extern void ip_vs_update_conntrack(struct sk_buff *skb, struct ip_vs_conn *cp, | 1214 | extern void ip_vs_update_conntrack(struct sk_buff *skb, struct ip_vs_conn *cp, |
@@ -1079,7 +1221,7 @@ extern void ip_vs_conn_drop_conntrack(struct ip_vs_conn *cp); | |||
1079 | 1221 | ||
1080 | #else | 1222 | #else |
1081 | 1223 | ||
1082 | static inline int ip_vs_conntrack_enabled(void) | 1224 | static inline int ip_vs_conntrack_enabled(struct netns_ipvs *ipvs) |
1083 | { | 1225 | { |
1084 | return 0; | 1226 | return 0; |
1085 | } | 1227 | } |