History

Merge branch 'master' of git://1984.lsi.us.es/net

David S. Miller committed 14 years ago

Commit 5414fc12 parents 3885ca7 6cf518511 files · +94 −40Browse files

Unified · Split

11 files
  1. include/net/ip_vs.h +3 −1
  2. net/netfilter/ipvs/ip_vs_core.c +11 −0
  3. net/netfilter/ipvs/ip_vs_ctl.c +32 −24
  4. net/netfilter/ipvs/ip_vs_ftp.c +2 −0
  5. net/netfilter/ipvs/ip_vs_lblc.c +3 −0
  6. net/netfilter/ipvs/ip_vs_lblcr.c +3 −0
  7. net/netfilter/ipvs/ip_vs_proto.c +27 −11
  8. net/netfilter/ipvs/ip_vs_proto_sctp.c +4 −1
  9. net/netfilter/ipvs/ip_vs_proto_tcp.c +4 −1
  10. net/netfilter/ipvs/ip_vs_proto_udp.c +4 −1
  11. net/netfilter/xt_CT.c +1 −1
include/net/ip_vs.h+3−1
@@ -393,7 +393,7 @@ struct ip_vs_protocol { · 392 unmodified lines
393393
394394 void (*exit)(struct ip_vs_protocol *pp);
395395
396− void (*init_netns)(struct net *net, struct ip_vs_proto_data *pd);
396+ int (*init_netns)(struct net *net, struct ip_vs_proto_data *pd);
397397
398398 void (*exit_netns)(struct net *net, struct ip_vs_proto_data *pd);
399399
@@ -1203,6 +1203,8 @@ ip_vs_lookup_real_service(struct net *net, int af, __u16 protocol, · 803 unmodified lines
12031203
12041204 extern int ip_vs_use_count_inc(void);
12051205 extern void ip_vs_use_count_dec(void);
1206+extern int ip_vs_register_nl_ioctl(void);
1207+extern void ip_vs_unregister_nl_ioctl(void);
12061208 extern int ip_vs_control_init(void);
12071209 extern void ip_vs_control_cleanup(void);
12081210 extern struct ip_vs_dest *
net/netfilter/ipvs/ip_vs_core.c+11−0
@@ -1924,6 +1924,7 @@ protocol_fail: · 1923 unmodified lines
19241924 control_fail:
19251925 ip_vs_estimator_net_cleanup(net);
19261926 estimator_fail:
1927+ net->ipvs = NULL;
19271928 return -ENOMEM;
19281929 }
19291930
@@ -1936,6 +1937,7 @@ static void __net_exit __ip_vs_cleanup(struct net *net) · 6 unmodified lines
19361937 ip_vs_control_net_cleanup(net);
19371938 ip_vs_estimator_net_cleanup(net);
19381939 IP_VS_DBG(2, "ipvs netns %d released\n", net_ipvs(net)->gen);
1940+ net->ipvs = NULL;
19391941 }
19401942
19411943 static void __net_exit __ip_vs_dev_cleanup(struct net *net)
@@ -1993,10 +1995,18 @@ static int __init ip_vs_init(void) · 51 unmodified lines
19931995 goto cleanup_dev;
19941996 }
19951997
1998+ ret = ip_vs_register_nl_ioctl();
1999+ if (ret < 0) {
2000+ pr_err("can't register netlink/ioctl.\n");
2001+ goto cleanup_hooks;
2002+ }
2003+
19962004 pr_info("ipvs loaded.\n");
19972005
19982006 return ret;
19992007
2008+cleanup_hooks:
2009+ nf_unregister_hooks(ip_vs_ops, ARRAY_SIZE(ip_vs_ops));
20002010 cleanup_dev:
20012011 unregister_pernet_device(&ipvs_core_dev_ops);
20022012 cleanup_sub:
@@ -2012,6 +2022,7 @@ exit: · 9 unmodified lines
20122022
20132023 static void __exit ip_vs_cleanup(void)
20142024 {
2025+ ip_vs_unregister_nl_ioctl();
20152026 nf_unregister_hooks(ip_vs_ops, ARRAY_SIZE(ip_vs_ops));
20162027 unregister_pernet_device(&ipvs_core_dev_ops);
20172028 unregister_pernet_subsys(&ipvs_core_ops); /* free ip_vs struct */
net/netfilter/ipvs/ip_vs_ctl.c+32−24
@@ -3680,7 +3680,7 @@ int __net_init ip_vs_control_net_init_sysctl(struct net *net) · 3679 unmodified lines
36803680 return 0;
36813681 }
36823682
3683−void __net_init ip_vs_control_net_cleanup_sysctl(struct net *net)
3683+void __net_exit ip_vs_control_net_cleanup_sysctl(struct net *net)
36843684 {
36853685 struct netns_ipvs *ipvs = net_ipvs(net);
36863686
@@ -3692,7 +3692,7 @@ void __net_init ip_vs_control_net_cleanup_sysctl(struct net *net) · 5 unmodified lines
36923692 #else
36933693
36943694 int __net_init ip_vs_control_net_init_sysctl(struct net *net) { return 0; }
3695−void __net_init ip_vs_control_net_cleanup_sysctl(struct net *net) { }
3695+void __net_exit ip_vs_control_net_cleanup_sysctl(struct net *net) { }
36963696
36973697 #endif
36983698
@@ -3750,21 +3750,10 @@ void __net_exit ip_vs_control_net_cleanup(struct net *net) · 51 unmodified lines
37503750 free_percpu(ipvs->tot_stats.cpustats);
37513751 }
37523752
3753−int __init ip_vs_control_init(void)
3753+int __init ip_vs_register_nl_ioctl(void)
37543754 {
3755− int idx;
37563755 int ret;
37573756
3758− EnterFunction(2);
3759−
3760− /* Initialize svc_table, ip_vs_svc_fwm_table, rs_table */
3761− for(idx = 0; idx < IP_VS_SVC_TAB_SIZE; idx++) {
3762− INIT_LIST_HEAD(&ip_vs_svc_table[idx]);
3763− INIT_LIST_HEAD(&ip_vs_svc_fwm_table[idx]);
3764− }
3765−
3766− smp_wmb(); /* Do we really need it now ? */
3767−
37683757 ret = nf_register_sockopt(&ip_vs_sockopts);
37693758 if (ret) {
37703759 pr_err("cannot register sockopt.\n");
@@ -3776,28 +3765,47 @@ int __init ip_vs_control_init(void) · 5 unmodified lines
37763765 pr_err("cannot register Generic Netlink interface.\n");
37773766 goto err_genl;
37783767 }
3779−
3780− ret = register_netdevice_notifier(&ip_vs_dst_notifier);
3781− if (ret < 0)
3782− goto err_notf;
3783−
3784− LeaveFunction(2);
37853768 return 0;
37863769
3787−err_notf:
3788− ip_vs_genl_unregister();
37893770 err_genl:
37903771 nf_unregister_sockopt(&ip_vs_sockopts);
37913772 err_sock:
37923773 return ret;
37933774 }
37943775
3776+void ip_vs_unregister_nl_ioctl(void)
3777+{
3778+ ip_vs_genl_unregister();
3779+ nf_unregister_sockopt(&ip_vs_sockopts);
3780+}
3781+
3782+int __init ip_vs_control_init(void)
3783+{
3784+ int idx;
3785+ int ret;
3786+
3787+ EnterFunction(2);
3788+
3789+ /* Initialize svc_table, ip_vs_svc_fwm_table, rs_table */
3790+ for (idx = 0; idx < IP_VS_SVC_TAB_SIZE; idx++) {
3791+ INIT_LIST_HEAD(&ip_vs_svc_table[idx]);
3792+ INIT_LIST_HEAD(&ip_vs_svc_fwm_table[idx]);
3793+ }
3794+
3795+ smp_wmb(); /* Do we really need it now ? */
3796+
3797+ ret = register_netdevice_notifier(&ip_vs_dst_notifier);
3798+ if (ret < 0)
3799+ return ret;
3800+
3801+ LeaveFunction(2);
3802+ return 0;
3803+}
3804+
37953805
37963806 void ip_vs_control_cleanup(void)
37973807 {
37983808 EnterFunction(2);
37993809 unregister_netdevice_notifier(&ip_vs_dst_notifier);
3800− ip_vs_genl_unregister();
3801− nf_unregister_sockopt(&ip_vs_sockopts);
38023810 LeaveFunction(2);
38033811 }
net/netfilter/ipvs/ip_vs_ftp.c+2−0
@@ -439,6 +439,8 @@ static int __net_init __ip_vs_ftp_init(struct net *net) · 438 unmodified lines
439439 struct ip_vs_app *app;
440440 struct netns_ipvs *ipvs = net_ipvs(net);
441441
442+ if (!ipvs)
443+ return -ENOENT;
442444 app = kmemdup(&ip_vs_ftp, sizeof(struct ip_vs_app), GFP_KERNEL);
443445 if (!app)
444446 return -ENOMEM;
net/netfilter/ipvs/ip_vs_lblc.c+3−0
@@ -551,6 +551,9 @@ static int __net_init __ip_vs_lblc_init(struct net *net) · 550 unmodified lines
551551 {
552552 struct netns_ipvs *ipvs = net_ipvs(net);
553553
554+ if (!ipvs)
555+ return -ENOENT;
556+
554557 if (!net_eq(net, &init_net)) {
555558 ipvs->lblc_ctl_table = kmemdup(vs_vars_table,
556559 sizeof(vs_vars_table),
net/netfilter/ipvs/ip_vs_lblcr.c+3−0
@@ -745,6 +745,9 @@ static int __net_init __ip_vs_lblcr_init(struct net *net) · 744 unmodified lines
745745 {
746746 struct netns_ipvs *ipvs = net_ipvs(net);
747747
748+ if (!ipvs)
749+ return -ENOENT;
750+
748751 if (!net_eq(net, &init_net)) {
749752 ipvs->lblcr_ctl_table = kmemdup(vs_vars_table,
750753 sizeof(vs_vars_table),
net/netfilter/ipvs/ip_vs_proto.c+27−11
@@ -59,9 +59,6 @@ static int __used __init register_ip_vs_protocol(struct ip_vs_protocol *pp) · 58 unmodified lines
5959 return 0;
6060 }
6161
62−#if defined(CONFIG_IP_VS_PROTO_TCP) || defined(CONFIG_IP_VS_PROTO_UDP) || \
63− defined(CONFIG_IP_VS_PROTO_SCTP) || defined(CONFIG_IP_VS_PROTO_AH) || \
64− defined(CONFIG_IP_VS_PROTO_ESP)
6562 /*
6663 * register an ipvs protocols netns related data
6764 */
@@ -81,12 +78,18 @@ register_ip_vs_proto_netns(struct net *net, struct ip_vs_protocol *pp) · 13 unmodified lines
8178 ipvs->proto_data_table[hash] = pd;
8279 atomic_set(&pd->appcnt, 0); /* Init app counter */
8380
84− if (pp->init_netns != NULL)
85− pp->init_netns(net, pd);
81+ if (pp->init_netns != NULL) {
82+ int ret = pp->init_netns(net, pd);
83+ if (ret) {
84+ /* unlink an free proto data */
85+ ipvs->proto_data_table[hash] = pd->next;
86+ kfree(pd);
87+ return ret;
88+ }
89+ }
8690
8791 return 0;
8892 }
89−#endif
9093
9194 /*
9295 * unregister an ipvs protocol
@@ -316,22 +319,35 @@ ip_vs_tcpudp_debug_packet(int af, struct ip_vs_protocol *pp, · 223 unmodified lines
316319 */
317320 int __net_init ip_vs_protocol_net_init(struct net *net)
318321 {
322+ int i, ret;
323+ static struct ip_vs_protocol *protos[] = {
319324 #ifdef CONFIG_IP_VS_PROTO_TCP
320− register_ip_vs_proto_netns(net, &ip_vs_protocol_tcp);
325+ &ip_vs_protocol_tcp,
321326 #endif
322327 #ifdef CONFIG_IP_VS_PROTO_UDP
323− register_ip_vs_proto_netns(net, &ip_vs_protocol_udp);
328+ &ip_vs_protocol_udp,
324329 #endif
325330 #ifdef CONFIG_IP_VS_PROTO_SCTP
326− register_ip_vs_proto_netns(net, &ip_vs_protocol_sctp);
331+ &ip_vs_protocol_sctp,
327332 #endif
328333 #ifdef CONFIG_IP_VS_PROTO_AH
329− register_ip_vs_proto_netns(net, &ip_vs_protocol_ah);
334+ &ip_vs_protocol_ah,
330335 #endif
331336 #ifdef CONFIG_IP_VS_PROTO_ESP
332− register_ip_vs_proto_netns(net, &ip_vs_protocol_esp);
337+ &ip_vs_protocol_esp,
333338 #endif
339+ };
340+
341+ for (i = 0; i < ARRAY_SIZE(protos); i++) {
342+ ret = register_ip_vs_proto_netns(net, protos[i]);
343+ if (ret < 0)
344+ goto cleanup;
345+ }
334346 return 0;
347+
348+cleanup:
349+ ip_vs_protocol_net_cleanup(net);
350+ return ret;
335351 }
336352
337353 void __net_exit ip_vs_protocol_net_cleanup(struct net *net)
net/netfilter/ipvs/ip_vs_proto_sctp.c+4−1
@@ -1090,7 +1090,7 @@ out: · 1089 unmodified lines
10901090 * timeouts is netns related now.
10911091 * ---------------------------------------------
10921092 */
1093−static void __ip_vs_sctp_init(struct net *net, struct ip_vs_proto_data *pd)
1093+static int __ip_vs_sctp_init(struct net *net, struct ip_vs_proto_data *pd)
10941094 {
10951095 struct netns_ipvs *ipvs = net_ipvs(net);
10961096
@@ -1098,6 +1098,9 @@ static void __ip_vs_sctp_init(struct net *net, struct ip_vs_proto_data *pd) · 1 unmodified line
10981098 spin_lock_init(&ipvs->sctp_app_lock);
10991099 pd->timeout_table = ip_vs_create_timeout_table((int *)sctp_timeouts,
11001100 sizeof(sctp_timeouts));
1101+ if (!pd->timeout_table)
1102+ return -ENOMEM;
1103+ return 0;
11011104 }
11021105
11031106 static void __ip_vs_sctp_exit(struct net *net, struct ip_vs_proto_data *pd)
net/netfilter/ipvs/ip_vs_proto_tcp.c+4−1
@@ -677,7 +677,7 @@ void ip_vs_tcp_conn_listen(struct net *net, struct ip_vs_conn *cp) · 676 unmodified lines
677677 * timeouts is netns related now.
678678 * ---------------------------------------------
679679 */
680−static void __ip_vs_tcp_init(struct net *net, struct ip_vs_proto_data *pd)
680+static int __ip_vs_tcp_init(struct net *net, struct ip_vs_proto_data *pd)
681681 {
682682 struct netns_ipvs *ipvs = net_ipvs(net);
683683
@@ -685,7 +685,10 @@ static void __ip_vs_tcp_init(struct net *net, struct ip_vs_proto_data *pd) · 1 unmodified line
685685 spin_lock_init(&ipvs->tcp_app_lock);
686686 pd->timeout_table = ip_vs_create_timeout_table((int *)tcp_timeouts,
687687 sizeof(tcp_timeouts));
688+ if (!pd->timeout_table)
689+ return -ENOMEM;
688690 pd->tcp_state_table = tcp_states;
691+ return 0;
689692 }
690693
691694 static void __ip_vs_tcp_exit(struct net *net, struct ip_vs_proto_data *pd)
net/netfilter/ipvs/ip_vs_proto_udp.c+4−1
@@ -467,7 +467,7 @@ udp_state_transition(struct ip_vs_conn *cp, int direction, · 466 unmodified lines
467467 cp->timeout = pd->timeout_table[IP_VS_UDP_S_NORMAL];
468468 }
469469
470−static void __udp_init(struct net *net, struct ip_vs_proto_data *pd)
470+static int __udp_init(struct net *net, struct ip_vs_proto_data *pd)
471471 {
472472 struct netns_ipvs *ipvs = net_ipvs(net);
473473
@@ -475,6 +475,9 @@ static void __udp_init(struct net *net, struct ip_vs_proto_data *pd) · 1 unmodified line
475475 spin_lock_init(&ipvs->udp_app_lock);
476476 pd->timeout_table = ip_vs_create_timeout_table((int *)udp_timeouts,
477477 sizeof(udp_timeouts));
478+ if (!pd->timeout_table)
479+ return -ENOMEM;
480+ return 0;
478481 }
479482
480483 static void __udp_exit(struct net *net, struct ip_vs_proto_data *pd)
net/netfilter/xt_CT.c+1−1
@@ -227,7 +227,7 @@ static int xt_ct_tg_check_v1(const struct xt_tgchk_param *par) · 226 unmodified lines
227227 }
228228
229229 #ifdef CONFIG_NF_CONNTRACK_TIMEOUT
230− if (info->timeout) {
230+ if (info->timeout[0]) {
231231 typeof(nf_ct_timeout_find_get_hook) timeout_find_get;
232232 struct nf_conn_timeout *timeout_ext;
233233