Monday 10 July 2017

Network Subsystem initialization call flow in linux

Network subsystem in Linux /net/core/dev.c file

1.  net_dev_init()(Initialize the DEV module. At boot time this walks the device list and unhooks any devices that fail to initialise (normally hardware not present) and leaves us with a valid list of present and active devices.)
     1. dev_proc_init() it is dedine in /net/core/net_procfs.c it create poc file system of network dev,statistic, softnet and pakctes.
     2. netdev_kobject_init() it initilize network attribute of network device.
     3.  register_pernet_subsys() it initilize the network queues
     4. skb_queue_head_init() it's initialize input packet queue for each CPU.
     http://elixir.free-electrons.com/linux/latest/source/include/linux/netdevice.h#L2755
       struct softnet_data {
     struct list_head    poll_list;
     struct sk_buff_head    process_queue;

    /* stats */
    unsigned int        processed;
    unsigned int        time_squeeze;
    unsigned int        received_rps;
  #ifdef CONFIG_RPS
    struct softnet_data    *rps_ipi_list;
 #endif
 #ifdef CONFIG_NET_FLOW_LIMIT
    struct sd_flow_limit __rcu *flow_limit;
 #endif
    struct Qdisc        *output_queue;
    struct Qdisc        **output_queue_tailp;
    struct sk_buff        *completion_queue;

 #ifdef CONFIG_RPS
    /* input_queue_head should be written by cpu owning this struct,
     * and only read by other cpus. Worth using a cache line.
     */
    unsigned int        input_queue_head ____cacheline_aligned_in_smp;

    /* Elements below can be accessed between CPUs for RPS/RFS */
    struct call_single_data    csd ____cacheline_aligned_in_smp;
    struct softnet_data    *rps_ipi_next;
    unsigned int        cpu;
    unsigned int        input_queue_tail;
 #endif
    unsigned int        dropped;
    struct sk_buff_head    input_pkt_queue;
    struct napi_struct    backlog;

 };
     5. skb_queue_head_init() it initialize process queue for each CPU.
     6. register_pernet_device(&loopback_net_ops) (The loopback device is special if any other network devices is present in a network namespace the loopback device must be present. Since we now dynamically allocate and free the
      loopback device ensure this invariant is maintained by keeping the loopback device as the first device on the  list of network devices.  Ensuring the loopback devices is the first device that appears and the last network device that disappears.)
     7. register_pernet_device(&default_device_ops). Initialize default device operations.
     8.open_softirq(NET_TX_SOFTIRQ, net_tx_action) and open_softirq(NET_RX_SOFTIRQ, net_rx_action). Register Tx and Rx soft IQR for network subsystem.
     9.dst_subsys_init() It register netowrk netifier call back functions.
   
   
    

No comments:

Post a Comment