From patchwork Mon Aug 19 11:06:07 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Boris Sukholitko X-Patchwork-Id: 13768182 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-qt1-f174.google.com (mail-qt1-f174.google.com [209.85.160.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 9957615535B for ; Mon, 19 Aug 2024 11:06:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.174 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724065601; cv=none; b=Li5dE+/gjBvoK39rkqqS2QlN83GTvl0j1pzkFjIDYuYjzLo2QKmqM0IQWTTVcTI70ecCZLYJIaRDyRqRAhXBV8qx9uarMmKWKmDOQt9wxifcuwawTiS0rVqBM+Irrnth31wB88KXQmWsw6j2Rc4RbKf5nYQeAF0fYAn4D8VnCbQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724065601; c=relaxed/simple; bh=xEAPvojJgqvr6PvJJHtBhFBxIdKTGTScam8mW+yLFYM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=XMQK1ARAD+4mIfwsKhzzQ3pFCj/g5ppzjkBZrBrk6sqG6FbALNM5YqSM+kwAzx5f16HS/zpjHJeheH5OKB6JmKKb2WezC6dxir7a9rbVn/0lNmAaQfL9pHkHQ2Vu/fGsXSH0lgapY7Gk6d2Afz7n+HST9n7Gu5ESdiT7q5k38QQ= 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=Sb3jLBXJ; arc=none smtp.client-ip=209.85.160.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="Sb3jLBXJ" Received: by mail-qt1-f174.google.com with SMTP id d75a77b69052e-44fe58fcf2bso25832691cf.2 for ; Mon, 19 Aug 2024 04:06:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; t=1724065598; x=1724670398; 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=ZZGFDxagONzXz7FVMHRPtOUOk+m8UJRKia/lDd9q95E=; b=Sb3jLBXJAMOO3RrLQMemU85bJX4l6J032RJC7mmctYAn7lkoGAv/bBTJlDrSgeTWwf eN+T8jQHVXaqw7MRt+eP95dp8MixtlRqgyp8b0GP1xh0qGvAp73LEPC1x/wKkg9ztXu4 G2yVly+KN2BBifN7jF++5bCQY80rTa9FtEqmk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724065598; x=1724670398; 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=ZZGFDxagONzXz7FVMHRPtOUOk+m8UJRKia/lDd9q95E=; b=GShrYaaD74g98TY/xRkPhwGGAipKqgX33y4bLET7ZHmqKXlGkq5ZI8w2Vieoq8jMyO +YF1D4AXYDYdRAqKVkru5BJ7y4y1r/7RsbpjrLvs7ZOReAX49U6UQhjcCzlzZb6KmpTF Lnx9yMhKSCsNz5pbgshDeA0qabHXeaswVGsKV/LmnR3E+41W8GdaBWWk1/2/k2OQ/Lo/ NQwG9guY2wktThf/KcHeaFtTltoJskIvTAQ38MjVKQFNOMhLYiXzLofEuPv8TMz5CXNa 5FgVW11suIHVfj3b2c04Elu8XjIHkAVm/m4oAvc8eoLjkcK8JZvEbCrTOMsaLHk76Yd8 pYwA== X-Gm-Message-State: AOJu0YxXd1GOdlZnBD+2+IszZ529ByuzdRkrmgpOEb1CoubkOqnZEDf1 Jn30eFH053PAAtJlNjg/uMBn62TqRqV9KoWiMBju1K5Sb1xVH5wxI7LVzQrQ+h/Rafu6m43GrYP hMS/UV7mDMPDT48hE5cqe3hwq58aZrWnmS7NJ1wmBViuxnNA/A4ScG85ld2IaDofHl6zHJZ1dj3 bV1H24ES5ACmhJfFCIo3EIwEcSo+Hzfe9UGdCAjTSv51gnO2sW X-Google-Smtp-Source: AGHT+IFXBuSSPVIEHAX7lrVuAdoXkNg0kj1cCNyYxaj2XgTLVCLTRZwtxYlg0aWhbKB+AahSw6a6TA== X-Received: by 2002:a05:622a:4ac9:b0:44f:dd14:5cd0 with SMTP id d75a77b69052e-453742facb4mr150315491cf.35.1724065597615; Mon, 19 Aug 2024 04:06:37 -0700 (PDT) Received: from localhost.localdomain ([192.19.250.250]) by smtp.gmail.com with ESMTPSA id d75a77b69052e-4536a072237sm38751911cf.86.2024.08.19.04.06.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Aug 2024 04:06:37 -0700 (PDT) From: Boris Sukholitko To: netdev@vger.kernel.org, Martin KaFai Lau , Daniel Borkmann , John Fastabend , Alexei Starovoitov , Andrii Nakryiko , Eduard Zingerman , Song Liu , Yonghong Song , KP Singh , Stanislav Fomichev , Hao Luo , Jiri Olsa , "David S . Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Pravin B Shelar , Jamal Hadi Salim , Cong Wang , Jiri Pirko , Shuah Khan , Willem de Bruijn , Pavel Begunkov , Mina Almasry , Lorenzo Bianconi , Sebastian Andrzej Siewior , David Howells , Liang Chen , Alexander Lobakin , =?utf-8?q?Thomas_Wei?= =?utf-8?q?=C3=9Fschuh?= , Ido Schimmel Cc: Ilya Lifshits Subject: [PATCH net-next v3 1/3] tc: adjust network header after 2nd vlan push Date: Mon, 19 Aug 2024 14:06:07 +0300 Message-ID: <20240819110609.101250-2-boris.sukholitko@broadcom.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20240819110609.101250-1-boris.sukholitko@broadcom.com> References: <20240819110609.101250-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 skb network header of the single-tagged vlan packet continues to point the vlan payload (e.g. IP) after second vlan tag is pushed by tc act_vlan. This causes problem at the dissector which expects double-tagged packet network header to point to the inner vlan. The fix is to adjust network header in tcf_act_vlan.c but requires refactoring of skb_vlan_push function. 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: err = skb_vlan_push(skb, p->tcfv_push_proto, p->tcfv_push_vid | (p->tcfv_push_prio << VLAN_PRIO_SHIFT), 0); if (err) goto drop; break; .... out: if (skb_at_tc_ingress(skb)) [3] skb_pull_rcsum(skb, skb->mac_len); And skb_vlan_push (net/core/skbuff.c:6204) function does: err = __vlan_insert_tag(skb, skb->vlan_proto, skb_vlan_tag_get(skb)); if (err) return err; skb->protocol = skb->vlan_proto; [2] skb->mac_len += VLAN_HLEN; in the case of pushing the second tag. 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 solution for the bug is to preserve "skb->data at second vlan header" semantics in the skb_vlan_push function. We do this by manipulating skb->network_header rather than skb->mac_len. skb_vlan_push callers are updated to do skb_reset_mac_len. Signed-off-by: Boris Sukholitko --- net/core/filter.c | 1 + net/core/skbuff.c | 2 +- net/openvswitch/actions.c | 8 ++++++-- net/sched/act_vlan.c | 1 + 4 files changed, 9 insertions(+), 3 deletions(-) diff --git a/net/core/filter.c b/net/core/filter.c index f3c72cf86099..74d2c906f35a 100644 --- a/net/core/filter.c +++ b/net/core/filter.c @@ -3189,6 +3189,7 @@ BPF_CALL_3(bpf_skb_vlan_push, struct sk_buff *, skb, __be16, vlan_proto, bpf_push_mac_rcsum(skb); ret = skb_vlan_push(skb, vlan_proto, vlan_tci); bpf_pull_mac_rcsum(skb); + skb_reset_mac_len(skb); bpf_compute_data_pointers(skb); return ret; diff --git a/net/core/skbuff.c b/net/core/skbuff.c index de2a044cc665..2c8f6f34c545 100644 --- a/net/core/skbuff.c +++ b/net/core/skbuff.c @@ -6244,7 +6244,7 @@ int skb_vlan_push(struct sk_buff *skb, __be16 vlan_proto, u16 vlan_tci) return err; skb->protocol = skb->vlan_proto; - skb->mac_len += VLAN_HLEN; + skb->network_header -= VLAN_HLEN; skb_postpush_rcsum(skb, skb->data + (2 * ETH_ALEN), VLAN_HLEN); } diff --git a/net/openvswitch/actions.c b/net/openvswitch/actions.c index 101f9a23792c..16e260014684 100644 --- a/net/openvswitch/actions.c +++ b/net/openvswitch/actions.c @@ -237,14 +237,18 @@ static int pop_vlan(struct sk_buff *skb, struct sw_flow_key *key) static int push_vlan(struct sk_buff *skb, struct sw_flow_key *key, const struct ovs_action_push_vlan *vlan) { + int err; + if (skb_vlan_tag_present(skb)) { invalidate_flow_key(key); } else { key->eth.vlan.tci = vlan->vlan_tci; key->eth.vlan.tpid = vlan->vlan_tpid; } - return skb_vlan_push(skb, vlan->vlan_tpid, - ntohs(vlan->vlan_tci) & ~VLAN_CFI_MASK); + err = skb_vlan_push(skb, vlan->vlan_tpid, + ntohs(vlan->vlan_tci) & ~VLAN_CFI_MASK); + skb_reset_mac_len(skb); + return err; } /* 'src' is already properly masked. */ diff --git a/net/sched/act_vlan.c b/net/sched/act_vlan.c index 22f4b1e8ade9..9e2dbde3cc29 100644 --- a/net/sched/act_vlan.c +++ b/net/sched/act_vlan.c @@ -96,6 +96,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_header(skb); return action; drop: From patchwork Mon Aug 19 11:06:08 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Boris Sukholitko X-Patchwork-Id: 13768183 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-oi1-f177.google.com (mail-oi1-f177.google.com [209.85.167.177]) (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 B654915535B for ; Mon, 19 Aug 2024 11:06:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.177 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724065607; cv=none; b=hl/jCioNEet5DWC7w/Nsy2YhUpLksO54vtE52OJtHWcaUdTU217UPH3JWADNsb9pZail5UHw9eVAnX9TFCDBUe3/jpK1Ec1pRQkIwsOeOMD/KdXDUIk3LoiCGt6cv4/gqpdvFwD8uPFSzyqKL98ZixmxTRpRdPy9IFE2MWY0Hq8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724065607; c=relaxed/simple; bh=Lhw+EJIzGQi4132lxIagTDi6xBVS/vZELXzYQ9g4xUw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=okNCSBHb52weGWsLjn9EywY3UfTo5ANgWkWHhtZan3k68onkJ7QL5q/F1hbHgR6RDYE+nF4gEQpukQ6gqPyYDW9j5NaVvEzw1d08Uwvoezj/YSnXEfx5rHMqrMywixxApopr8nOalIFiJUTFQHk2/DEL5HYDRIpV+2WqEmn/FvM= 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=TvgbulfJ; arc=none smtp.client-ip=209.85.167.177 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="TvgbulfJ" Received: by mail-oi1-f177.google.com with SMTP id 5614622812f47-3db18c4927bso2423728b6e.1 for ; Mon, 19 Aug 2024 04:06:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; t=1724065604; x=1724670404; 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=xh6Hmi0uPWAq1EzRKIGF9fSV7CZNe7f3f2yDixp6Zko=; b=TvgbulfJoFKDwpe7ELkATfqdylcUtoV1+aIspqKfLNG6ux9Q2yxKMzV1PeA/u+o6o4 yDhs3rr1RRPN4IJQ/4GYDWO0B7qffSLvZyS42a8dRLdhRqfpfZN0RWN1vtDvnG0ZC4uk LvNf+CioP+ucNQQm7pd1d3LwSr871e3ZmMfLY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724065604; x=1724670404; 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=xh6Hmi0uPWAq1EzRKIGF9fSV7CZNe7f3f2yDixp6Zko=; b=NY7d15IP4KIf3hOc8cHxUPIj4RxEcBL65wHfl2GBonK63b98xVoAtl+sduKH+5lQQL kwCTMAoLU837TPhhpyj7e7kqF6MD4OmcwIoFaHMe/mnhQNdKm/3poZc+MU8Ubi7Bk2YM rBD1MJqrupmCLYuACaMMTxt4AqkR1BUbG1lmZMaWY7/IjALS3tqXoXBk1uzqHiCFjjMG mtj8YVxzPZcasN/PKlVbeMGvFSG223DZLDtB1/bNuL+MqJFMKm314tW6/zzTfJoT23UO g7K/XYyuNruQli9XlAOaoP5xgM8hbwI9cN3uNDStam5QJkjuW1AGPJYvER4RXnv5ZdUg s/iQ== X-Gm-Message-State: AOJu0YyftrRrAwVitdSSD0AmRm3M7g52M9afII2pFigGshnBAS3cELpR YGrxPgHeqK0pYmYl9GUP/RVwQdKrqbZY7JXkjXCZBWZd51bixeKXrMpNmz9WIkO9TQJJOilri0L bxPRXiIJw1ckL8X+YCkedhbp4FkWuLGgqGU49adYT4i9N4EexrHfohHqLFxH3gLQ7sBOk8pdwuY sI8B0aVi5BJqJa53FvvqFum/6FGFVNegY/J3m771YYUIDEDIAq X-Google-Smtp-Source: AGHT+IE+X5bjrPIc6dlUIfZARh7SlbjlQC2o0TRImlG0FurgQAEpEvOAKrGZOopcNXk8byaVSFqOfA== X-Received: by 2002:a05:6808:222a:b0:3da:ab89:a806 with SMTP id 5614622812f47-3dd3ad5239bmr11164075b6e.25.1724065604014; Mon, 19 Aug 2024 04:06:44 -0700 (PDT) Received: from localhost.localdomain ([192.19.250.250]) by smtp.gmail.com with ESMTPSA id d75a77b69052e-4536a072237sm38751911cf.86.2024.08.19.04.06.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Aug 2024 04:06:43 -0700 (PDT) From: Boris Sukholitko To: netdev@vger.kernel.org, Martin KaFai Lau , Daniel Borkmann , John Fastabend , Alexei Starovoitov , Andrii Nakryiko , Eduard Zingerman , Song Liu , Yonghong Song , KP Singh , Stanislav Fomichev , Hao Luo , Jiri Olsa , "David S . Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Pravin B Shelar , Jamal Hadi Salim , Cong Wang , Jiri Pirko , Shuah Khan , Willem de Bruijn , Pavel Begunkov , Mina Almasry , Lorenzo Bianconi , Sebastian Andrzej Siewior , David Howells , Liang Chen , Alexander Lobakin , =?utf-8?q?Thomas_Wei?= =?utf-8?q?=C3=9Fschuh?= , Ido Schimmel Cc: Ilya Lifshits Subject: [PATCH net-next v3 2/3] selftests: tc_actions: test ingress 2nd vlan push Date: Mon, 19 Aug 2024 14:06:08 +0300 Message-ID: <20240819110609.101250-3-boris.sukholitko@broadcom.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20240819110609.101250-1-boris.sukholitko@broadcom.com> References: <20240819110609.101250-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 on ingress. Signed-off-by: Boris Sukholitko --- .../selftests/net/forwarding/tc_actions.sh | 23 ++++++++++++++++++- 1 file changed, 22 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..f2f1e99a90b2 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 ingress_2nd_vlan_push" NUM_NETIFS=4 source tc_common.sh source lib.sh @@ -244,6 +244,27 @@ mirred_egress_to_ingress_tcp_test() log_test "mirred_egress_to_ingress_tcp ($tcflags)" } +ingress_2nd_vlan_push() +{ + tc filter add dev $swp1 ingress pref 20 chain 0 handle 20 flower \ + $tcflags num_of_vlans 1 \ + action vlan push id 100 protocol 0x8100 action goto chain 5 + tc filter add dev $swp1 ingress pref 30 chain 5 handle 30 flower \ + $tcflags num_of_vlans 2 \ + cvlan_ethtype 0x800 action pass + + $MZ $h1 -c 1 -p 64 -a $h1mac -b $h2mac -A 192.0.2.1 -B 192.0.2.2 \ + -t ip -Q 10 -q + + tc_check_packets "dev $swp1 ingress" 30 1 + check_err $? "No double-vlan packets received" + + tc filter del dev $swp1 ingress pref 20 chain 0 handle 20 flower + tc filter del dev $swp1 ingress pref 30 chain 5 handle 30 flower + + log_test "ingress_2nd_vlan_push ($tcflags)" +} + setup_prepare() { h1=${NETIFS[p1]} From patchwork Mon Aug 19 11:06:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Boris Sukholitko X-Patchwork-Id: 13768184 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-qt1-f175.google.com (mail-qt1-f175.google.com [209.85.160.175]) (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 0AA641607A7 for ; Mon, 19 Aug 2024 11:06:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.175 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724065613; cv=none; b=p9Rty5B8nyIf2n8dERDR8mfIBa2yHdbl1gMdRuLKM4ZTT44bG+2txEsmC1acnxy0LFQ1nMKD0UtjWm/xVij1VEElPslxq/rNKMJ0/aLXkBygHZWZ10FSqknEZqsU11tLVzbg+tWgX5Xqsvdp4VcAf3UZhJ1IvMbbtfEl7tIOtMk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724065613; c=relaxed/simple; bh=2rvQ16eUsSUI86NjGJaanw+rVAkWujnMIDdufrVcTt0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=lbGuc/sBBgzhubRtwFesurUYFO91IcWs0FzcFz9RKP0416p9nilM/5GhFLXywoKCEndsVnGSUEb6qBGswpiSHb4TMwTNErday/uGluwVt5HS9BRdzPiSjBJjUmufd3DvchEZFb9QXM7CppYrGPDJbOebaJakD1NT9s5HuxO7zwE= 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=WQ8qJGhM; arc=none smtp.client-ip=209.85.160.175 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="WQ8qJGhM" Received: by mail-qt1-f175.google.com with SMTP id d75a77b69052e-44febbc323fso22164451cf.1 for ; Mon, 19 Aug 2024 04:06:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; t=1724065610; x=1724670410; 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=64T1/IUPdIC0djcgy0Ye7/9E+JF1//L5kmNcl5se5Cc=; b=WQ8qJGhM7S3bBdyNs2jKqu+CRhf99jwbBDumgXSSFHuTVqIULXWLhbWE+JS8rOqSk/ +HwNobIr51453zKyqgXFomrWQID4LDMlv/LZxlWkA0L09qr0p2vJdaC/Jz6L70Ax36+O uUHMF2m/Mm9qjKuM27ZaBS+8L/ZLZHiNATDJg= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724065610; x=1724670410; 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=64T1/IUPdIC0djcgy0Ye7/9E+JF1//L5kmNcl5se5Cc=; b=h32k/v8lrmG+ABacGjfuxsaEQ9SH7ifnZJ75cvhLHrtO5QiCihsUFGq504GD5KdETg 8nipCV6RDqgNcG9yxDboOL5jxNzihv343ZKP7w8gcaWPjymJMB0l0lQblpJN1HlA6J9E w4Wyt98zcoVHrwqsf0VZfToSpCIZGaDgi5PPbqr2a7QWetBqEgTqQmXhZRGp35aO+IYp zbvqYUyO5Y1OGMrfUb6EmHPdIOFyN8DbBtX9zAn3T5DaZOjowLDUdiUQ8HKhDfzwoSdZ yW+zTKGOJSl4kliI8rmyVM5U8TPqYBWWodAxqWHex0VE1sVpco2b347wzycozBYDrJOW uMXw== X-Gm-Message-State: AOJu0YxDu4GJcez31ycmCK6Cc6on1dmSeilSaclaBUtMZnJ6o6BnT1yI NHvvaqaNU6ldxyo6KVhwrrIvWRYUgFKDgBCCVvSCdSb3YL+DYDgAAq/8ctzXWayUdj2bziD/gl9 CCH2M80NxVJtghjdmlnh30aMOCs7LW4SaP4zuXAki0H2t2hmAYu1UEmJ4GJC36cry7C203qpMxe 8GEzXWO7+kQXSm3n65vU/UjqNWEZq8DNyPw0TKrVAEg9R9bsn+ X-Google-Smtp-Source: AGHT+IHhXcmVZzxC9OyrMmo+i+21aEcmHiWzWpBDIOumSUc/Keo47NUe1J7/Nx9FGAV6+O/0xt9n7Q== X-Received: by 2002:a05:622a:4d90:b0:453:6d98:4802 with SMTP id d75a77b69052e-454b68d3e71mr85095931cf.47.1724065610279; Mon, 19 Aug 2024 04:06:50 -0700 (PDT) Received: from localhost.localdomain ([192.19.250.250]) by smtp.gmail.com with ESMTPSA id d75a77b69052e-4536a072237sm38751911cf.86.2024.08.19.04.06.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Aug 2024 04:06:49 -0700 (PDT) From: Boris Sukholitko To: netdev@vger.kernel.org, Martin KaFai Lau , Daniel Borkmann , John Fastabend , Alexei Starovoitov , Andrii Nakryiko , Eduard Zingerman , Song Liu , Yonghong Song , KP Singh , Stanislav Fomichev , Hao Luo , Jiri Olsa , "David S . Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Pravin B Shelar , Jamal Hadi Salim , Cong Wang , Jiri Pirko , Shuah Khan , Willem de Bruijn , Pavel Begunkov , Mina Almasry , Lorenzo Bianconi , Sebastian Andrzej Siewior , David Howells , Liang Chen , Alexander Lobakin , =?utf-8?q?Thomas_Wei?= =?utf-8?q?=C3=9Fschuh?= , Ido Schimmel Cc: Ilya Lifshits Subject: [PATCH net-next v3 3/3] selftests: tc_actions: test egress 2nd vlan push Date: Mon, 19 Aug 2024 14:06:09 +0300 Message-ID: <20240819110609.101250-4-boris.sukholitko@broadcom.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20240819110609.101250-1-boris.sukholitko@broadcom.com> References: <20240819110609.101250-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 on egress. Signed-off-by: Boris Sukholitko --- .../selftests/net/forwarding/tc_actions.sh | 25 ++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/tools/testing/selftests/net/forwarding/tc_actions.sh b/tools/testing/selftests/net/forwarding/tc_actions.sh index f2f1e99a90b2..ea89e558672d 100755 --- a/tools/testing/selftests/net/forwarding/tc_actions.sh +++ b/tools/testing/selftests/net/forwarding/tc_actions.sh @@ -4,7 +4,8 @@ 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 ingress_2nd_vlan_push" + mirred_egress_to_ingress_tcp_test \ + ingress_2nd_vlan_push egress_2nd_vlan_push" NUM_NETIFS=4 source tc_common.sh source lib.sh @@ -265,6 +266,28 @@ ingress_2nd_vlan_push() log_test "ingress_2nd_vlan_push ($tcflags)" } +egress_2nd_vlan_push() +{ + tc filter add dev $h1 egress pref 20 chain 0 handle 20 flower \ + $tcflags num_of_vlans 0 \ + action vlan push id 10 protocol 0x8100 \ + pipe action vlan push id 100 protocol 0x8100 action goto chain 5 + tc filter add dev $h1 egress pref 30 chain 5 handle 30 flower \ + $tcflags num_of_vlans 2 \ + cvlan_ethtype 0x800 action pass + + $MZ $h1 -c 1 -p 64 -a $h1mac -b $h2mac -A 192.0.2.1 -B 192.0.2.2 \ + -t ip -q + + tc_check_packets "dev $h1 egress" 30 1 + check_err $? "No double-vlan packets received" + + tc filter del dev $h1 egress pref 20 chain 0 handle 20 flower + tc filter del dev $h1 egress pref 30 chain 5 handle 30 flower + + log_test "egress_2nd_vlan_push ($tcflags)" +} + setup_prepare() { h1=${NETIFS[p1]}