Messages in this thread Patch in this message | | | From | Joe Damato <> | Subject | [RFC,net-next v2 8/8] net: tcp: Support MSG_NTCOPY | Date | Sun, 12 Jun 2022 01:57:57 -0700 |
| |
Support non-temporal copies in the TCP sendmsg path. Previously, the only way to enable non-temporal copies was to enable them for the entire interface (via ethtool).
This change allows user programs to request non-temporal copies for specific sendmsg calls.
Signed-off-by: Joe Damato <jdamato@fastly.com> --- include/net/sock.h | 2 +- net/ipv4/tcp.c | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-)
diff --git a/include/net/sock.h b/include/net/sock.h index 0063e84..b666ecd 100644 --- a/include/net/sock.h +++ b/include/net/sock.h @@ -2200,7 +2200,7 @@ static inline int skb_do_copy_data_nocache(struct sock *sk, struct sk_buff *skb, if (!csum_and_copy_from_iter_full(to, copy, &csum, from)) return -EFAULT; skb->csum = csum_block_add(skb->csum, csum, offset); - } else if (sk->sk_route_caps & NETIF_F_NOCACHE_COPY) { + } else if (sk->sk_route_caps & NETIF_F_NOCACHE_COPY || iov_iter_copy_is_nt(from)) { if (!copy_from_iter_full_nocache(to, copy, from)) return -EFAULT; } else if (!copy_from_iter_full(to, copy, from)) diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c index 14ebb4e..5b36e00 100644 --- a/net/ipv4/tcp.c +++ b/net/ipv4/tcp.c @@ -1201,6 +1201,8 @@ int tcp_sendmsg_locked(struct sock *sk, struct msghdr *msg, size_t size) flags = msg->msg_flags; + msg_set_iter_copy_type(msg); + if (flags & MSG_ZEROCOPY && size && sock_flag(sk, SOCK_ZEROCOPY)) { skb = tcp_write_queue_tail(sk); uarg = msg_zerocopy_realloc(sk, size, skb_zcopy(skb)); -- 2.7.4
| |