Commit 1fd3ae8c authored by Pavel Begunkov's avatar Pavel Begunkov Committed by Jakub Kicinski

ipv6/udp: support externally provided ubufs

Teach ipv6/udp how to use external ubuf_info provided in msghdr and
also prepare it for managed frags by sprinkling
skb_zcopy_downgrade_managed() when it could mix managed and not managed
frags.
Signed-off-by: default avatarPavel Begunkov <asml.silence@gmail.com>
Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent c445f31b
...@@ -1542,7 +1542,23 @@ static int __ip6_append_data(struct sock *sk, ...@@ -1542,7 +1542,23 @@ static int __ip6_append_data(struct sock *sk,
rt->dst.dev->features & (NETIF_F_IPV6_CSUM | NETIF_F_HW_CSUM)) rt->dst.dev->features & (NETIF_F_IPV6_CSUM | NETIF_F_HW_CSUM))
csummode = CHECKSUM_PARTIAL; csummode = CHECKSUM_PARTIAL;
if (flags & MSG_ZEROCOPY && length && sock_flag(sk, SOCK_ZEROCOPY)) { if ((flags & MSG_ZEROCOPY) && length) {
struct msghdr *msg = from;
if (getfrag == ip_generic_getfrag && msg->msg_ubuf) {
if (skb_zcopy(skb) && msg->msg_ubuf != skb_zcopy(skb))
return -EINVAL;
/* Leave uarg NULL if can't zerocopy, callers should
* be able to handle it.
*/
if ((rt->dst.dev->features & NETIF_F_SG) &&
csummode == CHECKSUM_PARTIAL) {
paged = true;
zc = true;
uarg = msg->msg_ubuf;
}
} else if (sock_flag(sk, SOCK_ZEROCOPY)) {
uarg = msg_zerocopy_realloc(sk, length, skb_zcopy(skb)); uarg = msg_zerocopy_realloc(sk, length, skb_zcopy(skb));
if (!uarg) if (!uarg)
return -ENOBUFS; return -ENOBUFS;
...@@ -1556,6 +1572,7 @@ static int __ip6_append_data(struct sock *sk, ...@@ -1556,6 +1572,7 @@ static int __ip6_append_data(struct sock *sk,
skb_zcopy_set(skb, uarg, &extra_uref); skb_zcopy_set(skb, uarg, &extra_uref);
} }
} }
}
/* /*
* Let's try using as much space as possible. * Let's try using as much space as possible.
...@@ -1747,13 +1764,14 @@ static int __ip6_append_data(struct sock *sk, ...@@ -1747,13 +1764,14 @@ static int __ip6_append_data(struct sock *sk,
err = -EFAULT; err = -EFAULT;
goto error; goto error;
} }
} else if (!uarg || !uarg->zerocopy) { } else if (!zc) {
int i = skb_shinfo(skb)->nr_frags; int i = skb_shinfo(skb)->nr_frags;
err = -ENOMEM; err = -ENOMEM;
if (!sk_page_frag_refill(sk, pfrag)) if (!sk_page_frag_refill(sk, pfrag))
goto error; goto error;
skb_zcopy_downgrade_managed(skb);
if (!skb_can_coalesce(skb, i, pfrag->page, if (!skb_can_coalesce(skb, i, pfrag->page,
pfrag->offset)) { pfrag->offset)) {
err = -EMSGSIZE; err = -EMSGSIZE;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment