From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 42C62C433FE for ; Thu, 10 Feb 2022 17:34:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242694AbiBJRey (ORCPT ); Thu, 10 Feb 2022 12:34:54 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:45032 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241940AbiBJRex (ORCPT ); Thu, 10 Feb 2022 12:34:53 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7787EF1B; Thu, 10 Feb 2022 09:34:54 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 0E8F361E09; Thu, 10 Feb 2022 17:34:54 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id DB8ADC340EF; Thu, 10 Feb 2022 17:34:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1644514493; bh=RAVYSQx/4ghHVPmoaDi8n9up8m/CMo9DBlGXzYcSIFw=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=CIjUCVaQsjeyd1CU80njQyKfL+bV0DV7/HM7/twCsBGOVRnHLNtbPTmPx/eg5fu3f GqWkvWXr6HGenw0VArRpEe2Pln7aoYsKnNXVeaWZj8HgUrQWWByXNkKbSfOv5wf7YM pb1jEJRpsffvLxGsrYRqbQkdBOc9yIRVmXrygj8qLgUi2FzBWtx2CCgTYHaQzaC2mW un3tSL46ROfv7ACG64P3/APrRvfLGmOCHo+genBe8v/vUgXvxV3E7/eMaLryUi9v21 Ue98SDuToMh3Csh46y4CW5JWdT5vfxM76gmwer7KpLoqgxPmeaGb4v5bmkxVkyGEOV zaK6cN2V02QEQ== Date: Thu, 10 Feb 2022 18:34:49 +0100 From: Lorenzo Bianconi To: Alexei Starovoitov Cc: bpf , Network Development , Lorenzo Bianconi , "David S. Miller" , Jakub Kicinski , Alexei Starovoitov , Daniel Borkmann , Jesper Dangaard Brouer , Toke =?iso-8859-1?Q?H=F8iland-J=F8rgensen?= , Andrii Nakryiko , Paolo Abeni , Toshiaki Makita Subject: Re: [PATCH bpf-next] net: veth: account total xdp_frame len running ndo_xdp_xmit Message-ID: References: <705a05194508bc0c1b0c1a5de081bbb60f2693a5.1643712078.git.lorenzo@kernel.org> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="fEji8xlfT1CMJWVv" Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org --fEji8xlfT1CMJWVv Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable > On Tue, Feb 1, 2022 at 2:46 AM Lorenzo Bianconi wrot= e: > > > > Introduce xdp_get_frame_len utility routine to get the xdp_frame full > > length and account total frame size running XDP_REDIRECT of a > > non-linear xdp frame into a veth device. > > > > Signed-off-by: Lorenzo Bianconi > > --- > > drivers/net/veth.c | 4 ++-- > > include/net/xdp.h | 14 ++++++++++++++ > > 2 files changed, 16 insertions(+), 2 deletions(-) > > > > diff --git a/drivers/net/veth.c b/drivers/net/veth.c > > index 354a963075c5..22ecaf8b8f98 100644 > > --- a/drivers/net/veth.c > > +++ b/drivers/net/veth.c > > @@ -493,7 +493,7 @@ static int veth_xdp_xmit(struct net_device *dev, in= t n, > > struct xdp_frame *frame =3D frames[i]; > > void *ptr =3D veth_xdp_to_ptr(frame); > > > > - if (unlikely(frame->len > max_len || > > + if (unlikely(xdp_get_frame_len(frame) > max_len || > > __ptr_ring_produce(&rq->xdp_ring, ptr))) > > break; >=20 > Looks correct, but could you explain what happens without this fix? I guess this is just a theoretical issue, since at the moment we can't perf= orm a XDP_REDIRECT with a non-linear xdp buffer, but without this patch we will= fail to account peer max packet size since we take care of just the linear part = of the xdp_buff. I am working on adding xdp multi-buff support to veth driver so I will repo= st this patch into the series. >=20 > Any other drivers might have the same issue? I do not think so since other drivers are not able to map multi-frags yet (= veth already support it since we run __xdp_build_skb_from_frame()). Regards, Lorenzo --fEji8xlfT1CMJWVv Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iHUEABYKAB0WIQTquNwa3Txd3rGGn7Y6cBh0uS2trAUCYgVMuQAKCRA6cBh0uS2t rEOlAQCnhlHABC7kVQ+OnphlPVGyPvthx41F4zdr2wZTzkCnDAD/fGkIjtY6oPJ5 CbjDzGiLMyWhwNYJMpGPO7qthkthSQY= =C658 -----END PGP SIGNATURE----- --fEji8xlfT1CMJWVv--