http://lxr.free-electrons.com/source/net/core/dev.c#L52225164 /* 5165 * This is called single threaded during boot, so no need 5166 * to take the rtnl semaphore. 5167 */ 5168 static int __init net_dev_init(void) 5169 { 5170 int i, rc = -ENOMEM; 5171 5172 BUG_ON(!dev_boot_phase); 5173 5174 if (dev_proc_init()) 5175 goto out; 5176 5177 if (netdev_kobject_init()) 5178 goto out; 5179 5180 INIT_LIST_HEAD(&ptype_all); 5181 for (i = 0; i < PTYPE_HASH_SIZE; i++) 5182 INIT_LIST_HEAD(&ptype_base[i]); 5183 5184 if (register_pernet_subsys(&netdev_net_ops)) 5185 goto out; 5186 5187 /* 5188 * Initialise the packet receive queues. 5189 */ 5190 5191 for_each_possible_cpu(i) { 5192 struct softnet_data *queue; 5193 5194 queue = &per_cpu(softnet_data, i); 5195 skb_queue_head_init(&queue->input_pkt_queue); 5196 queue->completion_queue = NULL; 5197 INIT_LIST_HEAD(&queue->poll_list); 5198 5199 queue->backlog.poll = process_backlog; 5200 queue->backlog.weight = weight_p; 5201 queue->backlog.gro_list = NULL; 5202 } 5203 5204 dev_boot_phase = 0; 5205 5206 /* The loopback device is special if any other network devices 5207 * is present in a network namespace the loopback device must 5208 * be present. Since we now dynamically allocate and free the 5209 * loopback device ensure this invariant is maintained by 5210 * keeping the loopback device as the first device on the 5211 * list of network devices. Ensuring the loopback devices 5212 * is the first device that appears and the last network device 5213 * that disappears. 5214 */ 5215 if (register_pernet_device(&loopback_net_ops)) 5216 goto out; 5217 5218 if (register_pernet_device(&default_device_ops)) 5219 goto out; 5220 5221 open_softirq(NET_TX_SOFTIRQ, net_tx_action); 5222 open_softirq(NET_RX_SOFTIRQ, net_rx_action); 5223 5224 hotcpu_notifier(dev_cpu_callback, 0); 5225 dst_init(); 5226 dev_mcast_init(); 5227 rc = 0; 5228 out: 5229 return rc; 5230 } |