Linux Network Protocol Stack Network Device Management

  

Linux is known for its excellent network management capabilities. Why is Linux so efficient? Let's start with the management of network devices. Why should Linux be managed separately for network devices? This is because. Network devices are involved in many places in the protocol stack. As small as the IP address settings. Up to the update of IP routing. Efficient network device management is indispensable. Separate management of network devices can increase efficiency! Each network device, in Linux, will correspond to a data structure, net_device. From the structure of Linux 2.6.2, the definition of net_device is as follows: struct net_device {//device name, such as the common "ld0&; eth0” and other char name [IFNAMSIZ]; //the beginning of shared memory, End address unsigned long mem_end; /* shared mem end */unsigned long mem_start; /* shared mem start *///I/O base address of network device unsigned long base_addr; /* device I/O address *///The assigned interrupt number is unsigned int irq; /* device IRQ number *///Which port is used on the multiport device unsigned char if_port; /* Selectable AUI, TP,..*///DMA channel unsigned for the device Char dma; /* DMA channel *///state of the device unsigned long state; //next net_devicestruct net_device *next; //initialization function. Int (*init)(struct net_device *dev);struct net_device *next_sched;/* Interface index. Unique device identifier *///The corresponding serial number of the device in the kernel int ifindex; int iflink; //function pointer to get the interface state Struct net_device_stats* (*get_stats)(struct net_device *dev);struct iw_statistics* (*get_wireless_stats)(struct net_device *dev);struct iw_handler_def * wireless_handlers;struct ethtool_ops *ethtool_ops;//Transfer status. Check if the transfer is locked unsigned long trans_start; /* Time (in jiffies) of last Tx *///The most used time is unsigned long last_rx; /* Time of last Rx *///interface flag unsigned short flags; /* interface flags (a la BSD) */unsigned short gflags;unsigned short priv_flags; /* Like 'flags' but invisible to userspace. */unsigned short unused_alignment_fixer; /* Because we need priv_flags,* and we want to be 32- Bit aligned.*/unsigned mtu; /* interface MTU value */unsigned short type; /* interface hardware type */unsigned short hard_header_len; /* hardware hdr length */void *priv; /* pointer to private data */struct Net_device *master; /* Pointer to master device of a group,* which this device is member of.*//* Interface address info. */unsigned char broadcast[MAX_ADDR_LEN]; /* hw bcast add */unsigned char dev_addr[ ,null,null,3],MAX_ADDR_LEN]; /* hw address */unsigned char addr_len; /* hardware address length */struct dev_mc_list *mc_list; /* Multicast mac addresses */int mc_count; /* Number of installed Mcasts */int promiscuity;int allmulti;int watchdog_timeo;struct timer_list watchdog_timer;/* Protocol specific pointers */

void *atalk_ptr; /* AppleTalk link */void *ip_ptr; /* IPv4 specific data */

void *dn_ptr; /* DECnet specific data */void *ip6_ptr; /* IPv6 specific data */void *ec_ptr; /* Econet specific data */void *ax25_ptr; /* AX.25 specific data */struct list_head poll_list; /* Link to poll list */int quota;int weight;struct Qdisc *qdisc;struct Qdisc *qdisc_sleeping;struct Qdisc *qdisc_ingress;struct list_head qdisc_list;unsigned long tx_queue_len; /* Max frames per queue allowed *//* ingress path synchronizer */spinlock_t ingress_lock;/* hard_start_xmit synchronizer */spinlock_t xmit_lock;/* cpu id of processor entered to hard_start_xmit or -1,if nobody entered there.*/int xmit_lock_owner;/* device queue lock * /spinlock_t queue_lock;/* Number of references to this device */atomic_t refcnt;/* delayed register/unregister */struct list_head todo_list;/* device name Hash chain */struct hlist_node name_hlist;/* device index hash chain */struct hlist_node index_hlist;

Copyright © Windows knowledge All Rights Reserved