aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/loopback.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/net/loopback.c')
-rw-r--r--drivers/net/loopback.c26
1 files changed, 21 insertions, 5 deletions
diff --git a/drivers/net/loopback.c b/drivers/net/loopback.c
index f3018bb7570d..0f9d8c60c964 100644
--- a/drivers/net/loopback.c
+++ b/drivers/net/loopback.c
@@ -57,6 +57,7 @@
57#include <linux/ip.h> 57#include <linux/ip.h>
58#include <linux/tcp.h> 58#include <linux/tcp.h>
59#include <linux/percpu.h> 59#include <linux/percpu.h>
60#include <net/net_namespace.h>
60 61
61struct pcpu_lstats { 62struct pcpu_lstats {
62 unsigned long packets; 63 unsigned long packets;
@@ -252,7 +253,7 @@ static void loopback_setup(struct net_device *dev)
252} 253}
253 254
254/* Setup and register the loopback device. */ 255/* Setup and register the loopback device. */
255static int __init loopback_init(void) 256static int loopback_net_init(struct net *net)
256{ 257{
257 struct net_device *dev; 258 struct net_device *dev;
258 int err; 259 int err;
@@ -262,12 +263,13 @@ static int __init loopback_init(void)
262 if (!dev) 263 if (!dev)
263 goto out; 264 goto out;
264 265
266 dev->nd_net = net;
265 err = register_netdev(dev); 267 err = register_netdev(dev);
266 if (err) 268 if (err)
267 goto out_free_netdev; 269 goto out_free_netdev;
268 270
269 err = 0; 271 err = 0;
270 loopback_dev = dev; 272 net->loopback_dev = dev;
271 273
272out: 274out:
273 if (err) 275 if (err)
@@ -279,7 +281,21 @@ out_free_netdev:
279 goto out; 281 goto out;
280} 282}
281 283
282fs_initcall(loopback_init); 284static void loopback_net_exit(struct net *net)
285{
286 struct net_device *dev = net->loopback_dev;
287
288 unregister_netdev(dev);
289}
290
291static struct pernet_operations loopback_net_ops = {
292 .init = loopback_net_init,
293 .exit = loopback_net_exit,
294};
295
296static int __init loopback_init(void)
297{
298 return register_pernet_device(&loopback_net_ops);
299}
283 300
284struct net_device *loopback_dev; 301fs_initcall(loopback_init);
285EXPORT_SYMBOL(loopback_dev);