NAPI(New API). NAPI tries to prevent DoS attacks caused by packet floods that make the cpu spin in the hardirq handler. Instead of using
The packet journey goes on with the call to the input method of the
skb which has been positioned in net/ipv4/route.c:ip_route_input() to
one of the following function:
If the routing decided that this packet has to be forwarded to another device, the function net/ipv4/ip_forward.c:ip_forward() is called.
The first task of this function is to check the ip header's TTL. If it is <= 1 we drop the packet and return an ICMP time exceeded message to the sender.
We check the header's tailroom if we have enough tailroom for the destination device's link layer header and expand the skb if neccessary.
Next the TTL is decremented by one.
If our new packet is bigger than the MTU of the destination device and the don't fragment bit in the IP header is set, we drop the packet and send a ICMP frag needed message to the sender.
Finally it is time to call another one of the netfilter hooks - this time it is the NF_IP_FORWARD hook.
Assuming that the netfilter hooks is returning a NF_ACCEPT verdict, the function net/ipv4/ip_forward.c:ip_forward_finish() is the next step in our packet's journey.
ip_forward_finish() itself checks if we need to set any additional options in the IP header, and has and has net/ipv4/ip_options.c:ip_forward_options() doing this. Afterwards it calls include/net/ip.h:ip_send().
If we need some fragmentation, net/ipv4/output.c:ip_fragment() gets called, otherwise we continue in net/ipv4/ip_forward:ip_finish_output().
ip_output() does the NAT process and then calls the netfilter postrouting hook NF_POSTROUTING_HOOK and ip_finish_output2() on successfull traversal of the hook.
ip_finish_output2() calls prepends the hardware (link layer) header to our skb and calls dst->hh->hh_output() which seems to usually be net/core/dev.c:dev_queue_transmit().
dev_queue_xmit() enqueues the packet for transmission by the network device.
Of course I wouldn't have been able to write this document if not lots of other people had influenced me in some way, enabling me to understand all that code in the first place.
I want to list here:
Linus Torvalds, who got us started with that whole thing in the
first place.
Alan Cox, David Miller, Alexey Kuznetsov,
Andi Kleen: The net.gods
Rusty Russell for his great work on netfilter and his help at
LBW2000
Directly contributed to this document have so far:
Alexandre Dagan: <alexandre.dagan@linuxmail.org>