Chinaunix首页 | 论坛 | 博客
  • 博客访问: 351830
  • 博文数量: 51
  • 博客积分: 916
  • 博客等级: 准尉
  • 技术积分: 539
  • 用 户 组: 普通用户
  • 注册时间: 2008-12-01 15:37
文章分类

全部博文(51)

文章存档

2014年(1)

2012年(49)

2011年(1)

我的朋友

分类: LINUX

2012-08-20 15:47:01

原文:http://blog.sina.com.cn/s/blog_6ab74ccf0100y3n0.html

以下是debug出来的IP报文的行走路径。对理解网络部分可能有一点帮助。

可能不完全。欢迎补遗和更正。

IP报文经由函数路径
帖子给出的是调用树。右面的函数是调用者,左面的是被调用者。<>括号中的是iptables的钩子点。
()括号中的是一些关键动作,比如路由。


转发的报文
(route if need)dev_queue_xmit |
ip_finish_output2 | ip_finish_output | ip_output | ip_dst_output | ip_forward |(PREROUTING)(route) ip_rcv | netif_receive_skb | process_backlog | net_rx_action | __do_softirq | do_softirq | irq_exit | do_IRQ | common_interrupt | cpu_idle | rest_init | start_kernel

(route if need)dev_queue_xmit |
ip_finish_output2 | ip_finish_output | ip_output | ip_dst_output | ip_forward |(PREROUTING)(route) ip_rcv | netif_receive_skb | process_backlog | net_rx_action | __do_softirq | do_softirq | ksoftirqd

转发的报文仅在中断(硬,软)中运行。当机器作为网关时就是这样。


到本机的报文
Non-NAPI
ip_local_deliver_finish |
ip_local_deliver |(route) ip_rcv | netif_receive_skb | process_backlog | net_rx_action | __do_softirq | do_softirq | irq_exit | do_IRQ | common_interrupt | cpu_idle | rest_init | start_kernel

NAPI:
ip_local_deliver_finish |
ip_local_deliver | (route) ip_rcv | netif_receive_skb | e100_poll | net_rx_action | __do_softirq | do_softirq | irq_exit | do_IRQ | common_interrupt | cpu_idle | rest_init | start_kernel

到本机的报文会被APP取走。路径主要函数是tpc_recv msg | inet_recvmsg | sock_recvmsg | sys_recvfrom | sys_recv
, udp_recvmsg | .... 等。


本机发出的报文
(route if need)dev_queue_xmit |
ip_finish_output2 | ip_finish_output | ip_output | ip_dst_output | ip_push_pending_frames | raw_sendmsg | inet_sendmsg | sock_sendmsg | sys_sendmsg | sys_socketcall | sysenter_past_esp
阅读(1879) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~