TCP报文GSO分段的入口函数是tcp4_gso_segment,在tcpv4_offload对象中定义。
1、tcp4_gso_segment函数
static struct sk_buff *tcp4_gso_segment(struct sk_buff *skb,
netdev_features_t features)
{
if (!pskb_may_pull(skb, sizeof(struct tcphdr)))
return ERR_PTR(-EINVAL);
if (unlikely(skb->ip_summed != CHECKSUM_PARTIAL)) {
const struct iphdr *iph = ip_hdr(skb);
struct tcphdr *th = tcp_hdr(skb); //ip层报文保证了transport header值
/* Set up checksum pseudo header, usually expect stack to
* have done this already.
*/
th->check = 0;
skb->ip_summed = CHECKSUM_PARTIAL;
__tcp_v4_send_check(skb, iph->saddr, iph->daddr); //计算伪头check值
}
return tcp_gso_segment(skb, features); //TCP GSO分段
}
2、tcp_gso_segment函数
struct sk_buff *tcp_gso_segment(struct sk_buff *skb,
netdev_features_t features)
{
struct sk_buff *segs = ERR_PTR(-EINVAL);
unsigned int sum_truesize = 0;
struct tcphd

本文深入剖析Linux4.1.12内核中TCP报文的GSO(Giant Segment Offload)分段技术,主要关注tcp4_gso_segment函数。该函数在tcpv4_offload结构中,负责处理二层报文的分段工作,以优化网络传输效率。
最低0.47元/天 解锁文章
8345

被折叠的 条评论
为什么被折叠?



