diff options
Diffstat (limited to 'include/net/ip_vs.h')
-rw-r--r-- | include/net/ip_vs.h | 311 |
1 files changed, 241 insertions, 70 deletions
diff --git a/include/net/ip_vs.h b/include/net/ip_vs.h index 7312c3dd309f..0b2071d9326d 100644 --- a/include/net/ip_vs.h +++ b/include/net/ip_vs.h | |||
@@ -21,11 +21,104 @@ | |||
21 | #include <linux/timer.h> | 21 | #include <linux/timer.h> |
22 | 22 | ||
23 | #include <net/checksum.h> | 23 | #include <net/checksum.h> |
24 | #include <linux/netfilter.h> /* for union nf_inet_addr */ | ||
25 | #include <linux/ip.h> | ||
26 | #include <linux/ipv6.h> /* for struct ipv6hdr */ | ||
27 | #include <net/ipv6.h> /* for ipv6_addr_copy */ | ||
28 | |||
29 | struct ip_vs_iphdr { | ||
30 | int len; | ||
31 | __u8 protocol; | ||
32 | union nf_inet_addr saddr; | ||
33 | union nf_inet_addr daddr; | ||
34 | }; | ||
35 | |||
36 | static inline void | ||
37 | ip_vs_fill_iphdr(int af, const void *nh, struct ip_vs_iphdr *iphdr) | ||
38 | { | ||
39 | #ifdef CONFIG_IP_VS_IPV6 | ||
40 | if (af == AF_INET6) { | ||
41 | const struct ipv6hdr *iph = nh; | ||
42 | iphdr->len = sizeof(struct ipv6hdr); | ||
43 | iphdr->protocol = iph->nexthdr; | ||
44 | ipv6_addr_copy(&iphdr->saddr.in6, &iph->saddr); | ||
45 | ipv6_addr_copy(&iphdr->daddr.in6, &iph->daddr); | ||
46 | } else | ||
47 | #endif | ||
48 | { | ||
49 | const struct iphdr *iph = nh; | ||
50 | iphdr->len = iph->ihl * 4; | ||
51 | iphdr->protocol = iph->protocol; | ||
52 | iphdr->saddr.ip = iph->saddr; | ||
53 | iphdr->daddr.ip = iph->daddr; | ||
54 | } | ||
55 | } | ||
56 | |||
57 | static inline void ip_vs_addr_copy(int af, union nf_inet_addr *dst, | ||
58 | const union nf_inet_addr *src) | ||
59 | { | ||
60 | #ifdef CONFIG_IP_VS_IPV6 | ||
61 | if (af == AF_INET6) | ||
62 | ipv6_addr_copy(&dst->in6, &src->in6); | ||
63 | else | ||
64 | #endif | ||
65 | dst->ip = src->ip; | ||
66 | } | ||
67 | |||
68 | static inline int ip_vs_addr_equal(int af, const union nf_inet_addr *a, | ||
69 | const union nf_inet_addr *b) | ||
70 | { | ||
71 | #ifdef CONFIG_IP_VS_IPV6 | ||
72 | if (af == AF_INET6) | ||
73 | return ipv6_addr_equal(&a->in6, &b->in6); | ||
74 | #endif | ||
75 | return a->ip == b->ip; | ||
76 | } | ||
24 | 77 | ||
25 | #ifdef CONFIG_IP_VS_DEBUG | 78 | #ifdef CONFIG_IP_VS_DEBUG |
26 | #include <linux/net.h> | 79 | #include <linux/net.h> |
27 | 80 | ||
28 | extern int ip_vs_get_debug_level(void); | 81 | extern int ip_vs_get_debug_level(void); |
82 | |||
83 | static inline const char *ip_vs_dbg_addr(int af, char *buf, size_t buf_len, | ||
84 | const union nf_inet_addr *addr, | ||
85 | int *idx) | ||
86 | { | ||
87 | int len; | ||
88 | #ifdef CONFIG_IP_VS_IPV6 | ||
89 | if (af == AF_INET6) | ||
90 | len = snprintf(&buf[*idx], buf_len - *idx, "[" NIP6_FMT "]", | ||
91 | NIP6(addr->in6)) + 1; | ||
92 | else | ||
93 | #endif | ||
94 | len = snprintf(&buf[*idx], buf_len - *idx, NIPQUAD_FMT, | ||
95 | NIPQUAD(addr->ip)) + 1; | ||
96 | |||
97 | *idx += len; | ||
98 | BUG_ON(*idx > buf_len + 1); | ||
99 | return &buf[*idx - len]; | ||
100 | } | ||
101 | |||
102 | #define IP_VS_DBG_BUF(level, msg...) \ | ||
103 | do { \ | ||
104 | char ip_vs_dbg_buf[160]; \ | ||
105 | int ip_vs_dbg_idx = 0; \ | ||
106 | if (level <= ip_vs_get_debug_level()) \ | ||
107 | printk(KERN_DEBUG "IPVS: " msg); \ | ||
108 | } while (0) | ||
109 | #define IP_VS_ERR_BUF(msg...) \ | ||
110 | do { \ | ||
111 | char ip_vs_dbg_buf[160]; \ | ||
112 | int ip_vs_dbg_idx = 0; \ | ||
113 | printk(KERN_ERR "IPVS: " msg); \ | ||
114 | } while (0) | ||
115 | |||
116 | /* Only use from within IP_VS_DBG_BUF() or IP_VS_ERR_BUF macros */ | ||
117 | #define IP_VS_DBG_ADDR(af, addr) \ | ||
118 | ip_vs_dbg_addr(af, ip_vs_dbg_buf, \ | ||
119 | sizeof(ip_vs_dbg_buf), addr, \ | ||
120 | &ip_vs_dbg_idx) | ||
121 | |||
29 | #define IP_VS_DBG(level, msg...) \ | 122 | #define IP_VS_DBG(level, msg...) \ |
30 | do { \ | 123 | do { \ |
31 | if (level <= ip_vs_get_debug_level()) \ | 124 | if (level <= ip_vs_get_debug_level()) \ |
@@ -48,6 +141,8 @@ extern int ip_vs_get_debug_level(void); | |||
48 | pp->debug_packet(pp, skb, ofs, msg); \ | 141 | pp->debug_packet(pp, skb, ofs, msg); \ |
49 | } while (0) | 142 | } while (0) |
50 | #else /* NO DEBUGGING at ALL */ | 143 | #else /* NO DEBUGGING at ALL */ |
144 | #define IP_VS_DBG_BUF(level, msg...) do {} while (0) | ||
145 | #define IP_VS_ERR_BUF(msg...) do {} while (0) | ||
51 | #define IP_VS_DBG(level, msg...) do {} while (0) | 146 | #define IP_VS_DBG(level, msg...) do {} while (0) |
52 | #define IP_VS_DBG_RL(msg...) do {} while (0) | 147 | #define IP_VS_DBG_RL(msg...) do {} while (0) |
53 | #define IP_VS_DBG_PKT(level, pp, skb, ofs, msg) do {} while (0) | 148 | #define IP_VS_DBG_PKT(level, pp, skb, ofs, msg) do {} while (0) |
@@ -160,27 +255,10 @@ struct ip_vs_estimator { | |||
160 | 255 | ||
161 | struct ip_vs_stats | 256 | struct ip_vs_stats |
162 | { | 257 | { |
163 | __u32 conns; /* connections scheduled */ | 258 | struct ip_vs_stats_user ustats; /* statistics */ |
164 | __u32 inpkts; /* incoming packets */ | 259 | struct ip_vs_estimator est; /* estimator */ |
165 | __u32 outpkts; /* outgoing packets */ | ||
166 | __u64 inbytes; /* incoming bytes */ | ||
167 | __u64 outbytes; /* outgoing bytes */ | ||
168 | |||
169 | __u32 cps; /* current connection rate */ | ||
170 | __u32 inpps; /* current in packet rate */ | ||
171 | __u32 outpps; /* current out packet rate */ | ||
172 | __u32 inbps; /* current in byte rate */ | ||
173 | __u32 outbps; /* current out byte rate */ | ||
174 | |||
175 | /* | ||
176 | * Don't add anything before the lock, because we use memcpy() to copy | ||
177 | * the members before the lock to struct ip_vs_stats_user in | ||
178 | * ip_vs_ctl.c. | ||
179 | */ | ||
180 | 260 | ||
181 | spinlock_t lock; /* spin lock */ | 261 | spinlock_t lock; /* spin lock */ |
182 | |||
183 | struct ip_vs_estimator est; /* estimator */ | ||
184 | }; | 262 | }; |
185 | 263 | ||
186 | struct dst_entry; | 264 | struct dst_entry; |
@@ -202,21 +280,23 @@ struct ip_vs_protocol { | |||
202 | 280 | ||
203 | void (*exit)(struct ip_vs_protocol *pp); | 281 | void (*exit)(struct ip_vs_protocol *pp); |
204 | 282 | ||
205 | int (*conn_schedule)(struct sk_buff *skb, | 283 | int (*conn_schedule)(int af, struct sk_buff *skb, |
206 | struct ip_vs_protocol *pp, | 284 | struct ip_vs_protocol *pp, |
207 | int *verdict, struct ip_vs_conn **cpp); | 285 | int *verdict, struct ip_vs_conn **cpp); |
208 | 286 | ||
209 | struct ip_vs_conn * | 287 | struct ip_vs_conn * |
210 | (*conn_in_get)(const struct sk_buff *skb, | 288 | (*conn_in_get)(int af, |
289 | const struct sk_buff *skb, | ||
211 | struct ip_vs_protocol *pp, | 290 | struct ip_vs_protocol *pp, |
212 | const struct iphdr *iph, | 291 | const struct ip_vs_iphdr *iph, |
213 | unsigned int proto_off, | 292 | unsigned int proto_off, |
214 | int inverse); | 293 | int inverse); |
215 | 294 | ||
216 | struct ip_vs_conn * | 295 | struct ip_vs_conn * |
217 | (*conn_out_get)(const struct sk_buff *skb, | 296 | (*conn_out_get)(int af, |
297 | const struct sk_buff *skb, | ||
218 | struct ip_vs_protocol *pp, | 298 | struct ip_vs_protocol *pp, |
219 | const struct iphdr *iph, | 299 | const struct ip_vs_iphdr *iph, |
220 | unsigned int proto_off, | 300 | unsigned int proto_off, |
221 | int inverse); | 301 | int inverse); |
222 | 302 | ||
@@ -226,7 +306,8 @@ struct ip_vs_protocol { | |||
226 | int (*dnat_handler)(struct sk_buff *skb, | 306 | int (*dnat_handler)(struct sk_buff *skb, |
227 | struct ip_vs_protocol *pp, struct ip_vs_conn *cp); | 307 | struct ip_vs_protocol *pp, struct ip_vs_conn *cp); |
228 | 308 | ||
229 | int (*csum_check)(struct sk_buff *skb, struct ip_vs_protocol *pp); | 309 | int (*csum_check)(int af, struct sk_buff *skb, |
310 | struct ip_vs_protocol *pp); | ||
230 | 311 | ||
231 | const char *(*state_name)(int state); | 312 | const char *(*state_name)(int state); |
232 | 313 | ||
@@ -259,9 +340,10 @@ struct ip_vs_conn { | |||
259 | struct list_head c_list; /* hashed list heads */ | 340 | struct list_head c_list; /* hashed list heads */ |
260 | 341 | ||
261 | /* Protocol, addresses and port numbers */ | 342 | /* Protocol, addresses and port numbers */ |
262 | __be32 caddr; /* client address */ | 343 | u16 af; /* address family */ |
263 | __be32 vaddr; /* virtual address */ | 344 | union nf_inet_addr caddr; /* client address */ |
264 | __be32 daddr; /* destination address */ | 345 | union nf_inet_addr vaddr; /* virtual address */ |
346 | union nf_inet_addr daddr; /* destination address */ | ||
265 | __be16 cport; | 347 | __be16 cport; |
266 | __be16 vport; | 348 | __be16 vport; |
267 | __be16 dport; | 349 | __be16 dport; |
@@ -305,6 +387,45 @@ struct ip_vs_conn { | |||
305 | 387 | ||
306 | 388 | ||
307 | /* | 389 | /* |
390 | * Extended internal versions of struct ip_vs_service_user and | ||
391 | * ip_vs_dest_user for IPv6 support. | ||
392 | * | ||
393 | * We need these to conveniently pass around service and destination | ||
394 | * options, but unfortunately, we also need to keep the old definitions to | ||
395 | * maintain userspace backwards compatibility for the setsockopt interface. | ||
396 | */ | ||
397 | struct ip_vs_service_user_kern { | ||
398 | /* virtual service addresses */ | ||
399 | u16 af; | ||
400 | u16 protocol; | ||
401 | union nf_inet_addr addr; /* virtual ip address */ | ||
402 | u16 port; | ||
403 | u32 fwmark; /* firwall mark of service */ | ||
404 | |||
405 | /* virtual service options */ | ||
406 | char *sched_name; | ||
407 | unsigned flags; /* virtual service flags */ | ||
408 | unsigned timeout; /* persistent timeout in sec */ | ||
409 | u32 netmask; /* persistent netmask */ | ||
410 | }; | ||
411 | |||
412 | |||
413 | struct ip_vs_dest_user_kern { | ||
414 | /* destination server address */ | ||
415 | union nf_inet_addr addr; | ||
416 | u16 port; | ||
417 | |||
418 | /* real server options */ | ||
419 | unsigned conn_flags; /* connection flags */ | ||
420 | int weight; /* destination weight */ | ||
421 | |||
422 | /* thresholds for active connections */ | ||
423 | u32 u_threshold; /* upper threshold */ | ||
424 | u32 l_threshold; /* lower threshold */ | ||
425 | }; | ||
426 | |||
427 | |||
428 | /* | ||
308 | * The information about the virtual service offered to the net | 429 | * The information about the virtual service offered to the net |
309 | * and the forwarding entries | 430 | * and the forwarding entries |
310 | */ | 431 | */ |
@@ -314,8 +435,9 @@ struct ip_vs_service { | |||
314 | atomic_t refcnt; /* reference counter */ | 435 | atomic_t refcnt; /* reference counter */ |
315 | atomic_t usecnt; /* use counter */ | 436 | atomic_t usecnt; /* use counter */ |
316 | 437 | ||
438 | u16 af; /* address family */ | ||
317 | __u16 protocol; /* which protocol (TCP/UDP) */ | 439 | __u16 protocol; /* which protocol (TCP/UDP) */ |
318 | __be32 addr; /* IP address for virtual service */ | 440 | union nf_inet_addr addr; /* IP address for virtual service */ |
319 | __be16 port; /* port number for the service */ | 441 | __be16 port; /* port number for the service */ |
320 | __u32 fwmark; /* firewall mark of the service */ | 442 | __u32 fwmark; /* firewall mark of the service */ |
321 | unsigned flags; /* service status flags */ | 443 | unsigned flags; /* service status flags */ |
@@ -342,7 +464,8 @@ struct ip_vs_dest { | |||
342 | struct list_head n_list; /* for the dests in the service */ | 464 | struct list_head n_list; /* for the dests in the service */ |
343 | struct list_head d_list; /* for table with all the dests */ | 465 | struct list_head d_list; /* for table with all the dests */ |
344 | 466 | ||
345 | __be32 addr; /* IP address of the server */ | 467 | u16 af; /* address family */ |
468 | union nf_inet_addr addr; /* IP address of the server */ | ||
346 | __be16 port; /* port number of the server */ | 469 | __be16 port; /* port number of the server */ |
347 | volatile unsigned flags; /* dest status flags */ | 470 | volatile unsigned flags; /* dest status flags */ |
348 | atomic_t conn_flags; /* flags to copy to conn */ | 471 | atomic_t conn_flags; /* flags to copy to conn */ |
@@ -366,7 +489,7 @@ struct ip_vs_dest { | |||
366 | /* for virtual service */ | 489 | /* for virtual service */ |
367 | struct ip_vs_service *svc; /* service it belongs to */ | 490 | struct ip_vs_service *svc; /* service it belongs to */ |
368 | __u16 protocol; /* which protocol (TCP/UDP) */ | 491 | __u16 protocol; /* which protocol (TCP/UDP) */ |
369 | __be32 vaddr; /* virtual IP address */ | 492 | union nf_inet_addr vaddr; /* virtual IP address */ |
370 | __be16 vport; /* virtual port number */ | 493 | __be16 vport; /* virtual port number */ |
371 | __u32 vfwmark; /* firewall mark of service */ | 494 | __u32 vfwmark; /* firewall mark of service */ |
372 | }; | 495 | }; |
@@ -380,6 +503,9 @@ struct ip_vs_scheduler { | |||
380 | char *name; /* scheduler name */ | 503 | char *name; /* scheduler name */ |
381 | atomic_t refcnt; /* reference counter */ | 504 | atomic_t refcnt; /* reference counter */ |
382 | struct module *module; /* THIS_MODULE/NULL */ | 505 | struct module *module; /* THIS_MODULE/NULL */ |
506 | #ifdef CONFIG_IP_VS_IPV6 | ||
507 | int supports_ipv6; /* scheduler has IPv6 support */ | ||
508 | #endif | ||
383 | 509 | ||
384 | /* scheduler initializing service */ | 510 | /* scheduler initializing service */ |
385 | int (*init_service)(struct ip_vs_service *svc); | 511 | int (*init_service)(struct ip_vs_service *svc); |
@@ -479,16 +605,8 @@ extern void ip_vs_init_hash_table(struct list_head *table, int rows); | |||
479 | #ifndef CONFIG_IP_VS_TAB_BITS | 605 | #ifndef CONFIG_IP_VS_TAB_BITS |
480 | #define CONFIG_IP_VS_TAB_BITS 12 | 606 | #define CONFIG_IP_VS_TAB_BITS 12 |
481 | #endif | 607 | #endif |
482 | /* make sure that IP_VS_CONN_TAB_BITS is located in [8, 20] */ | 608 | |
483 | #if CONFIG_IP_VS_TAB_BITS < 8 | ||
484 | #define IP_VS_CONN_TAB_BITS 8 | ||
485 | #endif | ||
486 | #if CONFIG_IP_VS_TAB_BITS > 20 | ||
487 | #define IP_VS_CONN_TAB_BITS 20 | ||
488 | #endif | ||
489 | #if 8 <= CONFIG_IP_VS_TAB_BITS && CONFIG_IP_VS_TAB_BITS <= 20 | ||
490 | #define IP_VS_CONN_TAB_BITS CONFIG_IP_VS_TAB_BITS | 609 | #define IP_VS_CONN_TAB_BITS CONFIG_IP_VS_TAB_BITS |
491 | #endif | ||
492 | #define IP_VS_CONN_TAB_SIZE (1 << IP_VS_CONN_TAB_BITS) | 610 | #define IP_VS_CONN_TAB_SIZE (1 << IP_VS_CONN_TAB_BITS) |
493 | #define IP_VS_CONN_TAB_MASK (IP_VS_CONN_TAB_SIZE - 1) | 611 | #define IP_VS_CONN_TAB_MASK (IP_VS_CONN_TAB_SIZE - 1) |
494 | 612 | ||
@@ -500,11 +618,16 @@ enum { | |||
500 | }; | 618 | }; |
501 | 619 | ||
502 | extern struct ip_vs_conn *ip_vs_conn_in_get | 620 | extern struct ip_vs_conn *ip_vs_conn_in_get |
503 | (int protocol, __be32 s_addr, __be16 s_port, __be32 d_addr, __be16 d_port); | 621 | (int af, int protocol, const union nf_inet_addr *s_addr, __be16 s_port, |
622 | const union nf_inet_addr *d_addr, __be16 d_port); | ||
623 | |||
504 | extern struct ip_vs_conn *ip_vs_ct_in_get | 624 | extern struct ip_vs_conn *ip_vs_ct_in_get |
505 | (int protocol, __be32 s_addr, __be16 s_port, __be32 d_addr, __be16 d_port); | 625 | (int af, int protocol, const union nf_inet_addr *s_addr, __be16 s_port, |
626 | const union nf_inet_addr *d_addr, __be16 d_port); | ||
627 | |||
506 | extern struct ip_vs_conn *ip_vs_conn_out_get | 628 | extern struct ip_vs_conn *ip_vs_conn_out_get |
507 | (int protocol, __be32 s_addr, __be16 s_port, __be32 d_addr, __be16 d_port); | 629 | (int af, int protocol, const union nf_inet_addr *s_addr, __be16 s_port, |
630 | const union nf_inet_addr *d_addr, __be16 d_port); | ||
508 | 631 | ||
509 | /* put back the conn without restarting its timer */ | 632 | /* put back the conn without restarting its timer */ |
510 | static inline void __ip_vs_conn_put(struct ip_vs_conn *cp) | 633 | static inline void __ip_vs_conn_put(struct ip_vs_conn *cp) |
@@ -515,8 +638,9 @@ extern void ip_vs_conn_put(struct ip_vs_conn *cp); | |||
515 | extern void ip_vs_conn_fill_cport(struct ip_vs_conn *cp, __be16 cport); | 638 | extern void ip_vs_conn_fill_cport(struct ip_vs_conn *cp, __be16 cport); |
516 | 639 | ||
517 | extern struct ip_vs_conn * | 640 | extern struct ip_vs_conn * |
518 | ip_vs_conn_new(int proto, __be32 caddr, __be16 cport, __be32 vaddr, __be16 vport, | 641 | ip_vs_conn_new(int af, int proto, const union nf_inet_addr *caddr, __be16 cport, |
519 | __be32 daddr, __be16 dport, unsigned flags, | 642 | const union nf_inet_addr *vaddr, __be16 vport, |
643 | const union nf_inet_addr *daddr, __be16 dport, unsigned flags, | ||
520 | struct ip_vs_dest *dest); | 644 | struct ip_vs_dest *dest); |
521 | extern void ip_vs_conn_expire_now(struct ip_vs_conn *cp); | 645 | extern void ip_vs_conn_expire_now(struct ip_vs_conn *cp); |
522 | 646 | ||
@@ -532,24 +656,32 @@ static inline void ip_vs_control_del(struct ip_vs_conn *cp) | |||
532 | { | 656 | { |
533 | struct ip_vs_conn *ctl_cp = cp->control; | 657 | struct ip_vs_conn *ctl_cp = cp->control; |
534 | if (!ctl_cp) { | 658 | if (!ctl_cp) { |
535 | IP_VS_ERR("request control DEL for uncontrolled: " | 659 | IP_VS_ERR_BUF("request control DEL for uncontrolled: " |
536 | "%d.%d.%d.%d:%d to %d.%d.%d.%d:%d\n", | 660 | "%s:%d to %s:%d\n", |
537 | NIPQUAD(cp->caddr),ntohs(cp->cport), | 661 | IP_VS_DBG_ADDR(cp->af, &cp->caddr), |
538 | NIPQUAD(cp->vaddr),ntohs(cp->vport)); | 662 | ntohs(cp->cport), |
663 | IP_VS_DBG_ADDR(cp->af, &cp->vaddr), | ||
664 | ntohs(cp->vport)); | ||
665 | |||
539 | return; | 666 | return; |
540 | } | 667 | } |
541 | 668 | ||
542 | IP_VS_DBG(7, "DELeting control for: " | 669 | IP_VS_DBG_BUF(7, "DELeting control for: " |
543 | "cp.dst=%d.%d.%d.%d:%d ctl_cp.dst=%d.%d.%d.%d:%d\n", | 670 | "cp.dst=%s:%d ctl_cp.dst=%s:%d\n", |
544 | NIPQUAD(cp->caddr),ntohs(cp->cport), | 671 | IP_VS_DBG_ADDR(cp->af, &cp->caddr), |
545 | NIPQUAD(ctl_cp->caddr),ntohs(ctl_cp->cport)); | 672 | ntohs(cp->cport), |
673 | IP_VS_DBG_ADDR(cp->af, &ctl_cp->caddr), | ||
674 | ntohs(ctl_cp->cport)); | ||
546 | 675 | ||
547 | cp->control = NULL; | 676 | cp->control = NULL; |
548 | if (atomic_read(&ctl_cp->n_control) == 0) { | 677 | if (atomic_read(&ctl_cp->n_control) == 0) { |
549 | IP_VS_ERR("BUG control DEL with n=0 : " | 678 | IP_VS_ERR_BUF("BUG control DEL with n=0 : " |
550 | "%d.%d.%d.%d:%d to %d.%d.%d.%d:%d\n", | 679 | "%s:%d to %s:%d\n", |
551 | NIPQUAD(cp->caddr),ntohs(cp->cport), | 680 | IP_VS_DBG_ADDR(cp->af, &cp->caddr), |
552 | NIPQUAD(cp->vaddr),ntohs(cp->vport)); | 681 | ntohs(cp->cport), |
682 | IP_VS_DBG_ADDR(cp->af, &cp->vaddr), | ||
683 | ntohs(cp->vport)); | ||
684 | |||
553 | return; | 685 | return; |
554 | } | 686 | } |
555 | atomic_dec(&ctl_cp->n_control); | 687 | atomic_dec(&ctl_cp->n_control); |
@@ -559,17 +691,22 @@ static inline void | |||
559 | ip_vs_control_add(struct ip_vs_conn *cp, struct ip_vs_conn *ctl_cp) | 691 | ip_vs_control_add(struct ip_vs_conn *cp, struct ip_vs_conn *ctl_cp) |
560 | { | 692 | { |
561 | if (cp->control) { | 693 | if (cp->control) { |
562 | IP_VS_ERR("request control ADD for already controlled: " | 694 | IP_VS_ERR_BUF("request control ADD for already controlled: " |
563 | "%d.%d.%d.%d:%d to %d.%d.%d.%d:%d\n", | 695 | "%s:%d to %s:%d\n", |
564 | NIPQUAD(cp->caddr),ntohs(cp->cport), | 696 | IP_VS_DBG_ADDR(cp->af, &cp->caddr), |
565 | NIPQUAD(cp->vaddr),ntohs(cp->vport)); | 697 | ntohs(cp->cport), |
698 | IP_VS_DBG_ADDR(cp->af, &cp->vaddr), | ||
699 | ntohs(cp->vport)); | ||
700 | |||
566 | ip_vs_control_del(cp); | 701 | ip_vs_control_del(cp); |
567 | } | 702 | } |
568 | 703 | ||
569 | IP_VS_DBG(7, "ADDing control for: " | 704 | IP_VS_DBG_BUF(7, "ADDing control for: " |
570 | "cp.dst=%d.%d.%d.%d:%d ctl_cp.dst=%d.%d.%d.%d:%d\n", | 705 | "cp.dst=%s:%d ctl_cp.dst=%s:%d\n", |
571 | NIPQUAD(cp->caddr),ntohs(cp->cport), | 706 | IP_VS_DBG_ADDR(cp->af, &cp->caddr), |
572 | NIPQUAD(ctl_cp->caddr),ntohs(ctl_cp->cport)); | 707 | ntohs(cp->cport), |
708 | IP_VS_DBG_ADDR(cp->af, &ctl_cp->caddr), | ||
709 | ntohs(ctl_cp->cport)); | ||
573 | 710 | ||
574 | cp->control = ctl_cp; | 711 | cp->control = ctl_cp; |
575 | atomic_inc(&ctl_cp->n_control); | 712 | atomic_inc(&ctl_cp->n_control); |
@@ -647,7 +784,8 @@ extern struct ip_vs_stats ip_vs_stats; | |||
647 | extern const struct ctl_path net_vs_ctl_path[]; | 784 | extern const struct ctl_path net_vs_ctl_path[]; |
648 | 785 | ||
649 | extern struct ip_vs_service * | 786 | extern struct ip_vs_service * |
650 | ip_vs_service_get(__u32 fwmark, __u16 protocol, __be32 vaddr, __be16 vport); | 787 | ip_vs_service_get(int af, __u32 fwmark, __u16 protocol, |
788 | const union nf_inet_addr *vaddr, __be16 vport); | ||
651 | 789 | ||
652 | static inline void ip_vs_service_put(struct ip_vs_service *svc) | 790 | static inline void ip_vs_service_put(struct ip_vs_service *svc) |
653 | { | 791 | { |
@@ -655,14 +793,16 @@ static inline void ip_vs_service_put(struct ip_vs_service *svc) | |||
655 | } | 793 | } |
656 | 794 | ||
657 | extern struct ip_vs_dest * | 795 | extern struct ip_vs_dest * |
658 | ip_vs_lookup_real_service(__u16 protocol, __be32 daddr, __be16 dport); | 796 | ip_vs_lookup_real_service(int af, __u16 protocol, |
797 | const union nf_inet_addr *daddr, __be16 dport); | ||
798 | |||
659 | extern int ip_vs_use_count_inc(void); | 799 | extern int ip_vs_use_count_inc(void); |
660 | extern void ip_vs_use_count_dec(void); | 800 | extern void ip_vs_use_count_dec(void); |
661 | extern int ip_vs_control_init(void); | 801 | extern int ip_vs_control_init(void); |
662 | extern void ip_vs_control_cleanup(void); | 802 | extern void ip_vs_control_cleanup(void); |
663 | extern struct ip_vs_dest * | 803 | extern struct ip_vs_dest * |
664 | ip_vs_find_dest(__be32 daddr, __be16 dport, | 804 | ip_vs_find_dest(int af, const union nf_inet_addr *daddr, __be16 dport, |
665 | __be32 vaddr, __be16 vport, __u16 protocol); | 805 | const union nf_inet_addr *vaddr, __be16 vport, __u16 protocol); |
666 | extern struct ip_vs_dest *ip_vs_try_bind_dest(struct ip_vs_conn *cp); | 806 | extern struct ip_vs_dest *ip_vs_try_bind_dest(struct ip_vs_conn *cp); |
667 | 807 | ||
668 | 808 | ||
@@ -683,6 +823,8 @@ extern void ip_vs_sync_conn(struct ip_vs_conn *cp); | |||
683 | /* | 823 | /* |
684 | * IPVS rate estimator prototypes (from ip_vs_est.c) | 824 | * IPVS rate estimator prototypes (from ip_vs_est.c) |
685 | */ | 825 | */ |
826 | extern int ip_vs_estimator_init(void); | ||
827 | extern void ip_vs_estimator_cleanup(void); | ||
686 | extern void ip_vs_new_estimator(struct ip_vs_stats *stats); | 828 | extern void ip_vs_new_estimator(struct ip_vs_stats *stats); |
687 | extern void ip_vs_kill_estimator(struct ip_vs_stats *stats); | 829 | extern void ip_vs_kill_estimator(struct ip_vs_stats *stats); |
688 | extern void ip_vs_zero_estimator(struct ip_vs_stats *stats); | 830 | extern void ip_vs_zero_estimator(struct ip_vs_stats *stats); |
@@ -704,6 +846,19 @@ extern int ip_vs_icmp_xmit | |||
704 | (struct sk_buff *skb, struct ip_vs_conn *cp, struct ip_vs_protocol *pp, int offset); | 846 | (struct sk_buff *skb, struct ip_vs_conn *cp, struct ip_vs_protocol *pp, int offset); |
705 | extern void ip_vs_dst_reset(struct ip_vs_dest *dest); | 847 | extern void ip_vs_dst_reset(struct ip_vs_dest *dest); |
706 | 848 | ||
849 | #ifdef CONFIG_IP_VS_IPV6 | ||
850 | extern int ip_vs_bypass_xmit_v6 | ||
851 | (struct sk_buff *skb, struct ip_vs_conn *cp, struct ip_vs_protocol *pp); | ||
852 | extern int ip_vs_nat_xmit_v6 | ||
853 | (struct sk_buff *skb, struct ip_vs_conn *cp, struct ip_vs_protocol *pp); | ||
854 | extern int ip_vs_tunnel_xmit_v6 | ||
855 | (struct sk_buff *skb, struct ip_vs_conn *cp, struct ip_vs_protocol *pp); | ||
856 | extern int ip_vs_dr_xmit_v6 | ||
857 | (struct sk_buff *skb, struct ip_vs_conn *cp, struct ip_vs_protocol *pp); | ||
858 | extern int ip_vs_icmp_xmit_v6 | ||
859 | (struct sk_buff *skb, struct ip_vs_conn *cp, struct ip_vs_protocol *pp, | ||
860 | int offset); | ||
861 | #endif | ||
707 | 862 | ||
708 | /* | 863 | /* |
709 | * This is a simple mechanism to ignore packets when | 864 | * This is a simple mechanism to ignore packets when |
@@ -748,7 +903,12 @@ static inline char ip_vs_fwd_tag(struct ip_vs_conn *cp) | |||
748 | } | 903 | } |
749 | 904 | ||
750 | extern void ip_vs_nat_icmp(struct sk_buff *skb, struct ip_vs_protocol *pp, | 905 | extern void ip_vs_nat_icmp(struct sk_buff *skb, struct ip_vs_protocol *pp, |
751 | struct ip_vs_conn *cp, int dir); | 906 | struct ip_vs_conn *cp, int dir); |
907 | |||
908 | #ifdef CONFIG_IP_VS_IPV6 | ||
909 | extern void ip_vs_nat_icmp_v6(struct sk_buff *skb, struct ip_vs_protocol *pp, | ||
910 | struct ip_vs_conn *cp, int dir); | ||
911 | #endif | ||
752 | 912 | ||
753 | extern __sum16 ip_vs_checksum_complete(struct sk_buff *skb, int offset); | 913 | extern __sum16 ip_vs_checksum_complete(struct sk_buff *skb, int offset); |
754 | 914 | ||
@@ -759,6 +919,17 @@ static inline __wsum ip_vs_check_diff4(__be32 old, __be32 new, __wsum oldsum) | |||
759 | return csum_partial((char *) diff, sizeof(diff), oldsum); | 919 | return csum_partial((char *) diff, sizeof(diff), oldsum); |
760 | } | 920 | } |
761 | 921 | ||
922 | #ifdef CONFIG_IP_VS_IPV6 | ||
923 | static inline __wsum ip_vs_check_diff16(const __be32 *old, const __be32 *new, | ||
924 | __wsum oldsum) | ||
925 | { | ||
926 | __be32 diff[8] = { ~old[3], ~old[2], ~old[1], ~old[0], | ||
927 | new[3], new[2], new[1], new[0] }; | ||
928 | |||
929 | return csum_partial((char *) diff, sizeof(diff), oldsum); | ||
930 | } | ||
931 | #endif | ||
932 | |||
762 | static inline __wsum ip_vs_check_diff2(__be16 old, __be16 new, __wsum oldsum) | 933 | static inline __wsum ip_vs_check_diff2(__be16 old, __be16 new, __wsum oldsum) |
763 | { | 934 | { |
764 | __be16 diff[2] = { ~old, new }; | 935 | __be16 diff[2] = { ~old, new }; |