Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp329806rwr; Wed, 19 Apr 2023 07:08:06 -0700 (PDT) X-Google-Smtp-Source: AKy350YB3dqgomSjPxABnoS2inkhlCHFjcqZFb9U2RbXyhRqkcYAg2GwBpS8f6pm94M+Lahj7gnF X-Received: by 2002:a05:6a00:1255:b0:63b:6933:a328 with SMTP id u21-20020a056a00125500b0063b6933a328mr4374845pfi.28.1681913286147; Wed, 19 Apr 2023 07:08:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681913286; cv=none; d=google.com; s=arc-20160816; b=imxsxfAhH4jtz2SuRDlNgxn3CdYSQu3/6e/i4eRy9xyO47Dp/wVFMHL8aemISBYonq J4rgmyKwvxwavyQOhetm/BXxISd1BykGVwcf5gIgAXeuPS6fboHjEJWE17iMBLCFeWwH 40MOqklxF4XTUNLRD7PH11gD1iHE+i+/p4unlqrX1DtVlneyB6AMFWsJHDRz69Efq4bD SHEdTlDX0QEUpnzfmXezZr4O+gP10YUCjNIdzAGpKMkDdXW0BQs63fvBXbTS1RIAFO5/ BArIZxgOhGBoyriyje1X1BWI8FTgp/KMLPMGn5By4Wpcv43qZrSXv7RYyXVzYXwLE5Cc DQmA== 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=Mksm0VsOLdOSoNAlcmc7x0LG0P70M6uaU5xaJTR9Yi8=; b=Z1t8efLay+S6x9ssOp+01WrWUSt6q+ufcQ7EBqaXKAbYuKPUe+vPOh1V5/vptPsfaG MBjabwtGxn1iEZtl4pg4yLUxJx3Vt2K08TDCe9CneS9rwBMNKttd+haApvUtPedSkvaT Y+eP7jP2ZfFqjq9eKNO9MjUyM9hyCdgxSiOa30OX7FclheXbiQ3k9/v7xaFqeYVs1uKw I576FsrEDjBFpw/60QW3GRJWkK6/24dT8e2tkZbPUdZPnQ6TWSAF7MDSLPuwvWMtkOdq SXE5ON8SpxfOZW2OqFCRywusij8kRzqwxUOgW44kOtZCEP3N6Z+9o9fOFCleRW6/LuYA jJsA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=DK6QZdWz; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id v18-20020aa799d2000000b00624ac1abef6si16769900pfi.218.2023.04.19.07.07.49; Wed, 19 Apr 2023 07:08:06 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=DK6QZdWz; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 S230385AbjDSOAP (ORCPT + 99 others); Wed, 19 Apr 2023 10:00:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33338 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229814AbjDSN7n (ORCPT ); Wed, 19 Apr 2023 09:59:43 -0400 Received: from mail-qv1-xf2c.google.com (mail-qv1-xf2c.google.com [IPv6:2607:f8b0:4864:20::f2c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 59BC312D; Wed, 19 Apr 2023 06:59:42 -0700 (PDT) Received: by mail-qv1-xf2c.google.com with SMTP id m16so21185274qvx.9; Wed, 19 Apr 2023 06:59:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1681912781; x=1684504781; 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=Mksm0VsOLdOSoNAlcmc7x0LG0P70M6uaU5xaJTR9Yi8=; b=DK6QZdWzS5tUiY0UP95E6A9p627Ll66ULAwC7NBNG4nAQpMiyCtJEeQujRVq1f56wH YCv53uh/b41UZ+f2O+fWlx9iNUguAQkUlmnB2qYA+ciNzIS5sbj36s0TEC8lRHVkDzBi nEwJdJORaidlqP4NNMTe3ruSJxcQzV5WlBRhQzOFOG7jjk7tkYGno/QgmIoNiOw8i5UM mANnQFW0biJC68/3SmdPnOC+aMZ/yZs4KzrAJG3Ls90L25ahihrIXfjITgjLlJMacEnT 5DKHNgidoVua5RHtW8tSZjh4OXJvZXFOM232QD0SaaLHWRWXbD065+z/LMD5XDpGSwdU iBFQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681912781; x=1684504781; 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=Mksm0VsOLdOSoNAlcmc7x0LG0P70M6uaU5xaJTR9Yi8=; b=fHzvM+/P9LKQw+C6qRhhtKaWECimJRJNplGgemHJxt1oKOEd8cH0Gb1TfYWbu2/Vlx W1tHymLQ/JNjwgHGLIUpXByBkLv5enPHuEu0fAuIJ/Ij99iD2fZThq9L2+5hTbEX2AQa lA1AfEzBiTJFZ2FsgxYGhVGeIW4SL8L5RREp1cS30OdGqlUkv/R0FHIHJLnST9NLG3k8 MEREC1VywhFL2ix1YTpPmPw+9h1FoFRiWxJn+wQ2iliH+KIJabwrSc5SJIZKTXShrlAj DMNny8QYWE5VEcxvuVBcJG6OPZ9ie8TPOpgWmbYi0E99EtxcrXWKpCllPWPj7InmNHXJ 18yA== X-Gm-Message-State: AAQBX9ex+AhUqXIpTAS/bc/GxMkLXIcqj0qpo5RK10NNUnWZJdf08GBA KaZloZT0dJUKKnbTIVnYVoo= X-Received: by 2002:ad4:5baf:0:b0:5ef:50ea:2914 with SMTP id 15-20020ad45baf000000b005ef50ea2914mr26894910qvq.22.1681912781381; Wed, 19 Apr 2023 06:59:41 -0700 (PDT) Received: from localhost (240.157.150.34.bc.googleusercontent.com. [34.150.157.240]) by smtp.gmail.com with ESMTPSA id l3-20020a0ce083000000b005f44239c1d6sm160189qvk.68.2023.04.19.06.59.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 19 Apr 2023 06:59:40 -0700 (PDT) Date: Wed, 19 Apr 2023 09:59:40 -0400 From: Willem de Bruijn To: =?UTF-8?B?5rKI5a6J55CqKOWHm+eOpSk=?= , linux-kernel@vger.kernel.org Cc: =?UTF-8?B?6LCI6Ym06ZSL?= , =?UTF-8?B?5rKI5a6J55CqKOWHm+eOpSk=?= , Willem de Bruijn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , netdev@vger.kernel.org Message-ID: <643ff3cca2eb3_38347529476@willemb.c.googlers.com.notmuch> In-Reply-To: <20230419072420.315079-1-amy.saq@antgroup.com> References: <20230419072420.315079-1-amy.saq@antgroup.com> Subject: RE: [PATCH v9] net/packet: support mergeable feature of virtio Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org =E6=B2=88=E5=AE=89=E7=90=AA(=E5=87=9B=E7=8E=A5) wrote: > From: Jianfeng Tan > = > Packet sockets, like tap, can be used as the backend for kernel vhost. > In packet sockets, virtio net header size is currently hardcoded to be > the size of struct virtio_net_hdr, which is 10 bytes; however, it is no= t > always the case: some virtio features, such as mrg_rxbuf, need virtio > net header to be 12-byte long. > = > Mergeable buffers, as a virtio feature, is worthy of supporting: packet= s > that are larger than one-mbuf size will be dropped in vhost worker's > handle_rx if mrg_rxbuf feature is not used, but large packets > cannot be avoided and increasing mbuf's size is not economical. > = > With this virtio feature enabled by virtio-user, packet sockets with > hardcoded 10-byte virtio net header will parse mac head incorrectly in > packet_snd by taking the last two bytes of virtio net header as part of= > mac header. > This incorrect mac header parsing will cause packet to be dropped due t= o > invalid ether head checking in later under-layer device packet receivin= g. > = > By adding extra field vnet_hdr_sz with utilizing holes in struct > packet_sock to record currently used virtio net header size and support= ing > extra sockopt PACKET_VNET_HDR_SZ to set specified vnet_hdr_sz, packet > sockets can know the exact length of virtio net header that virtio user= > gives. > In packet_snd, tpacket_snd and packet_recvmsg, instead of using > hardcoded virtio net header size, it can get the exact vnet_hdr_sz from= > corresponding packet_sock, and parse mac header correctly based on this= > information to avoid the packets being mistakenly dropped. > = > Signed-off-by: Jianfeng Tan > Co-developed-by: Anqi Shen > Signed-off-by: Anqi Shen Reviewed-by: Willem de Bruijn =