免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 2151 | 回复: 0
打印 上一主题 下一主题

[函数] IP报文经由函数路径 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2007-06-06 09:42 |只看该作者 |倒序浏览
IP报文经由函数路径。还是发在这里,看程序的人多。对读KERNEL网络部分程序会有帮助的。
(原来发在linux 网络问题 上)

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

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

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


转发的报文
(route if need)dev_queue_xmit |
ip_finish_output2 | <POSTROUTING> ip_finish_output | ip_output | ip_dst_output |<FORWARD> 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 | <POSTROUTING> ip_finish_output | ip_output | ip_dst_output |<FORWARD> ip_forward |(PREROUTING)(route) ip_rcv | netif_receive_skb | process_backlog | net_rx_action | __do_softirq | do_softirq | ksoftirqd

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



到本机的报文
ip_local_deliver_finish |
<LOCALIN> ip_local_deliver |<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

ip_local_deliver_finish |
<LOCALIN> ip_local_deliver | <PREROUTING>(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_recvmsg | inet_recvmsg | sock_recvmsg | sys_recvfrom | sys_recv
, udp_recvmsg | .... 等。


本机发出的报文
(route if need)dev_queue_xmit |
ip_finish_output2 |<POSTROUTING> ip_finish_output | ip_output | ip_dst_output | <LOCALOUT> ip_push_pending_frames | raw_sendmsg | inet_sendmsg | sock_sendmsg | sys_sendmsg | sys_socketcall | sysenter_past_esp
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP