Results 1 to 1 of 1
Thread: tcp_sendmsg() vs. tcp_sendpage()
Enjoy an ad free experience by logging in. Not a member yet? Register.
- Join Date
- Feb 2009
tcp_sendmsg() vs. tcp_sendpage()
I have one question about tcp_sendmsg() vs. tcp_sendpage().
When tcp_sendpage() tries to allocate a new skb, it will call sk_stream_alloc_pskb(sk, 0, 0, sk->sk_allocation). So initially the new skb will have a data buffer big enough only for L2~L4 headers and skb_shinfo. Then tcp_sendpage() will store user data's page info directly into skb_shinfo(skb)->frags.
In contrast, when tcp_sendmsg() tries to allocate a new skb, it will call sk_stream_alloc_pskb(sk, select_size(sk, tp), 0, sk->sk_allocation). So if the outbound interface supports scatter/gather but not gso, the new skb initially will have a page-sized data buffer that will be used to store some of the tcp payload. If the input data len is greater than a page, tcp_sendmsg() will create a skb with some tcp payload in the main skb buffer and the rest of the payload in page frames pointed by skb_shinfo(skb)->frags. Why is it done this way instead of in the same way as tcp_sendpage()? I thought storing tcp payload only in page frames and storing the page info into skb_shinfo(skb)->frags will facilitate breaking tcp payload into segments later by avoiding extra data copies. Am I missing something?