diff options
author | Hans Schillstrom <hans.schillstrom@ericsson.com> | 2011-01-03 08:44:52 -0500 |
---|---|---|
committer | Simon Horman <horms@verge.net.au> | 2011-01-12 20:30:27 -0500 |
commit | 9bbac6a904d0816dae58b454692c54d6773cc20d (patch) | |
tree | f29698f1230e2a0b6fda2546f1f6da256d442979 /net | |
parent | 9330419d9aa4f97df412ac9be9fc0388c67dd315 (diff) |
IPVS: netns, common protocol changes and use of appcnt.
appcnt and timeout_table moved from struct ip_vs_protocol to
ip_vs proto_data.
struct net *net added as first param to
- register_app()
- unregister_app()
- app_conn_bind()
- ip_vs_conn_new()
[horms@verge.net.au: removed cosmetic-change-only hunk]
Signed-off-by: Hans Schillstrom <hans.schillstrom@ericsson.com>
Acked-by: Julian Anastasov <ja@ssi.bg>
Signed-off-by: Simon Horman <horms@verge.net.au>
Diffstat (limited to 'net')
-rw-r--r-- | net/netfilter/ipvs/ip_vs_conn.c | 6 | ||||
-rw-r--r-- | net/netfilter/ipvs/ip_vs_proto_sctp.c | 4 | ||||
-rw-r--r-- | net/netfilter/ipvs/ip_vs_proto_tcp.c | 5 | ||||
-rw-r--r-- | net/netfilter/ipvs/ip_vs_proto_udp.c | 4 | ||||
-rw-r--r-- | net/netfilter/ipvs/ip_vs_sync.c | 55 |
5 files changed, 39 insertions, 35 deletions
diff --git a/net/netfilter/ipvs/ip_vs_conn.c b/net/netfilter/ipvs/ip_vs_conn.c index a7aba6a4697..b2024c94234 100644 --- a/net/netfilter/ipvs/ip_vs_conn.c +++ b/net/netfilter/ipvs/ip_vs_conn.c | |||
@@ -804,7 +804,7 @@ ip_vs_conn_new(const struct ip_vs_conn_param *p, | |||
804 | struct ip_vs_dest *dest, __u32 fwmark) | 804 | struct ip_vs_dest *dest, __u32 fwmark) |
805 | { | 805 | { |
806 | struct ip_vs_conn *cp; | 806 | struct ip_vs_conn *cp; |
807 | struct ip_vs_protocol *pp = ip_vs_proto_get(p->protocol); | 807 | struct ip_vs_proto_data *pd = ip_vs_proto_data_get(&init_net, p->protocol); |
808 | 808 | ||
809 | cp = kmem_cache_zalloc(ip_vs_conn_cachep, GFP_ATOMIC); | 809 | cp = kmem_cache_zalloc(ip_vs_conn_cachep, GFP_ATOMIC); |
810 | if (cp == NULL) { | 810 | if (cp == NULL) { |
@@ -863,8 +863,8 @@ ip_vs_conn_new(const struct ip_vs_conn_param *p, | |||
863 | #endif | 863 | #endif |
864 | ip_vs_bind_xmit(cp); | 864 | ip_vs_bind_xmit(cp); |
865 | 865 | ||
866 | if (unlikely(pp && atomic_read(&pp->appcnt))) | 866 | if (unlikely(pd && atomic_read(&pd->appcnt))) |
867 | ip_vs_bind_app(cp, pp); | 867 | ip_vs_bind_app(cp, pd->pp); |
868 | 868 | ||
869 | /* | 869 | /* |
870 | * Allow conntrack to be preserved. By default, conntrack | 870 | * Allow conntrack to be preserved. By default, conntrack |
diff --git a/net/netfilter/ipvs/ip_vs_proto_sctp.c b/net/netfilter/ipvs/ip_vs_proto_sctp.c index 19bc37976ea..0f14f793318 100644 --- a/net/netfilter/ipvs/ip_vs_proto_sctp.c +++ b/net/netfilter/ipvs/ip_vs_proto_sctp.c | |||
@@ -1035,7 +1035,7 @@ static int sctp_register_app(struct ip_vs_app *inc) | |||
1035 | } | 1035 | } |
1036 | } | 1036 | } |
1037 | list_add(&inc->p_list, &ipvs->sctp_apps[hash]); | 1037 | list_add(&inc->p_list, &ipvs->sctp_apps[hash]); |
1038 | atomic_inc(&pd->pp->appcnt); | 1038 | atomic_inc(&pd->appcnt); |
1039 | out: | 1039 | out: |
1040 | spin_unlock_bh(&ipvs->sctp_app_lock); | 1040 | spin_unlock_bh(&ipvs->sctp_app_lock); |
1041 | 1041 | ||
@@ -1048,7 +1048,7 @@ static void sctp_unregister_app(struct ip_vs_app *inc) | |||
1048 | struct ip_vs_proto_data *pd = ip_vs_proto_data_get(&init_net, IPPROTO_SCTP); | 1048 | struct ip_vs_proto_data *pd = ip_vs_proto_data_get(&init_net, IPPROTO_SCTP); |
1049 | 1049 | ||
1050 | spin_lock_bh(&ipvs->sctp_app_lock); | 1050 | spin_lock_bh(&ipvs->sctp_app_lock); |
1051 | atomic_dec(&pd->pp->appcnt); | 1051 | atomic_dec(&pd->appcnt); |
1052 | list_del(&inc->p_list); | 1052 | list_del(&inc->p_list); |
1053 | spin_unlock_bh(&ipvs->sctp_app_lock); | 1053 | spin_unlock_bh(&ipvs->sctp_app_lock); |
1054 | } | 1054 | } |
diff --git a/net/netfilter/ipvs/ip_vs_proto_tcp.c b/net/netfilter/ipvs/ip_vs_proto_tcp.c index d7c24553279..290b3803d8c 100644 --- a/net/netfilter/ipvs/ip_vs_proto_tcp.c +++ b/net/netfilter/ipvs/ip_vs_proto_tcp.c | |||
@@ -596,7 +596,7 @@ static int tcp_register_app(struct ip_vs_app *inc) | |||
596 | } | 596 | } |
597 | } | 597 | } |
598 | list_add(&inc->p_list, &ipvs->tcp_apps[hash]); | 598 | list_add(&inc->p_list, &ipvs->tcp_apps[hash]); |
599 | atomic_inc(&pd->pp->appcnt); | 599 | atomic_inc(&pd->appcnt); |
600 | 600 | ||
601 | out: | 601 | out: |
602 | spin_unlock_bh(&ipvs->tcp_app_lock); | 602 | spin_unlock_bh(&ipvs->tcp_app_lock); |
@@ -611,7 +611,7 @@ tcp_unregister_app(struct ip_vs_app *inc) | |||
611 | struct ip_vs_proto_data *pd = ip_vs_proto_data_get(&init_net, IPPROTO_TCP); | 611 | struct ip_vs_proto_data *pd = ip_vs_proto_data_get(&init_net, IPPROTO_TCP); |
612 | 612 | ||
613 | spin_lock_bh(&ipvs->tcp_app_lock); | 613 | spin_lock_bh(&ipvs->tcp_app_lock); |
614 | atomic_dec(&pd->pp->appcnt); | 614 | atomic_dec(&pd->appcnt); |
615 | list_del(&inc->p_list); | 615 | list_del(&inc->p_list); |
616 | spin_unlock_bh(&ipvs->tcp_app_lock); | 616 | spin_unlock_bh(&ipvs->tcp_app_lock); |
617 | } | 617 | } |
@@ -701,7 +701,6 @@ struct ip_vs_protocol ip_vs_protocol_tcp = { | |||
701 | .protocol = IPPROTO_TCP, | 701 | .protocol = IPPROTO_TCP, |
702 | .num_states = IP_VS_TCP_S_LAST, | 702 | .num_states = IP_VS_TCP_S_LAST, |
703 | .dont_defrag = 0, | 703 | .dont_defrag = 0, |
704 | .appcnt = ATOMIC_INIT(0), | ||
705 | .init = NULL, | 704 | .init = NULL, |
706 | .exit = NULL, | 705 | .exit = NULL, |
707 | .init_netns = __ip_vs_tcp_init, | 706 | .init_netns = __ip_vs_tcp_init, |
diff --git a/net/netfilter/ipvs/ip_vs_proto_udp.c b/net/netfilter/ipvs/ip_vs_proto_udp.c index aa85df2f14a..3719837a8fd 100644 --- a/net/netfilter/ipvs/ip_vs_proto_udp.c +++ b/net/netfilter/ipvs/ip_vs_proto_udp.c | |||
@@ -373,7 +373,7 @@ static int udp_register_app(struct ip_vs_app *inc) | |||
373 | } | 373 | } |
374 | } | 374 | } |
375 | list_add(&inc->p_list, &ipvs->udp_apps[hash]); | 375 | list_add(&inc->p_list, &ipvs->udp_apps[hash]); |
376 | atomic_inc(&pd->pp->appcnt); | 376 | atomic_inc(&pd->appcnt); |
377 | 377 | ||
378 | out: | 378 | out: |
379 | spin_unlock_bh(&ipvs->udp_app_lock); | 379 | spin_unlock_bh(&ipvs->udp_app_lock); |
@@ -388,7 +388,7 @@ udp_unregister_app(struct ip_vs_app *inc) | |||
388 | struct netns_ipvs *ipvs = net_ipvs(&init_net); | 388 | struct netns_ipvs *ipvs = net_ipvs(&init_net); |
389 | 389 | ||
390 | spin_lock_bh(&ipvs->udp_app_lock); | 390 | spin_lock_bh(&ipvs->udp_app_lock); |
391 | atomic_dec(&pd->pp->appcnt); | 391 | atomic_dec(&pd->appcnt); |
392 | list_del(&inc->p_list); | 392 | list_del(&inc->p_list); |
393 | spin_unlock_bh(&ipvs->udp_app_lock); | 393 | spin_unlock_bh(&ipvs->udp_app_lock); |
394 | } | 394 | } |
diff --git a/net/netfilter/ipvs/ip_vs_sync.c b/net/netfilter/ipvs/ip_vs_sync.c index 662aa2c22a0..6831e8fac8d 100644 --- a/net/netfilter/ipvs/ip_vs_sync.c +++ b/net/netfilter/ipvs/ip_vs_sync.c | |||
@@ -725,17 +725,16 @@ ip_vs_conn_fill_param_sync(int af, union ip_vs_sync_conn *sc, | |||
725 | * Param: ... | 725 | * Param: ... |
726 | * timeout is in sec. | 726 | * timeout is in sec. |
727 | */ | 727 | */ |
728 | static void ip_vs_proc_conn(struct ip_vs_conn_param *param, unsigned flags, | 728 | static void ip_vs_proc_conn(struct net *net, struct ip_vs_conn_param *param, |
729 | unsigned state, unsigned protocol, unsigned type, | 729 | unsigned int flags, unsigned int state, |
730 | unsigned int protocol, unsigned int type, | ||
730 | const union nf_inet_addr *daddr, __be16 dport, | 731 | const union nf_inet_addr *daddr, __be16 dport, |
731 | unsigned long timeout, __u32 fwmark, | 732 | unsigned long timeout, __u32 fwmark, |
732 | struct ip_vs_sync_conn_options *opt, | 733 | struct ip_vs_sync_conn_options *opt) |
733 | struct ip_vs_protocol *pp) | ||
734 | { | 734 | { |
735 | struct ip_vs_dest *dest; | 735 | struct ip_vs_dest *dest; |
736 | struct ip_vs_conn *cp; | 736 | struct ip_vs_conn *cp; |
737 | 737 | ||
738 | |||
739 | if (!(flags & IP_VS_CONN_F_TEMPLATE)) | 738 | if (!(flags & IP_VS_CONN_F_TEMPLATE)) |
740 | cp = ip_vs_conn_in_get(param); | 739 | cp = ip_vs_conn_in_get(param); |
741 | else | 740 | else |
@@ -821,17 +820,23 @@ static void ip_vs_proc_conn(struct ip_vs_conn_param *param, unsigned flags, | |||
821 | if (timeout > MAX_SCHEDULE_TIMEOUT / HZ) | 820 | if (timeout > MAX_SCHEDULE_TIMEOUT / HZ) |
822 | timeout = MAX_SCHEDULE_TIMEOUT / HZ; | 821 | timeout = MAX_SCHEDULE_TIMEOUT / HZ; |
823 | cp->timeout = timeout*HZ; | 822 | cp->timeout = timeout*HZ; |
824 | } else if (!(flags & IP_VS_CONN_F_TEMPLATE) && pp->timeout_table) | 823 | } else { |
825 | cp->timeout = pp->timeout_table[state]; | 824 | struct ip_vs_proto_data *pd; |
826 | else | 825 | |
827 | cp->timeout = (3*60*HZ); | 826 | pd = ip_vs_proto_data_get(net, protocol); |
827 | if (!(flags & IP_VS_CONN_F_TEMPLATE) && pd && pd->timeout_table) | ||
828 | cp->timeout = pd->timeout_table[state]; | ||
829 | else | ||
830 | cp->timeout = (3*60*HZ); | ||
831 | } | ||
828 | ip_vs_conn_put(cp); | 832 | ip_vs_conn_put(cp); |
829 | } | 833 | } |
830 | 834 | ||
831 | /* | 835 | /* |
832 | * Process received multicast message for Version 0 | 836 | * Process received multicast message for Version 0 |
833 | */ | 837 | */ |
834 | static void ip_vs_process_message_v0(const char *buffer, const size_t buflen) | 838 | static void ip_vs_process_message_v0(struct net *net, const char *buffer, |
839 | const size_t buflen) | ||
835 | { | 840 | { |
836 | struct ip_vs_sync_mesg_v0 *m = (struct ip_vs_sync_mesg_v0 *)buffer; | 841 | struct ip_vs_sync_mesg_v0 *m = (struct ip_vs_sync_mesg_v0 *)buffer; |
837 | struct ip_vs_sync_conn_v0 *s; | 842 | struct ip_vs_sync_conn_v0 *s; |
@@ -879,7 +884,6 @@ static void ip_vs_process_message_v0(const char *buffer, const size_t buflen) | |||
879 | } | 884 | } |
880 | } else { | 885 | } else { |
881 | /* protocol in templates is not used for state/timeout */ | 886 | /* protocol in templates is not used for state/timeout */ |
882 | pp = NULL; | ||
883 | if (state > 0) { | 887 | if (state > 0) { |
884 | IP_VS_DBG(2, "BACKUP v0, Invalid template state %u\n", | 888 | IP_VS_DBG(2, "BACKUP v0, Invalid template state %u\n", |
885 | state); | 889 | state); |
@@ -894,9 +898,9 @@ static void ip_vs_process_message_v0(const char *buffer, const size_t buflen) | |||
894 | s->vport, ¶m); | 898 | s->vport, ¶m); |
895 | 899 | ||
896 | /* Send timeout as Zero */ | 900 | /* Send timeout as Zero */ |
897 | ip_vs_proc_conn(¶m, flags, state, s->protocol, AF_INET, | 901 | ip_vs_proc_conn(net, ¶m, flags, state, s->protocol, AF_INET, |
898 | (union nf_inet_addr *)&s->daddr, s->dport, | 902 | (union nf_inet_addr *)&s->daddr, s->dport, |
899 | 0, 0, opt, pp); | 903 | 0, 0, opt); |
900 | } | 904 | } |
901 | } | 905 | } |
902 | 906 | ||
@@ -945,7 +949,7 @@ static int ip_vs_proc_str(__u8 *p, unsigned int plen, unsigned int *data_len, | |||
945 | /* | 949 | /* |
946 | * Process a Version 1 sync. connection | 950 | * Process a Version 1 sync. connection |
947 | */ | 951 | */ |
948 | static inline int ip_vs_proc_sync_conn(__u8 *p, __u8 *msg_end) | 952 | static inline int ip_vs_proc_sync_conn(struct net *net, __u8 *p, __u8 *msg_end) |
949 | { | 953 | { |
950 | struct ip_vs_sync_conn_options opt; | 954 | struct ip_vs_sync_conn_options opt; |
951 | union ip_vs_sync_conn *s; | 955 | union ip_vs_sync_conn *s; |
@@ -1043,7 +1047,6 @@ static inline int ip_vs_proc_sync_conn(__u8 *p, __u8 *msg_end) | |||
1043 | } | 1047 | } |
1044 | } else { | 1048 | } else { |
1045 | /* protocol in templates is not used for state/timeout */ | 1049 | /* protocol in templates is not used for state/timeout */ |
1046 | pp = NULL; | ||
1047 | if (state > 0) { | 1050 | if (state > 0) { |
1048 | IP_VS_DBG(3, "BACKUP, Invalid template state %u\n", | 1051 | IP_VS_DBG(3, "BACKUP, Invalid template state %u\n", |
1049 | state); | 1052 | state); |
@@ -1058,18 +1061,18 @@ static inline int ip_vs_proc_sync_conn(__u8 *p, __u8 *msg_end) | |||
1058 | } | 1061 | } |
1059 | /* If only IPv4, just silent skip IPv6 */ | 1062 | /* If only IPv4, just silent skip IPv6 */ |
1060 | if (af == AF_INET) | 1063 | if (af == AF_INET) |
1061 | ip_vs_proc_conn(¶m, flags, state, s->v4.protocol, af, | 1064 | ip_vs_proc_conn(net, ¶m, flags, state, s->v4.protocol, af, |
1062 | (union nf_inet_addr *)&s->v4.daddr, s->v4.dport, | 1065 | (union nf_inet_addr *)&s->v4.daddr, s->v4.dport, |
1063 | ntohl(s->v4.timeout), ntohl(s->v4.fwmark), | 1066 | ntohl(s->v4.timeout), ntohl(s->v4.fwmark), |
1064 | (opt_flags & IPVS_OPT_F_SEQ_DATA ? &opt : NULL), | 1067 | (opt_flags & IPVS_OPT_F_SEQ_DATA ? &opt : NULL) |
1065 | pp); | 1068 | ); |
1066 | #ifdef CONFIG_IP_VS_IPV6 | 1069 | #ifdef CONFIG_IP_VS_IPV6 |
1067 | else | 1070 | else |
1068 | ip_vs_proc_conn(¶m, flags, state, s->v6.protocol, af, | 1071 | ip_vs_proc_conn(net, ¶m, flags, state, s->v6.protocol, af, |
1069 | (union nf_inet_addr *)&s->v6.daddr, s->v6.dport, | 1072 | (union nf_inet_addr *)&s->v6.daddr, s->v6.dport, |
1070 | ntohl(s->v6.timeout), ntohl(s->v6.fwmark), | 1073 | ntohl(s->v6.timeout), ntohl(s->v6.fwmark), |
1071 | (opt_flags & IPVS_OPT_F_SEQ_DATA ? &opt : NULL), | 1074 | (opt_flags & IPVS_OPT_F_SEQ_DATA ? &opt : NULL) |
1072 | pp); | 1075 | ); |
1073 | #endif | 1076 | #endif |
1074 | return 0; | 1077 | return 0; |
1075 | /* Error exit */ | 1078 | /* Error exit */ |
@@ -1083,7 +1086,8 @@ out: | |||
1083 | * ip_vs_conn entries. | 1086 | * ip_vs_conn entries. |
1084 | * Handles Version 0 & 1 | 1087 | * Handles Version 0 & 1 |
1085 | */ | 1088 | */ |
1086 | static void ip_vs_process_message(__u8 *buffer, const size_t buflen) | 1089 | static void ip_vs_process_message(struct net *net, __u8 *buffer, |
1090 | const size_t buflen) | ||
1087 | { | 1091 | { |
1088 | struct ip_vs_sync_mesg *m2 = (struct ip_vs_sync_mesg *)buffer; | 1092 | struct ip_vs_sync_mesg *m2 = (struct ip_vs_sync_mesg *)buffer; |
1089 | __u8 *p, *msg_end; | 1093 | __u8 *p, *msg_end; |
@@ -1136,7 +1140,8 @@ static void ip_vs_process_message(__u8 *buffer, const size_t buflen) | |||
1136 | return; | 1140 | return; |
1137 | } | 1141 | } |
1138 | /* Process a single sync_conn */ | 1142 | /* Process a single sync_conn */ |
1139 | if ((retc=ip_vs_proc_sync_conn(p, msg_end)) < 0) { | 1143 | retc = ip_vs_proc_sync_conn(net, p, msg_end); |
1144 | if (retc < 0) { | ||
1140 | IP_VS_ERR_RL("BACKUP, Dropping buffer, Err: %d in decoding\n", | 1145 | IP_VS_ERR_RL("BACKUP, Dropping buffer, Err: %d in decoding\n", |
1141 | retc); | 1146 | retc); |
1142 | return; | 1147 | return; |
@@ -1146,7 +1151,7 @@ static void ip_vs_process_message(__u8 *buffer, const size_t buflen) | |||
1146 | } | 1151 | } |
1147 | } else { | 1152 | } else { |
1148 | /* Old type of message */ | 1153 | /* Old type of message */ |
1149 | ip_vs_process_message_v0(buffer, buflen); | 1154 | ip_vs_process_message_v0(net, buffer, buflen); |
1150 | return; | 1155 | return; |
1151 | } | 1156 | } |
1152 | } | 1157 | } |
@@ -1500,7 +1505,7 @@ static int sync_thread_backup(void *data) | |||
1500 | /* disable bottom half, because it accesses the data | 1505 | /* disable bottom half, because it accesses the data |
1501 | shared by softirq while getting/creating conns */ | 1506 | shared by softirq while getting/creating conns */ |
1502 | local_bh_disable(); | 1507 | local_bh_disable(); |
1503 | ip_vs_process_message(tinfo->buf, len); | 1508 | ip_vs_process_message(&init_net, tinfo->buf, len); |
1504 | local_bh_enable(); | 1509 | local_bh_enable(); |
1505 | } | 1510 | } |
1506 | } | 1511 | } |