// 向raw sock传递skb
// 步骤:
// 1.根据协议号获取监听指定protocol的sock
// 2.向raw sock传递skb
1.1 int raw_local_deliver(struct sk_buff *skb, int protocol)
{
int hash;
struct sock *raw_sk;
//获取监听指定协议的raw sock
hash = protocol & (RAW_HTABLE_SIZE - 1);
raw_sk = sk_head(&raw_v4_hashinfo.ht[hash]);
//向raw socket传递
if (raw_sk && !raw_v4_input(skb, ip_hdr(skb), hash))
raw_sk = NULL;
return raw_sk != NULL;
}
// 向raw sock传递skb
// 步骤:
// 1.获取raw sock链表, 查找可接收此skb的sock
// 1.1 如果raw sock指定了协议号,源地址,目的地址,设备号,则逐项匹配
// 2.向sock传递skb的拷贝
1.2 static int raw_v4_input(struct sk_buff *skb, const struct iphdr *iph, int hash)
{
struct sock *sk;
struct hlist_head *head;
int delivered = 0;
struct net *net;
read_lock(&raw_v4_hashinfo.lock);
head = &raw_v4_hashinfo.ht[hash];
if (hlist_empty(head))
goto out;
net = dev_net(skb->dev);
sk = __raw_v4_lookup(net, __sk_he
网络子系统82_inet协议族-SOCK_RAW(三)
最新推荐文章于 2022-08-10 14:37:07 发布