/*
* The loopback device is special. There is only one instance
* per network namespace.
*/
static void loopback_setup(struct net_device *dev)
{
dev->mtu = (16 * 1024) + 20 + 20 + 12;
dev->flags = IFF_LOOPBACK;
dev->header_ops = ð_header_ops;
dev->netdev_ops = &loopback_ops;
}
/* Setup and register the loopback device. */
static int loopback_net_init(struct net *net)
{
struct net_device *dev;
//1.
dev = alloc_netdev(0, "lo", loopback_setup);
//4.
register_netdev(dev);
net->loopback_dev = dev;
return 0;
}
/* Registered in net/core/dev.c */
struct pernet_operations __net_initdata loopback_net_ops = {
.init = loopback_net_init,
.exit = loopback_net_exit,
};