Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 81935
b: refs/heads/master
c: 3cb609d
h: refs/heads/master
i:
  81933: e173598
  81931: ae5faf9
  81927: b2c8c7f
  81919: 86990bb
v: v3
  • Loading branch information
Alexey Dobriyan authored and David S. Miller committed Feb 1, 2008
1 parent 4e44185 commit 9f5e715
Show file tree
Hide file tree
Showing 6 changed files with 68 additions and 22 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: 715cf35ac9291f31a4fea7d022695a64cac0af80
refs/heads/master: 3cb609d57c20027a8b39fc60b79b930a89da82d4
4 changes: 2 additions & 2 deletions trunk/include/linux/netfilter/x_tables.h
Original file line number Diff line number Diff line change
Expand Up @@ -357,8 +357,8 @@ extern struct xt_table *xt_find_table_lock(struct net *net, int af,
const char *name);
extern void xt_table_unlock(struct xt_table *t);

extern int xt_proto_init(int af);
extern void xt_proto_fini(int af);
extern int xt_proto_init(struct net *net, int af);
extern void xt_proto_fini(struct net *net, int af);

extern struct xt_table_info *xt_alloc_table_info(unsigned int size);
extern void xt_free_table_info(struct xt_table_info *info);
Expand Down
21 changes: 18 additions & 3 deletions trunk/net/ipv4/netfilter/arp_tables.c
Original file line number Diff line number Diff line change
Expand Up @@ -1822,11 +1822,26 @@ static struct nf_sockopt_ops arpt_sockopts = {
.owner = THIS_MODULE,
};

static int __net_init arp_tables_net_init(struct net *net)
{
return xt_proto_init(net, NF_ARP);
}

static void __net_exit arp_tables_net_exit(struct net *net)
{
xt_proto_fini(net, NF_ARP);
}

static struct pernet_operations arp_tables_net_ops = {
.init = arp_tables_net_init,
.exit = arp_tables_net_exit,
};

static int __init arp_tables_init(void)
{
int ret;

ret = xt_proto_init(NF_ARP);
ret = register_pernet_subsys(&arp_tables_net_ops);
if (ret < 0)
goto err1;

Expand All @@ -1851,7 +1866,7 @@ static int __init arp_tables_init(void)
err3:
xt_unregister_target(&arpt_standard_target);
err2:
xt_proto_fini(NF_ARP);
unregister_pernet_subsys(&arp_tables_net_ops);
err1:
return ret;
}
Expand All @@ -1861,7 +1876,7 @@ static void __exit arp_tables_fini(void)
nf_unregister_sockopt(&arpt_sockopts);
xt_unregister_target(&arpt_error_target);
xt_unregister_target(&arpt_standard_target);
xt_proto_fini(NF_ARP);
unregister_pernet_subsys(&arp_tables_net_ops);
}

EXPORT_SYMBOL(arpt_register_table);
Expand Down
21 changes: 18 additions & 3 deletions trunk/net/ipv4/netfilter/ip_tables.c
Original file line number Diff line number Diff line change
Expand Up @@ -2213,11 +2213,26 @@ static struct xt_match icmp_matchstruct __read_mostly = {
.family = AF_INET,
};

static int __net_init ip_tables_net_init(struct net *net)
{
return xt_proto_init(net, AF_INET);
}

static void __net_exit ip_tables_net_exit(struct net *net)
{
xt_proto_fini(net, AF_INET);
}

static struct pernet_operations ip_tables_net_ops = {
.init = ip_tables_net_init,
.exit = ip_tables_net_exit,
};

static int __init ip_tables_init(void)
{
int ret;

ret = xt_proto_init(AF_INET);
ret = register_pernet_subsys(&ip_tables_net_ops);
if (ret < 0)
goto err1;

Expand Down Expand Up @@ -2247,7 +2262,7 @@ static int __init ip_tables_init(void)
err3:
xt_unregister_target(&ipt_standard_target);
err2:
xt_proto_fini(AF_INET);
unregister_pernet_subsys(&ip_tables_net_ops);
err1:
return ret;
}
Expand All @@ -2260,7 +2275,7 @@ static void __exit ip_tables_fini(void)
xt_unregister_target(&ipt_error_target);
xt_unregister_target(&ipt_standard_target);

xt_proto_fini(AF_INET);
unregister_pernet_subsys(&ip_tables_net_ops);
}

EXPORT_SYMBOL(ipt_register_table);
Expand Down
22 changes: 19 additions & 3 deletions trunk/net/ipv6/netfilter/ip6_tables.c
Original file line number Diff line number Diff line change
Expand Up @@ -2238,11 +2238,26 @@ static struct xt_match icmp6_matchstruct __read_mostly = {
.family = AF_INET6,
};

