Delivery to the Transport Layer

Let us go back to ip_local_deliver. After packet defragmentation, the netfilter hook nf_ip_local_in is called to resume processing in ip_local_deliver_finish.

There the packet is passed to a transport layer function that must first be determined by reference to the protocol identifier. All protocols based on the IP layer have an instance of the structure net_protocol that is defined as follows:

include/net/protocol.h struct net_protocol { int void

□ handler is the protocol routine to which the packets are passed (in the form of socket buffers) for further processing.

□ err_handler is invoked when an ICMP error message is received and needs to be passed to higher levels.

The inet_add_protocol standard function is used to store each instance in the inet_protos array that maps the protocols onto the individual list positions using a hashing method.

Once the IP header has been "removed" by means of the usual pointer manipulations in the socket buffer, all that remains to be done is to invoke the corresponding receive routine of the network access layer stored in the handler field of inet_protocol, for example, the tcp_v4_rcv routine to receive TCP packets and udp_rcv to receive UDP packets. Section 12.9 examines the implementation of these functions.

fragment cache uses a timer mechanism to remove fragments from the cache. When it expires, fragments in the cache are deleted if not all fragments have arrived by then.

Continue reading here: Packet Forwarding

Was this article helpful?

0 0