title: Which is the correct way to register a new net_device?
body: <p>i'm trying to register a new <code>net_device</code> in linux...i can alloc and register it correctly and <code>ifconfig</code> shows it. The problem arrives when i try to put the interface up:</p>
  
  <pre><code>ifconfig my_dev up
  </code></pre>
  
  <p>A kernel freeze occurs...the problem is present only on x86 machines and i can't figure out the reason...on a pcc machine all works well. The code is very simple:</p>
  
  <pre><code>static struct net_device *my_dev;
  
  static int veth_dev_init(struct net_device *dev);
  static int veth_open(struct net_device *dev);
  static int veth_close(struct net_device *dev);
  static int veth_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd);
  
  static struct veth_priv
  {
     ...
  };
  
  static struct net_device_ops veth_ops =
  {
    .ndo_init = veth_dev_init,
    .ndo_open = veth_open,
    .ndo_stop = veth_close,
    .ndo_do_ioctl = veth_ioctl
  };
  
  static int __init veth_init()
  {
    my_dev = alloc_netdev(sizeof(struct veth_priv), "my_dev", ether_setup);
    if (my_dev == NULL)
      return -ENOMEM;
  
    my_dev-&gt;netdev_ops = &amp;veth_ops;
  
    register_netdev(my_dev);
    return 0;
  }
  
  static void __exit veth_exit()
  {
    unregister_netdev(my_dev);
    free_netdev(my_dev);
  }
  
  module_init(veth_init);
  module_exit(veth_exit);
  </code></pre>
  
  <p>The first four functions <code>veth_dev_init, veth_open, veth_close</code> and <code>veth_ioctl</code> simply return 0.
  Maybe is there a missing field in <code>veth_ops</code> structure?</p>
  
  <p>Thank you all!</p>