diff mbox series

[{xenial,disco}:linux-azure,1/1] SAUCE: af_packet: Fix skb protocol value in tpacket_fill_skb()

Message ID 20191212140044.1805-2-marcelo.cerri@canonical.com
State New
Headers show
Series LP:#1855461 - [linux-azure] SAUCE patch to "Fix skb protocol value in tpacket_fill_skb()" | expand

Commit Message

Marcelo Henrique Cerri Dec. 12, 2019, 2 p.m. UTC
From: Raghav Kempanna <kraghav@vmware.com>

BugLink: https://bugs.launchpad.net/bugs/1855461

Adapted from upstream patches for 4.15:
75c65772c3d1 ("net/packet: Ask driver for protocol if not provided by user")
18bed89107a4 ("af_packet: fix the tx skb protocol in raw sockets with ETH_P_ALL")

Signed-off-by: Raghav Kempanna <kraghav@vmware.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
Signed-off-by: Marcelo Henrique Cerri <marcelo.cerri@canonical.com>
---
 net/packet/af_packet.c | 9 +++++++++
 1 file changed, 9 insertions(+)

Comments

Colin Ian King Dec. 12, 2019, 2:14 p.m. UTC | #1
On 12/12/2019 14:00, Marcelo Henrique Cerri wrote:
> From: Raghav Kempanna <kraghav@vmware.com>
> 
> BugLink: https://bugs.launchpad.net/bugs/1855461
> 
> Adapted from upstream patches for 4.15:
> 75c65772c3d1 ("net/packet: Ask driver for protocol if not provided by user")
> 18bed89107a4 ("af_packet: fix the tx skb protocol in raw sockets with ETH_P_ALL")
> 
> Signed-off-by: Raghav Kempanna <kraghav@vmware.com>
> Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
> Signed-off-by: Marcelo Henrique Cerri <marcelo.cerri@canonical.com>
> ---
>  net/packet/af_packet.c | 9 +++++++++
>  1 file changed, 9 insertions(+)
> 
> diff --git a/net/packet/af_packet.c b/net/packet/af_packet.c
> index 1e25e06df2db..ea74f2ffe41d 100644
> --- a/net/packet/af_packet.c
> +++ b/net/packet/af_packet.c
> @@ -2550,6 +2550,15 @@ static int tpacket_fill_skb(struct packet_sock *po, struct sk_buff *skb,
>  		len = ((to_write > len_max) ? len_max : to_write);
>  	}
>  
> +	if ((!skb->protocol || skb->protocol == htons(ETH_P_ALL)) &&
> +	    sock->type == SOCK_RAW) {
> +		const struct ethhdr *eth;
> +
> +		skb_reset_mac_header(skb);
> +		eth = eth_hdr(skb);
> +		skb->protocol = eth->h_proto;
> +	}
> +
>  	skb_probe_transport_header(skb, 0);
>  
>  	return tp_len;
> 

Looks like a reasonable sauce patch derived from the two commits. It's
had some positive tests results, so that is good too. So..

Acked-by: Colin Ian King <colin.king@canonical.com>
Kleber Sacilotto de Souza Dec. 12, 2019, 3:30 p.m. UTC | #2
On 2019-12-12 15:00, Marcelo Henrique Cerri wrote:
> From: Raghav Kempanna <kraghav@vmware.com>
> 
> BugLink: https://bugs.launchpad.net/bugs/1855461
> 
> Adapted from upstream patches for 4.15:
> 75c65772c3d1 ("net/packet: Ask driver for protocol if not provided by user")
> 18bed89107a4 ("af_packet: fix the tx skb protocol in raw sockets with ETH_P_ALL")
> 
> Signed-off-by: Raghav Kempanna <kraghav@vmware.com>
> Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
> Signed-off-by: Marcelo Henrique Cerri <marcelo.cerri@canonical.com>

The merge of these two commits seems to be correct and the test
results are good. Therefore:

Acked-by: Kleber Sacilotto de Souza <kleber.souza@canonical.com>

> ---
>  net/packet/af_packet.c | 9 +++++++++
>  1 file changed, 9 insertions(+)
> 
> diff --git a/net/packet/af_packet.c b/net/packet/af_packet.c
> index 1e25e06df2db..ea74f2ffe41d 100644
> --- a/net/packet/af_packet.c
> +++ b/net/packet/af_packet.c
> @@ -2550,6 +2550,15 @@ static int tpacket_fill_skb(struct packet_sock *po, struct sk_buff *skb,
>  		len = ((to_write > len_max) ? len_max : to_write);
>  	}
>  
> +	if ((!skb->protocol || skb->protocol == htons(ETH_P_ALL)) &&
> +	    sock->type == SOCK_RAW) {
> +		const struct ethhdr *eth;
> +
> +		skb_reset_mac_header(skb);
> +		eth = eth_hdr(skb);
> +		skb->protocol = eth->h_proto;
> +	}
> +
>  	skb_probe_transport_header(skb, 0);
>  
>  	return tp_len;
>
diff mbox series

Patch

diff --git a/net/packet/af_packet.c b/net/packet/af_packet.c
index 1e25e06df2db..ea74f2ffe41d 100644
--- a/net/packet/af_packet.c
+++ b/net/packet/af_packet.c
@@ -2550,6 +2550,15 @@  static int tpacket_fill_skb(struct packet_sock *po, struct sk_buff *skb,
 		len = ((to_write > len_max) ? len_max : to_write);
 	}
 
+	if ((!skb->protocol || skb->protocol == htons(ETH_P_ALL)) &&
+	    sock->type == SOCK_RAW) {
+		const struct ethhdr *eth;
+
+		skb_reset_mac_header(skb);
+		eth = eth_hdr(skb);
+		skb->protocol = eth->h_proto;
+	}
+
 	skb_probe_transport_header(skb, 0);
 
 	return tp_len;