The kernel provides several functions that are used by higher protocol layers to send data via IP. ip_queue_xmit, whose code flow diagram, shown in Figure 12-18, is the one most frequently used.
The first task is to find a route for the packet. The kernel exploits the fact that all packets originating from a socket have the same destination address so that the route doesn't have to be determined afresh each time. A pointer to the corresponding data structure discussed below is linked with the socket data structure. When the first packet of a socket is sent, the kernel is required to find a new route (discussed below).
Once ip_send_check has generated the checksum for the packet,20 the kernel calls the netfilter hook nf_ip_local_out. The dst_output function is then invoked; it is based on the destination-specific skb->dst->output function of the socket buffer found during routing. Normally, this is ip_output, which is the point where locally generated and forwarded packets are brought together.
Continue reading here: Transition to the Network Access Layer
Was this article helpful?