Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp4529809pxj; Wed, 12 May 2021 07:35:31 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzV6fic67eA9tWDMyPseaDZSWiDCjpo0qC23sjd8BbHF9+xR49MZPjs6z9sBFN0ApTyyMBW X-Received: by 2002:a05:6512:33c4:: with SMTP id d4mr26123874lfg.536.1620830131456; Wed, 12 May 2021 07:35:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620830131; cv=none; d=google.com; s=arc-20160816; b=U+L3lCt6nZUV+agd03tAqUL2AvpBDP8JJDB5AB2nhsZd0utXtKVjKjQ8ABerZPSv57 WxbK0GB1OJVi8DLyer8j+Vw767P3qjrywc29A7gCuXLnZ6b9VL5CfW1mg5d9cVr5ujtF 0zk761dPgn+vpFv7VujcM3KJtn1B1ypDgpSncNdKB7vr4HUV/fRDEuu8TkRmB9seH0iA 07iNgOpAdy9sgZ1DxpzNMBMdQ1rKOeU/c0ofKGdaZQSEUHelDFRfnvHr9LkUiybx9z4H Ny8S7nnOJZkeAPxOkUerMDhvjMddTlcSVI8YlQjpeCiLR4cRh3H4+LdzYuEHloy6wQcg UGEA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=v8nnd2ujlB60GPiA1lPsUn5BttskeOt6aee1p1TS5NI=; b=R+cGhyEXd4pye+zeE35kxz/19hClukYZGRYjNB/AB1rj14GtPvjc/QspPDQPE+sDEi f6kth6Rel798vr6dY6lbPrkRpo/iGnSZ0q90yAPoqOGD5e6pq51tutb5HKvAVCuuZlTt dudTPMFk8Hko7FzK+yxm8z2nnTLwOxhaJue0aykbpZz4keoGG1gZ02CHCc1e5b6Dwn7s 41CwLV3sKarO86JgVTnAZ18O+i6KjKTVwZpuIekOkgpj/BEf3kkn/J9f2kKryK6RAGJb 1m52vR4eHJwnvlm7oBQvfKRh/NyVknv3NXN3yw7Mlobf9o165YGQLT8YeUnH6+FgmqI4 IWuQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=Wpp5b+dJ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id k5si94907lfu.569.2021.05.12.07.35.01; Wed, 12 May 2021 07:35:31 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=Wpp5b+dJ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230429AbhELOea (ORCPT + 99 others); Wed, 12 May 2021 10:34:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34916 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230370AbhELOe3 (ORCPT ); Wed, 12 May 2021 10:34:29 -0400 Received: from mail-ed1-x532.google.com (mail-ed1-x532.google.com [IPv6:2a00:1450:4864:20::532]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 07228C061574 for ; Wed, 12 May 2021 07:33:21 -0700 (PDT) Received: by mail-ed1-x532.google.com with SMTP id s6so27297523edu.10 for ; Wed, 12 May 2021 07:33:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=v8nnd2ujlB60GPiA1lPsUn5BttskeOt6aee1p1TS5NI=; b=Wpp5b+dJz7p84pYFu61NJPWS4c2Iy94l38MMIIrcvuSyboDZb8mrAauO3NExSxNvxO gxIiCahmDKdGGZLEachs9sYewc/p5Ffh5QD8PfCExLjZ9o4ms/CuLM7muZKbmq6kgAmz DoReFAC9jIdpFjCoLD9tthT3L7CPfVDbJoDVUq2838G0Gl0SWXxLGu/Q7nMpaNyPR1dX 1WWj5jqBeK0ZE76jprusRBgJ7gBIiGpZR8ajL4z4CQwT65uNBW2DDzDoEBCWOkLiTKpl uGDnqh2B7/aQwFYH5XPtPD83rkFQSovCQU+TH3bz/2A1RT2m5FZvOUqeeKwShBXTC5kg wGgg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=v8nnd2ujlB60GPiA1lPsUn5BttskeOt6aee1p1TS5NI=; b=lFrymaZLHA3ahfj1/MruMOejXj9YqpeHt3BRjBKOsWPlfkCVcT0bS/4VzNlQbJ+xAz Q+XXGTaJGpJurWzR1bXrlWsbv+dwkdCeKnqK3J7imbyRp0+ecsQfLuNGZdsik3EXp0VA CGPb7d0bftu/DtIcK7OC2MqZ0QiUJFiuiYh0mjrwys6kRJXf4ZAM0+yT6WmdsZT7cD6+ HEnEU60txiwEtmZ+VMGpIs/klfUH996lo7cikfJ8mLyUctrVArO02d3t484Wi6lY6hMQ yOWF00bMsRbCHyS7zOh2GjwyvOsy4IonMSNwD4MShmrOnxeJ93KOvaFbF1CJ5E5l1lgi uBjA== X-Gm-Message-State: AOAM5311TLIzuXj9vK9OHG3vf3X1FAsmlwDe3f44Wvckwpi/Jq1NoUmt ffpBBU5gIuZyLp+QQQVLU5zMwMxvIJv0nQ== X-Received: by 2002:aa7:c7d5:: with SMTP id o21mr44134734eds.166.1620829998603; Wed, 12 May 2021 07:33:18 -0700 (PDT) Received: from mail-wr1-f53.google.com (mail-wr1-f53.google.com. [209.85.221.53]) by smtp.gmail.com with ESMTPSA id wn14sm14517068ejb.28.2021.05.12.07.33.17 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 12 May 2021 07:33:17 -0700 (PDT) Received: by mail-wr1-f53.google.com with SMTP id l14so23858236wrx.5 for ; Wed, 12 May 2021 07:33:17 -0700 (PDT) X-Received: by 2002:a05:6000:1787:: with SMTP id e7mr45453515wrg.12.1620829996861; Wed, 12 May 2021 07:33:16 -0700 (PDT) MIME-Version: 1.0 References: <20210511044253.469034-1-yuri.benditovich@daynix.com> <20210511044253.469034-3-yuri.benditovich@daynix.com> In-Reply-To: From: Willem de Bruijn Date: Wed, 12 May 2021 10:32:39 -0400 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH 2/4] virtio-net: add support of UDP segmentation (USO) on the host To: Yuri Benditovich Cc: David Miller , Jakub Kicinski , "Michael S. Tsirkin" , Jason Wang , Network Development , linux-kernel , virtualization , Yan Vugenfirer Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, May 12, 2021 at 2:10 AM Yuri Benditovich wrote: > > On Tue, May 11, 2021 at 8:48 PM Willem de Bruijn > wrote: > > > > On Tue, May 11, 2021 at 12:43 AM Yuri Benditovich > > wrote: > > > > > > Large UDP packet provided by the guest with GSO type set to > > > VIRTIO_NET_HDR_GSO_UDP_L4 will be divided to several UDP > > > packets according to the gso_size field. > > > > > > Signed-off-by: Yuri Benditovich > > > --- > > > include/linux/virtio_net.h | 5 +++++ > > > 1 file changed, 5 insertions(+) > > > > > > diff --git a/include/linux/virtio_net.h b/include/linux/virtio_net.h > > > index b465f8f3e554..4ecf9a1ca912 100644 > > > --- a/include/linux/virtio_net.h > > > +++ b/include/linux/virtio_net.h > > > @@ -51,6 +51,11 @@ static inline int virtio_net_hdr_to_skb(struct sk_buff *skb, > > > ip_proto = IPPROTO_UDP; > > > thlen = sizeof(struct udphdr); > > > break; > > > + case VIRTIO_NET_HDR_GSO_UDP_L4: > > > + gso_type = SKB_GSO_UDP_L4; > > > + ip_proto = IPPROTO_UDP; > > > + thlen = sizeof(struct udphdr); > > > + break; > > > > If adding a new VIRTIO_NET_HDR type I suggest adding separate IPv4 and > > IPv6 variants, analogous to VIRTIO_NET_HDR_GSO_TCPV[46]. To avoid > > having to infer protocol again, as for UDP fragmentation offload (the > > retry case below this code). > > Thank you for denoting this important point of distinguishing between v4 and v6. > Let's try to take a deeper look to see what is the correct thing to do > and please correct me if I'm wrong: > 1. For USO we do not need to guess the protocol as it is used with > VIRTIO_NET_HDR_F_NEEDS_CSUM (unlike UFO) Enforcing that is a good start. We should also enforce that skb->protocol is initialized to one of htons(ETH_P_IP) or htons(ETH_P_IPV6), so that it does not have to be inferred by parsing. These requirements were not enforced for previous values, and cannot be introduced afterwards, which has led to have to add that extra code to handle these obscure edge cases. I agree that with well behaved configurations, the need for separate _V4 and _V6 variants is not needed. > and the USO packets > transmitted by the guest are under the same clause as both > VIRTIO_NET_HDR_GSO_TCP, i.e. under if (hdr->flags & > VIRTIO_NET_HDR_F_NEEDS_CSUM) { > 2. If we even define VIRTIO_NET_HDR_GSO_UDPv4_L4 and > VIRTIO_NET_HDR_GSO_UDPv6_L4 - both will be translated to > SKB_GSO_UDP_L4, so this information is immediately lost (the code will > look like: > case VIRTIO_NET_HDR_GSO_UDP4_L4: case VIRTIO_NET_HDR_GSO_UDP6_L4 > gso_type = SKB_GSO_UDP; > > 3. When we will define the respective guest features (like > VIRTIO_NET_F_HOST_USO4 VIRTIO_NET_F_HOST_USO6) we will need to > recreate the virtio_net header from the skb when both v4 and v6 have > the same SKB_GSO_UDP_L4, (see virtio_net_hdr_from_skb) and I'm not > sure whether somebody needs the exact v4 or v6 information on guest RX > path. FWIW, it is good to keep in mind that virtio_net_hdr is also used outside virtio, in both ingress and egress paths. > 4. What is completely correct is that when we will start working with > the guest RX path we will need to define something like NETIF_F_USO4 > and NETIF_F_USO6 and configure them according to exact guest offload > capabilities. > Do you agree? I don't immediately see the need for advertising this device feature on a per-protocol basis. Can you elaborate?