Received: by 2002:a05:7412:419a:b0:f3:1519:9f41 with SMTP id i26csp1261539rdh; Fri, 24 Nov 2023 08:24:59 -0800 (PST) X-Google-Smtp-Source: AGHT+IGYkfTBKheqfthZnTfNNPtmnMC/PUMl4awj7LpRJxZ9kqLM4bX8IemLWkgx+6OZ3WkeWmHx X-Received: by 2002:a05:6a21:3704:b0:187:afb0:c2f7 with SMTP id yl4-20020a056a21370400b00187afb0c2f7mr3089778pzb.45.1700843099332; Fri, 24 Nov 2023 08:24:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700843099; cv=none; d=google.com; s=arc-20160816; b=ycu6zZsbpd94n3PLyvBV7vjb/ve3/KaDRn0z2k85ZnewLzY86kHmkbhZXh7SvVjNdr KegJ9kK4UxJ/Rw2j7ryi0cf3aBEYueD9oZDpvx+aKtcU1ofTZEobYnTHYWSmo+fwR1Yt ie5YOu0vSazjdIQKOVguTzZtWL0dsbxVefsFPR9qWvQWG5oqlQItLRGru+c3vBO9G1/g lxUnZxm2QQDSo3RC0561ji0gqYuFq5rUBZKQS0MgYtqnqTQkTE2UUo7O6tU59v9k0Pqy 6unezelpmoNlHFHW57O5rGQtI788pwY62rOcsH+A0kGmh/2HEKuZWPOMnDxSZ7CKJR64 ZFTA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version:subject :references:in-reply-to:message-id:cc:to:from:date:dkim-signature; bh=OXuq367Ccm4+D5k3pODmrs76JvxYvWomp+aKIM/G+no=; fh=tCjht9WQ3QTpDKj7jRFLazf1XhlhIti8b2Ofrflgqa4=; b=p2LRQpuRO3pYaZakbX39v1nHyJ1L3c+wbSEMvihIfK7uCW5v/cKe2SkAKFqIItG7G/ mtxPU0d9fxdDmXTPsqMz7va2ya3iSBlF3FFRsIZyqsFtkHOBIVSGuC/bS/qvPMzHtBnc lF0yuTD9mjlZmM3MkQ5uV2VFufnbQ0O07Wmpgk0o3P3iCC8wBQcrYoBQ9lpKwviw0hBa TVeYS7lk5kuGUObzJMpQbzoopj8aNFJ8E4JntP/Jj7R0vNhBzSCZqnb+Z0hbk9VT/Bci tvfEtPxa42DuxOCh+xhvcQtHkOIUZmW7mGRSFgmzSW4H5yW7uPuKn872Z4l4yKeWEFe8 9Owg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=TI5cWHmX; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 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 fry.vger.email (fry.vger.email. [23.128.96.38]) by mx.google.com with ESMTPS id 13-20020a17090a08cd00b0028103abc77csi4520912pjn.18.2023.11.24.08.24.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Nov 2023 08:24:59 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) client-ip=23.128.96.38; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=TI5cWHmX; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id 9030A80E6DF8; Fri, 24 Nov 2023 08:24:56 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230434AbjKXQYg (ORCPT + 99 others); Fri, 24 Nov 2023 11:24:36 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53846 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229659AbjKXQYd (ORCPT ); Fri, 24 Nov 2023 11:24:33 -0500 Received: from mail-qk1-x72c.google.com (mail-qk1-x72c.google.com [IPv6:2607:f8b0:4864:20::72c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7B97BD41; Fri, 24 Nov 2023 08:24:40 -0800 (PST) Received: by mail-qk1-x72c.google.com with SMTP id af79cd13be357-7789a4c01easo113924885a.0; Fri, 24 Nov 2023 08:24:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1700843079; x=1701447879; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:subject:references :in-reply-to:message-id:cc:to:from:date:from:to:cc:subject:date :message-id:reply-to; bh=OXuq367Ccm4+D5k3pODmrs76JvxYvWomp+aKIM/G+no=; b=TI5cWHmXa1riHiMFUQtMFmaskaXkgg9yOv5lslt+upNFa7PSOTpFLLoxjsbQIcfwhf 4TmQN8suqD75FXESJ5JHD0f/TKnc1aQF3L2LDT5nZetOJEJ7HoBhWieksptHYFwSrGUx hmxEAyvXXCjYMlOuz1yyyGr+INBcfUrhjHJpba/RfsuytZWOXvCuJDPaCprQ8+Hgs5t3 pj9Eds8ESI/xC7i0CT0iEA+jD54O0ogO+cem77iEHH8grEAwoFrGF4FTGaasSeQnc/pb X6grry8cO6pVCbMKibCkgwoVSc2j77RYqwxsuSQT41lM0K7l5sXBtFWeycDlANvdy66E 4xlA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700843079; x=1701447879; h=content-transfer-encoding:mime-version:subject:references :in-reply-to:message-id:cc:to:from:date:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=OXuq367Ccm4+D5k3pODmrs76JvxYvWomp+aKIM/G+no=; b=dwa0TeSa324CRUDOitLD9jT3s5iRMONPcXM1RKmE9aEd25OZs02fiBQt+JEqt7zwsc 0R91paaoJ+X8H4VQJyWm207EjmoNLfrH8eYwksD01R3E03xkOPAdpkPbK8SKUy0hLOQB dh5JwpvU51+aN8asD9tPlWuhxjV1h0zdskxEmteQqp/YyfnLIpn3sQa6TEpnSy6ePwf4 HpxkEuwCaDa5J/FwM/cr3ssjowhcktnLkupbwcAaq5nizHKs0SP3lb0r3jlgl5G8GFdW GArj6RzCrIHirb0iK+VOIO3yYWiDNZOcd3gTgFKEea7CsuazTuYay7HL/sf625tNygPl z9GA== X-Gm-Message-State: AOJu0YwX49t67jjrgjqluBrawscJPB7yiXRbmQZjMrPkyi9itUj1Atdg 0hTrMCX3Ak6D98PraAKgp28= X-Received: by 2002:a05:620a:55b2:b0:77d:5ca7:a6ce with SMTP id vr18-20020a05620a55b200b0077d5ca7a6cemr3487998qkn.28.1700843079420; Fri, 24 Nov 2023 08:24:39 -0800 (PST) Received: from localhost (240.157.150.34.bc.googleusercontent.com. [34.150.157.240]) by smtp.gmail.com with ESMTPSA id qs14-20020a05620a394e00b0077d87da84d1sm39091qkn.23.2023.11.24.08.24.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Nov 2023 08:24:39 -0800 (PST) Date: Fri, 24 Nov 2023 11:24:38 -0500 From: Willem de Bruijn To: Mike Pattrick , Willem de Bruijn Cc: netdev@vger.kernel.org, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, linux-kernel@vger.kernel.org Message-ID: <6560ce46db783_f482f29451@willemb.c.googlers.com.notmuch> In-Reply-To: References: <20231123183835.635210-1-mkp@redhat.com> <655fc32bb506e_d14d4294b3@willemb.c.googlers.com.notmuch> <655fe8e5b5cf5_d9fc5294a0@willemb.c.googlers.com.notmuch> Subject: Re: [PATCH net-next] packet: Account for VLAN_HLEN in csum_start when virtio_net_hdr is enabled Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-0.6 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (fry.vger.email [0.0.0.0]); Fri, 24 Nov 2023 08:24:56 -0800 (PST) Mike Pattrick wrote: > On Thu, Nov 23, 2023 at 7:06=E2=80=AFPM Willem de Bruijn > wrote: > > > > Mike Pattrick wrote: > > > On Thu, Nov 23, 2023 at 4:25=E2=80=AFPM Willem de Bruijn > > > wrote: > > > > > > > > Mike Pattrick wrote: > > > > > Af_packet provides checksum offload offsets to usermode applica= tions > > > > > through struct virtio_net_hdr when PACKET_VNET_HDR is enabled o= n the > > > > > socket. For skbuffs with a vlan being sent to a SOCK_RAW socket= , > > > > > af_packet will include the link level header and so csum_start = needs > > > > > to be adjusted accordingly. > > > > > > > > Is this patch based on observing an incorrect offset in a workloa= d, > > > > or on code inspection? > > > > > > Based on an incorrect offset in a workload. The setup involved send= ing > > > vxlan traffic though a veth interface configured with a vlan. The > > > vnet_hdr's csum_start value was off by 4, and this problem went awa= y > > > when the vlan was removed. > > > > > > I'll take another look at this patch. > > > > This is a vlan device on top of a veth device? On which device and at= > > which point (ingress or egress) are you receiving the packet over the= > > packet socket? > = > Just for maximum clarity I'll include the extracted commands below, > but roughly there is a vlan device on top of a vxlan device on top of > a vlan device on top of a veth, in a namespace. > = > ip netns add at_ns0 > ip netns exec at_ns0 ip link add dev at_vxlan1 type vxlan remote > 172.31.1.100 id 0 dstport 4789 > ip netns exec at_ns0 ip addr add dev at_vxlan1 10.2.1.1/24 > ip netns exec at_ns0 ip link set dev at_vxlan1 mtu 1450 up > ip link add p0 type veth peer name ovs-p0 > ethtool -K p0 sg on > ethtool -K p0 tso on > ip link set p0 netns at_ns0 > ip link set dev ovs-p0 up > ip netns exec at_ns0 ip addr add "172.31.2.1/24" dev p0 > ip netns exec at_ns0 ip link set dev p0 up > ip netns exec at_ns0 ip link add link at_vxlan1 name at_vxlan1.100 > type vlan proto 802.1q id 100 > ip netns exec at_ns0 ip link set dev at_vxlan1.100 up > ip netns exec at_ns0 ip addr add dev at_vxlan1.100 "10.1.1.1/24" > ip netns exec at_ns0 ip link add link p0 name p0.42 type vlan proto 802= .1q id 42 > ip netns exec at_ns0 ip link set dev p0.42 up > ip netns exec at_ns0 ip addr add dev p0.42 "172.31.1.1/24" > ip addr add "172.31.1.100/24" dev p0 > ip link set dev p0 up Are these two lines intended to be ovs-p0 rather than p0? As p0 lives inside the netns (and already has an address) > ip netns exec at_ns0 ping 10.1.1.100 > = > An AF_PACKET socket on ovs-p0 receives the incorrect csum_start. > Setting up the same with a geneve tunnel and udpcsum enabled produces > the same result. Removing vlan 100 also yields an incorrect > csum_start. Removing only vlan 42 yields a correct csum_start. I wonder if a simple checksum offloaded UDP packet sent over a vlan directly on top of veth, like .100 has a correct offset before your patch, but incorrect offset after. The issue you are encountering might be that vxlan does not support vlan offload, so validate_xmit_vlan will pull the vlan into the header with __vlan_hwaccel_push_inside, but this does not adjust csum_start. Not sure, but perhaps you can instrument your kernel and see where the offset goes wrong. It is not inside the pf_packet socket, in any case. = > > > > From a quick glance, in all cases that I see the VLAN tag is kept in > > skb->vlan_tci, so is never part of the packet payload. > > > > But checksum offload with VXLAN can be non-trivial on its own. If > > type & SKB_GSO_UDP_TUNNEL_CSUM | SKB_GSO_TUNNEL_REMCSUM, say. Then > > csum_start will point to the checksum in vxlanhdr. > > > =