调用inet_hash将对应的socket挂到一个chainlist上
Call treace
1 | inet_listen |
bind的port是通过tcp_hashinfo
里的bhash管理的。
跟tcp client的端口号管理有一样。
注:bind 系统调用时,还不会把当前的socket挂载到listen队列上,需要等待listen系统调用。
bind系统调用只是把对应的这个端口給占用上了, 其他程序没发bind。
inet有些例外,因为inet支持的类型太过复杂(maybe), 所以引入了一个inetsw的链表数组。
就像注释里说的一样。inetsw是inet socket创建的基础,包含创建inet socket全部的所需要信息。
inetsw
1 | 125 /* The inetsw table contains everything that inet_create needs to |
inetsw
是一个链表头的数据,每个链表是具有相同的type的, 具体见socket type.
每个节点是一个struct inet_protosw
. 每个节点是通过net_register_protosw
插入到其type对应的链表里的。
1 | upstream source v4.2+(commit ID:a794b4f). |
1 | 97 struct inet_hashinfo tcp_hashinfo; |
1 | > connect syscall |
There is a important data struct struct inet_hashinfo
其对应的变量是 tcp_hashinfo
.
共包含3部分:
1 | 5.5.1. Bridge Zero Copy Transmit |
内核代码有一个关键数据结构:skb的pkt_type字段。
在收发路径这个域被赋值为PACKET_OUTGOING或者其他。
这个值被传递到往用户空间,libpcap根据它判断报文的方向是否是期望的。
1 | 24 #define PACKET_HOST 0 /* To us */ |
vhost net 的目的是为了避免在host kerne上做一次qemu的调度,提升性能。
xmit: 让vm的数据报在 host的内核就把报文发送出去。
rcv:
vhost_poll
是vhost里最关键的一个数据结构。1 | 27 /* Pol> > file (eventfd or socket) */ |
1 | ==> ipvlan_start_xmit |
1 | ==> ipvlan_start_xmit |
1 | ==> ipvlan_start_xmit |
All the packet are get by the rx_handler
, ipvlan_handle_frame
.
lookup the dest ipvlan port(net_device)
by the dst IPv4/6 address, and send to it.
1 | ==> ipvlan_handle_frame |
1 | ==> ipvlan_handle_frame |
1 | ipvlan_start_xmit |
1 | 308 static const struct net_device_ops ipvlan_netdev_ops = { |
1 | 495 int ipvlan_queue_xmit(struct sk_buff *skb, struct net_device *dev) |
1 | 457 static int ipvlan_xmit_mode_l2(struct sk_buff *skb, struct net_device *dev) |