下载此文档

路由过程分析.docx


文档分类:高等教育 | 页数:约5页 举报非法文档有奖
1/5
下载提示
  • 1.该资料是网友上传的,本站提供全文预览,预览什么样,下载就什么样。
  • 2.下载该文档所得收入归上传者、原创者。
  • 3.下载的文档,不会出现我们的网址水印。
1/5 下载此文档
文档列表 文档介绍
Document serial number【UU89WT-UU98YT-UU8CB-UUUT-UUT108】
路由过程分析
重要数据结构
struct fib_config {
u8 fc_dst_len; We drop all the packets that has local source
* addresses, because every properly looped back packet
* must have correct destination already attached by output routine.
*
* Such approach solves two big problems:
* 1. Not simplex devices are handled properly.
* 2. IP spoofing attempts are filtered with 100% of guarantee.
*/
非本机发往本机
与本机发往本机的流程相比,非本机发往本机的流程显得比较简单
首先netif_recveive_skb从网卡接收到IP报文,遍历ptype_base列表,调用ip_rcv 进入网络三层
ip_rcv
-> ip_rcv_finish
-> skb_dst (skb) == NULL,故需要走ip_route_input 进行目的路由查找
-> ip_route_input
-> ip_route_input_slow
-> fib_lookup
-> ip_mkroute_input (转发)
-> dst_input
校验函数fib_lookup返回结果,若结果 == RTN_LOCAL表明是发往本机的报文,否则需要转发.
若发往本机:
= net->loopback_dev
= ip_local_deliver
若需要转发:
首先检测是否开启了ip_forward (通过echo 1 > /proc/sys/net/ipv4/ip_forward开启)
ip_mkroute_input
-> __mkroute_input
->
->
-> 加入缓存
故最终
若发往本机,则调用dst_input = [skb_dst(skb)->input] = ip_local_deliver
若需要转发,则调用dst_input = [skb_dst(skb)->input] = ip_forward
而ip_forward又调用dst_output = [skb_dst(skb)->output] = ip_output
内核与用户接口
ip route命令
[***@net/ipv4/]
rtnl_register(PF_INET, RTM_NEWROUTE, inet_rtm_newroute, NULL, NULL); .)
-> notifier_chain_register(...) // 注册通知
[***@net/ipv4/]
inet_rtm_newaddr
-> 给网卡

路由过程分析 来自淘豆网m.daumloan.com转载请标明出处.

相关文档 更多>>
非法内容举报中心
文档信息
  • 页数5
  • 收藏数0 收藏
  • 顶次数0
  • 上传人Mars_H
  • 文件大小73 KB
  • 时间2021-10-30