Linux: network :创建raw socket的时候
创建socket的函数packet_create,会注册一个 packet_rcv相关的回调函数。
这个函数负责将packet,skb的对象,放到socket queue里。在BPF过滤之后。
/*
* This function makes lazy skb cloning in hope that most of packets
* are discarded by BPF.
*
* Note tricky part: we DO mangle shared skb! skb->data, skb->len
* and skb->cb are mangled. It works because (and until) packets
* falling here are owned by current CPU. Output packets are cloned
* by dev_queue_xmit_nit(), input packets are processed by net_bh
* sequencially, so that if we return skb to original state on exit,
* we will not harm anyone.
*/
如果注册的是arp层的raw socket,最终二层ARP的处理是通过遍历ptype,会顺序调用arp_rcv/arp_process来完成neigbor的更新等操作ÿ