//more = skb_shinfo(skb)->tso_segs,由tcp传递
1.1 static inline void ip_select_ident_more(struct iphdr *iph, struct dst_entry *dst, struct sock *sk, int more)
{
if (iph->frag_off & htons(IP_DF)) {//禁止分片
if (sk && inet_sk(sk)->daddr) {
iph->id = htons(inet_sk(sk)->id);//使用sock中指定的id
inet_sk(sk)->id += 1 + more;//sock中id递增
} else
iph->id = 0;
} else
__ip_select_ident(iph, dst, more);//可分片ip报文选择id
}
//调用路径ip_select_ident_more->__ip_select_ident
//函数主要任务:
// 1.处理路由项与inet_peer的绑定
// 2.通过inet_peer,或者全局ip_fallback_id获取id
1.2 void __ip_select_ident(struct iphdr *iph, struct dst_entry *dst, int more)
{
struct rtable *rt = (struct rtable *) dst;
if (rt) {//存在到目的地址的路由
if (rt->peer == NULL)//inet_peer结构,表示该缓存路由项的目的ip地址对应的主机
rt_bind_peer(rt, 1);//寻找和该端点相匹配的inet_peer结构,如果不存在,尝试创建一个新的inet_peer
if (rt->peer) {//通过inet_peer的计数器&#
网络子系统49_ip协议报头id选取
最新推荐文章于 2024-04-29 05:15:40 发布
本文详细介绍了Linux内核如何为IP协议报头选择ID,包括处理禁止分片的情况、通过`inet_peer`结构获取ID以及在没有路由项时使用静态变量`ip_fallback_id`。主要涉及`ip_select_ident_more`和`__ip_select_ident`函数,以及它们如何与`inet_getid`协作来确保递增且唯一的ID。
摘要由CSDN通过智能技术生成