Netdev Archive on lore.kernel.org
 help / color / Atom feed
* [PATCH net] macvlan: use skb_reset_mac_header() in macvlan_queue_xmit()
@ 2020-01-14 21:00 Eric Dumazet
  2020-01-15  1:38 ` Matteo Croce
  2020-01-16 12:14 ` David Miller
  0 siblings, 2 replies; 3+ messages in thread
From: Eric Dumazet @ 2020-01-14 21:00 UTC (permalink / raw)
  To: David S . Miller; +Cc: netdev, Eric Dumazet, Eric Dumazet, Jurgen Van Ham

I missed the fact that macvlan_broadcast() can be used both
in RX and TX.

skb_eth_hdr() makes only sense in TX paths, so we can not
use it blindly in macvlan_broadcast()

Fixes: 96cc4b69581d ("macvlan: do not assume mac_header is set in macvlan_broadcast()")
Signed-off-by: Eric Dumazet <edumazet@google.com>
Reported-by: Jurgen Van Ham <juvanham@gmail.com>
---
 drivers/net/macvlan.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/net/macvlan.c b/drivers/net/macvlan.c
index 747c0542a53c763676d491c91a5b704f0eb9848e..c5bf61565726b15aa1ea63590d7d8627b0c20d4a 100644
--- a/drivers/net/macvlan.c
+++ b/drivers/net/macvlan.c
@@ -259,7 +259,7 @@ static void macvlan_broadcast(struct sk_buff *skb,
 			      struct net_device *src,
 			      enum macvlan_mode mode)
 {
-	const struct ethhdr *eth = skb_eth_hdr(skb);
+	const struct ethhdr *eth = eth_hdr(skb);
 	const struct macvlan_dev *vlan;
 	struct sk_buff *nskb;
 	unsigned int i;
@@ -513,10 +513,11 @@ static int macvlan_queue_xmit(struct sk_buff *skb, struct net_device *dev)
 	const struct macvlan_dev *dest;
 
 	if (vlan->mode == MACVLAN_MODE_BRIDGE) {
-		const struct ethhdr *eth = (void *)skb->data;
+		const struct ethhdr *eth = skb_eth_hdr(skb);
 
 		/* send to other bridge ports directly */
 		if (is_multicast_ether_addr(eth->h_dest)) {
+			skb_reset_mac_header(skb);
 			macvlan_broadcast(skb, port, dev, MACVLAN_MODE_BRIDGE);
 			goto xmit_world;
 		}
-- 
2.25.0.rc1.283.g88dfdc4193-goog


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH net] macvlan: use skb_reset_mac_header() in macvlan_queue_xmit()
  2020-01-14 21:00 [PATCH net] macvlan: use skb_reset_mac_header() in macvlan_queue_xmit() Eric Dumazet
@ 2020-01-15  1:38 ` Matteo Croce
  2020-01-16 12:14 ` David Miller
  1 sibling, 0 replies; 3+ messages in thread
From: Matteo Croce @ 2020-01-15  1:38 UTC (permalink / raw)
  To: Eric Dumazet; +Cc: David S . Miller, netdev, Eric Dumazet, Jurgen Van Ham

On Tue, Jan 14, 2020 at 10:01 PM Eric Dumazet <edumazet@google.com> wrote:
>
> I missed the fact that macvlan_broadcast() can be used both
> in RX and TX.
>
> skb_eth_hdr() makes only sense in TX paths, so we can not
> use it blindly in macvlan_broadcast()
>
> Fixes: 96cc4b69581d ("macvlan: do not assume mac_header is set in macvlan_broadcast()")
> Signed-off-by: Eric Dumazet <edumazet@google.com>
> Reported-by: Jurgen Van Ham <juvanham@gmail.com>

Tested-by: Matteo Croce <mcroce@redhat.com>

-- 
Matteo Croce
per aspera ad upstream


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH net] macvlan: use skb_reset_mac_header() in macvlan_queue_xmit()
  2020-01-14 21:00 [PATCH net] macvlan: use skb_reset_mac_header() in macvlan_queue_xmit() Eric Dumazet
  2020-01-15  1:38 ` Matteo Croce
@ 2020-01-16 12:14 ` David Miller
  1 sibling, 0 replies; 3+ messages in thread
From: David Miller @ 2020-01-16 12:14 UTC (permalink / raw)
  To: edumazet; +Cc: netdev, eric.dumazet, juvanham

From: Eric Dumazet <edumazet@google.com>
Date: Tue, 14 Jan 2020 13:00:35 -0800

> I missed the fact that macvlan_broadcast() can be used both
> in RX and TX.
> 
> skb_eth_hdr() makes only sense in TX paths, so we can not
> use it blindly in macvlan_broadcast()
> 
> Fixes: 96cc4b69581d ("macvlan: do not assume mac_header is set in macvlan_broadcast()")
> Signed-off-by: Eric Dumazet <edumazet@google.com>
> Reported-by: Jurgen Van Ham <juvanham@gmail.com>

Applied and queued up for -stable, thanks Eric.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, back to index

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-01-14 21:00 [PATCH net] macvlan: use skb_reset_mac_header() in macvlan_queue_xmit() Eric Dumazet
2020-01-15  1:38 ` Matteo Croce
2020-01-16 12:14 ` David Miller

Netdev Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/netdev/0 netdev/git/0.git
	git clone --mirror https://lore.kernel.org/netdev/1 netdev/git/1.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 netdev netdev/ https://lore.kernel.org/netdev \
		netdev@vger.kernel.org
	public-inbox-index netdev

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.netdev


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git