• tcp/ip 发包时,函数调用:从 tcp_connect() 到 __dev_queue_xmit()


    tcp_connect()
          --> tcp_transmit_skb()		# tcp_output.c // actually transmits TCP packets queued in by tcp_do_sendmsg().
            --> icsk->icsk_af_ops->queue_xmit	# kernel/net/ipv4/tcp_output.c	( .queue_xmit = ip_queue_xmit )
            --> ip_queue_xmit()			# kernel/net/ipv4/ip_output.c
    *         --> ip_local_out()			# kernel/net/ipv4/ip_output.c
                --> __ip_local_out()		# kernel/net/ipv4/ip_output.c	//调用netfilter,返回值为1说明允许报文通过
                  --> nf_hook()			# kernel/include/linux/netfilter.h
                    --> nf_hook_thresh()		# kernel/include/linux/netfilter.h 
    						  Returns 1 if the hook has allowed the packet to pass.
    ip_forward    --> dst_output()			# kernel/include/net/dst.h
                    --> skb_dst(skb)->output(net, sk, skb)	# kernel/include/net/dst.h	// //实际调用 ip_output 函数
    *               --> ip_output()			# kernel/net/ipv4/ip_output.c
                      --> ip_finish_output()	# kernel/net/ipv4/ip_output.c
    *                   --> ip_finish_output2()	# kernel/net/ipv4/ip_output.c
    *                     --> dst_neigh_output()	# kernel/include/net/dst.h
                            --> neigh_hh_output()		# kernel/include/net/neighbour.h //支持硬件缓存头方法的发送
                              --> dev_queue_xmit()		# kernel/net/core/dev.c
                            --> n->output()			# //不支持硬件缓存头的方法的发送
    *                         --> neigh_resolve_output()	# kernel/net/core/neighbour.c
                                --> neigh_event_send()	# kernel/include/net/neighbour.h
                                  --> __neigh_event_send()	# kernel/net/core/neighbour.c
    *                               --> neigh_probe()	# kernel/net/core/neighbour.c
                                      --> neigh->ops->solicit # 实际调用 arp_solicit 函数,该函数会发送 arp 请求
    *                                 --> arp_solicit()	# kernel/net/ipv4/arp.c
    *                                   --> arp_send_dst()	# kernel/net/ipv4/arp.c // Create and send an arp packet.
    *                                     --> arp_create()	# kernel/net/ipv4/arp.c
    *                                     --> arp_xmit()	# kernel/net/ipv4/arp.c
    *                                       --> arp_xmit_finish()	# kernel/net/ipv4/arp.c
    *                                         --> dev_queue_xmit()		# kernel/net/core/dev.c
                                                --> __dev_queue_xmit()	# kernel/net/core/dev.c
                                --> dev_queue_xmit()	# kernel/net/core/dev.c
    *                             --> __dev_queue_xmit()	# kernel/net/core/dev.c
    *                               --> __dev_xmit_skb()	# kernel/net/core/dev.c
    
                            -->  neigh_update()		# kernel/net/core/neighbour.c
                              --> neigh_connect(neigh);	# 修改output函数为neigh_connected_output
                              --> n1->output(n1, skb);	# 调用neigh的output函数,此时已经改成connect函数
                                --> neigh_connected_output() # kernel/net/core/neighbour.c
                                  --> dev_queue_xmit()	# kernel/net/core/dev.c
    


  • 相关阅读:
    CCF认证201809-2买菜
    git删除本地保存的账号和密码
    mysql表分区
    使用java代码将时间戳和时间互相转换
    Mysql数据库表被锁定处理
    mysql查询某个数据库表的数量
    编译nginx错误:make[1]: *** [/pcre//Makefile] Error 127
    LINUX下安装pcre出现WARNING: 'aclocal-1.15' is missing on your system错误的解决办法
    linux下安装perl
    [剑指Offer]26-树的子结构
  • 原文地址:https://www.cnblogs.com/ztguang/p/12644473.html
Copyright © 2020-2023  润新知