Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 327575
b: refs/heads/master
c: be97fdb
h: refs/heads/master
i:
  327573: 0604cb5
  327571: 7ba8bc2
  327567: 018acc2
v: v3
  • Loading branch information
Julian Anastasov authored and Simon Horman committed Aug 10, 2012
1 parent 6339561 commit 1c20952
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 36 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: aaea4ed74d71dda1cf2cc19c206552d537201452
refs/heads/master: be97fdb5fbcc828240c51769cd28cba609158703
5 changes: 2 additions & 3 deletions trunk/include/net/ip_vs.h
Original file line number Diff line number Diff line change
Expand Up @@ -808,8 +808,6 @@ struct netns_ipvs {
struct list_head rs_table[IP_VS_RTAB_SIZE];
/* ip_vs_app */
struct list_head app_list;
/* ip_vs_ftp */
struct ip_vs_app *ftp_app;
/* ip_vs_proto */
#define IP_VS_PROTO_TAB_SIZE 32 /* must be power of 2 */
struct ip_vs_proto_data *proto_data_table[IP_VS_PROTO_TAB_SIZE];
Expand Down Expand Up @@ -1179,7 +1177,8 @@ extern void ip_vs_service_net_cleanup(struct net *net);
* (from ip_vs_app.c)
*/
#define IP_VS_APP_MAX_PORTS 8
extern int register_ip_vs_app(struct net *net, struct ip_vs_app *app);
extern struct ip_vs_app *register_ip_vs_app(struct net *net,
struct ip_vs_app *app);
extern void unregister_ip_vs_app(struct net *net, struct ip_vs_app *app);
extern int ip_vs_bind_app(struct ip_vs_conn *cp, struct ip_vs_protocol *pp);
extern void ip_vs_unbind_app(struct ip_vs_conn *cp);
Expand Down
58 changes: 42 additions & 16 deletions trunk/net/netfilter/ipvs/ip_vs_app.c
Original file line number Diff line number Diff line change
Expand Up @@ -180,22 +180,38 @@ register_ip_vs_app_inc(struct net *net, struct ip_vs_app *app, __u16 proto,
}


/*
* ip_vs_app registration routine
*/
int register_ip_vs_app(struct net *net, struct ip_vs_app *app)
/* Register application for netns */
struct ip_vs_app *register_ip_vs_app(struct net *net, struct ip_vs_app *app)
{
struct netns_ipvs *ipvs = net_ipvs(net);
/* increase the module use count */
ip_vs_use_count_inc();
struct ip_vs_app *a;
int err = 0;

if (!ipvs)
return ERR_PTR(-ENOENT);

mutex_lock(&__ip_vs_app_mutex);

list_add(&app->a_list, &ipvs->app_list);
list_for_each_entry(a, &ipvs->app_list, a_list) {
if (!strcmp(app->name, a->name)) {
err = -EEXIST;
goto out_unlock;
}
}
a = kmemdup(app, sizeof(*app), GFP_KERNEL);
if (!a) {
err = -ENOMEM;
goto out_unlock;
}
INIT_LIST_HEAD(&a->incs_list);
list_add(&a->a_list, &ipvs->app_list);
/* increase the module use count */
ip_vs_use_count_inc();

out_unlock:
mutex_unlock(&__ip_vs_app_mutex);

return 0;
return err ? ERR_PTR(err) : a;
}


Expand All @@ -205,20 +221,29 @@ int register_ip_vs_app(struct net *net, struct ip_vs_app *app)
*/
void unregister_ip_vs_app(struct net *net, struct ip_vs_app *app)
{
struct ip_vs_app *inc, *nxt;
struct netns_ipvs *ipvs = net_ipvs(net);
struct ip_vs_app *a, *anxt, *inc, *nxt;

if (!ipvs)
return;

mutex_lock(&__ip_vs_app_mutex);

list_for_each_entry_safe(inc, nxt, &app->incs_list, a_list) {
ip_vs_app_inc_release(net, inc);
}
list_for_each_entry_safe(a, anxt, &ipvs->app_list, a_list) {
if (app && strcmp(app->name, a->name))
continue;
list_for_each_entry_safe(inc, nxt, &a->incs_list, a_list) {
ip_vs_app_inc_release(net, inc);
}

list_del(&app->a_list);
list_del(&a->a_list);
kfree(a);

mutex_unlock(&__ip_vs_app_mutex);
/* decrease the module use count */
ip_vs_use_count_dec();
}

/* decrease the module use count */
ip_vs_use_count_dec();
mutex_unlock(&__ip_vs_app_mutex);
}


Expand Down Expand Up @@ -586,5 +611,6 @@ int __net_init ip_vs_app_net_init(struct net *net)

void __net_exit ip_vs_app_net_cleanup(struct net *net)
{
unregister_ip_vs_app(net, NULL /* all */);
proc_net_remove(net, "ip_vs_app");
}
21 changes: 5 additions & 16 deletions trunk/net/netfilter/ipvs/ip_vs_ftp.c
Original file line number Diff line number Diff line change
Expand Up @@ -441,16 +441,10 @@ static int __net_init __ip_vs_ftp_init(struct net *net)

if (!ipvs)
return -ENOENT;
app = kmemdup(&ip_vs_ftp, sizeof(struct ip_vs_app), GFP_KERNEL);
if (!app)
return -ENOMEM;
INIT_LIST_HEAD(&app->a_list);
INIT_LIST_HEAD(&app->incs_list);
ipvs->ftp_app = app;

ret = register_ip_vs_app(net, app);
if (ret)
goto err_exit;
app = register_ip_vs_app(net, &ip_vs_ftp);
if (IS_ERR(app))
return PTR_ERR(app);

for (i = 0; i < ports_count; i++) {
if (!ports[i])
Expand All @@ -464,20 +458,15 @@ static int __net_init __ip_vs_ftp_init(struct net *net)
return 0;

err_unreg:
unregister_ip_vs_app(net, app);
err_exit:
kfree(ipvs->ftp_app);
unregister_ip_vs_app(net, &ip_vs_ftp);
return ret;
}
/*
* netns exit
*/
static void __ip_vs_ftp_exit(struct net *net)
{
struct netns_ipvs *ipvs = net_ipvs(net);

unregister_ip_vs_app(net, ipvs->ftp_app);
kfree(ipvs->ftp_app);
unregister_ip_vs_app(net, &ip_vs_ftp);
}

static struct pernet_operations ip_vs_ftp_ops = {
Expand Down

0 comments on commit 1c20952

Please sign in to comment.