static int __net_init ip6_tables_net_init(struct net *net)
{
return xt_proto_init(net, AF_INET6);
}

static void __net_exit ip6_tables_net_exit(struct net *net)
{
xt_proto_fini(net, AF_INET6);
}

static struct pernet_operations ip6_tables_net_ops = {
.init = ip6_tables_net_init,
.exit = ip6_tables_net_exit,
};

static int __init ip6_tables_init(void)
{
int ret;

ret = xt_proto_init(AF_INET6);
ret = register_pernet_subsys(&ip6_tables_net_ops);
if (ret < 0)
goto err1;

Expand Down Expand Up @@ -2272,7 +2287,7 @@ static int __init ip6_tables_init(void)
err3:
xt_unregister_target(&ip6t_standard_target);
err2:
xt_proto_fini(AF_INET6);
unregister_pernet_subsys(&ip6_tables_net_ops);
err1:
return ret;
}
Expand All @@ -2284,7 +2299,8 @@ static void __exit ip6_tables_fini(void)
xt_unregister_match(&icmp6_matchstruct);
xt_unregister_target(&ip6t_error_target);
xt_unregister_target(&ip6t_standard_target);
xt_proto_fini(AF_INET6);

unregister_pernet_subsys(&ip6_tables_net_ops);
}

/*
Expand Down
20 changes: 10 additions & 10 deletions trunk/net/netfilter/x_tables.c
Original file line number Diff line number Diff line change
Expand Up @@ -922,7 +922,7 @@ static const struct file_operations xt_target_ops = {

#endif /* CONFIG_PROC_FS */

int xt_proto_init(int af)
int xt_proto_init(struct net *net, int af)
{
#ifdef CONFIG_PROC_FS
char buf[XT_FUNCTION_MAXNAMELEN];
Expand All @@ -936,22 +936,22 @@ int xt_proto_init(int af)
#ifdef CONFIG_PROC_FS
strlcpy(buf, xt_prefix[af], sizeof(buf));
strlcat(buf, FORMAT_TABLES, sizeof(buf));
proc = proc_net_fops_create(&init_net, buf, 0440, &xt_table_ops);
proc = proc_net_fops_create(net, buf, 0440, &xt_table_ops);
if (!proc)
goto out;
proc->data = (void *)(unsigned long)af;


strlcpy(buf, xt_prefix[af], sizeof(buf));
strlcat(buf, FORMAT_MATCHES, sizeof(buf));
proc = proc_net_fops_create(&init_net, buf, 0440, &xt_match_ops);
proc = proc_net_fops_create(net, buf, 0440, &xt_match_ops);
if (!proc)
goto out_remove_tables;
proc->data = (void *)(unsigned long)af;

strlcpy(buf, xt_prefix[af], sizeof(buf));
strlcat(buf, FORMAT_TARGETS, sizeof(buf));
proc = proc_net_fops_create(&init_net, buf, 0440, &xt_target_ops);
proc = proc_net_fops_create(net, buf, 0440, &xt_target_ops);
if (!proc)
goto out_remove_matches;
proc->data = (void *)(unsigned long)af;
Expand All @@ -963,34 +963,34 @@ int xt_proto_init(int af)
out_remove_matches:
strlcpy(buf, xt_prefix[af], sizeof(buf));
strlcat(buf, FORMAT_MATCHES, sizeof(buf));
proc_net_remove(&init_net, buf);
proc_net_remove(net, buf);

out_remove_tables:
strlcpy(buf, xt_prefix[af], sizeof(buf));
strlcat(buf, FORMAT_TABLES, sizeof(buf));
proc_net_remove(&init_net, buf);
proc_net_remove(net, buf);
out:
return -1;
#endif
}
EXPORT_SYMBOL_GPL(xt_proto_init);

void xt_proto_fini(int af)
void xt_proto_fini(struct net *net, int af)
{
#ifdef CONFIG_PROC_FS
char buf[XT_FUNCTION_MAXNAMELEN];

strlcpy(buf, xt_prefix[af], sizeof(buf));
strlcat(buf, FORMAT_TABLES, sizeof(buf));
proc_net_remove(&init_net, buf);
proc_net_remove(net, buf);

strlcpy(buf, xt_prefix[af], sizeof(buf));
strlcat(buf, FORMAT_TARGETS, sizeof(buf));
proc_net_remove(&init_net, buf);
proc_net_remove(net, buf);

strlcpy(buf, xt_prefix[af], sizeof(buf));
strlcat(buf, FORMAT_MATCHES, sizeof(buf));
proc_net_remove(&init_net, buf);
proc_net_remove(net, buf);
#endif /*CONFIG_PROC_FS*/
}
EXPORT_SYMBOL_GPL(xt_proto_fini);
Expand Down

0 comments on commit 9f5e715

Please sign in to comment.