Linux内核网络协议栈笔记

Linux内核网络协议栈笔记

参考文献《Understanding Linux Network Internals》中用了整整一章(part II)来介绍system initialization。本文只提供一个简单的概述,如果需要详细信息,还请看参考文献。

我们这里所说的初始化过程指的是从硬件加电启动,到可以从网络接收或发送数据包之前的过程。在Linux系统中,网卡拥有双重身份:struct pci_dev和struct net_device。pci_dev对象代表通用硬件的性质,是作为一个标准的PCI的设备插入了PCI的卡槽,由驱动程序进行管理;另一方面,net_device对象代表网络传输的性质,与内核的网络协议栈交互,进行数据传输。因此我们也必须通过两个方面来进行初始化,但是后者是我们的重点。而且我们并不关心内核与硬件的交互细节,例如寄存器读写与I/O映射等。

内核在初始化时,也会初始化一些与网络相关的数据结构;而且对应我们前面的日志所提及的内核网络协议栈层次结构(点这里),内核也需要一定的初始化工作来建立这种层次结构。

笔者认

void __init sock_init(void )
{
    //Initialize sock SLAB cache.

     sk_init();
    //Initialize skbuff SLAB cache 

     skb_init();
    //Initialize the protocols module. 

     init_inodecache();
     register_filesystem(&
sock_fs_type);
     sock_mnt = kern_mount(&
sock_fs_type);
    //The real protocol initialization is performed when do_initcalls is run.  

     netfilter_init();
}

为初始化最重要的就是重要数据结构(通常用粗体标注)。因此也希望读者能够记住重要的数据结构的作用。

下面我们将分层,自底向上的分析整个初始化过程:

(一)驱动程序层

本文中以一个realtek 8139系列网卡作为例子,因为其驱动只有一个c文件(/drivers/net/8139too.c),比较容易分析。读者也可以参考e1000网卡的另一篇文章(点这里)。内核版本基于2.6.11。

驱动程序加载/注册主要包括以下的步骤:

(a)将设备驱动程序(pci_driver)添加到内核驱动程序链表中;

(b)调用每个驱动中的probe函数(其中重要一步就是初始化net_device对象)。

下面进行详细分解。

通常,在Linux中使用insmod命令加载一个驱动程序模块,例如8139too.o目标文件。加载之后,Linux会默认执行模块中的module_init(rtl8139_init_module)宏函数,其中的参数rtl8139_init_module是一个函数指针,指向在具体的驱动程序8139too.o中声明的rtl8139_init_module函数。这个函数定义如下:

static int __init rtl8139_init_module (void )
return pci_module_init (&rtl8139_pci_driver); }

pci_module_init是一个宏定义,实际上就等于pci_register_driver函数。(在2.6.30内核版本中,直接变成了return pci_register_driver(&rtl8139_pci_driver) )。pci_register_driver函数的注释说明了它的作用:register a new pci driver.Adds the driver structure to the list of registered drivers。也就是把如下的这样一个驱动程序(pci_driver类型)挂到系统的驱动程序链表中:

static struct pci_driver rtl8139_pci_driver =  {
.name   =
 DRV_NAME,
.id_table =
 rtl8139_pci_tbl,
.probe   =
 rtl8139_init_one,
.remove   =
 __devexit_p(rtl8139_remove_one),
#ifdef CONFIG_PM
.suspend =
 rtl8139_suspend,
.resume   =
 rtl8139_resume,
#endif /* CONFIG_PM */

};

这一步我们应该这样理解(熟悉面向对象编程的读者):所有的pci_driver应该提供一致的接口(比如remove卸载/suspend挂起);但是这些接口的每个具体实现是不同的(pci声卡和pci显卡的挂起应该是不同的),所以采用了这样的函数指针结构。这个pci_driver结构其中最重要的就是probe函数指针,指向rtl8139_init_one,具体后面会解释。
但是pci_register_driver并不仅仅完成了注册驱动这个任务,它内部调用了driver_register函数(/drivers/base/driver.c中):

int driver_register(struct device_driver *  drv)
{
INIT_LIST_HEAD(&drv->
devices);
init_MUTEX_LOCKED(&drv->
unload_sem);
return
 bus_add_driver(drv);
}

前两个就是实现了添加到链表的功能,bus_add_driver才是主要的函数(/drivers/base/bus.c中),内部又调用了driver_attach函数,这个函数的主体是一个list_for_each循环,对链表中的每一个成员调用driver_probe_device函数(哈哈,出现了probe!),这个函数就调用了drv->probe(dev)(drv就是pci_driver类型的对象)!这样也就调用了驱动程序中的probe函数指针,也就是调用了rtl8139_init_one函数。

函数rtl8139_init_one的主要作用就是给net_device对象分配空间(分配空间由函数rtl8139_init_board完成)并初始化。分配空间主要是内存空间。分配的资源包括I/O端口,内存映射(操作系统基本概念,请自行google)的地址范围以及IRQ中断号等。而初始化主要是设置net_device对象中的各个成员变量及成员函数,其中比较重要的是hard_start_xmit(通过硬件发送数据)/poll(轮询)/open(启动)等函数(粗体标注),代码如下:

static int __devinit rtl8139_init_one (struct pci_dev *pdev, const struct pci_device_id * ent)
{
    struct net_device *dev =
 NULL;
     rtl8139_init_board (pdev, &
dev);
/* The Rtl8139-specific entries in the device structure. */

         dev
->open =  rtl8139_open;
         dev->hard_start_xmit =
 rtl8139_start_xmit;
         dev->poll =
 rtl8139_poll;
         dev->stop =
 rtl8139_close;
         dev->do_ioctl =
 netdev_ioctl;
}

整个的调用链如下:pci_register_driver ==> driver_register ==> bus_add_driver ==> driver_attach ==> driver_probe_device ==> drv->probe ==> rtl8139_init_one(生成net_device)

一个简单的net_device生命周期示意图如下(左边为初始化,右边为卸载):

Linux内核网络协议栈笔记2:初始化 - englishman2008 - 孤蓬万里征

这个net_device数据结构的生成,标志着网络硬件和驱动程序层初始化完毕。也意味着,网络协议栈与硬件之间的纽带已经建立起来。

(二)设备无关层/网络协议层/协议无关接口socket层

Linux内核在启动后所执行的一些内核函数如下图所示:

Linux内核网络协议栈笔记2:初始化 - englishman2008 - 孤蓬万里征

系统初始化的过程中会调用do_basic_setup函数进行一些初始化操作。其中2.6.11内核中就直接包括了driver_init()驱动程序初始化,以及sock_init函数初始化socket层。然后do_initcalls()函数调用一组前缀为__init类型(这个宏就表示为需要在系统初始化时执行)的函数。与网络相关的以__init宏标记的函数有:net_dev_init初始化设备无关层;inet_init初始化网络协议层。

(fs_initcall和module_init这两个宏也具有类似的作用。由于这一阶段处于系统初始化,宏定义比较多,欲详细了解各种宏的使用的读者请参阅参考文献《Understanding Linux Network Internals》Part II Chapter 7)

我们下面详细介绍一下这三个初始化函数都进行了哪些工作。

(a)net_dev_init(在文件/net/core/dev.c中):设备操作层

