- rcu的介绍: Paul McKenney, Linux Journal
- rx 网卡收到报文之后的处理:
int netif_receive_skb(struct sk_buff *skb) { trace_netif_receive_skb_entry(skb); return netif_receive_skb_internal(skb); } EXPORT_SYMBOL(netif_receive_skb);
- 网络初始化的时候二层网上投递根据二层的protocol进行相对应的处理,比如ipv4的入口就是
ip_rcv
这个函数/* inet_init 函数中 */ dev_add_pack(&ip_packet_type);
所以各种类型的注册可以跟着上面的注册函数去找即可。
- 网桥的设置函数: br_dev_setup, 里面有函数指针各种ops(ethtool, net_dev_ops)的对接。
- 网桥的删除: br_dev_delete,先删除port后清理fdb,最后停掉gc,删除/sys文件系统相关。
- ip_rcv之后处理分本地投递和转发两个路径,对应函数为: ip_local_deliver ip_forward
rth->u.dst.input = ip_forward; rth->u.dst.output = ip_output;
还是挂接好函数指针,后面在 dst_output这样的函数中直接call。
决定路由的函数: ip_route_input 就会得到对应的函数指针,并设置skb->dst字段。
还有本地投递的处理函数
int ip_local_deliver(struct sk_buff *skb) static inline int ip_local_deliver_finish(struct sk_buff *skb)
- egress路径: ip_queue_xmit tcp发送路径会调这个函数。
函数的最后的Netfilter hook:
return NF_HOOK(PF_INET, NF_IP_LOCAL_OUT, skb, NULL, rt->u.dst.dev, dst_output);
- 中断BH处理softirq注册函数
open_softirq(NET_TX_SOFTIRQ, net_tx_action, NULL); open_softirq(NET_RX_SOFTIRQ, net_rx_action, NULL);
- 二层cache: 在dst_entry中会有指针最终指向二层headercache,因为二层比较死,很多场景不必一次次拼装,只需要拿cache过来用好了,比如一个场景:到网关 的二层信息基本上不变。
- task_struct
- 指向父进程的指针: parent
struct task_struct *parent; /* parent process */
- chilren列表:
struct list_head children; /* list of my children */ struct list_head sibling; /* linkage in my parent's children list */
- 兄弟进程列表:
struct list_head sibling; /* linkage in my parent's children list */
- 所有进程串呀串:
struct list_head tasks;
- 指向父进程的指针: parent
- 发送处理
int ip_queue_xmit(struct sk_buff *skb, int ipfragok) 查找路由,找到然后增加3层头信息,最终经典的NF_HOOK return NF_HOOK(PF_INET, NF_IP_LOCAL_OUT, skb, NULL, rt->u.dst.dev, dst_output); int ip_route_output_flow(struct rtable **rp, struct flowi *flp, struct sock *sk, int flags) 处理rawsocket情况 static int raw_sendmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg, size_t len)