vrf: Stop corrupting skb->csum when capturing CHECKSUM_COMPLETE packets
Subsystems (3)
PATCH 1/1 vrf: Stop corrupting skb->csum when capturing CHECKSUM_COMPLETE packets
The VRF device is an Ethernet device but it can have non-Ethernet ports such as IP tunnels. Before the cited commit, capturing packets from such ports on the VRF device resulted in these packets being detected as malformed since they lack an Ethernet header.
The cited commit fixed it by pushing a dummy Ethernet header to such packets before the capture and pulling it afterwards. In the case of CHECKSUM_COMPLETE packets it also updated skb->csum with the checksum of the dummy Ethernet header. This is wrong as skb->csum should not include the checksum of the Ethernet header ("checksum of the _whole_ packet as seen by netif_rx()").
This also means that L4 protocols receive a corrupted skb->csum and potentially drop the packet, as is the case with UDP packets whose checksum was completed by software.
Fix by removing the unnecessary call to skb_postpush_rcsum().
--- drivers/net/vrf.c | 2 -- 1 file changed, 2 deletions(-)
drivers/net/vrf.c +0 -2
@@ -1175,8 +1175,6 @@ static int vrf_prepare_mac_header(struct sk_buff *skb, skb->protocol = eth->h_proto; skb->pkt_type =PACKET_HOST ; -skb_postpush_rcsum (skb, skb->data,ETH_HLEN ); -skb_pull_inline (skb,ETH_HLEN );return 0 ;
Signature · 1 line
2.55.0
Quoted 18 lines · Ido Schimmel
The VRF device is an Ethernet device but it can have non-Ethernet ports such as IP tunnels. Before the cited commit, capturing packets from such ports on the VRF device resulted in these packets being detected as malformed since they lack an Ethernet header.
The cited commit fixed it by pushing a dummy Ethernet header to such packets before the capture and pulling it afterwards. In the case of
CHECKSUM_COMPLETEpackets it also updatedskb->csumwith the checksum of the dummy Ethernet header. This is wrong asskb->csumshould not include the checksum of the Ethernet header ("checksum of the _whole_ packet as seen bynetif_rx()").This also means that L4 protocols receive a corrupted
skb->csumand potentially drop the packet, as is the case with UDP packets whose checksum was completed by software.Fix by removing the unnecessary call to
skb_postpush_rcsum().
Quoted 8 lines
Fixes 048939088220 ("vrf: add mac header for tunneled packets when sniffer is attached")Reported-by Stefano Sasso <[email protected]>Closes https://lore.kernel.org/netdev/CALtE316UtL3x7LL6uxfXzx8rW6AbzYPeDOb478hqJCr_-dj=Wg@mail.gmail.com/ open hereSigned-off-by Ido Schimmel <[email protected]>--- drivers/net/vrf.c | 2 -- 1 file changed, 2 deletions(-)
Thanks, Ido.
Eric Dumazet
Reviewed-byQuoted 29 lines · David Ahern
Quoted 18 lines · Ido Schimmel
The VRF device is an Ethernet device but it can have non-Ethernet ports such as IP tunnels. Before the cited commit, capturing packets from such ports on the VRF device resulted in these packets being detected as malformed since they lack an Ethernet header.
The cited commit fixed it by pushing a dummy Ethernet header to such packets before the capture and pulling it afterwards. In the case of
CHECKSUM_COMPLETEpackets it also updatedskb->csumwith the checksum of the dummy Ethernet header. This is wrong asskb->csumshould not include the checksum of the Ethernet header ("checksum of the _whole_ packet as seen bynetif_rx()").This also means that L4 protocols receive a corrupted
skb->csumand potentially drop the packet, as is the case with UDP packets whose checksum was completed by software.Fix by removing the unnecessary call to
skb_postpush_rcsum().Quoted 8 lines
Fixes 048939088220 ("vrf: add mac header for tunneled packets when sniffer is attached")Reported-by Stefano Sasso <[email protected]>Closes https://lore.kernel.org/netdev/CALtE316UtL3x7LL6uxfXzx8rW6AbzYPeDOb478hqJCr_-dj=Wg@mail.gmail.com/ open hereSigned-off-by Ido Schimmel <[email protected]>--- drivers/net/vrf.c | 2 -- 1 file changed, 2 deletions(-)
Quoted 1 line
Reviewed-by David Ahern <[email protected]>
Quoted 18 lines · On Tue, 22 Sep 2026 16:12:39 +0300 Ido Schimmel <[email protected]> wrote:
The VRF device is an Ethernet device but it can have non-Ethernet ports such as IP tunnels. Before the cited commit, capturing packets from such ports on the VRF device resulted in these packets being detected as malformed since they lack an Ethernet header.
The cited commit fixed it by pushing a dummy Ethernet header to such packets before the capture and pulling it afterwards. In the case of
CHECKSUM_COMPLETEpackets it also updatedskb->csumwith the checksum of the dummy Ethernet header. This is wrong asskb->csumshould not include the checksum of the Ethernet header ("checksum of the _whole_ packet as seen bynetif_rx()").This also means that L4 protocols receive a corrupted
skb->csumand potentially drop the packet, as is the case with UDP packets whose checksum was completed by software.Fix by removing the unnecessary call to
skb_postpush_rcsum().
Quoted 8 lines
Fixes 048939088220 ("vrf: add mac header for tunneled packets when sniffer is attached")Reported-by Stefano Sasso <[email protected]>Closes https://lore.kernel.org/netdev/CALtE316UtL3x7LL6uxfXzx8rW6AbzYPeDOb478hqJCr_-dj=Wg@mail.gmail.com/ open hereSigned-off-by Ido Schimmel <[email protected]>--- drivers/net/vrf.c | 2 -- 1 file changed, 2 deletions(-)
Thanks for taking this, and thanks to Stefano for the report and the reproducer.
This patch was applied to netdev/net.git (main) by Jakub Kicinski <[email protected]>:
Hello:
This patch was applied to netdev/net.git (main)
by Jakub Kicinski <[email protected]>:
Quoted 5 lines · On Tue, 22 Sep 2026 16:12:39 +0300 you wrote:
The VRF device is an Ethernet device but it can have non-Ethernet ports such as IP tunnels. Before the cited commit, capturing packets from such ports on the VRF device resulted in these packets being detected as malformed since they lack an Ethernet header.
Quoted 8 lines
The cited commit fixed it by pushing a dummy Ethernet header to such packets before the capture and pulling it afterwards. In the case of
CHECKSUM_COMPLETEpackets it also updatedskb->csumwith the checksum of the dummy Ethernet header. This is wrong asskb->csumshould not include the checksum of the Ethernet header ("checksum of the _whole_ packet as seen bynetif_rx()").[...]
Here is the summary with links:
- [net] vrf: Stop corrupting skb->csum when capturing CHECKSUM_COMPLETE packets
https://git.kernel.org/netdev/net/c/ab7aa05c06ae
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html