Linux Kernel Architecture

(Jacob Rumans) #1

Chapter 12: Networks


The fast path code doesn’t bother with processing ACK segments but delegates this task totcp_ack. Here,
obsolete packets and packets sent too early owing to faulty TCP implementations at the receiving end or
to unfortunate combinations of transmission errors and time-outs are filtered out. The most important
tasks of this function are not only to analyze new information on the connection (e.g., on the receiving
window) and on other subtleties of the TCP protocol, but also to delete acknowledged data from the
retransmission queue (discussed below). This queue holds all sent packets and retransmits them if they
are not acknowledged by means of an ACK within a certain time period.

Because it has been established during selection of the packet for fast path handling that the data received
immediately follow the previous segment, the data can be acknowledged by means of an ACK to the
sender without the need for any further checks. Finally, thesk_data_readyfunction pointer stored in the
socket is invoked to inform the user process that new data are available.

What is the difference between the slow path and the fast path? Owing to the many TCP options, the
code in the slow path is more extensive. For this reason, I won’t go into the many special situations that
can arise because they are less of a kernel problemand more of a general problem of TCP connections
(detailed descriptions are available in, e.g., [Ste94] and [WPR+01]).

In the slow path, data cannot be forwarded directly to the socket because complicated packet option
checks are necessary, and these may be followed by potential TCP subsystem responses. Data arriving
out of sequence are placed on a special wait queue, where they remain until a contiguous data segment
is complete. Only then can the complete data be forwarded to the socket.

SendingPackets


As seen from the TCP layer, the sending of TCP packets begins with the invocation of thetcp_sendmsg
function by higher network instances. Figure 12-31 shows the associated code flow diagram.

No connection?

Copy data into socket buffer

tcp_sendmsg

sk_stream_wait_connect

tcp_push_one

tcp_snd_test

update_send_head

tcp_transmit_skb af_specific->queue_xmit

Set resend timer if necessary
Figure 12-31: Code flow diagram fortcp_sendmsg.

Naturally, the state of the socket used must be TCP_ESTABLISHED before data transmission can begin.
If this is not the case, the kernel waits (with the help ofwait_for_tcp_connect) until a connection has
Free download pdf