2 * ip_vs_proto_tcp.c: TCP load balancing support for IPVS
4 * Authors: Wensong Zhang <wensong@linuxvirtualserver.org>
5 * Julian Anastasov <ja@ssi.bg>
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version
10 * 2 of the License, or (at your option) any later version.
12 * Changes: Hans Schillstrom <hans.schillstrom@ericsson.com>
14 * Network name space (netns) aware.
15 * Global data moved to netns i.e struct netns_ipvs
16 * tcp_timeouts table has copy per netns in a hash table per
17 * protocol ip_vs_proto_data and is handled by netns
20 #define KMSG_COMPONENT "IPVS"
21 #define pr_fmt(fmt) KMSG_COMPONENT ": " fmt
23 #include <linux/kernel.h>
25 #include <linux/tcp.h> /* for tcphdr */
27 #include <net/tcp.h> /* for csum_tcpudp_magic */
28 #include <net/ip6_checksum.h>
29 #include <linux/netfilter.h>
30 #include <linux/netfilter_ipv4.h>
32 #include <net/ip_vs.h>
35 tcp_conn_schedule(struct netns_ipvs *ipvs, int af, struct sk_buff *skb,
36 struct ip_vs_proto_data *pd,
37 int *verdict, struct ip_vs_conn **cpp,
38 struct ip_vs_iphdr *iph)
40 struct ip_vs_service *svc;
41 struct tcphdr _tcph, *th;
42 __be16 _ports[2], *ports = NULL;
44 /* In the event of icmp, we're only guaranteed to have the first 8
45 * bytes of the transport header, so we only check the rest of the
46 * TCP packet for non-ICMP packets
48 if (likely(!ip_vs_iph_icmp(iph))) {
49 th = skb_header_pointer(skb, iph->len, sizeof(_tcph), &_tcph);
51 if (th->rst || !(sysctl_sloppy_tcp(ipvs) || th->syn))
56 ports = skb_header_pointer(
57 skb, iph->len, sizeof(_ports), &_ports);
65 /* No !th->ack check to allow scheduling on SYN+ACK for Active FTP */
67 if (likely(!ip_vs_iph_inverse(iph)))
68 svc = ip_vs_service_find(ipvs, af, skb->mark, iph->protocol,
69 &iph->daddr, ports[1]);
71 svc = ip_vs_service_find(ipvs, af, skb->mark, iph->protocol,
72 &iph->saddr, ports[0]);
77 if (ip_vs_todrop(ipvs)) {
79 * It seems that we are very loaded.
80 * We have to drop this packet :(
87 * Let the virtual server select a real server for the
88 * incoming connection, and create a connection entry.
90 *cpp = ip_vs_schedule(svc, skb, pd, &ignored, iph);
91 if (!*cpp && ignored <= 0) {
93 *verdict = ip_vs_leave(svc, skb, pd, iph);
105 tcp_fast_csum_update(int af, struct tcphdr *tcph,
106 const union nf_inet_addr *oldip,
107 const union nf_inet_addr *newip,
108 __be16 oldport, __be16 newport)
110 #ifdef CONFIG_IP_VS_IPV6
113 csum_fold(ip_vs_check_diff16(oldip->ip6, newip->ip6,
114 ip_vs_check_diff2(oldport, newport,
115 ~csum_unfold(tcph->check))));
119 csum_fold(ip_vs_check_diff4(oldip->ip, newip->ip,
120 ip_vs_check_diff2(oldport, newport,
121 ~csum_unfold(tcph->check))));
126 tcp_partial_csum_update(int af, struct tcphdr *tcph,
127 const union nf_inet_addr *oldip,
128 const union nf_inet_addr *newip,
129 __be16 oldlen, __be16 newlen)
131 #ifdef CONFIG_IP_VS_IPV6
134 ~csum_fold(ip_vs_check_diff16(oldip->ip6, newip->ip6,
135 ip_vs_check_diff2(oldlen, newlen,
136 csum_unfold(tcph->check))));
140 ~csum_fold(ip_vs_check_diff4(oldip->ip, newip->ip,
141 ip_vs_check_diff2(oldlen, newlen,
142 csum_unfold(tcph->check))));
147 tcp_snat_handler(struct sk_buff *skb, struct ip_vs_protocol *pp,
148 struct ip_vs_conn *cp, struct ip_vs_iphdr *iph)
151 unsigned int tcphoff = iph->len;
153 int payload_csum = 0;
155 #ifdef CONFIG_IP_VS_IPV6
156 if (cp->af == AF_INET6 && iph->fragoffs)
159 oldlen = skb->len - tcphoff;
161 /* csum_check requires unshared skb */
162 if (!skb_make_writable(skb, tcphoff+sizeof(*tcph)))
165 if (unlikely(cp->app != NULL)) {
168 /* Some checks before mangling */
169 if (pp->csum_check && !pp->csum_check(cp->af, skb, pp))
172 /* Call application helper if needed */
173 if (!(ret = ip_vs_app_pkt_out(cp, skb)))
175 /* ret=2: csum update is needed after payload mangling */
177 oldlen = skb->len - tcphoff;
182 tcph = (void *)skb_network_header(skb) + tcphoff;
183 tcph->source = cp->vport;
185 /* Adjust TCP checksums */
186 if (skb->ip_summed == CHECKSUM_PARTIAL) {
187 tcp_partial_csum_update(cp->af, tcph, &cp->daddr, &cp->vaddr,
189 htons(skb->len - tcphoff));
190 } else if (!payload_csum) {
191 /* Only port and addr are changed, do fast csum update */
192 tcp_fast_csum_update(cp->af, tcph, &cp->daddr, &cp->vaddr,
193 cp->dport, cp->vport);
194 if (skb->ip_summed == CHECKSUM_COMPLETE)
195 skb->ip_summed = (cp->app && pp->csum_check) ?
196 CHECKSUM_UNNECESSARY : CHECKSUM_NONE;
198 /* full checksum calculation */
200 skb->csum = skb_checksum(skb, tcphoff, skb->len - tcphoff, 0);
201 #ifdef CONFIG_IP_VS_IPV6
202 if (cp->af == AF_INET6)
203 tcph->check = csum_ipv6_magic(&cp->vaddr.in6,
206 cp->protocol, skb->csum);
209 tcph->check = csum_tcpudp_magic(cp->vaddr.ip,
214 skb->ip_summed = CHECKSUM_UNNECESSARY;
216 IP_VS_DBG(11, "O-pkt: %s O-csum=%d (+%zd)\n",
217 pp->name, tcph->check,
218 (char*)&(tcph->check) - (char*)tcph);
225 tcp_dnat_handler(struct sk_buff *skb, struct ip_vs_protocol *pp,
226 struct ip_vs_conn *cp, struct ip_vs_iphdr *iph)
229 unsigned int tcphoff = iph->len;
231 int payload_csum = 0;
233 #ifdef CONFIG_IP_VS_IPV6
234 if (cp->af == AF_INET6 && iph->fragoffs)
237 oldlen = skb->len - tcphoff;
239 /* csum_check requires unshared skb */
240 if (!skb_make_writable(skb, tcphoff+sizeof(*tcph)))
243 if (unlikely(cp->app != NULL)) {
246 /* Some checks before mangling */
247 if (pp->csum_check && !pp->csum_check(cp->af, skb, pp))
251 * Attempt ip_vs_app call.
252 * It will fix ip_vs_conn and iph ack_seq stuff
254 if (!(ret = ip_vs_app_pkt_in(cp, skb)))
256 /* ret=2: csum update is needed after payload mangling */
258 oldlen = skb->len - tcphoff;
263 tcph = (void *)skb_network_header(skb) + tcphoff;
264 tcph->dest = cp->dport;
267 * Adjust TCP checksums
269 if (skb->ip_summed == CHECKSUM_PARTIAL) {
270 tcp_partial_csum_update(cp->af, tcph, &cp->vaddr, &cp->daddr,
272 htons(skb->len - tcphoff));
273 } else if (!payload_csum) {
274 /* Only port and addr are changed, do fast csum update */
275 tcp_fast_csum_update(cp->af, tcph, &cp->vaddr, &cp->daddr,
276 cp->vport, cp->dport);
277 if (skb->ip_summed == CHECKSUM_COMPLETE)
278 skb->ip_summed = (cp->app && pp->csum_check) ?
279 CHECKSUM_UNNECESSARY : CHECKSUM_NONE;
281 /* full checksum calculation */
283 skb->csum = skb_checksum(skb, tcphoff, skb->len - tcphoff, 0);
284 #ifdef CONFIG_IP_VS_IPV6
285 if (cp->af == AF_INET6)
286 tcph->check = csum_ipv6_magic(&cp->caddr.in6,
289 cp->protocol, skb->csum);
292 tcph->check = csum_tcpudp_magic(cp->caddr.ip,
297 skb->ip_summed = CHECKSUM_UNNECESSARY;
304 tcp_csum_check(int af, struct sk_buff *skb, struct ip_vs_protocol *pp)
306 unsigned int tcphoff;
308 #ifdef CONFIG_IP_VS_IPV6
310 tcphoff = sizeof(struct ipv6hdr);
313 tcphoff = ip_hdrlen(skb);
315 switch (skb->ip_summed) {
317 skb->csum = skb_checksum(skb, tcphoff, skb->len - tcphoff, 0);
318 case CHECKSUM_COMPLETE:
319 #ifdef CONFIG_IP_VS_IPV6
320 if (af == AF_INET6) {
321 if (csum_ipv6_magic(&ipv6_hdr(skb)->saddr,
322 &ipv6_hdr(skb)->daddr,
324 ipv6_hdr(skb)->nexthdr,
326 IP_VS_DBG_RL_PKT(0, af, pp, skb, 0,
327 "Failed checksum for");
332 if (csum_tcpudp_magic(ip_hdr(skb)->saddr,
335 ip_hdr(skb)->protocol,
337 IP_VS_DBG_RL_PKT(0, af, pp, skb, 0,
338 "Failed checksum for");
343 /* No need to checksum. */
351 #define TCP_DIR_INPUT 0
352 #define TCP_DIR_OUTPUT 4
353 #define TCP_DIR_INPUT_ONLY 8
355 static const int tcp_state_off[IP_VS_DIR_LAST] = {
356 [IP_VS_DIR_INPUT] = TCP_DIR_INPUT,
357 [IP_VS_DIR_OUTPUT] = TCP_DIR_OUTPUT,
358 [IP_VS_DIR_INPUT_ONLY] = TCP_DIR_INPUT_ONLY,
362 * Timeout table[state]
364 static const int tcp_timeouts[IP_VS_TCP_S_LAST+1] = {
365 [IP_VS_TCP_S_NONE] = 2*HZ,
366 [IP_VS_TCP_S_ESTABLISHED] = 15*60*HZ,
367 [IP_VS_TCP_S_SYN_SENT] = 2*60*HZ,
368 [IP_VS_TCP_S_SYN_RECV] = 1*60*HZ,
369 [IP_VS_TCP_S_FIN_WAIT] = 2*60*HZ,
370 [IP_VS_TCP_S_TIME_WAIT] = 2*60*HZ,
371 [IP_VS_TCP_S_CLOSE] = 10*HZ,
372 [IP_VS_TCP_S_CLOSE_WAIT] = 60*HZ,
373 [IP_VS_TCP_S_LAST_ACK] = 30*HZ,
374 [IP_VS_TCP_S_LISTEN] = 2*60*HZ,
375 [IP_VS_TCP_S_SYNACK] = 120*HZ,
376 [IP_VS_TCP_S_LAST] = 2*HZ,
379 static const char *const tcp_state_name_table[IP_VS_TCP_S_LAST+1] = {
380 [IP_VS_TCP_S_NONE] = "NONE",
381 [IP_VS_TCP_S_ESTABLISHED] = "ESTABLISHED",
382 [IP_VS_TCP_S_SYN_SENT] = "SYN_SENT",
383 [IP_VS_TCP_S_SYN_RECV] = "SYN_RECV",
384 [IP_VS_TCP_S_FIN_WAIT] = "FIN_WAIT",
385 [IP_VS_TCP_S_TIME_WAIT] = "TIME_WAIT",
386 [IP_VS_TCP_S_CLOSE] = "CLOSE",
387 [IP_VS_TCP_S_CLOSE_WAIT] = "CLOSE_WAIT",
388 [IP_VS_TCP_S_LAST_ACK] = "LAST_ACK",
389 [IP_VS_TCP_S_LISTEN] = "LISTEN",
390 [IP_VS_TCP_S_SYNACK] = "SYNACK",
391 [IP_VS_TCP_S_LAST] = "BUG!",
394 static const bool tcp_state_active_table[IP_VS_TCP_S_LAST] = {
395 [IP_VS_TCP_S_NONE] = false,
396 [IP_VS_TCP_S_ESTABLISHED] = true,
397 [IP_VS_TCP_S_SYN_SENT] = true,
398 [IP_VS_TCP_S_SYN_RECV] = true,
399 [IP_VS_TCP_S_FIN_WAIT] = false,
400 [IP_VS_TCP_S_TIME_WAIT] = false,
401 [IP_VS_TCP_S_CLOSE] = false,
402 [IP_VS_TCP_S_CLOSE_WAIT] = false,
403 [IP_VS_TCP_S_LAST_ACK] = false,
404 [IP_VS_TCP_S_LISTEN] = false,
405 [IP_VS_TCP_S_SYNACK] = true,
408 #define sNO IP_VS_TCP_S_NONE
409 #define sES IP_VS_TCP_S_ESTABLISHED
410 #define sSS IP_VS_TCP_S_SYN_SENT
411 #define sSR IP_VS_TCP_S_SYN_RECV
412 #define sFW IP_VS_TCP_S_FIN_WAIT
413 #define sTW IP_VS_TCP_S_TIME_WAIT
414 #define sCL IP_VS_TCP_S_CLOSE
415 #define sCW IP_VS_TCP_S_CLOSE_WAIT
416 #define sLA IP_VS_TCP_S_LAST_ACK
417 #define sLI IP_VS_TCP_S_LISTEN
418 #define sSA IP_VS_TCP_S_SYNACK
420 struct tcp_states_t {
421 int next_state[IP_VS_TCP_S_LAST];
424 static const char * tcp_state_name(int state)
426 if (state >= IP_VS_TCP_S_LAST)
428 return tcp_state_name_table[state] ? tcp_state_name_table[state] : "?";
431 static bool tcp_state_active(int state)
433 if (state >= IP_VS_TCP_S_LAST)
435 return tcp_state_active_table[state];
438 static struct tcp_states_t tcp_states [] = {
440 /* sNO, sES, sSS, sSR, sFW, sTW, sCL, sCW, sLA, sLI, sSA */
441 /*syn*/ {{sSR, sES, sES, sSR, sSR, sSR, sSR, sSR, sSR, sSR, sSR }},
442 /*fin*/ {{sCL, sCW, sSS, sTW, sTW, sTW, sCL, sCW, sLA, sLI, sTW }},
443 /*ack*/ {{sES, sES, sSS, sES, sFW, sTW, sCL, sCW, sCL, sLI, sES }},
444 /*rst*/ {{sCL, sCL, sCL, sSR, sCL, sCL, sCL, sCL, sLA, sLI, sSR }},
447 /* sNO, sES, sSS, sSR, sFW, sTW, sCL, sCW, sLA, sLI, sSA */
448 /*syn*/ {{sSS, sES, sSS, sSR, sSS, sSS, sSS, sSS, sSS, sLI, sSR }},
449 /*fin*/ {{sTW, sFW, sSS, sTW, sFW, sTW, sCL, sTW, sLA, sLI, sTW }},
450 /*ack*/ {{sES, sES, sSS, sES, sFW, sTW, sCL, sCW, sLA, sES, sES }},
451 /*rst*/ {{sCL, sCL, sSS, sCL, sCL, sTW, sCL, sCL, sCL, sCL, sCL }},
454 /* sNO, sES, sSS, sSR, sFW, sTW, sCL, sCW, sLA, sLI, sSA */
455 /*syn*/ {{sSR, sES, sES, sSR, sSR, sSR, sSR, sSR, sSR, sSR, sSR }},
456 /*fin*/ {{sCL, sFW, sSS, sTW, sFW, sTW, sCL, sCW, sLA, sLI, sTW }},
457 /*ack*/ {{sES, sES, sSS, sES, sFW, sTW, sCL, sCW, sCL, sLI, sES }},
458 /*rst*/ {{sCL, sCL, sCL, sSR, sCL, sCL, sCL, sCL, sLA, sLI, sCL }},
461 static struct tcp_states_t tcp_states_dos [] = {
463 /* sNO, sES, sSS, sSR, sFW, sTW, sCL, sCW, sLA, sLI, sSA */
464 /*syn*/ {{sSR, sES, sES, sSR, sSR, sSR, sSR, sSR, sSR, sSR, sSA }},
465 /*fin*/ {{sCL, sCW, sSS, sTW, sTW, sTW, sCL, sCW, sLA, sLI, sSA }},
466 /*ack*/ {{sES, sES, sSS, sSR, sFW, sTW, sCL, sCW, sCL, sLI, sSA }},
467 /*rst*/ {{sCL, sCL, sCL, sSR, sCL, sCL, sCL, sCL, sLA, sLI, sCL }},
470 /* sNO, sES, sSS, sSR, sFW, sTW, sCL, sCW, sLA, sLI, sSA */
471 /*syn*/ {{sSS, sES, sSS, sSA, sSS, sSS, sSS, sSS, sSS, sLI, sSA }},
472 /*fin*/ {{sTW, sFW, sSS, sTW, sFW, sTW, sCL, sTW, sLA, sLI, sTW }},
473 /*ack*/ {{sES, sES, sSS, sES, sFW, sTW, sCL, sCW, sLA, sES, sES }},
474 /*rst*/ {{sCL, sCL, sSS, sCL, sCL, sTW, sCL, sCL, sCL, sCL, sCL }},
477 /* sNO, sES, sSS, sSR, sFW, sTW, sCL, sCW, sLA, sLI, sSA */
478 /*syn*/ {{sSA, sES, sES, sSR, sSA, sSA, sSA, sSA, sSA, sSA, sSA }},
479 /*fin*/ {{sCL, sFW, sSS, sTW, sFW, sTW, sCL, sCW, sLA, sLI, sTW }},
480 /*ack*/ {{sES, sES, sSS, sES, sFW, sTW, sCL, sCW, sCL, sLI, sES }},
481 /*rst*/ {{sCL, sCL, sCL, sSR, sCL, sCL, sCL, sCL, sLA, sLI, sCL }},
484 static void tcp_timeout_change(struct ip_vs_proto_data *pd, int flags)
486 int on = (flags & 1); /* secure_tcp */
489 ** FIXME: change secure_tcp to independent sysctl var
490 ** or make it per-service or per-app because it is valid
491 ** for most if not for all of the applications. Something
492 ** like "capabilities" (flags) for each object.
494 pd->tcp_state_table = (on ? tcp_states_dos : tcp_states);
497 static inline int tcp_state_idx(struct tcphdr *th)
511 set_tcp_state(struct ip_vs_proto_data *pd, struct ip_vs_conn *cp,
512 int direction, struct tcphdr *th)
515 int new_state = IP_VS_TCP_S_CLOSE;
516 int state_off = tcp_state_off[direction];
519 * Update state offset to INPUT_ONLY if necessary
520 * or delete NO_OUTPUT flag if output packet detected
522 if (cp->flags & IP_VS_CONN_F_NOOUTPUT) {
523 if (state_off == TCP_DIR_OUTPUT)
524 cp->flags &= ~IP_VS_CONN_F_NOOUTPUT;
526 state_off = TCP_DIR_INPUT_ONLY;
529 if ((state_idx = tcp_state_idx(th)) < 0) {
530 IP_VS_DBG(8, "tcp_state_idx=%d!!!\n", state_idx);
535 pd->tcp_state_table[state_off+state_idx].next_state[cp->state];
538 if (new_state != cp->state) {
539 struct ip_vs_dest *dest = cp->dest;
541 IP_VS_DBG_BUF(8, "%s %s [%c%c%c%c] %s:%d->"
542 "%s:%d state: %s->%s conn->refcnt:%d\n",
544 ((state_off == TCP_DIR_OUTPUT) ?
545 "output " : "input "),
550 IP_VS_DBG_ADDR(cp->daf, &cp->daddr),
552 IP_VS_DBG_ADDR(cp->af, &cp->caddr),
554 tcp_state_name(cp->state),
555 tcp_state_name(new_state),
556 refcount_read(&cp->refcnt));
559 if (!(cp->flags & IP_VS_CONN_F_INACTIVE) &&
560 !tcp_state_active(new_state)) {
561 atomic_dec(&dest->activeconns);
562 atomic_inc(&dest->inactconns);
563 cp->flags |= IP_VS_CONN_F_INACTIVE;
564 } else if ((cp->flags & IP_VS_CONN_F_INACTIVE) &&
565 tcp_state_active(new_state)) {
566 atomic_inc(&dest->activeconns);
567 atomic_dec(&dest->inactconns);
568 cp->flags &= ~IP_VS_CONN_F_INACTIVE;
574 cp->timeout = pd->timeout_table[cp->state = new_state];
575 else /* What to do ? */
576 cp->timeout = tcp_timeouts[cp->state = new_state];
580 * Handle state transitions
583 tcp_state_transition(struct ip_vs_conn *cp, int direction,
584 const struct sk_buff *skb,
585 struct ip_vs_proto_data *pd)
587 struct tcphdr _tcph, *th;
589 #ifdef CONFIG_IP_VS_IPV6
590 int ihl = cp->af == AF_INET ? ip_hdrlen(skb) : sizeof(struct ipv6hdr);
592 int ihl = ip_hdrlen(skb);
595 th = skb_header_pointer(skb, ihl, sizeof(_tcph), &_tcph);
599 spin_lock_bh(&cp->lock);
600 set_tcp_state(pd, cp, direction, th);
601 spin_unlock_bh(&cp->lock);
604 static inline __u16 tcp_app_hashkey(__be16 port)
606 return (((__force u16)port >> TCP_APP_TAB_BITS) ^ (__force u16)port)
611 static int tcp_register_app(struct netns_ipvs *ipvs, struct ip_vs_app *inc)
615 __be16 port = inc->port;
617 struct ip_vs_proto_data *pd = ip_vs_proto_data_get(ipvs, IPPROTO_TCP);
619 hash = tcp_app_hashkey(port);
621 list_for_each_entry(i, &ipvs->tcp_apps[hash], p_list) {
622 if (i->port == port) {
627 list_add_rcu(&inc->p_list, &ipvs->tcp_apps[hash]);
628 atomic_inc(&pd->appcnt);
636 tcp_unregister_app(struct netns_ipvs *ipvs, struct ip_vs_app *inc)
638 struct ip_vs_proto_data *pd = ip_vs_proto_data_get(ipvs, IPPROTO_TCP);
640 atomic_dec(&pd->appcnt);
641 list_del_rcu(&inc->p_list);
646 tcp_app_conn_bind(struct ip_vs_conn *cp)
648 struct netns_ipvs *ipvs = cp->ipvs;
650 struct ip_vs_app *inc;
653 /* Default binding: bind app only for NAT */
654 if (IP_VS_FWD_METHOD(cp) != IP_VS_CONN_F_MASQ)
657 /* Lookup application incarnations and bind the right one */
658 hash = tcp_app_hashkey(cp->vport);
660 list_for_each_entry_rcu(inc, &ipvs->tcp_apps[hash], p_list) {
661 if (inc->port == cp->vport) {
662 if (unlikely(!ip_vs_app_inc_get(inc)))
665 IP_VS_DBG_BUF(9, "%s(): Binding conn %s:%u->"
666 "%s:%u to app %s on port %u\n",
668 IP_VS_DBG_ADDR(cp->af, &cp->caddr),
670 IP_VS_DBG_ADDR(cp->af, &cp->vaddr),
672 inc->name, ntohs(inc->port));
676 result = inc->init_conn(inc, cp);
686 * Set LISTEN timeout. (ip_vs_conn_put will setup timer)
688 void ip_vs_tcp_conn_listen(struct ip_vs_conn *cp)
690 struct ip_vs_proto_data *pd = ip_vs_proto_data_get(cp->ipvs, IPPROTO_TCP);
692 spin_lock_bh(&cp->lock);
693 cp->state = IP_VS_TCP_S_LISTEN;
694 cp->timeout = (pd ? pd->timeout_table[IP_VS_TCP_S_LISTEN]
695 : tcp_timeouts[IP_VS_TCP_S_LISTEN]);
696 spin_unlock_bh(&cp->lock);
699 /* ---------------------------------------------
700 * timeouts is netns related now.
701 * ---------------------------------------------
703 static int __ip_vs_tcp_init(struct netns_ipvs *ipvs, struct ip_vs_proto_data *pd)
705 ip_vs_init_hash_table(ipvs->tcp_apps, TCP_APP_TAB_SIZE);
706 pd->timeout_table = ip_vs_create_timeout_table((int *)tcp_timeouts,
707 sizeof(tcp_timeouts));
708 if (!pd->timeout_table)
710 pd->tcp_state_table = tcp_states;
714 static void __ip_vs_tcp_exit(struct netns_ipvs *ipvs, struct ip_vs_proto_data *pd)
716 kfree(pd->timeout_table);
720 struct ip_vs_protocol ip_vs_protocol_tcp = {
722 .protocol = IPPROTO_TCP,
723 .num_states = IP_VS_TCP_S_LAST,
727 .init_netns = __ip_vs_tcp_init,
728 .exit_netns = __ip_vs_tcp_exit,
729 .register_app = tcp_register_app,
730 .unregister_app = tcp_unregister_app,
731 .conn_schedule = tcp_conn_schedule,
732 .conn_in_get = ip_vs_conn_in_get_proto,
733 .conn_out_get = ip_vs_conn_out_get_proto,
734 .snat_handler = tcp_snat_handler,
735 .dnat_handler = tcp_dnat_handler,
736 .csum_check = tcp_csum_check,
737 .state_name = tcp_state_name,
738 .state_transition = tcp_state_transition,
739 .app_conn_bind = tcp_app_conn_bind,
740 .debug_packet = ip_vs_tcpudp_debug_packet,
741 .timeout_change = tcp_timeout_change,