[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20190318053952.115180-1-komachi.yoshiki@lab.ntt.co.jp>
Date: Mon, 18 Mar 2019 14:39:52 +0900
From: Yoshiki Komachi <komachi.yoshiki@....ntt.co.jp>
To: "David S. Miller" <davem@...emloft.net>
Cc: Yoshiki Komachi <komachi.yoshiki@....ntt.co.jp>,
netdev@...r.kernel.org, "Yoshiki Komachi" <ysk@...sfc.keio.ac.jp>
Subject: [PATCH net] af_packet: fix the tx skb protocol in raw sockets with ETH_P_ALL
I am using "protocol ip" filters in TC to manipulate TC flower
classifiers, which are only available with "protocol ip". However,
I faced an issue that packets sent via raw sockets with ETH_P_ALL
did not match the ip filters even if they did satisfy the condition
(e.g., DHCP offer from dhcpd).
I have determined that the behavior was caused by an unexpected
value stored in skb->protocol, namely, ETH_P_ALL instead of ETH_P_IP,
when packets were sent via raw sockets with ETH_P_ALL set.
IMHO, storing ETH_P_ALL in skb->protocol is not appropriate for
packets sent via raw sockets because ETH_P_ALL is not a real ether
type used on wire, but a virtual one.
This patch fixes the tx protocol selection in cases of transmission
via raw sockets created with ETH_P_ALL so that it asks the driver to
extract protocol from the Ethernet header.
Signed-off-by: Yoshiki Komachi <komachi.yoshiki@....ntt.co.jp>
---
net/packet/af_packet.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/net/packet/af_packet.c b/net/packet/af_packet.c
index 8376bc1..9f6170f 100644
--- a/net/packet/af_packet.c
+++ b/net/packet/af_packet.c
@@ -1852,7 +1852,8 @@ static int packet_rcv_spkt(struct sk_buff *skb, struct net_device *dev,
static void packet_parse_headers(struct sk_buff *skb, struct socket *sock)
{
- if (!skb->protocol && sock->type == SOCK_RAW) {
+ if ((!skb->protocol || skb->protocol == htons(ETH_P_ALL)) &&
+ sock->type == SOCK_RAW) {
skb_reset_mac_header(skb);
skb->protocol = dev_parse_header_protocol(skb);
}
--
1.8.3.1
Powered by blists - more mailing lists