mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Hervé Boisse" <admin@netgeek.ovh>
To: "David S. Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@google.com>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>
Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
	"Hervé Boisse" <admin@netgeek.ovh>
Subject: [PATCH net 1/2] net/af_packet: fix tx skb protocol on SOCK_PACKET sockets
Date: Tue, 10 Jan 2023 20:17:24 +0100	[thread overview]
Message-ID: <20230110191725.22675-1-admin@netgeek.ovh> (raw)

Commit 75c65772c3d1 ("net/packet: Ask driver for protocol if not provided
by user") introduces packet_parse_headers() to extract protocol for
SOCK_RAW sockets.
But, SOCK_PACKET sockets which provide similar behaviour are not considered
so far and packets sent by those sockets will have their protocol unset.

Extract the skb protocol value from the packet for SOCK_PACKET sockets, as
currently done for SOCK_RAW sockets.

Fixes: 75c65772c3d1 ("net/packet: Ask driver for protocol if not provided by user")
Signed-off-by: Hervé Boisse <admin@netgeek.ovh>
---
 net/packet/af_packet.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/packet/af_packet.c b/net/packet/af_packet.c
index b5ab98ca2511..c18274f65b17 100644
--- a/net/packet/af_packet.c
+++ b/net/packet/af_packet.c
@@ -1928,7 +1928,7 @@ static void packet_parse_headers(struct sk_buff *skb, struct socket *sock)
 	int depth;
 
 	if ((!skb->protocol || skb->protocol == htons(ETH_P_ALL)) &&
-	    sock->type == SOCK_RAW) {
+	    (sock->type == SOCK_RAW || sock->type == SOCK_PACKET)) {
 		skb_reset_mac_header(skb);
 		skb->protocol = dev_parse_header_protocol(skb);
 	}
-- 
2.38.2


             reply	other threads:[~2023-01-10 19:37 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-10 19:17 Hervé Boisse [this message]
2023-01-10 19:17 ` [PATCH net 2/2] net/af_packet: fix tx skb network header on SOCK_RAW sockets over VLAN device Hervé Boisse
2023-01-12 12:48   ` Paolo Abeni
2023-01-12 15:27     ` =?unknown-8bit?B?SGVydsOp?= Boisse
2023-01-12 15:47       ` Paolo Abeni
2023-01-12 16:22         ` Hervé Boisse
2023-01-12 18:38           ` Willem de Bruijn
2023-01-12 16:04   ` Willem de Bruijn
2023-01-12 15:48 ` [PATCH net 1/2] net/af_packet: fix tx skb protocol on SOCK_PACKET sockets Willem de Bruijn

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=20230110191725.22675-1-admin@netgeek.ovh \
    --to=admin@netgeek.ovh \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    /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

all inboxes | Powered by JetHome®