Received: by 2002:ab2:6d45:0:b0:1fb:d597:ff75 with SMTP id d5csp512802lqr; Wed, 5 Jun 2024 12:23:55 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWEZFvXAAhQMRUGInlYPSQVl3TAG7AlUUhQAPGo+DXZMOA2fwBuN0L+GLm4f5AFrL9s1zocbjmS6V0beuijTAlHE+yULDa24q4W1cfYtQ== X-Google-Smtp-Source: AGHT+IFc0ayuG7vtU7UDmyoG7AkfUxfNtD8eWuLSMDIamfXAwGDMoiFe/0BEd52aXDTifYatlyzT X-Received: by 2002:a05:620a:4108:b0:795:1ede:3c1b with SMTP id af79cd13be357-79523d3a786mr439088285a.28.1717615435183; Wed, 05 Jun 2024 12:23:55 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717615435; cv=pass; d=google.com; s=arc-20160816; b=1BLAnY+X1JvQzSX/iGhNLXvR7lzNwi5GGQAZQwsS/enWdzuGH4OeElxTYmbzU3Bc15 E/17if4kbS+hb05kdnak5EwEyg7brNDzt9u2IMySKtGuqS2Vw4k21q1Bd7lRSupZwe2M 87IA7QKHWNHrJO8scUH+NQFv2xeCOfcT2uL00kg9zogR49qq4vHZ+03MTNp77oNt7unr v5H37R0xdQr35QgUwZkAd9ONz6d8bM0OLiWaHha8xiqewnpsVCkRczfmtNaKfgJSWXrQ cnobco1nBDjW/Qg3vCRr6o1ad5Dgr0uXU8qCUC+PFiJPbeWNZAL4Q3uSdmY+QEKybiU/ ZrSA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :dkim-signature; bh=usKi1lQoAvyD3EOCOJA05MMV4ZqwLjC/fYmPgHVdfmc=; fh=ph6QWphI0UnyqGjwX41yrrD0Yl1BcHrl4pzLW8dsV8M=; b=mEcrL0bQXde8VLKHI9uDVkhUree1EbJ9YuTj4IhCCImtu0oROX8FKxXtX9PNkyRhi0 ePwLT2Uz3DQh3jqdSxweSJbN4hVw37Bm+SGqCSorqpBwIbTlhQ4PY0kfW0SFYzED3Eua CE40rWHc2IKkWiUwJph0+HpoNccV6fKKFiys1qex6aRdUI8EXjvt+OQpfGMxzAAnomw7 HtMAH76lf26HdQy1DFF0AX16+H8FNwWUyp/Eo0TJ34pYEBDrySoFKvg/v2/1Kyvn3xIX f4AlQZ9iWfugT5xDyW4PfGgr9kZPOoR3yHfEPE7BA/WrfaPKt2UyrSxwG+Gp3mtoSIED b0Gg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=Q5ANUpTM; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-203096-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-203096-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id af79cd13be357-7952cf184fcsi62761585a.699.2024.06.05.12.23.55 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Jun 2024 12:23:55 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-203096-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=Q5ANUpTM; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-203096-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-203096-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 7D7C31C22989 for ; Wed, 5 Jun 2024 19:23:54 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E669114EC73; Wed, 5 Jun 2024 19:23:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Q5ANUpTM" Received: from mail-vk1-f179.google.com (mail-vk1-f179.google.com [209.85.221.179]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id ABB3F41C79; Wed, 5 Jun 2024 19:23:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.179 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717615414; cv=none; b=AzPuoxxEyv7G3LRBst2T9r+3Ez3daoN0YTPhpYEJCYaIF2lGNsukDn0cjplLkklz0dzIaEQl8iAkybz/1IbVS85YDtNbF3ennflbg6dAXtOLOoq0sRJuD6y+WJ16geCgM2Wew8biI8yJGaxdsN0L7l11kGBytdmDPsKA57dPzRo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717615414; c=relaxed/simple; bh=xEQRH3jAJkXGlRaNB3fgJoxXqBOJ4rsKcAteON05fpk=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=h6/eW/sJabUMpoKG1/VJWxVchki1Pj45qdlUQdhKx2Oacqls5p91fse5UrhQClEiHumnKuPsMZhWedlS88Vq4ehi1BGIeZssmqzfDA+cwn/znhKYEecOLy5jVtomlLaIwuM0l1P5cUIW1VHFCClKDQQE4alAmwPeno0V5Eq4ogg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=Q5ANUpTM; arc=none smtp.client-ip=209.85.221.179 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-vk1-f179.google.com with SMTP id 71dfb90a1353d-4eb24694941so54161e0c.0; Wed, 05 Jun 2024 12:23:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1717615410; x=1718220210; darn=vger.kernel.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=usKi1lQoAvyD3EOCOJA05MMV4ZqwLjC/fYmPgHVdfmc=; b=Q5ANUpTMfeQs6ZrRn3Uq7M6jOnRqlxeuSiMGZ4SqNIbg4Sot7nh36BAHbvffSYbPNv 84zYrZiF2jzcETc2yKjYSYv6/i1iLYjOM2dOagkg0bNxed9POjFFmjgmi9aIuHv1n/h/ xqE/ys97SCF6wV+7gcB/Rs6coKHIjdTk5UqNPclgw2kbXl4QxoOKuR1iJ5AOTycXjcor KzyIwVGWQndEuzjV3syrLtVXp/o/thsGuVpj5cfpMO2kczuuDrJu54ZwKMqFHyv4XhZg v/fQO6lOloj2rExucKmoa8aWcFrt11Qa5Wv9d+/HnbR6ovqnkcfZrY8hab9LF2WkRpnO +VvA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717615410; x=1718220210; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=usKi1lQoAvyD3EOCOJA05MMV4ZqwLjC/fYmPgHVdfmc=; b=NGS4Z+fNxd1IVzcVIZx964U/VKsWWI2fjMz3fhJy+RCDMDvavap+cLsOKIhsYUmOpY wNWbbzySjl5ucSMQxeYOOY12o8iSZcoE1La08ilWoEyXkWezAnpuiAV4b0/aKtRIinT+ 8utq/2UsJOuvtp50iln4MbFiQxOHF6QNW7jjZt/AKpg7D//9kPg0h123AR7RgIUpkdQ7 a3iFWpIB8Ke7Xfu2Zfg1IQog4QHWo/VCUdb4PS7BLrkVKRV9bxG+Jtuy0OPmMaFLhrp2 IPtnafcCNpRrKHguqEvIR33Gdd6q6fujd83YCZ7LwKuI7XVsf9Yca2yZfYl8gUJQT8cj ui3A== X-Forwarded-Encrypted: i=1; AJvYcCVkvBqtygDe3m9v9ATC7c/Vr2pIGEgB06CwOGCNLSpBlPc3RaBDUBlPWmNBttUhds96g/68KFat/SoPKNwTtoKvG3rBjhZ9sJQ/3hek6xhdZXNC557B6F8jCiPEHcnM8SMk+TPo X-Gm-Message-State: AOJu0Yx17ffWZ91EhNvx74C4jTC3vLJIOIjX1VTG9c4mbktDRDmUtZ4e Audw+Ii6mgs80Gr8J78IEbiVkTM/NpTf8Nw1yklZhuTfQRIaH0q2H2sq3lIUxNw+23pg1TzcE5c 6CU6AnEVjq3L0hqfjX7LGTS+15PU= X-Received: by 2002:a1f:fc4c:0:b0:4eb:39c9:c935 with SMTP id 71dfb90a1353d-4eb3a4ff73cmr3559305e0c.14.1717615410379; Wed, 05 Jun 2024 12:23:30 -0700 (PDT) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240604054823.20649-1-chengen.du@canonical.com> <665f9bccaa91c_2bf7de294f4@willemb.c.googlers.com.notmuch> <6df76928-be7f-483e-9685-88ee245ef1bf@orange.com> In-Reply-To: <6df76928-be7f-483e-9685-88ee245ef1bf@orange.com> From: Willem de Bruijn Date: Wed, 5 Jun 2024 15:22:52 -0400 Message-ID: Subject: Re: [PATCH v5] af_packet: Handle outgoing VLAN packets without hardware offloading To: alexandre.ferrieux@orange.com Cc: Chengen Du , davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, kaber@trash.net, linux-kernel@vger.kernel.org, stable@vger.kernel.org Content-Type: text/plain; charset="UTF-8" > > > This adds some parsing overhead in the datapath. SOCK_RAW does not > > > need it, as it can see the whole VLAN tag. Perhaps limit the new > > > branches to SOCK_DGRAM cases? Then the above can also be simplified. > > > > I considered this approach before, but it would result in different > > metadata for SOCK_DGRAM and SOCK_RAW scenarios. This difference makes > > me hesitate because it might be better to provide consistent metadata > > to describe the same packet, regardless of the receiver's approach. > > These are just my thoughts and I'm open to further discussion. > > FWIW, I vote for Willem's approach here: there is no problem with having > different metadata in SOCK_DGRAM and SOCK_RAW, as the underlying parsing efforts > are different anyway, along with the start offset for BPF. > (No, I'm not super happy to see BPF code reaching out to offset -4096 or so to > get VLAN as metadata. That just smells like a horrendous kludge.) > To me, it makes plenty of sense to have: > - SOCK_DGRAM for compatibility (used by everyone today), doing all historical > shenanigans with VLANs and metadata > - SOCK_RAW for a modern, new API, making no assumption on encapsulation, and > presenting an untouched linear frame > - yes this means different BPF code for the same filter between the two modes > > Again, my .02c Thanks for chiming in. Generally agreed. We cannot modify established SOCK_RAW behavior in arbitrary ways either. But there are already two forms in which VLAN data may arrive. And with SOCK_RAW in-band VLAN tags can be parsed as is. (fyi, your message was dropped by the list's plaintext filter)