Linux Kernel Architecture

(Jacob Rumans) #1

Chapter 12: Networks


protocols. Changes are apparent, however, when data are passed to the IP layer. Figure 12-22 shows a
(coarse-grained) code flow diagram for IPv6 implementation.

ipv6_rcv

ip6_input_finish

Routing

Forwarding
ip6_forward

Transport Layer (TCP, UDP)

Host to Host Layer (Ethernet, etc.)

Netfilter:
NF_IP6_PRE_ROUTING

Netfilter:
NF_IP6_LOCAL_IN

Netfilter:
NF_IP6_LOCAL_OUT

Netfilter:
Poll Mechanism NF_IP6_FORWARD

Netfilter:
NF_IP6_POST_ROUTING

ip6_output

ip6_xmit

Routing

Figure 12-22: Code flow diagram for IPv6 implementation.

As the diagram shows, the structural changes between version 4 and version 6 are minor. Although the
function names are different, the code follows more or less the same path through the kernel. For reasons
of space, the implementation details are not discussed.^24

12.9 Transport Layer


Two main IP-based transport protocols are used— UDP to send datagrams, and TCP to set up secure,
connection-oriented services. Whereas UPD is a simple, easily implemented protocol, TCP has several
well-concealed (but nevertheless well-known) booby traps and stumbling blocks that make implementa-
tion all the more complex.

12.9.1 UDP


As explained in the previous section,ip_local_deliverdistributes the transport data contents of IP
packets.udp_rcvfromnet/ipv4/udp.cis used to further process UDP datagram packets. The associated
code flow diagram is shown in Figure 12-23.

udp_rcvis just a wrapper function for__udp4_lib_rcvsince the code is shared with the implementation
of the UDP-lite protocol as defined in RFC 3828.

As usual, the input parameter passed to the function is a socket buffer. Once it has been established
that the packet data are intact, it is necessary to find a listening socket using__udp4_lib_lookup.The
connection parameters can be derived from the UDP header, whose structure is shown in Figure 12-24.

(^24) Note that the names of the netfilter hooks will be changed in the same manner as noted for IPv4 in kernel 2.6.25, which was still
under development when this book was written. The constants will not be prefixedNF_IP6_anymore, but instead byNFINET.
The same set of constants is thus used for IPv4 and IPv6.

Free download pdf