From: Shaiq Wani <shaiq.wani@intel.com>
To: dev@dpdk.org, bruce.richardson@intel.com, aman.deep.singh@intel.com
Subject: [PATCH v2] net/ice: fix L2TPv2 outer MAC in training packet
Date: Thu, 9 Apr 2026 10:48:35 +0530 [thread overview]
Message-ID: <20260409051835.3413336-2-shaiq.wani@intel.com> (raw)
In-Reply-To: <20260409051835.3413336-1-shaiq.wani@intel.com>
In ice_fdir_get_gen_prgm_pkt() there are two pointers into the
training-packet buffer:
pkt – start of the full packet (outer Ethernet header, offset 0)
loc – start of the current protocol segment; equals pkt for
non-tunnel flows but points past the tunnel header for
tunnel flows
The L2TPv2 cases wrote the outer source and destination MAC addresses
through loc. For non-tunnel L2TPv2, loc == pkt so this happened to
work, but it is semantically wrong: outer Ethernet fields must always
be written relative to pkt so the code remains correct regardless of
the tunnel/non-tunnel path taken.
Replace loc with pkt in the four L2TPv2 MAC-insertion case blocks
(IPv4 control, IPv4 data/PPP, IPv6 control, IPv6 data/PPP)
Fixes: bf662653976e ("net/ice/base: support L2TPv2 flow rule")
Signed-off-by: Shaiq Wani <shaiq.wani@intel.com>
---
v2:
- Split from combined outer-MAC patch into separate fix.
- Add comment documenting difference between pkt vs loc pointers.
drivers/net/intel/ice/base/ice_fdir.c | 22 ++++++++++++++--------
1 file changed, 14 insertions(+), 8 deletions(-)
diff --git a/drivers/net/intel/ice/base/ice_fdir.c b/drivers/net/intel/ice/base/ice_fdir.c
index 2c0cb99854..f6c826e5b5 100644
--- a/drivers/net/intel/ice/base/ice_fdir.c
+++ b/drivers/net/intel/ice/base/ice_fdir.c
@@ -3830,6 +3830,12 @@ ice_fdir_get_gen_prgm_pkt(struct ice_hw *hw, struct ice_fdir_fltr *input,
enum ice_fltr_ptype flow;
u16 tnl_port;
u8 *loc;
+
+ /* pkt = start of full packet buffer (outer Ethernet header, offset 0).
+ * loc = start of current protocol segment; equals pkt for non-tunnel
+ * flows, but points past the tunnel header for tunnel flows.
+ * Use pkt for outer L2 fields, loc for the active segment.
+ */
u16 idx;
u16 flags_version;
u16 pos;
@@ -4599,16 +4605,16 @@ ice_fdir_get_gen_prgm_pkt(struct ice_hw *hw, struct ice_fdir_fltr *input,
input->ip.v6.tc);
break;
case ICE_FLTR_PTYPE_NONF_IPV4_L2TPV2_CONTROL:
- ice_pkt_insert_mac_addr(loc, input->ext_data_outer.dst_mac);
- ice_pkt_insert_mac_addr(loc + ETH_ALEN,
+ ice_pkt_insert_mac_addr(pkt, input->ext_data_outer.dst_mac);
+ ice_pkt_insert_mac_addr(pkt + ETH_ALEN,
input->ext_data_outer.src_mac);
ice_pkt_insert_u16(loc, ICE_IPV4_L2TPV2_LEN_SESS_ID_OFFSET,
input->l2tpv2_data.session_id);
break;
case ICE_FLTR_PTYPE_NONF_IPV4_L2TPV2:
case ICE_FLTR_PTYPE_NONF_IPV4_L2TPV2_PPP:
- ice_pkt_insert_mac_addr(loc, input->ext_data_outer.dst_mac);
- ice_pkt_insert_mac_addr(loc + ETH_ALEN,
+ ice_pkt_insert_mac_addr(pkt, input->ext_data_outer.dst_mac);
+ ice_pkt_insert_mac_addr(pkt + ETH_ALEN,
input->ext_data_outer.src_mac);
flags_version = BE16_TO_CPU(input->l2tpv2_data.flags_version);
if (flags_version & ICE_L2TPV2_FLAGS_LEN) {
@@ -4622,16 +4628,16 @@ ice_fdir_get_gen_prgm_pkt(struct ice_hw *hw, struct ice_fdir_fltr *input,
}
break;
case ICE_FLTR_PTYPE_NONF_IPV6_L2TPV2_CONTROL:
- ice_pkt_insert_mac_addr(loc, input->ext_data_outer.dst_mac);
- ice_pkt_insert_mac_addr(loc + ETH_ALEN,
+ ice_pkt_insert_mac_addr(pkt, input->ext_data_outer.dst_mac);
+ ice_pkt_insert_mac_addr(pkt + ETH_ALEN,
input->ext_data_outer.src_mac);
ice_pkt_insert_u16(loc, ICE_IPV6_L2TPV2_LEN_SESS_ID_OFFSET,
input->l2tpv2_data.session_id);
break;
case ICE_FLTR_PTYPE_NONF_IPV6_L2TPV2:
case ICE_FLTR_PTYPE_NONF_IPV6_L2TPV2_PPP:
- ice_pkt_insert_mac_addr(loc, input->ext_data_outer.dst_mac);
- ice_pkt_insert_mac_addr(loc + ETH_ALEN,
+ ice_pkt_insert_mac_addr(pkt, input->ext_data_outer.dst_mac);
+ ice_pkt_insert_mac_addr(pkt + ETH_ALEN,
input->ext_data_outer.src_mac);
flags_version = BE16_TO_CPU(input->l2tpv2_data.flags_version);
if (flags_version & ICE_L2TPV2_FLAGS_LEN) {
--
2.43.0
prev parent reply other threads:[~2026-04-09 5:23 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-09 5:18 [PATCH v2] net/ice: detect L2TPv2 tunnel type in pre-scan loop Shaiq Wani
2026-04-09 5:18 ` Shaiq Wani [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260409051835.3413336-2-shaiq.wani@intel.com \
--to=shaiq.wani@intel.com \
--cc=aman.deep.singh@intel.com \
--cc=bruce.richardson@intel.com \
--cc=dev@dpdk.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox