July 15, 2004
The path of a forwarded packet.
I've just had occasion to figure out (with the help of kgdb) the path a forwarded packet takes through the Linux 2.6 stack. In terms of just called functions, here it is:
netif_receive_skb() from network driver ip_rcv() via packet_type.func ip_rcv_finish() via NF_HOOK(PF_INET, NF_IP_PRE_ROUTING, skb, dev, NULL, ip_rcv_finish); calls ip_route_input() (which calls ip_route_input_slow()) to route packet internally dst_input() directly ip_forward() via skb->dst.input(); set up by ip_route_input_slow() calls xfrm4_policy_check(NULL, XFRM_POLICY_FWD, skb) may drop packet if blocked here calls xfrm4_route_forward(skb) may drop packet if blocked here ip_forward_finish() via NF_HOOK(PF_INET, NF_IP_FORWARD, skb, skb->dev, rt->u.dst.dev, ip_forward_finish); dst_output() ip_output() via skb->dst.output(), op cit ip_finish_output() if no fragmenting needed ip_finish_output2() via NF_HOOK(PF_INET, NF_IP_POST_ROUTING, skb, NULL, dev, ip_finish_output2); ...then device output routine...