Skip to content

Commit

Permalink
[NETNS][FRAGS]: Make the pernet subsystem for fragments.
Browse files Browse the repository at this point in the history
On namespace start we mainly prepare the ctl variables.

When the namespace is stopped we have to kill all the fragments that
point to this namespace.  The inet_frags_exit_net() handles it.

Signed-off-by: Pavel Emelyanov <xemul@openvz.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Pavel Emelyanov authored and David S. Miller committed Jan 28, 2008
1 parent 3140c25 commit 81566e8
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 2 deletions.
1 change: 1 addition & 0 deletions include/net/inet_frag.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ void inet_frags_init(struct inet_frags *);
void inet_frags_fini(struct inet_frags *);

void inet_frags_init_net(struct netns_frags *nf);
void inet_frags_exit_net(struct netns_frags *nf, struct inet_frags *f);

void inet_frag_kill(struct inet_frag_queue *q, struct inet_frags *f);
void inet_frag_destroy(struct inet_frag_queue *q,
Expand Down
7 changes: 7 additions & 0 deletions net/ipv4/inet_fragment.c
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,13 @@ void inet_frags_fini(struct inet_frags *f)
}
EXPORT_SYMBOL(inet_frags_fini);

void inet_frags_exit_net(struct netns_frags *nf, struct inet_frags *f)
{
nf->low_thresh = 0;
inet_frag_evictor(nf, f);
}
EXPORT_SYMBOL(inet_frags_exit_net);

static inline void fq_unlink(struct inet_frag_queue *fq, struct inet_frags *f)
{
write_lock(&f->lock);
Expand Down
13 changes: 12 additions & 1 deletion net/ipv4/ip_fragment.c
Original file line number Diff line number Diff line change
Expand Up @@ -713,9 +713,20 @@ static int ipv4_frags_init_net(struct net *net)
return ip4_frags_ctl_register(net);
}

static void ipv4_frags_exit_net(struct net *net)
{
ip4_frags_ctl_unregister(net);
inet_frags_exit_net(&net->ipv4.frags, &ip4_frags);
}

static struct pernet_operations ip4_frags_ops = {
.init = ipv4_frags_init_net,
.exit = ipv4_frags_exit_net,
};

void __init ipfrag_init(void)
{
ipv4_frags_init_net(&init_net);
register_pernet_subsys(&ip4_frags_ops);
ip4_frags.hashfn = ip4_hashfn;
ip4_frags.constructor = ip4_frag_init;
ip4_frags.destructor = ip4_frag_free;
Expand Down
14 changes: 13 additions & 1 deletion net/ipv6/reassembly.c
Original file line number Diff line number Diff line change
Expand Up @@ -728,6 +728,17 @@ static int ipv6_frags_init_net(struct net *net)
return ip6_frags_sysctl_register(net);
}

static void ipv6_frags_exit_net(struct net *net)
{
ip6_frags_sysctl_unregister(net);
inet_frags_exit_net(&net->ipv6.frags, &ip6_frags);
}

static struct pernet_operations ip6_frags_ops = {
.init = ipv6_frags_init_net,
.exit = ipv6_frags_exit_net,
};

int __init ipv6_frag_init(void)
{
int ret;
Expand All @@ -736,7 +747,7 @@ int __init ipv6_frag_init(void)
if (ret)
goto out;

ipv6_frags_init_net(&init_net);
register_pernet_subsys(&ip6_frags_ops);

ip6_frags.hashfn = ip6_hashfn;
ip6_frags.constructor = ip6_frag_init;
Expand All @@ -754,5 +765,6 @@ int __init ipv6_frag_init(void)
void ipv6_frag_exit(void)
{
inet_frags_fini(&ip6_frags);
unregister_pernet_subsys(&ip6_frags_ops);
inet6_del_protocol(&frag_protocol, IPPROTO_FRAGMENT);
}

0 comments on commit 81566e8

Please sign in to comment.