[PATCH v3] net/ice: fix L2TPv2 outer MAC in training packet
Shaiq Wani
shaiq.wani at intel.com
Thu Apr 9 09:44:41 CEST 2026
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 at intel.com>
---
v3:
- Fixed checkpatch issue.
- Moved comment after all declarations.
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..1846fbc515 100644
--- a/drivers/net/intel/ice/base/ice_fdir.c
+++ b/drivers/net/intel/ice/base/ice_fdir.c
@@ -3835,6 +3835,12 @@ ice_fdir_get_gen_prgm_pkt(struct ice_hw *hw, struct ice_fdir_fltr *input,
u16 pos;
u16 offset;
+ /* 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.
+ */
+
if (input->flow_type == ICE_FLTR_PTYPE_NONF_IPV4_OTHER) {
switch (input->ip.v4.proto) {
case ICE_IP_PROTO_TCP:
@@ -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
More information about the dev
mailing list