]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
vrf: fix packet sniffing for traffic originating from ip tunnels
authorEyal Birger <eyal.birger@gmail.com>
Thu, 31 Mar 2022 07:26:43 +0000 (10:26 +0300)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 13 Apr 2022 18:03:13 +0000 (20:03 +0200)
commit361f704d57aa1c83b32a171f2bc4ac608a4c4902
treeab5d27e485c10f6455c59bd2a916084838d35a6d
parent29be1816cbab9a0dc6243120939fd10a92753756
vrf: fix packet sniffing for traffic originating from ip tunnels

[ Upstream commit 012d69fbfcc739f846766c1da56ef8b493b803b5 ]

in commit 048939088220
("vrf: add mac header for tunneled packets when sniffer is attached")
an Ethernet header was cooked for traffic originating from tunnel devices.

However, the header is added based on whether the mac_header is unset
and ignores cases where the device doesn't expose a mac header to upper
layers, such as in ip tunnels like ipip and gre.

Traffic originating from such devices still appears garbled when capturing
on the vrf device.

Fix by observing whether the original device exposes a header to upper
layers, similar to the logic done in af_packet.

In addition, skb->mac_len needs to be adjusted after adding the Ethernet
header for the skb_push/pull() surrounding dev_queue_xmit_nit() to work
on these packets.

Fixes: 048939088220 ("vrf: add mac header for tunneled packets when sniffer is attached")
Signed-off-by: Eyal Birger <eyal.birger@gmail.com>
Reviewed-by: David Ahern <dsahern@kernel.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/net/vrf.c