From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-io1-xd2e.google.com (mail-io1-xd2e.google.com [IPv6:2607:f8b0:4864:20::d2e]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.bufferbloat.net (Postfix) with ESMTPS id B78A83B29E for ; Wed, 22 Dec 2021 02:17:26 -0500 (EST) Received: by mail-io1-xd2e.google.com with SMTP id m9so1744499iop.0 for ; Tue, 21 Dec 2021 23:17:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :content-transfer-encoding; bh=UV/8fLTL5xkV2wqdcisZ4Z2Cre9VzUJwDuu4mkLM2pQ=; b=MY5lcKHfFVh65ZFpn7AcPL2sz0VfSJACLpoGo4KquwgcMQ+xW/GHj8yPK08+DR7fam jvYmqrQvVqbE6+R83pZUKXFCDlN+BEw5inDScccFpSrk4863luV8wsGjz/5fcI0RKjug HyZ05JrRzy0U0NVEzHi0In4j7uJODvQQNYC+DleASXvPDi5bch8y7tjTGkSsN8C0GwYC DmuRZDJHn7D5CVtcehh1nJ+UFuMOXxMjhw9lIDpM+I38iSumipSAjacjk1/vMAKKZhHh rAJF8Cm8fQqARcXzdAYOQMFQDLll8+8hRICsZbn29mboFdormkub10KxfZms+SANBO0V L81g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:content-transfer-encoding; bh=UV/8fLTL5xkV2wqdcisZ4Z2Cre9VzUJwDuu4mkLM2pQ=; b=Y2g4TDaMryNvJyXkAP9LGC3jEquUWNiLWiO9nJ5XZPXbMdiOzJnqSbLiugHqvH+zep ek8e6ya7VTFDIcX/lbLx+j5VxBqx9WkzkGlHYUFBWykNW+6hoBFnzI6skMjpHqmIu7do FKGQfeBLwDaBFOotcfiVImnJjvNCVSUINTFqeHvfSv0sYxKYEMAsQGW83I1JjGBDCxjr 7rfQFEaCOG67tqARasBOYYNY1Zfvn9kSjvUOrPV3G0NoR7dUTEri0HUXWT4Aqc9yQ3MQ rqyJakm2+Drnyb8joRgTmF5bsJehwt67Qt4G6fUe3m1htgIYMyx5NXND0PnfSE/SkSJK 7HKA== X-Gm-Message-State: AOAM533uBk/P9cBuuA5Zai7w88RYpd8HRJOG+K1yQoldwtCY0wHGQbOG P9GztXQ4YhuPOk7yI9/KOFndRkvZk6Sf1Q7EIX6dKlsS X-Google-Smtp-Source: ABdhPJx7mgVjmNjCv99n/HPDKkA2q6eVYEBJ31o4S3T50CkZ8eF1v5aV1sO0YAYehCTk5AT1mhpWbRKLRLDzV/AAtJo= X-Received: by 2002:a05:6638:3292:: with SMTP id f18mr891667jav.115.1640157445779; Tue, 21 Dec 2021 23:17:25 -0800 (PST) MIME-Version: 1.0 References: <70428063e99a4418d2e519a496ebd1096d45ac59.1640029579.git.asml.silence@gmail.com> In-Reply-To: <70428063e99a4418d2e519a496ebd1096d45ac59.1640029579.git.asml.silence@gmail.com> From: Dave Taht Date: Tue, 21 Dec 2021 23:17:13 -0800 Message-ID: To: cerowrt-devel Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Subject: [Cerowrt-devel] Fwd: [RFC v2 07/19] ipv6/udp: add support msgdr::msg_ubuf X-BeenThere: cerowrt-devel@lists.bufferbloat.net X-Mailman-Version: 2.1.20 Precedence: list List-Id: Development issues regarding the cerowrt test router project List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 22 Dec 2021 07:17:26 -0000 zerocopy udp ---------- Forwarded message --------- From: Pavel Begunkov Date: Tue, Dec 21, 2021 at 11:16 PM Subject: [RFC v2 07/19] ipv6/udp: add support msgdr::msg_ubuf To: , , Cc: Jakub Kicinski , Jonathan Lemon , David S . Miller , Willem de Bruijn , Eric Dumazet , David Ahern , Jens Axboe , Pavel Begunkov Make ipv6/udp to use ubuf_info passed in struct msghdr if it was specified. Signed-off-by: Pavel Begunkov --- net/ipv6/ip6_output.c | 49 ++++++++++++++++++++++++++++++++----------- 1 file changed, 37 insertions(+), 12 deletions(-) diff --git a/net/ipv6/ip6_output.c b/net/ipv6/ip6_output.c index 2f044a49afa8..822e3894dd3b 100644 --- a/net/ipv6/ip6_output.c +++ b/net/ipv6/ip6_output.c @@ -1452,6 +1452,7 @@ static int __ip6_append_data(struct sock *sk, unsigned int maxnonfragsize, headersize; unsigned int wmem_alloc_delta =3D 0; bool paged, extra_uref =3D false; + bool zc =3D false; skb =3D skb_peek_tail(queue); if (!skb) { @@ -1516,17 +1517,37 @@ static int __ip6_append_data(struct sock *sk, rt->dst.dev->features & (NETIF_F_IPV6_CSUM | NETIF_F_HW_CSUM)) csummode =3D CHECKSUM_PARTIAL; - if (flags & MSG_ZEROCOPY && length && sock_flag(sk, SOCK_ZEROCOPY))= { - uarg =3D msg_zerocopy_realloc(sk, length, skb_zcopy(skb)); - if (!uarg) - return -ENOBUFS; - extra_uref =3D !skb_zcopy(skb); /* only ref on new uarg *= / - if (rt->dst.dev->features & NETIF_F_SG && - csummode =3D=3D CHECKSUM_PARTIAL) { - paged =3D true; - } else { - uarg->zerocopy =3D 0; - skb_zcopy_set(skb, uarg, &extra_uref); + if ((flags & MSG_ZEROCOPY) && length) { + struct msghdr *msg =3D from; + + if (getfrag =3D=3D ip_generic_getfrag && msg->msg_ubuf) { + uarg =3D msg->msg_ubuf; + if (skb_zcopy(skb) && uarg !=3D skb_zcopy(skb)) + return -EINVAL; + + if (rt->dst.dev->features & NETIF_F_SG && + csummode =3D=3D CHECKSUM_PARTIAL) { + paged =3D true; + zc =3D true; + } else { + /* Drop uarg if can't zerocopy, callers sho= uld + * be able to handle it. + */ + uarg =3D NULL; + } + } else if (sock_flag(sk, SOCK_ZEROCOPY)) { + uarg =3D msg_zerocopy_realloc(sk, length, skb_zcopy= (skb)); + if (!uarg) + return -ENOBUFS; + extra_uref =3D !skb_zcopy(skb); /* only ref on new uarg */ + if (rt->dst.dev->features & NETIF_F_SG && + csummode =3D=3D CHECKSUM_PARTIAL) { + paged =3D true; + zc =3D true; + } else { + uarg->zerocopy =3D 0; + skb_zcopy_set(skb, uarg, &extra_uref); + } } } @@ -1717,9 +1738,13 @@ static int __ip6_append_data(struct sock *sk, err =3D -EFAULT; goto error; } - } else if (!uarg || !uarg->zerocopy) { + } else if (!zc) { int i =3D skb_shinfo(skb)->nr_frags; + if (skb_shinfo(skb)->flags & SKBFL_MANAGED_FRAGS) { + err =3D -EFAULT; + goto error; + } err =3D -ENOMEM; if (!sk_page_frag_refill(sk, pfrag)) goto error; -- 2.34.1 --=20 I tried to build a better future, a few times: https://wayforward.archive.org/?site=3Dhttps%3A%2F%2Fwww.icei.org Dave T=C3=A4ht CEO, TekLibre, LLC