Linux Network Stack Walkthrough (2.4.20)


The following is a walkthrough of the routines in the Linux 2.4.20 network stack, focusing on IP networking. I've written this up in an attempt to understand in some detail the functioning of the Linux networking code. The walkthrough follows the sequence of function calls that occur for received and locally-generated network traffic. The analysis walks through each function, giving a short description of the functionality provided by each successive clause (related group of lines), and indicating which routines are called from within the function. Corresponding line numbers are listed for each clause; the Linux source code can be conveniently inspected using the Linux Cross Reference website. This document thus provides a sort of annotated reference to the source code. It's still a work-in-progress, so additional explanation will be added; in particular, question-marks are an indication that more description needs to be added for an indicated clause. I hope to eventually add a more discursive discussion, with overviews at different levels of detail.




Received traffic:

Core (layer 2, protocol-independent) receive routines:



Question??? Why loop through poll list? Seems like only one item could ever be on list, which is processor's softnet_data blog_dev???


Note: when searching for packet handler in ptype list, always "one behind" in search loop (pt_prev)


IP (layer 3) receive routines:



Routing (received packets):



Local delivery:




Forwarding:



Output:

IP (layer 3) output routines:




Core (layer 2) output routines:





Locally generated traffic:


UDP (layer 4) send routines:


IP (layer 3) send routines:


Routing (locally-generated packets):








Bridging code:












To do: