5206 /*
5207  *      Initialize the DEV module. At boot time this walks the device list and
5208  *      unhooks any devices that fail to initialise (normally hardware not
5209  *      present) and leaves us with a valid list of present and active devices.
5210  *
5211  */
5212
5213 /*
5214  *       This is called single threaded during boot, so no need
5215  *       to take the rtnl semaphore.
5216  */
5217 static int __init net_dev_init(void)
5218 {
5219         int i, rc = -ENOMEM;
5220
5221         BUG_ON(!dev_boot_phase);
5222
5223         if (dev_proc_init())
5224                 goto out;
5225
5226         if (netdev_kobject_init())
5227                 goto out;
5228
5229         INIT_LIST_HEAD(&ptype_all);
5230         for (i = 0; i < PTYPE_HASH_SIZE; i++)
5231                 INIT_LIST_HEAD(&ptype_base[i]);
5232
5233         if (register_pernet_subsys(&netdev_net_ops))
5234                 goto out;
5235
5236         /*
5237          *      Initialise the packet receive queues.
5238          */
5239
5240         for_each_possible_cpu(i) {
5241                 struct softnet_data *queue;
5242
5243                 queue = &per_cpu(softnet_data, i);
5244                 skb_queue_head_init(&queue->input_pkt_queue);
5245                 queue->completion_queue = NULL;
5246                 INIT_LIST_HEAD(&queue->poll_list);
5247
5248                 queue->backlog.poll = process_backlog;
5249                 queue->backlog.weight = weight_p;
5250                 queue->backlog.gro_list = NULL;
5251                 queue->backlog.gro_count = 0;
5252         }
5253
5254         dev_boot_phase = 0;
5255
5256         /* The loopback device is special if any other network devices
5257          * is present in a network namespace the loopback device must
5258          * be present. Since we now dynamically allocate and free the
5259          * loopback device ensure this invariant is maintained by
5260          * keeping the loopback device as the first device on the
5261          * list of network devices.  Ensuring the loopback devices
5262          * is the first device that appears and the last network device
5263          * that disappears.
5264          */
5265         if (register_pernet_device(&loopback_net_ops))
5266                 goto out;
5267
5268         if (register_pernet_device(&default_device_ops))
5269                 goto out;
5270
5271         open_softirq(NET_TX_SOFTIRQ, net_tx_action);
5272         open_softirq(NET_RX_SOFTIRQ, net_rx_action);
5273
5274         hotcpu_notifier(dev_cpu_callback, 0);
5275         dst_init();
5276         dev_mcast_init();
5277         rc = 0;
5278 out:
5279         return rc;
5280 }
5281
5282 subsys_initcall(net_dev_init);
5283
5284 static int __init initialize_hashrnd(void)
5285 {
5286         get_random_bytes(&skb_tx_hashrnd, sizeof(skb_tx_hashrnd));
5287         return 0;
5288 }
5289
5290 late_initcall_sync(initialize_hashrnd);






Reply via email to