static int __init net_dev_init(void )
{
    if
 (dev_proc_init())
    if
 (netdev_sysfs_init())
     INIT_LIST_HEAD(&
ptype_all);
    
    for (i = 0; i < 16; i++

         INIT_LIST_HEAD(&
ptype_base[i]);
    for (i = 0; i < ARRAY_SIZE(dev_name_head); i++
)
         INIT_HLIST_HEAD(&
dev_name_head[i]);
    for (i = 0; i < ARRAY_SIZE(dev_index_head); i++
)
         INIT_HLIST_HEAD(&
dev_index_head[i]);

    //Initialise the packet receive queues.

    for (i = 0; i < NR_CPUS; i++ ) {
        struct softnet_data *
queue;

         queue = &
per_cpu(softnet_data, i);
         skb_queue_head_init(&queue->
input_pkt_queue);
         queue->throttle = 0
;
         queue->cng_level = 0
;
         queue->avg_blog = 10; /* arbitrary non-zero */

         queue
->completion_queue =  NULL;
         INIT_LIST_HEAD(&queue->
poll_list);
         set_bit(__LINK_STATE_START, &queue->
backlog_dev.state);
         queue->backlog_dev.weight =
 weight_p;
         queue->backlog_dev.poll =
 process_backlog;
         atomic_set(&queue->backlog_dev.refcnt, 1
);
     }

     open_softirq(NET_TX_SOFTIRQ, net_tx_action, NULL);
     open_softirq(NET_RX_SOFTIRQ, net_rx_action, NULL);
}

这个函数所做的具体工作主要包括:初始化softnet_data这个数据结构(每个CPU都有一个这样的队列,表示要交给此CPU处理的数据包);注册网络相关软中断(参见我关于软中断的文章,点这里)。

(b)inet_init(在文件/net/ipv4/af_inet.c中):网络层

由于各种网络协议是按照协议族(protocol family,PF或者address family,AF)为单位组织起来的。我们在这里仅以Internet协议族(AF_INET或者PF_INET,在内核中这二者是等价的)为例。

有时候这一层又被称为INET socket层(对应的数据结构为struct sock),请注意与BSD socket层区别(对应数据结构为struct socket):BSD socket层提供一组统一的接口,与协议无关;但具体到网络层就必须与协议相关了,因此操作也会有一些不同。

代码如下(有删节):

static int __init inet_init(void )
{
    struct sk_buff *
dummy_skb;
    struct inet_protosw *
q;
    struct list_head *
r;

     rc = sk_alloc_slab(&tcp_prot, "tcp_sock"
);
     rc = sk_alloc_slab(&udp_prot, "udp_sock"
);
     rc = sk_alloc_slab(&raw_prot, "raw_sock"
);

    //Tell SOCKET that we are aliveLinux内核网络协议栈笔记2:初始化 - englishman2008 - 孤蓬万里征 

       (void)sock_register(& inet_family_ops);

    //Add all the base protocols.

    if (inet_add_protocol(&udp_protocol, IPPROTO_UDP) < 0 );
    if (inet_add_protocol(&tcp_protocol, IPPROTO_TCP) < 0
);

    /* Register the socket-side information for inet_create. */

    
for (r = &inetsw[0]; r < &inetsw[SOCK_MAX]; ++ r)
         INIT_LIST_HEAD(r);
    for (q = inetsw_array; q < &inetsw_array[INETSW_ARRAY_LEN]; ++
q)
        inet_register_protosw(q);

    //Set the ARP module up

     arp_init();
      //Set the IP module up

     ip_init();
     tcp_v4_init(&
inet_family_ops);
    /* Setup TCP slab cache for open requests. */

     tcp_init();
    
    
//dev_add_pack(&ip_packet_type);
}
module_init(inet_init);

这个函数中包括的主要函数包括:

sock_register:在以前的文章中说过,Linux内核网络协议栈采用了分层结构,所以层与层之间肯定是松耦合的。上层的socket层并不知道下面的网络协议层都具体包括哪些协议。因此本函数有两个作用:(a)周知INET协议族;(b)注册到socket模块上。

inet_add_protocol:在协议族中添加具体的协议。

inet_register_protosw:各种inet协议族中的协议在内核中是保存在inetsw_array[]数组,其中元素为inet_protosw类型(/include/net/protocol.h文件中),每一个元素对应一个协议。每一个协议又有两个数据结构:struct proto/struct proto_ops。这两个结构中都是一些函数操作,但proto表示每个协议独特的操作,而proto_ops是通用的socket操作(包含在struct socket中);这种区别就类似于INET socket和BSD socket的区别。

(c)sock_init(在文件/net/socket.c中):BSD socket层

定义如下(代码有删节):

此函数主要执行的工作是:初始化socksk_buff数据结构(这些重要的数据结构在后面的文章中还会涉及);由于sock属于linux文件系统的一部分,因此要注册成为文件系统;以及如果使用netfilter,也要进行初始化。

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
深入理解Linux网络内幕(英文) If you've ever wondered how Linux carries out the complicated tasks assigned to it by the IP protocols -- or if you just want to learn about modern networking through real-life examples -- "Understanding Linux Network Internals" is for you. Like the popular O'Reilly book, "Understanding the Linux Kernel," this book clearly explains the underlying concepts and teaches you how to follow the actual C code that implements it. Although some background in the TCP/IP protocols is helpful, you can learn a great deal from this text about the protocols themselves and their uses. And if you already have a base knowledge of C, you can use the book's code walkthroughs to figure out exactly what this sophisticated part of the Linux kernel is doing. Part of the difficulty in understanding networks -- and implementing them -- is that the tasks are broken up and performed at many different times by different pieces of code. One of the strengths of this book is to integrate the pieces and reveal the relationships between far-flung functions and data structures. "Understanding Linux Network Internals" is both a big-picture discussion and a no-nonsense guide to the details of Linux networking. Topics include: Key problems with networking Network interface card (NIe device drivers System initialization Layer 2 (link-layer) tasks and implementation Layer 3 (IPv4) tasks and implementation Neighbor infrastructure and protocols (ARP) Bridging Routing ICMP Author Christian Benvenuti, an operating system designer specializing in networking, explains much more than how Linux code works. He shows the purposes of major networking features and the trade-offs involved inchoosing one solution over another. A large number of flowcharts and other diagrams enhance the book's understandability. Part I: General Background 背景知识 Chapter 1. Introduction 简介 Section 1.1. Basic Terminology 基础技术 Section 1.2. Common Coding Patterns 通用程序模式 Section 1.3. User-Space Tools 用户空间的工具 Section 1.4. Browsing the Source Code 浏览代码 Section 1.5. When a Feature Is Offered as a Patch 一些特性什么时候以补丁的形式提供 Chapter 2. Critical Data Structures 重要数据结构 Section 2.1. The Socket Buffer: sk_buff Structure 套接字缓存:sk_buff结构 Section 2.2. net_device Structure net_device结构 Section 2.3. Files Mentioned in This Chapter 本章所涉及的到的(代码)文件 Chapter 3. User-Space-to-Kernel Interface 从用户空间到内核态的接口 Section 3.1. Overview 简介 Section 3.2. procfs Versus sysctl Section 3.3. ioctl Section 3.4. Netlink 网络链接 Section 3.5. Serializing Configuration Changes 不断的配置变化 Part II: System Initialization 系统初始化 Chapter 4. Notification Chains (消息)通知链 Section 4.1. Reasons for Notification Chains 通知链的原因 Section 4.2. Overview 简介 Section 4.3. Defining a Chain 定义一个链 Section 4.4. Registering with a Chain 注册链 Section 4.5. Notifying Events on a Chain 在链上标记事件 Section 4.6. Notification Chains for the Networking Subsystems 网络子层的标记链 Section 4.7. Tuning via /proc Filesystem Section 4.8. Functions and Variables Featured in This Chapter 本章所涉及的到的函数与变量 Section 4.9. Files and Directories Featured in This Chapter 本章所涉及的到的(代码)文件 Chapter 5. Network Device Initialization 网络设备的组织 Section 5.1. System Initialization Overview 简介 Section 5.2. Device Registration and Initialization 设备注册与初始化 Section 5.3. Basic Goals of NIC Initialization NIC初始化的基本目标 Section 5.4. Interaction Between Devices and Kernel 设备与内核的交互 Section 5.5. Initialization Options 初始化选项 Section 5.6. Module Options 模块选项 Section 5.7. Initializing the Device Handling Layer: net_dev_init 设备处理层的初始化 Section 5.8. User-Space Helpers 用户空间的帮助 Section 5.9. Virtual Devices 虚拟设备 Section 5.10. Tuning via /proc Filesystem Section 5.11. Functions and Variables Featured in This Chapter Section 5.12. Files and Directories Featured in This Chapter Chapter 6. The PCI Layer and Network Interface Cards PCI层的网卡 Section 6.1. Data Structures Featured in This Chapter 本章的数据结构 Section 6.2. Registering a PCI NIC Device Driver PIC NIC设备驱动的注册 Section 6.3. Power Management and Wake-on-LAN 电源管理以及LAN唤醒 Section 6.4. Example of PCI NIC Driver Registration 示例 Section 6.5. The Big Picture 框架图 Section 6.6. Tuning via /proc Filesystem Section 6.7. Functions and Variables Featured in This Chapter Section 6.8. Files and Directories Featured in This Chapter Chapter 7. Kernel Infrastructure for Component Initialization 组件初始化的底层内核(实现) Section 7.1. Boot-Time Kernel Options 内核启动选项 Section 7.2. Module Initialization Code 模块初始化 Section 7.3. Optimized Macro-Based Tagging 基于标记的模块优化 Section 7.4. Boot-Time Initialization Routines 启动时的初始化例程 Section 7.5. Memory Optimizations 内存优化 Section 7.6. Tuning via /proc Filesystem Section 7.7. Functions and Variables Featured in This Chapter Section 7.8. Files and Directories Featured in This Chapter Chapter 8. Device Registration and Initialization 设备的注册与初始化 Section 8.1. When a Device Is Registered 什么时候注册一个设备 Section 8.2. When a Device Is Unregistered Section 8.3. Allocating net_device Structures 给XX结构分配内存 Section 8.4. Skeleton of NIC Registration and Unregistration NIC注册与反注册的框架 Section 8.5. Device Initialization 设备初始化 Section 8.6. Organization of net_device Structures XX结构的组织 Section 8.7. Device State 设备状态 Section 8.8. Registering and Unregistering Devices Section 8.9. Device Registration Section 8.10. Device Unregistration Section 8.11. Enabling and Disabling a Network Device 网络设备的使能与去使能 Section 8.12. Updating the Device Queuing Discipline State 更新设备的?? Section 8.13. Configuring Device-Related Information from User Space 从用户空间配置与设备相关的信息 Section 8.14. Virtual Devices Section 8.15. Locking 查找 Section 8.16. Tuning via /proc Filesystem Section 8.17. Functions and Variables Featured in This Chapter Section 8.18. Files and Directories Featured in This Chapter Part III: Transmission and Reception 传输与接收 Chapter 9. Interrupts and Network Drivers 网络设备的中断 Section 9.1. Decisions and Traffic Direction 数据流的方向与决策 Section 9.2. Notifying Drivers When Frames Are Received 在数据帧接收到时通知驱动 Section 9.3. Interrupt Handlers 中断处理 Section 9.4. softnet_data Structure XX数据结构 Chapter 10. Frame Reception 帧接收 Section 10.1. Interactions with Other Features 与其它特性交互 Section 10.2. Enabling and Disabling a Device 设备的使能与去使能 Section 10.3. Queues 队列 Section 10.4. Notifying the Kernel of Frame Reception: NAPI and netif_rx 帧接收时通知内核 Section 10.5. Old Interface Between Device Drivers and Kernel: First Part of netif_rx 内核到设备驱动之间的老的接口 Section 10.6. Congestion Management 阻塞管理 Section 10.7. Processing the NET_RX_SOFTIRQ: net_rx_action Chapter 11. Frame Transmission 帧传输 Section 11.1. Enabling and Disabling Transmissions Chapter 12. General and Reference Material About Interrupts 中断的常识和和参考 Section 12.1. Statistics 统计 Section 12.2. Tuning via /proc and sysfs Filesystems Section 12.3. Functions and Variables Featured in This Part of the Book Section 12.4. Files and Directories Featured in This Part of the Book Chapter 13. Protocol Handlers 协议处理 Section 13.1. Overview of Network Stack Section 13.2. Executing the Right Protocol Handler Section 13.3. Protocol Handler Organization Section 13.4. Protocol Handler Registration Section 13.5. Ethernet Versus IEEE 802.3 Frames Section 13.6. Tuning via /proc Filesystem Section 13.7. Functions and Variables Featured in This Chapter Section 13.8. Files and Directories Featured in This Chapter Part IV: Bridging 网桥 Chapter 14. Bridging: Concepts Section 14.1. Repeaters, Bridges, and Routers 中继器,网桥和路由器 Section 14.2. Bridges Versus Switches 网桥与交换机 Section 14.3. Hosts 服务器 Section 14.4. Merging LANs with Bridges 聚合LAN和网桥 Section 14.5. Bridging Different LAN Technologies Section 14.6. Address Learning 寻址 Section 14.7. Multiple Bridges 多网桥 Chapter 15. Bridging: The Spanning Tree Protocol 网桥,生成树协议 Section 15.1. Basic Terminology 基础技术 Section 15.2. Example of Hierarchical Switched L2 Topology 分级交换机的二层拓扑示例 Section 15.3. Basic Elements of the Spanning Tree Protocol 生成树协议的基本元素 Section 15.4. Bridge and Port IDs 网桥和端口ID Section 15.5. Bridge Protocol Data Units (BPDUs) 交换机协议数据单元 Section 15.6. Defining the Active Topology Section 15.7. Timers 计时器 Section 15.8. Topology Changes Section 15.9. BPDU Encapsulation Section 15.10. Transmitting Configuration BPDUs Section 15.11. Processing Ingress Frames Section 15.12. Convergence Time 时间收敛 Section 15.13. Overview of Newer Spanning Tree Protocols Chapter 16. Bridging: Linux Implementation 桥接:Linux的实现 Section 16.1. Bridge Device Abstraction Section 16.2. Important Data Structures Section 16.3. Initialization of Bridging Code Section 16.4. Creating Bridge Devices and Bridge Ports Section 16.5. Creating a New Bridge Device Section 16.6. Bridge Device Setup Routine Section 16.7. Deleting a Bridge Section 16.8. Adding Ports to a Bridge Section 16.9. Enabling and Disabling a Bridge Device Section 16.10. Enabling and Disabling a Bridge Port Section 16.11. Changing State on a Bridge Port Section 16.12. The Big Picture Section 16.13. Forwarding Database Section 16.14. Handling Ingress Traffic Section 16.15. Transmitting on a Bridge Device Section 16.16. Spanning Tree Protocol (STP) Section 16.17. netdevice Notification Chain Chapter 17. Bridging: Miscellaneous Topics 桥接:其它的主题 Section 17.1. User-Space Configuration Tools Section 17.2. Tuning via /proc Filesystem Section 17.3. Tuning via /sys Filesystem Section 17.4. Statistics Section 17.5. Data Structures Featured in This Part of the Book Section 17.6. Functions and Variables Featured in This Part of the Book Section 17.7. Files and Directories Featured in This Part of the Book Part V: Internet Protocol Version 4 (IPv4) IP协议(V4) Chapter 18. Internet Protocol Version 4 (IPv4): Concepts Section 18.1. IP Protocol: The Big Picture Section 18.2. IP Header Section 18.3. IP Options Section 18.4. Packet Fragmentation/Defragmentation Section 18.5. Checksums Chapter 19. Internet Protocol Version 4 (IPv4): Linux Foundations and Features Section 19.1. Main IPv4 Data Structures Section 19.2. General Packet Handling Section 19.3. IP Options Chapter 20. Internet Protocol Version 4 (IPv4): Forwarding and Local Delivery Section 20.1. Forwarding Section 20.2. Local Delivery Chapter 21. Internet Protocol Version 4 (IPv4): Transmission Section 21.1. Key Functions That Perform Transmission Section 21.2. Interface to the Neighboring Subsystem Chapter 22. Internet Protocol Version 4 (IPv4): Handling Fragmentation Section 22.1. IP Fragmentation Section 22.2. IP Defragmentation Chapter 23. Internet Protocol Version 4 (IPv4): Miscellaneous Topics Section 23.1. Long-Living IP Peer Information Section 23.2. Selecting the IP Header's ID Field Section 23.3. IP Statistics Section 23.4. IP Configuration Section 23.5. IP-over-IP Section 23.6. IPv4: What's Wrong with It? Section 23.7. Tuning via /proc Filesystem Section 23.8. Data Structures Featured in This Part of the Book Section 23.9. Functions and Variables Featured in This Part of the Book Section 23.10. Files and Directories Featured in This Part of the Book Chapter 24. Layer Four Protocol and Raw IP Handling Section 24.1. Available L4 Protocols Section 24.2. L4 Protocol Registration Section 24.3. L3 to L4 Delivery: ip_local_deliver_finish Section 24.4. IPv4 Versus IPv6 Section 24.5. Tuning via /proc Filesystem Section 24.6. Functions and Variables Featured in This Chapter Section 24.7. Files and Directories Featured in This Chapter Chapter 25. Internet Control Message Protocol (ICMPv4) Section 25.1. ICMP Header Section 25.2. ICMP Payload Section 25.3. ICMP Types Section 25.4. Applications of the ICMP Protocol Section 25.5. The Big Picture Section 25.6. Protocol Initialization Section 25.7. Data Structures Featured in This Chapter Section 25.8. Transmitting ICMP Messages Section 25.9. ICMP Statistics Section 25.10. Passing Error Notifications to the Transport Layer Section 25.11. Tuning via /proc Filesystem Section 25.12. Functions and Variables Featured in This Chapter Section 25.13. Files and Directories Featured in This Chapter Part VI: Neighboring Subsystem Chapter 26. Neighboring Subsystem: Concepts Section 26.1. What Is a Neighbor? Section 26.2. Reasons That Neighboring Protocols Are Needed Section 26.3. Linux Implementation Section 26.4. Proxying the Neighboring Protocol Section 26.5. When Solicitation Requests Are Transmitted and Processed Section 26.6. Neighbor States and Network Unreachability Detection (NUD) Chapter 27. Neighboring Subsystem: Infrastructure Section 27.1. Main Data Structures Section 27.2. Common Interface Between L3 Protocols and Neighboring Protocols Section 27.3. General Tasks of the Neighboring Infrastructure Section 27.4. Reference Counts on neighbour Structures Section 27.5. Creating a neighbour Entry Section 27.6. Neighbor Deletion Section 27.7. Acting As a Proxy Section 27.8. L2 Header Caching Section 27.9. Protocol Initialization and Cleanup Section 27.10. Interaction with Other Subsystems Section 27.11. Interaction Between Neighboring Protocols and L3 Transmission Functions Section 27.12. Queuing Chapter 28. Neighboring Subsystem: Address Resolution Protocol (ARP) Section 28.1. ARP Packet Format Section 28.2. Example of an ARP Transaction Section 28.3. Gratuitous ARP Section 28.4. Responding from Multiple Interfaces Section 28.5. Tunable ARP Options Section 28.6. ARP Protocol Initialization Section 28.7. Initialization of a neighbour Structure Section 28.8. Transmitting and Receiving ARP Packets Section 28.9. Processing Ingress ARP Packets Section 28.10. Proxy ARP Section 28.11. Examples Section 28.12. External Events Section 28.13. ARPD Section 28.14. Reverse Address Resolution Protocol (RARP) Section 28.15. Improvements in ND (IPv6) over ARP (IPv4) Chapter 29. Neighboring Subsystem: Miscellaneous Topics Section 29.1. System Administration of Neighbors Section 29.2. Tuning via /proc Filesystem Section 29.3. Data Structures Featured in This Part of the Book Section 29.4. Files and Directories Featured in This Part of the Book Part VII: Routing Chapter 30. Routing: Concepts Section 30.1. Routers, Routes, and Routing Tables Section 30.2. Essential Elements of Routing Section 30.3. Routing Table Section 30.4. Lookups Section 30.5. Packet Reception Versus Packet Transmission Chapter 31. Routing: Advanced Section 31.1. Concepts Behind Policy Routing Section 31.2. Concepts Behind Multipath Routing Section 31.3. Interactions with Other Kernel Subsystems Section 31.4. Routing Protocol Daemons Section 31.5. Verbose Monitoring Section 31.6. ICMP_REDIRECT Messages Section 31.7. Reverse Path Filtering Chapter 32. Routing: Li nux Implementation Section 32.1. Kernel Options Section 32.2. Main Data Structures Section 32.3. Route and Address Scopes Section 32.4. Primary and Secondary IP Addresses Section 32.5. Generic Helper Routines and Macros Section 32.6. Global Locks Section 32.7. Routing Subsystem Initialization Section 32.8. External Events Section 32.9. Interactions with Other Subsystems Chapter 33. Routing: The Routing Cache Section 33.1. Routing Cache Initialization Section 33.2. Hash Table Organization Section 33.3. Major Cache Operations Section 33.4. Multipath Caching Section 33.5. Interface Between the DST and Calling Protocols Section 33.6. Flushing the Routing Cache Section 33.7. Garbage Collection Section 33.8. Egress ICMP REDIRECT Rate Limiting Chapter 34. Routing: Routing Tables Section 34.1. Organization of Routing Hash Tables Section 34.2. Routing Table Initialization Section 34.3. Adding and Removing Routes Section 34.4. Policy Routing and Its Effects on Routing Table Definitions Chapter 35. Routing: Lookups Section 35.1. High-Level View of Lookup Functions Section 35.2. Helper Routines Section 35.3. The Table Lookup: fn_hash_lookup Section 35.4. fib_lookup Function Section 35.5. Setting Functions for Reception and Transmission Section 35.6. General Structure of the Input and Output Routing Routines Section 35.7. Input Routing Section 35.8. Output Routing Section 35.9. Effects of Multipath on Next Hop Selection Section 35.10. Policy Routing Section 35.11. Source Routing Section 35.12. Policy Routing and Routing Table Based Classifier Chapter 36. Routing: Miscellaneous Topics Section 36.1. User-Space Configuration Tools Section 36.2. Statistics Section 36.3. Tuning via /proc Filesystem Section 36.4. Enabling and Disabling Forwarding Section 36.5. Data Structures Featured in This Part of the Book Section 36.6. Functions and Variables Featured in This Part of the Book Section 36.7. Files and Directories Featured in This Part of the Book About the Authors Colophon Index
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值