diff options
author | Eric W. Biederman <ebiederm@xmission.com> | 2009-11-29 10:46:16 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2009-12-01 19:15:59 -0500 |
commit | 671011720baa222b6de667cd688aed4dc8908924 (patch) | |
tree | 1eebe8867121b00223d811be897fdc9fa4682b04 /net/ipv6/sit.c | |
parent | ac31cd3cbadc45d6ed2a0ae5d116918b15bb6c22 (diff) |
net: Simplify ipip6 aka sit pernet operations.
Take advantage of the new pernet automatic storage management,
and stop using compatibility network namespace functions.
Signed-off-by: Eric W. Biederman <ebiederm@xmission.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ipv6/sit.c')
-rw-r--r-- | net/ipv6/sit.c | 25 |
1 files changed, 6 insertions, 19 deletions
diff --git a/net/ipv6/sit.c b/net/ipv6/sit.c index d9deaa7753ef..976e68244b99 100644 --- a/net/ipv6/sit.c +++ b/net/ipv6/sit.c | |||
@@ -1164,17 +1164,8 @@ static void sit_destroy_tunnels(struct sit_net *sitn, struct list_head *head) | |||
1164 | 1164 | ||
1165 | static int sit_init_net(struct net *net) | 1165 | static int sit_init_net(struct net *net) |
1166 | { | 1166 | { |
1167 | struct sit_net *sitn = net_generic(net, sit_net_id); | ||
1167 | int err; | 1168 | int err; |
1168 | struct sit_net *sitn; | ||
1169 | |||
1170 | err = -ENOMEM; | ||
1171 | sitn = kzalloc(sizeof(struct sit_net), GFP_KERNEL); | ||
1172 | if (sitn == NULL) | ||
1173 | goto err_alloc; | ||
1174 | |||
1175 | err = net_assign_generic(net, sit_net_id, sitn); | ||
1176 | if (err < 0) | ||
1177 | goto err_assign; | ||
1178 | 1169 | ||
1179 | sitn->tunnels[0] = sitn->tunnels_wc; | 1170 | sitn->tunnels[0] = sitn->tunnels_wc; |
1180 | sitn->tunnels[1] = sitn->tunnels_l; | 1171 | sitn->tunnels[1] = sitn->tunnels_l; |
@@ -1201,37 +1192,33 @@ err_reg_dev: | |||
1201 | dev_put(sitn->fb_tunnel_dev); | 1192 | dev_put(sitn->fb_tunnel_dev); |
1202 | free_netdev(sitn->fb_tunnel_dev); | 1193 | free_netdev(sitn->fb_tunnel_dev); |
1203 | err_alloc_dev: | 1194 | err_alloc_dev: |
1204 | /* nothing */ | ||
1205 | err_assign: | ||
1206 | kfree(sitn); | ||
1207 | err_alloc: | ||
1208 | return err; | 1195 | return err; |
1209 | } | 1196 | } |
1210 | 1197 | ||
1211 | static void sit_exit_net(struct net *net) | 1198 | static void sit_exit_net(struct net *net) |
1212 | { | 1199 | { |
1213 | struct sit_net *sitn; | 1200 | struct sit_net *sitn = net_generic(net, sit_net_id); |
1214 | LIST_HEAD(list); | 1201 | LIST_HEAD(list); |
1215 | 1202 | ||
1216 | sitn = net_generic(net, sit_net_id); | ||
1217 | rtnl_lock(); | 1203 | rtnl_lock(); |
1218 | sit_destroy_tunnels(sitn, &list); | 1204 | sit_destroy_tunnels(sitn, &list); |
1219 | unregister_netdevice_queue(sitn->fb_tunnel_dev, &list); | 1205 | unregister_netdevice_queue(sitn->fb_tunnel_dev, &list); |
1220 | unregister_netdevice_many(&list); | 1206 | unregister_netdevice_many(&list); |
1221 | rtnl_unlock(); | 1207 | rtnl_unlock(); |
1222 | kfree(sitn); | ||
1223 | } | 1208 | } |
1224 | 1209 | ||
1225 | static struct pernet_operations sit_net_ops = { | 1210 | static struct pernet_operations sit_net_ops = { |
1226 | .init = sit_init_net, | 1211 | .init = sit_init_net, |
1227 | .exit = sit_exit_net, | 1212 | .exit = sit_exit_net, |
1213 | .id = &sit_net_id, | ||
1214 | .size = sizeof(struct sit_net), | ||
1228 | }; | 1215 | }; |
1229 | 1216 | ||
1230 | static void __exit sit_cleanup(void) | 1217 | static void __exit sit_cleanup(void) |
1231 | { | 1218 | { |
1232 | xfrm4_tunnel_deregister(&sit_handler, AF_INET6); | 1219 | xfrm4_tunnel_deregister(&sit_handler, AF_INET6); |
1233 | 1220 | ||
1234 | unregister_pernet_gen_device(sit_net_id, &sit_net_ops); | 1221 | unregister_pernet_device(&sit_net_ops); |
1235 | rcu_barrier(); /* Wait for completion of call_rcu()'s */ | 1222 | rcu_barrier(); /* Wait for completion of call_rcu()'s */ |
1236 | } | 1223 | } |
1237 | 1224 | ||
@@ -1246,7 +1233,7 @@ static int __init sit_init(void) | |||
1246 | return -EAGAIN; | 1233 | return -EAGAIN; |
1247 | } | 1234 | } |
1248 | 1235 | ||
1249 | err = register_pernet_gen_device(&sit_net_id, &sit_net_ops); | 1236 | err = register_pernet_device(&sit_net_ops); |
1250 | if (err < 0) | 1237 | if (err < 0) |
1251 | xfrm4_tunnel_deregister(&sit_handler, AF_INET6); | 1238 | xfrm4_tunnel_deregister(&sit_handler, AF_INET6); |
1252 | 1239 | ||