From patchwork Wed Aug 14 13:06:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Boris Sukholitko X-Patchwork-Id: 13763468 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-pf1-f171.google.com (mail-pf1-f171.google.com [209.85.210.171]) (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 447581109 for ; Wed, 14 Aug 2024 13:06:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.171 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723640801; cv=none; b=rxOQfbAwn/7+ASrvp4hIxKgw3vFT4gx4qgeJrnX3tmR2+cL1zDzvjDpxHXKciFWTiWr5t4pl9/8qpT8dgGOJY6MvJ5L/2HMPNKBraM0uJbF7P0dPe0GQDsZFfiDoVLql1nn7f4SQWB0vni9V0yernUosQwzmECfiL1HJ7jUDXwI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723640801; c=relaxed/simple; bh=SlklGaSkB1CVAnGcEiIJsuqo82vRigsMVmvwV1Rzjjc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=SHqPm5BB+uIrCIqbKrSZUrZ+J2fyVt386rE8ikksdqs8/DcYy4nCt5j15oM6fjmhooXhdH6aN4jq6sFXixAxRaJcmB5q72Tc6Qgkwb+7d+nyh1U3vGiv/A4aEC9kZJ3uAxQibRAaCrG9RNVIJ5gr/Gbze+P36zpZnBiUb7E+PE8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=broadcom.com; spf=fail smtp.mailfrom=broadcom.com; dkim=pass (1024-bit key) header.d=broadcom.com header.i=@broadcom.com header.b=Nx2uzmij; arc=none smtp.client-ip=209.85.210.171 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=broadcom.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=broadcom.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=broadcom.com header.i=@broadcom.com header.b="Nx2uzmij" Received: by mail-pf1-f171.google.com with SMTP id d2e1a72fcca58-70d18d4b94cso4969682b3a.2 for ; Wed, 14 Aug 2024 06:06:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; t=1723640799; x=1724245599; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=rJdRS+SiiKicF87avM76gJAE3mWhqo9TmxE70LOsA1M=; b=Nx2uzmijo+LP4BtzcCXQ/Ml7X2NznbCzybNcLDwUPwDw8zm5T7pgKiRXnEUEK5OujE qMsYXNLoRhodMvfr0dWgetuigTnm2OSRnRedGw/hrfVvqqr2A81Ta0q4eeBJlms99AQD J0h0pyaj4wvN9g/WNPNayVcrqpcnEFpLRv6xY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723640799; x=1724245599; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=rJdRS+SiiKicF87avM76gJAE3mWhqo9TmxE70LOsA1M=; b=q4PgS3pFf64ZjIINSFzRThoaRt9f4KqZA2sdrp6Lnvgg+dF0Vz7cAWGA7xYwwTdaER vnCSevJlkn6pTBq2u0/+MAhMf6xUBL4tcu99RmLsV8gCDyGIEU/Q6HXN4Gjbm1leJm00 /JksCl5z7fN2s1QWjEUByyqx72SyWEzIw5//YzJ5a4pzWkY9hrUp/uLwdhB2j5v8BZXz TSdMkXJhdn4SOYWnXWQQHkQ+3TmZD+3P8WK2tT2SvwXQGNCmpIukH+lUFo9EIWlMxvuC eN3UWQuwng15LRckmdMH2A1qMAiEz3bKae7xQiAdl3WZUPcRLp2Z8/mQngf0nMLVgFX7 1r3Q== X-Gm-Message-State: AOJu0YyjncRMmz/KAO++QjBlNg82fuHXM0/kFSMwUIw4hp73bzBWrhDB JZ3RsRNN79ycFXpz2qWYVW3KlPrqgqd/OpChnQrsW5guq8pmEZPaxrOiYtbmgPVWECR1lJSo8M5 x53isntWPgiDGmXXJ99ncauFHJzPiHI8CVY4sCvXTUu18bMYzZa8n+FIwb263wF1YPKSnfNUMna W4sDXRFGqP+m/aaK8RfYWVlmRWIICT+QRV6OcYn72euFDmVDJ9 X-Google-Smtp-Source: AGHT+IHtR8wc6H7BmYCMXw9Fe/+/9RGP+sY5pV/IRcBYSi6n+iwcy/T5+YA4I0mchKBGxtpL8KNJKA== X-Received: by 2002:a05:6a00:4f95:b0:710:4d55:4d39 with SMTP id d2e1a72fcca58-712670e8635mr3028656b3a.4.1723640798593; Wed, 14 Aug 2024 06:06:38 -0700 (PDT) Received: from localhost.localdomain ([192.19.250.250]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-711841effe9sm4904543b3a.31.2024.08.14.06.06.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Aug 2024 06:06:37 -0700 (PDT) From: Boris Sukholitko To: netdev@vger.kernel.org, "David S . Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Jamal Hadi Salim , Cong Wang , Jiri Pirko , Mina Almasry , Pavel Begunkov , Alexander Lobakin , Lorenzo Bianconi , David Howells Cc: Ilya Lifshits Subject: [PATCH net-next v2 1/6] skb: add skb_vlan_flush helper Date: Wed, 14 Aug 2024 16:06:13 +0300 Message-ID: <20240814130618.2885431-2-boris.sukholitko@broadcom.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20240814130618.2885431-1-boris.sukholitko@broadcom.com> References: <20240814130618.2885431-1-boris.sukholitko@broadcom.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org Refactor flushing of the inner vlan in the skb_vlan_push by moving the code into static skb_vlan_flush helper. Signed-off-by: Boris Sukholitko --- net/core/skbuff.c | 40 ++++++++++++++++++++++++---------------- 1 file changed, 24 insertions(+), 16 deletions(-) diff --git a/net/core/skbuff.c b/net/core/skbuff.c index 83f8cd8aa2d1..23f0db1db048 100644 --- a/net/core/skbuff.c +++ b/net/core/skbuff.c @@ -6220,30 +6220,38 @@ int skb_vlan_pop(struct sk_buff *skb) } EXPORT_SYMBOL(skb_vlan_pop); +static int skb_vlan_flush(struct sk_buff *skb) +{ + int offset = skb->data - skb_mac_header(skb); + int err; + + if (WARN_ONCE(offset, + "skb_vlan_push got skb with skb->data not at mac header (offset %d)\n", + offset)) { + return -EINVAL; + } + + err = __vlan_insert_tag(skb, skb->vlan_proto, + skb_vlan_tag_get(skb)); + if (err) + return err; + + skb->protocol = skb->vlan_proto; + skb->mac_len += VLAN_HLEN; + + skb_postpush_rcsum(skb, skb->data + (2 * ETH_ALEN), VLAN_HLEN); + return 0; +} + /* Push a vlan tag either into hwaccel or into payload (if hwaccel tag present). * Expects skb->data at mac header. */ int skb_vlan_push(struct sk_buff *skb, __be16 vlan_proto, u16 vlan_tci) { if (skb_vlan_tag_present(skb)) { - int offset = skb->data - skb_mac_header(skb); - int err; - - if (WARN_ONCE(offset, - "skb_vlan_push got skb with skb->data not at mac header (offset %d)\n", - offset)) { - return -EINVAL; - } - - err = __vlan_insert_tag(skb, skb->vlan_proto, - skb_vlan_tag_get(skb)); + int err = skb_vlan_flush(skb); if (err) return err; - - skb->protocol = skb->vlan_proto; - skb->mac_len += VLAN_HLEN; - - skb_postpush_rcsum(skb, skb->data + (2 * ETH_ALEN), VLAN_HLEN); } __vlan_hwaccel_put_tag(skb, vlan_proto, vlan_tci); return 0; From patchwork Wed Aug 14 13:06:14 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Boris Sukholitko X-Patchwork-Id: 13763469 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-pf1-f176.google.com (mail-pf1-f176.google.com [209.85.210.176]) (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 D9C3C1109 for ; Wed, 14 Aug 2024 13:06:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.176 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723640806; cv=none; b=u+UDo2ZCCw45WXWyB/Gn+zERGt0iJ1bJgVqcLbTa8ZFGV2z1Fo2BkMcglJitnyGzFIcLG8YJWqaOdCCVi4zpEd3S7RakkTGJXjNFYo6D+94/8i5LuyCF1V/Do08/nGIQYTfOdniQOrDgl9L5C2J5HOcmzUVrTSfSEASCzA0aIwY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723640806; c=relaxed/simple; bh=YuT7tgOIJJfuO/twk1piOsn+GOR2DJ2NNNUzwgW9wPU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=GmSXFcLoDMRpMNuf2hr7HRJfsCuj3fl4rw8q6kttDDhhUfyi9GBOh9UZm6Y2bk/Z9fd9yIBF+3rJg1JkjA/Zo1XA9ljTDjRwUbbkl8nds3JyPReEaE2IOM3wY/P/Oo8AcHfub5yD3wAl8gJKxupWkarfh8ZoAJBzkOnOVVLxZco= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=broadcom.com; spf=fail smtp.mailfrom=broadcom.com; dkim=pass (1024-bit key) header.d=broadcom.com header.i=@broadcom.com header.b=QzbIXfDt; arc=none smtp.client-ip=209.85.210.176 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=broadcom.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=broadcom.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=broadcom.com header.i=@broadcom.com header.b="QzbIXfDt" Received: by mail-pf1-f176.google.com with SMTP id d2e1a72fcca58-7106e2d0ec1so4688462b3a.2 for ; Wed, 14 Aug 2024 06:06:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; t=1723640804; x=1724245604; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=pbTOvAUXILro3y1EmGJyFXmNSNhQtv1tC+lWw1ig7R0=; b=QzbIXfDtmZ8SOLRCNX4afhAb5SX6q5Cifkmuu579vZqNOkHp/2wqtkZf6njdZ/NTIz OILccKz8edDwIKI+2HOxSUlCh+tVthZMfEk3JWJ4zh3J1/IU1xSc2gebOak4VA8Hp3Qo maAtscwis+/C28M+QOGqzgVmT+nYw8WGhFwwI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723640804; x=1724245604; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=pbTOvAUXILro3y1EmGJyFXmNSNhQtv1tC+lWw1ig7R0=; b=THS/HR/Nx5shflbvQUY74H4JsGr/eG9gVPvPDiiRbNxG0B+MvtHd3aSiFc3Jp3QN9y MlgHvTp3BUtRIBgLnIus9g4LNfzUDzIxOD81RJcPvC+Q/444gcUubPdAiQRfLxYeW5Dn GLC1+QrTf3OuJU1V1+KLXk2qJdsI+B/cABtKKyCZspTMdoyKIXHoMqVEw+eI+gMNvaAQ k3Ivr+0BoFdAGNUPdn3LsUfbhHYSle7EfWtnO/D5NOv/AXh7u8camLxScoTk9lqPuYe2 +/s+TukfhU/rhCnLhB6avJak39xka1Tf8ZUlUWTTeBGkskgOCWj9cuvtKcaw2OW8wAN4 9PTg== X-Gm-Message-State: AOJu0Yx0tASExvof0Jgd2rGDnkoxAFVbaFqnekqBEbuGQG/8rnxl/eEg ho9paVTTjza9E7ghPA7WWPjpXsKLv6WLh68bXU42pLqU+qNXfuiRyuWqgX7uOCXinTvCEb8xKJT 1AygWONJXAmOUH9WGdWwAkbEJHnqXSVV8k+RSFEu7w5dHCDgAPaKPaDTFN/ZflbgrRNmSosUPKw XApKuRvxz6gSZFxiwEiaFcd0UsbEtfQaqsXrR4PaE3PVdQBSFz X-Google-Smtp-Source: AGHT+IFl9foKY9Yinyk+5LmC8WJCLj1BfV1CYr0rIE6L83nn5qKDxB0bDZtB9fzKNn0fqUMJEh2s2g== X-Received: by 2002:a05:6a20:c78e:b0:1c6:fc56:744 with SMTP id adf61e73a8af0-1c8eae97a21mr3241638637.31.1723640803518; Wed, 14 Aug 2024 06:06:43 -0700 (PDT) Received: from localhost.localdomain ([192.19.250.250]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-711841effe9sm4904543b3a.31.2024.08.14.06.06.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Aug 2024 06:06:43 -0700 (PDT) From: Boris Sukholitko To: netdev@vger.kernel.org, "David S . Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Jamal Hadi Salim , Cong Wang , Jiri Pirko , Mina Almasry , Pavel Begunkov , Alexander Lobakin , Lorenzo Bianconi , David Howells Cc: Ilya Lifshits Subject: [PATCH net-next v2 2/6] skb: move mac_len adjustment out of skb_vlan_flush Date: Wed, 14 Aug 2024 16:06:14 +0300 Message-ID: <20240814130618.2885431-3-boris.sukholitko@broadcom.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20240814130618.2885431-1-boris.sukholitko@broadcom.com> References: <20240814130618.2885431-1-boris.sukholitko@broadcom.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org Let its callers worry about skb headers adjustment. Signed-off-by: Boris Sukholitko --- net/core/skbuff.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/net/core/skbuff.c b/net/core/skbuff.c index 23f0db1db048..1bd817c8ddc8 100644 --- a/net/core/skbuff.c +++ b/net/core/skbuff.c @@ -6237,7 +6237,6 @@ static int skb_vlan_flush(struct sk_buff *skb) return err; skb->protocol = skb->vlan_proto; - skb->mac_len += VLAN_HLEN; skb_postpush_rcsum(skb, skb->data + (2 * ETH_ALEN), VLAN_HLEN); return 0; @@ -6252,6 +6251,8 @@ int skb_vlan_push(struct sk_buff *skb, __be16 vlan_proto, u16 vlan_tci) int err = skb_vlan_flush(skb); if (err) return err; + + skb->mac_len += VLAN_HLEN; } __vlan_hwaccel_put_tag(skb, vlan_proto, vlan_tci); return 0; From patchwork Wed Aug 14 13:06:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Boris Sukholitko X-Patchwork-Id: 13763470 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-pf1-f178.google.com (mail-pf1-f178.google.com [209.85.210.178]) (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 EF63A1109 for ; Wed, 14 Aug 2024 13:06:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.178 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723640811; cv=none; b=sKrRORrd0wpmlrn63JmGa6q9+X8+2S7/p66PJ8AGoFzDMdv37fiOBYIStlRuIHrVt2gEer1VwuYtDDSIIhx9D/8s9HkGeKvnkWqUeDL91Ak6VMguED2tyQAc6wu6AlD4jby9G00zSns43YbH+M5ie9seMRM4dbNdRhkhBFH1fVQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723640811; c=relaxed/simple; bh=c0Z0S1anIl0K69+F6MOi89jUgaugq+mo8EhGncANIoE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=tDAV6TaQQW8C0CxCNxeCuFE2L3rCocrJc5A4NW9I4JqxxvGLMiBq/Ia1BSdzmRMFGBEs3dZzdT1LkHrpPk1nb5RtwxdXwTsBprLXHYX53wfI+ANwyspCLDq+bMeXUOLiP2BUCt2062EWUv6HzNDqjB67G00XIalKiG3EqjEivrw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=broadcom.com; spf=fail smtp.mailfrom=broadcom.com; dkim=pass (1024-bit key) header.d=broadcom.com header.i=@broadcom.com header.b=UjqDilPx; arc=none smtp.client-ip=209.85.210.178 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=broadcom.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=broadcom.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=broadcom.com header.i=@broadcom.com header.b="UjqDilPx" Received: by mail-pf1-f178.google.com with SMTP id d2e1a72fcca58-710bdddb95cso3989763b3a.3 for ; Wed, 14 Aug 2024 06:06:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; t=1723640809; x=1724245609; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=7BMdfpqrY5tm8/jK+EFC7SH1Yd5hnsxPDDCueoCM2z4=; b=UjqDilPx11O2wPo+JNejKrj9guhcbKuSbVJ/Y+DLXScZkx7tvPpUDjEZNMRuPI1gXQ tJcoFu/wqpBt8IgDX1Z5rpxSdZWvg/YCFXHfTG5+g//nu4s+HlnLSZmnlFHSasIeENoy Q2I0HiWYC7h5kRWEb1sv2fKNxs4y7XReZjo0Y= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723640809; x=1724245609; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=7BMdfpqrY5tm8/jK+EFC7SH1Yd5hnsxPDDCueoCM2z4=; b=PGOPPyrGUrpKhV45e6Y/n5HGkrtRsnI2XhZhmoWP/rFGRh15YY6yL9nAFclONrsSYh q+8TqaiTlecGf0SDkSNxG4xbYg6aOh7b4gdOpeg7QpeVBMiH9r14FVG/VcIwM1sEFfKO okKZuz/fhQgirynGD6r1F7aNfamBlSyI5MlRcYh+yHg8w6Bd9DybFZeO1OMMp3ZXYSlg GkoOPL4OFY51/5FVXi7DxE4jnpwQgOTSW9ocFquw4uxqZ2LteFEDvpFj0KASX+q9dWWS 2rxrODCsge76s0CfMvBgRfFStG8/S5FNx5/NVNDAbeoLxUFlkImo1cN8+mXVqHThe02J sBKg== X-Gm-Message-State: AOJu0Yxk1hvlH0wEMrBf7nVtZPDeHK9ga6zWrWQc0JqAZ95S/KtEUSsS XtxJwuWMit7LfwRDuTouDwbfgNBJpD/J0qXHOG1SmC7kO5XH4u7n2BKfpON9h2CQ50xFqyksoNQ mKDOJCTpKfO5Y8N2kaKl9qXl6YKFxZUdDSQXgh570nf0eizzfRn0k7hDq/a45Ib18JFruegbM26 mPS3I3ekmGdt+51qqMlN5Bjc2gkz50MZsT3bMYtrfjwyX5oaI6 X-Google-Smtp-Source: AGHT+IGnVjhFwurCHNbjYjv51rVCX+lKZITY0tBAUZPAueDe48jrzk6cUutpKf5mx8ECVu//RzDXIw== X-Received: by 2002:a05:6a00:4607:b0:70d:1dcf:e2b4 with SMTP id d2e1a72fcca58-712670f76edmr3403413b3a.1.1723640808453; Wed, 14 Aug 2024 06:06:48 -0700 (PDT) Received: from localhost.localdomain ([192.19.250.250]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-711841effe9sm4904543b3a.31.2024.08.14.06.06.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Aug 2024 06:06:47 -0700 (PDT) From: Boris Sukholitko To: netdev@vger.kernel.org, "David S . Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Jamal Hadi Salim , Cong Wang , Jiri Pirko , Mina Almasry , Pavel Begunkov , Alexander Lobakin , Lorenzo Bianconi , David Howells Cc: Ilya Lifshits Subject: [PATCH net-next v2 3/6] skb: export skb_vlan_flush Date: Wed, 14 Aug 2024 16:06:15 +0300 Message-ID: <20240814130618.2885431-4-boris.sukholitko@broadcom.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20240814130618.2885431-1-boris.sukholitko@broadcom.com> References: <20240814130618.2885431-1-boris.sukholitko@broadcom.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org Make skb_vlan_flush callable by other customers of skbuff. Signed-off-by: Boris Sukholitko --- include/linux/skbuff.h | 1 + net/core/skbuff.c | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h index cf8f6ce06742..5a9f06691c80 100644 --- a/include/linux/skbuff.h +++ b/include/linux/skbuff.h @@ -4054,6 +4054,7 @@ int skb_ensure_writable(struct sk_buff *skb, unsigned int write_len); int skb_ensure_writable_head_tail(struct sk_buff *skb, struct net_device *dev); int __skb_vlan_pop(struct sk_buff *skb, u16 *vlan_tci); int skb_vlan_pop(struct sk_buff *skb); +int skb_vlan_flush(struct sk_buff *skb); int skb_vlan_push(struct sk_buff *skb, __be16 vlan_proto, u16 vlan_tci); int skb_eth_pop(struct sk_buff *skb); int skb_eth_push(struct sk_buff *skb, const unsigned char *dst, diff --git a/net/core/skbuff.c b/net/core/skbuff.c index 1bd817c8ddc8..e28b2c8b717d 100644 --- a/net/core/skbuff.c +++ b/net/core/skbuff.c @@ -6220,7 +6220,7 @@ int skb_vlan_pop(struct sk_buff *skb) } EXPORT_SYMBOL(skb_vlan_pop); -static int skb_vlan_flush(struct sk_buff *skb) +int skb_vlan_flush(struct sk_buff *skb) { int offset = skb->data - skb_mac_header(skb); int err; @@ -6241,6 +6241,7 @@ static int skb_vlan_flush(struct sk_buff *skb) skb_postpush_rcsum(skb, skb->data + (2 * ETH_ALEN), VLAN_HLEN); return 0; } +EXPORT_SYMBOL(skb_vlan_flush); /* Push a vlan tag either into hwaccel or into payload (if hwaccel tag present). * Expects skb->data at mac header. From patchwork Wed Aug 14 13:06:16 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Boris Sukholitko X-Patchwork-Id: 13763471 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-pf1-f179.google.com (mail-pf1-f179.google.com [209.85.210.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 DDC391AED2E for ; Wed, 14 Aug 2024 13:06:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.179 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723640816; cv=none; b=WzNGmia99leALDQK6l0FLumxTkqg+02R3Y6hMqCOTS+ZxGm8l44YYbENndUHqrtoy08n7SpKOFs8Zz8HK0CMTEnsPN4ubi/PXuzIa+7V9juMgDXUOlxz7YS/0exvog2VOtnbMsyjqIbNZ4eLpoinxvk+kSnwVoTj+wX5MW+b7jc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723640816; c=relaxed/simple; bh=v/yXJrBDlpAQrlFKowIyb4g9XUvrM0bLLMWzVwzKonU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=SmZPcd9aMLFV4AwaQU4UB+QggxbYHImKpoGl9c3JNxUJKNGQEdy2q96gNRUkNo/Qnrp82r6O9fttDTbzyAIjZhQlrmNl0Lx3q3BZLMhi2zjHwCpvtMZ3/tgs9mLrtTyg92uI5HGJd5q7jGnN8DqceucMkj0HX4XzTB2ols9MfZU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=broadcom.com; spf=fail smtp.mailfrom=broadcom.com; dkim=pass (1024-bit key) header.d=broadcom.com header.i=@broadcom.com header.b=LF6xQuzs; arc=none smtp.client-ip=209.85.210.179 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=broadcom.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=broadcom.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=broadcom.com header.i=@broadcom.com header.b="LF6xQuzs" Received: by mail-pf1-f179.google.com with SMTP id d2e1a72fcca58-710d1de6e79so4582704b3a.0 for ; Wed, 14 Aug 2024 06:06:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; t=1723640814; x=1724245614; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=5vsfsWl1qU21FyjK2pca4Vhgh1w520tV98Txp3TT/7s=; b=LF6xQuzsYjBRh90q9VzS89X+WNyQp9IQVSFREGoHySUlc54vVQwWXGRaM7iIC+D7pW KOCd0lav/X0h9+4GKhEYHpPgju82FGlT7S2+I39hZ0SDx8JdR7QczJKizEaKwAyS1v4R zVQuzIJ+I4xa26y+ZzMkX2KoSgHnDi6nseC30= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723640814; x=1724245614; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=5vsfsWl1qU21FyjK2pca4Vhgh1w520tV98Txp3TT/7s=; b=C/YOkLqR8ZtiMrF5J0d2B8xpDvd7dztq6BrHfbeIN88R39J8caP9dBIURM26A8el0R H4WqUnM4cJDKytynx921N2nmwjpA2Oz8hjlfuIf4jGvMahMQhtWN2m94NeSn0qEP/BNv r/EdbjnfpLQSEw9mbZRch0u60woyhc391xEyayUJrUAmT+/pXlbNU/AWJ5s4LJfBarSF IcF0zmASIJXvCj6K/AG2+qQQjwBfRku3TDGmopgUjnQWtYULv92fUVSNOVHiDljedazi yszaOJSZ6UN8MtdSnY3qxpAfEH6A5BVH6X8KFEaBdSiIgPZ5rq++gAyllQRbRHwEfvO1 jQJQ== X-Gm-Message-State: AOJu0Yy7kvrwSr/TX5fA/hdfouxy2jt3F3R+aSIwWjFzRzERnFgiNYPa sL5Mqx+bgSviTj0Az3uhuZN9eYwvZs2UNIFw67YKVvbNdcj6ddyMFeGr4AkstsGUKvW7p6v6UPl +zwxOTLu5pvqTIcCaaDvgfMv8AYiCIAoYUlAE0vYGz/63+DX9bae2gJHS+l/9wsgrhGCH3gK+WX vdHFLgM9uyRV1pKXPKjUk+w46XK6QcpIbX94SSnlKgjmUm5k3p X-Google-Smtp-Source: AGHT+IEV9Z75VXA9r04zQ9iN3coGrXnqqdUMsX+f3yCJOgJT9JGiA0P/WXHNQ+FFXEwgfGla+VSB0w== X-Received: by 2002:a05:6a20:9f89:b0:1c4:818c:2986 with SMTP id adf61e73a8af0-1c8eae895acmr3377500637.13.1723640813475; Wed, 14 Aug 2024 06:06:53 -0700 (PDT) Received: from localhost.localdomain ([192.19.250.250]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-711841effe9sm4904543b3a.31.2024.08.14.06.06.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Aug 2024 06:06:52 -0700 (PDT) From: Boris Sukholitko To: netdev@vger.kernel.org, "David S . Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Jamal Hadi Salim , Cong Wang , Jiri Pirko , Mina Almasry , Pavel Begunkov , Alexander Lobakin , Lorenzo Bianconi , David Howells Cc: Ilya Lifshits Subject: [PATCH net-next v2 4/6] act_vlan: open code skb_vlan_push Date: Wed, 14 Aug 2024 16:06:16 +0300 Message-ID: <20240814130618.2885431-5-boris.sukholitko@broadcom.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20240814130618.2885431-1-boris.sukholitko@broadcom.com> References: <20240814130618.2885431-1-boris.sukholitko@broadcom.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org Prepare to do act_vlan specific network header adjustment by copy-pasting several lines of skb_vlan_push code. Signed-off-by: Boris Sukholitko --- net/sched/act_vlan.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/net/sched/act_vlan.c b/net/sched/act_vlan.c index 22f4b1e8ade9..84b79096df2a 100644 --- a/net/sched/act_vlan.c +++ b/net/sched/act_vlan.c @@ -49,10 +49,15 @@ TC_INDIRECT_SCOPE int tcf_vlan_act(struct sk_buff *skb, goto drop; break; case TCA_VLAN_ACT_PUSH: - err = skb_vlan_push(skb, p->tcfv_push_proto, p->tcfv_push_vid | + if (skb_vlan_tag_present(skb)) { + err = skb_vlan_flush(skb); + if (err) + goto drop; + + skb->mac_len += VLAN_HLEN; + } + __vlan_hwaccel_put_tag(skb, p->tcfv_push_proto, p->tcfv_push_vid | (p->tcfv_push_prio << VLAN_PRIO_SHIFT)); - if (err) - goto drop; break; case TCA_VLAN_ACT_MODIFY: /* No-op if no vlan tag (either hw-accel or in-payload) */ From patchwork Wed Aug 14 13:06:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Boris Sukholitko X-Patchwork-Id: 13763472 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-pf1-f169.google.com (mail-pf1-f169.google.com [209.85.210.169]) (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 BF6211AED2E for ; Wed, 14 Aug 2024 13:06:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.169 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723640821; cv=none; b=uspWyi12Yh6Q+Vf9XxEEIPW4zwAypKuomgWbFcu6wOvoA5iXNr9qc7PqZ45LKH/phRxNH2i8kBsd6w2d33RzEtRtUMgpnyElXHvmUtYHFZN1eijsziboN5Xlptao1HL3XJFnptrBhZXY9jVKOFAEXAaq+gZntLG8pFBFeRZLd/g= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723640821; c=relaxed/simple; bh=awncP+NbvdzC4cT4Ugklak4GH4LxTINDlQi4Kzk3Y1Y=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Z4XkRLe7BEE+L7PyO54ZxvSyYO+QJBOLaFuB8M7ZdVP5diqPSeYTt4FAFqcgWsQMDSjZfwrLDc7YyoXjhIsnp9qZ54EsZEc9EjKIJqgbzWHdO3Z6HVgPgFNw0ooGdbWIC7DclBiajfTjZ1VcCJIYVVhECnb8PWspXfxx6Pfu4cg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=broadcom.com; spf=fail smtp.mailfrom=broadcom.com; dkim=pass (1024-bit key) header.d=broadcom.com header.i=@broadcom.com header.b=d/tMg0nB; arc=none smtp.client-ip=209.85.210.169 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=broadcom.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=broadcom.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=broadcom.com header.i=@broadcom.com header.b="d/tMg0nB" Received: by mail-pf1-f169.google.com with SMTP id d2e1a72fcca58-7106e2d0ec1so4688729b3a.2 for ; Wed, 14 Aug 2024 06:06:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; t=1723640819; x=1724245619; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=d+8wRwU8tWwhWYpBIsJnKE89P/+rgqOTvwYqNON+ucs=; b=d/tMg0nBMqleBi5I2/qrkm3x7VpzYFVtkL7FK7XS8Knq8ik0yTpeS2r7TQNbhqXfox QHhNz9YWs2Q2bcLbesMIhPVzFlzagYBA8+5TFqy8p6b9P6Cvt4bOtCFZesvG9i7GRdm6 pbtkQ85J4w41f/zvCkKoVogjPdVTBqquVUMBs= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723640819; x=1724245619; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=d+8wRwU8tWwhWYpBIsJnKE89P/+rgqOTvwYqNON+ucs=; b=psl8EYAVIZNtkl6IVaRNXnwGevgKE5QJw5osZA4FzvVvYepoke+Z0g2DA4cGLKVU+0 iDFRV68nKQGgaffCrL2xumx8x5PaH9PE9UV30RI6uPo6GGrP5Ntdeeo8qKC5m5I3qTuU pP7I1cJqecRhDJrr0QTYujsH3EvgpLtVGxdRHNuk5nvzHSoaoIIi4QgW/UEqLjgBv7P1 T9RV/3CtdLepTjGPIAZ4i84LyZPix5JyeYWTDNH+zUAsx6W/F4+5tzi/5dTR3r/jBIkI DsalSoqw5O0TXgQm3py7xg6j4kPWuJeyKjffsSzvPkKYU+AWVqp1TjvFMMNGieNbQTTn g7DA== X-Gm-Message-State: AOJu0Yywc/sL9c8aJSHi0Q3olOZsv7Hf2IYMma9J8BJeYieX9D7c76pM KlrIE742PbiRVGURnIVY/Z47hbDNtSS/HLBtRwEDwYA0uTk4csI83SLbAlEuWfYvOfqjHWSoH0I GVXINGo0aBDDTDXM5QG+QjGv4yJdpEun/ZYoPCWxfidVYAUmAqN/CLN/SLu3IquQCS+R0m9JvNZ gfcleSmyqF0TqrGltJM5kW5tLJBJvmjqKfRZk2Z33PdB/oRT5s X-Google-Smtp-Source: AGHT+IHLsvZ9uxUhCbWDraEppjMGzCyB1fcQYQGKk299s0XvtoUHR1kzCLkSxE575LGj2u3tKeqCEg== X-Received: by 2002:a05:6a00:3a25:b0:70a:f57c:fa27 with SMTP id d2e1a72fcca58-712673ac923mr2911907b3a.19.1723640818422; Wed, 14 Aug 2024 06:06:58 -0700 (PDT) Received: from localhost.localdomain ([192.19.250.250]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-711841effe9sm4904543b3a.31.2024.08.14.06.06.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Aug 2024 06:06:57 -0700 (PDT) From: Boris Sukholitko To: netdev@vger.kernel.org, "David S . Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Jamal Hadi Salim , Cong Wang , Jiri Pirko , Mina Almasry , Pavel Begunkov , Alexander Lobakin , Lorenzo Bianconi , David Howells Cc: Ilya Lifshits Subject: [PATCH net-next v2 5/6] act_vlan: adjust network header Date: Wed, 14 Aug 2024 16:06:17 +0300 Message-ID: <20240814130618.2885431-6-boris.sukholitko@broadcom.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20240814130618.2885431-1-boris.sukholitko@broadcom.com> References: <20240814130618.2885431-1-boris.sukholitko@broadcom.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org Consider the following shell script snippet configuring TC rules on the veth interface: ip link add veth0 type veth peer veth1 ip link set veth0 up ip link set veth1 up tc qdisc add dev veth0 clsact tc filter add dev veth0 ingress pref 10 chain 0 flower \ num_of_vlans 2 cvlan_ethtype 0x800 action goto chain 5 tc filter add dev veth0 ingress pref 20 chain 0 flower \ num_of_vlans 1 action vlan push id 100 \ protocol 0x8100 action goto chain 5 tc filter add dev veth0 ingress pref 30 chain 5 flower \ num_of_vlans 2 cvlan_ethtype 0x800 action simple sdata "success" Sending double-tagged vlan packet with the IP payload inside: cat <protocol; } else { vlan = __skb_header_pointer(skb, nhoff, sizeof(_vlan), data, hlen, &_vlan); if (!vlan) { fdret = FLOW_DISSECT_RET_OUT_BAD; break; } proto = vlan->h_vlan_encapsulated_proto; nhoff += sizeof(*vlan); } The "else" clause above gets the protocol of the encapsulated packet from the skb data at the network header location. printk debugging has showed that in the good double-tagged packet case proto is htons(0x800 == ETH_P_IP) as expected. However in the single-tagged packet case proto is garbage leading to the failure to match tc filter 30. proto is being set from the skb header pointed by nhoff parameter which is defined at the beginning of __skb_flow_dissect (net/core/flow_dissector.c:1055 in the current version): nhoff = skb_network_offset(skb); Therefore the culprit seems to be that the skb network offset is different between double-tagged packet received from the interface and single-tagged packet having its vlan tag pushed by TC. Lets look at the interesting points of the lifetime of the single/double tagged packets as they traverse our packet flow. Both of them will start at __netif_receive_skb_core where the first vlan tag will be stripped: if (eth_type_vlan(skb->protocol)) { skb = skb_vlan_untag(skb); if (unlikely(!skb)) goto out; } At this stage in double-tagged case skb->data points to the second vlan tag while in single-tagged case skb->data points to the network (eg. IP) header. Looking at TC vlan push action (net/sched/act_vlan.c) we have the following code at tcf_vlan_act (interesting points are in square brackets): if (skb_at_tc_ingress(skb)) [1] skb_push_rcsum(skb, skb->mac_len); .... case TCA_VLAN_ACT_PUSH: if (skb_vlan_tag_present(skb)) { int err = skb_vlan_flush(skb); if (err) goto drop; [2] skb->mac_len += VLAN_HLEN; } break; .... out: if (skb_at_tc_ingress(skb)) [3] skb_pull_rcsum(skb, skb->mac_len); Lets look at what happens with skb->data of the single-tagged packet at each of the above points: 1. As a result of the skb_push_rcsum, skb->data is moved back to the start of the packet. 2. First VLAN tag is moved from the skb into packet buffer, skb->mac_len is incremented, skb->data still points to the start of the packet. 3. As a result of the skb_pull_rcsum, skb->data is moved forward by the modified skb->mac_len, thus pointing to the network header again. Then __skb_flow_dissect will get confused by having double-tagged vlan packet with the skb->data at the network header. The same bug happens also on the egress path. The root cause there is that skb->network_header is in disagreement with skb->mac_len. This patch fixes both of the above problems by adjusting skb->network_header rather than skb->mac_vlan. skb->mac_vlan is being reset accordingly after skb_pull_rcsum is done. Signed-off-by: Boris Sukholitko --- net/sched/act_vlan.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/net/sched/act_vlan.c b/net/sched/act_vlan.c index 84b79096df2a..c113f8026f1f 100644 --- a/net/sched/act_vlan.c +++ b/net/sched/act_vlan.c @@ -54,7 +54,7 @@ TC_INDIRECT_SCOPE int tcf_vlan_act(struct sk_buff *skb, if (err) goto drop; - skb->mac_len += VLAN_HLEN; + skb->network_header -= VLAN_HLEN; } __vlan_hwaccel_put_tag(skb, p->tcfv_push_proto, p->tcfv_push_vid | (p->tcfv_push_prio << VLAN_PRIO_SHIFT)); @@ -101,6 +101,7 @@ TC_INDIRECT_SCOPE int tcf_vlan_act(struct sk_buff *skb, if (skb_at_tc_ingress(skb)) skb_pull_rcsum(skb, skb->mac_len); + skb_reset_mac_len(skb); return action; drop: From patchwork Wed Aug 14 13:06:18 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Boris Sukholitko X-Patchwork-Id: 13763473 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-pf1-f174.google.com (mail-pf1-f174.google.com [209.85.210.174]) (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 86CD41AE867 for ; Wed, 14 Aug 2024 13:07:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.174 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723640825; cv=none; b=pVzMDgxOzrkdyn9UiQ6O3pUKSUOeGLP5AcK5mxETPkovC/QClBiB9HtODvq0ZViat/k8kVBY3zeKQqkaORbfv12z47w8wgs+NxP1Z/BMIyWGUqBDtUswi7RG7M8hUs5Yd1DyxNp+a4CkU270JJd8Xt7ndKy0shaSzcxWVlfwZUc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723640825; c=relaxed/simple; bh=yNH29HNWWHeCPSbBtmTNpA5OZ2ZJrWr5Qtn5n6iU4M4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=WnO92y4qzES+C8d/qhHW3UjCICtdoouj0+nciulmdh0RKWuMZP7xhz9gBoa++w1Bw21o1HbTvaWPKjbuvoYiiWWiUN0AqAnZesZsNAjxEF11NCLV7ZUh6a0mL+wZvfE+ThpzNc0JaUdjLaVHAyxx7CxRp82JtvZg4XLQrt73bHw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=broadcom.com; spf=fail smtp.mailfrom=broadcom.com; dkim=pass (1024-bit key) header.d=broadcom.com header.i=@broadcom.com header.b=aRU2vFcz; arc=none smtp.client-ip=209.85.210.174 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=broadcom.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=broadcom.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=broadcom.com header.i=@broadcom.com header.b="aRU2vFcz" Received: by mail-pf1-f174.google.com with SMTP id d2e1a72fcca58-710bdddb95cso3989961b3a.3 for ; Wed, 14 Aug 2024 06:07:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; t=1723640823; x=1724245623; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=nSb9nL1NXkMQuWYyldqJJuCwmx8megk+Vrk+Mj+E3j4=; b=aRU2vFczBN/+4KXandcBv3F/uoMfA++xZ4hNNViuM5FH4piwJjTn/lU1nrzTxYT8ha y2R1xJbcDTOxKiUIiqASGBApU65JJQvQj1OpPKjf72lAaWgD7/0UNlVv0xlthuen4JEi geXzDkeV4ebZjNH9CkyvFhASk6Po7BHWCPUBs= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723640823; x=1724245623; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=nSb9nL1NXkMQuWYyldqJJuCwmx8megk+Vrk+Mj+E3j4=; b=P8olhYvqgE0r8L3pr3bQraAAtNkeBeupAS6OfsmRqhr/rTW5sK4OoEO3/F4OdWtFo3 KsCgK1d8VP8jK5qnqzDrTU+jyO1egEDP6h4okQYPXczEVniUxkpsngaqZFgdBKMbpyP0 qFzrj9Lt1fhVp330+W4EqCTCva/+uRg+YfNyno9isA0/UpQ/k6Z2f9dbShZaILGXctNL VWPWcntJp14Ctjbz8MF5hiv4sK21DJ5kGRgFa6xdX8Grt54ACD6vSlav1LAKnTNOh5BR LspMdjvyy6QXE6SVDPcfRQKeJrXlko0R3WdT8o8pQYympR0McsB6i10n5vXL5Ud99/5g MxvA== X-Gm-Message-State: AOJu0YxF46LIDKYZfH52UVIs2/mAxO6ePBeU5R3aatpk3UPliL1Spcl2 bFEjhvKBC7MT1V9u6bErLETgTNiryMKbqTAnarSE1B2zbsp53EbIMo/O+qKA/Szbv3cLLOvzb7K Ei7Rhq9/epRWMMYOcNNbcRdbn4gGVTvKoRzGuZC9toVSQFguVBA3aZeSNw6Bo6pvr38CPb2vo6W je0dRAspRK4pFm5dBclfh08eZvwu9d0xbFrz+gkAFkfXeFgbnf X-Google-Smtp-Source: AGHT+IEkBg5i98a9ytQQCQyqXg1DzSuk0W8IzE17ZS/37iNXx3VWz2bq0aqk6VvSyTCs0yrl9lTPBw== X-Received: by 2002:a05:6a20:c78e:b0:1c6:fc56:744 with SMTP id adf61e73a8af0-1c8eae97a21mr3243317637.31.1723640823317; Wed, 14 Aug 2024 06:07:03 -0700 (PDT) Received: from localhost.localdomain ([192.19.250.250]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-711841effe9sm4904543b3a.31.2024.08.14.06.06.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Aug 2024 06:07:02 -0700 (PDT) From: Boris Sukholitko To: netdev@vger.kernel.org, "David S . Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Jamal Hadi Salim , Cong Wang , Jiri Pirko , Mina Almasry , Pavel Begunkov , Alexander Lobakin , Lorenzo Bianconi , David Howells Cc: Ilya Lifshits Subject: [PATCH net-next v2 6/6] selftests: forwarding: tc_actions: test vlan flush Date: Wed, 14 Aug 2024 16:06:18 +0300 Message-ID: <20240814130618.2885431-7-boris.sukholitko@broadcom.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20240814130618.2885431-1-boris.sukholitko@broadcom.com> References: <20240814130618.2885431-1-boris.sukholitko@broadcom.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org Add new test checking the correctness of inner vlan flushing to the skb data when outer vlan tag is added through act_vlan. Signed-off-by: Boris Sukholitko --- .../selftests/net/forwarding/tc_actions.sh | 22 ++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/tools/testing/selftests/net/forwarding/tc_actions.sh b/tools/testing/selftests/net/forwarding/tc_actions.sh index 589629636502..65ff80d66b17 100755 --- a/tools/testing/selftests/net/forwarding/tc_actions.sh +++ b/tools/testing/selftests/net/forwarding/tc_actions.sh @@ -4,7 +4,7 @@ ALL_TESTS="gact_drop_and_ok_test mirred_egress_redirect_test \ mirred_egress_mirror_test matchall_mirred_egress_mirror_test \ gact_trap_test mirred_egress_to_ingress_test \ - mirred_egress_to_ingress_tcp_test" + mirred_egress_to_ingress_tcp_test vlan_flush_test" NUM_NETIFS=4 source tc_common.sh source lib.sh @@ -244,6 +244,26 @@ mirred_egress_to_ingress_tcp_test() log_test "mirred_egress_to_ingress_tcp ($tcflags)" } +vlan_flush_test() +{ + ip link add x$h1 type veth peer x$h2 + ip link set x$h1 up + ip link set x$h2 up + + tc qdisc add dev x$h1 clsact + tc filter add dev x$h1 ingress pref 20 chain 0 handle 20 flower num_of_vlans 1 \ + action vlan push id 100 protocol 0x8100 action goto chain 5 + tc filter add dev x$h1 ingress pref 30 chain 5 handle 30 flower num_of_vlans 2 \ + cvlan_ethtype 0x800 action pass + + $MZ x$h2 -t udp -Q 10 -q + tc_check_packets "dev x$h1 ingress" 30 1 + check_err $? "No double-vlan packets received" + + ip link del x$h1 + log_test "vlan_flush_test ($tcflags)" +} + setup_prepare() { h1=${NETIFS[p1]}