Skip to contentSkip to conversation

macvlan: Disable LRO on lowerdev; warn if it's turned back on

PATCH In review Ben Hutchings 4 participants 6 messages Feb 21, 2012 – Feb 25, 2012

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 macvlan: Disable LRO on lowerdev; warn if it's turned back on

Large Receive Offload (LRO) is only appropriate for packets that are destined for the host, and should be disabled if received packets may be forwarded.

Further, macvtap_skb_to_vnet_hdr() will BUG() on a packet received with LRO (but not GRO).

---
I'm not really familiar with macvlan so I'm not certain that this should be applied to all modes.

Ben.

 drivers/net/macvlan.c |    7 +++++++
 1 files changed, 7 insertions(+), 0 deletions(-)
drivers/net/macvlan.c +7 -0
index 9ea9921..c64e26c 100644
@@ -168,6 +168,11 @@ static rx_handler_result_t macvlan_handle_frame(struct sk_buff **pskb)
 	unsigned int len = 0;
 	int ret = NET_RX_DROP;
 
+	if (skb_warn_if_lro(skb)) {
+		kfree_skb(skb);
+		return RX_HANDLER_CONSUMED;
+	}
+
 	port = macvlan_port_get_rcu(skb->dev);
 	if (is_multicast_ether_addr(eth->h_dest)) {
 		skb = ip_check_defrag(skb, IP_DEFRAG_MACVLAN);
@@ -717,6 +722,8 @@ int macvlan_common_newlink(struct net *src_net, struct net_device *dev,
 		memcpy(dev->dev_addr, lowerdev->dev_addr, ETH_ALEN);
 	}
 
+	dev_disable_lro(lowerdev);
+
 	port->count += 1;
 	err = register_netdevice(dev);
 	if (err < 0)
Signature · 7 lines
1.7.7.6


-- 
Ben Hutchings, Staff Engineer, Solarflare
Not speaking for my employer; that's the marketing department's job.
They asked us to note that Solarflare product names are trademarked.
#1 lore raw
Quoted 8 lines · Ben Hutchings

Large Receive Offload (LRO) is only appropriate for packets that are destined for the host, and should be disabled if received packets may be forwarded.

Further, macvtap_skb_to_vnet_hdr() will BUG() on a packet received with LRO (but not GRO).

Quoted 9 lines

---
I'm not really familiar with macvlan so I'm not certain that this should be applied to all modes.

Ben.

 drivers/net/macvlan.c |    7 +++++++
 1 files changed, 7 insertions(+), 0 deletions(-)

But this patch assumes the macvlan is forwarding traffic to a guest via macvtap. Which is an assumption that may not be true.

It seems more appropriate for the macvtap driver to do these checks after all its the driver that may BUG() with LRO.

Thanks,
John

#2 lore raw
Quoted 19 lines · John Fastabend
Quoted 8 lines · Ben Hutchings

Large Receive Offload (LRO) is only appropriate for packets that are destined for the host, and should be disabled if received packets may be forwarded.

Further, macvtap_skb_to_vnet_hdr() will BUG() on a packet received with LRO (but not GRO).

Quoted 9 lines

---
I'm not really familiar with macvlan so I'm not certain that this should be applied to all modes.

Ben.

 drivers/net/macvlan.c |    7 +++++++
 1 files changed, 7 insertions(+), 0 deletions(-)
Quoted 5 lines

But this patch assumes the macvlan is forwarding traffic to a guest via macvtap. Which is an assumption that may not be true.

It seems more appropriate for the macvtap driver to do these checks after all its the driver that may BUG() with LRO.

That's what I thought at first, but then I looked through what macvlan was doing and it certainly appears to re-transmit skbs in all modes. That's not valid when gso_size != 0 and gso_type == 0.

Ben.

Signature · 3 lines
Ben Hutchings, Staff Engineer, Solarflare
Not speaking for my employer; that's the marketing department's job.
They asked us to note that Solarflare product names are trademarked.
#3 lore raw
Quoted 23 lines · Ben Hutchings
Quoted 22 lines · John Fastabend
Quoted 8 lines · Ben Hutchings

Large Receive Offload (LRO) is only appropriate for packets that are destined for the host, and should be disabled if received packets may be forwarded.

Further, macvtap_skb_to_vnet_hdr() will BUG() on a packet received with LRO (but not GRO).

Quoted 9 lines

---
I'm not really familiar with macvlan so I'm not certain that this should be applied to all modes.

Ben.

  drivers/net/macvlan.c |    7 +++++++
  1 files changed, 7 insertions(+), 0 deletions(-)

But this patch assumes the macvlan is forwarding traffic to a guest via macvtap. Which is an assumption that may not be true.

Quoted 6 lines
Quoted 2 lines

It seems more appropriate for the macvtap driver to do these checks after all its the driver that may BUG() with LRO.

That's what I thought at first, but then I looked through what macvlan was doing and it certainly appears to re-transmit skbs in all modes. That's not valid when gso_size != 0 and gso_type == 0.

You can put an IP on a mac-vlan and receive packets on it like normal Ethernet interfaces. They wouldn't be re-transmitted in that case, would they?

Quoted 3 lines

Ben.

Signature · 2 lines
Ben Greear <[email protected]>
Candela Technologies Inc  http://www.candelatech.com
#4 lore raw
Quoted 27 lines · Ben Greear
Quoted 26 lines · Ben Hutchings
Quoted 24 lines · John Fastabend
Quoted 8 lines · Ben Hutchings

Large Receive Offload (LRO) is only appropriate for packets that are destined for the host, and should be disabled if received packets may be forwarded.

Further, macvtap_skb_to_vnet_hdr() will BUG() on a packet received with LRO (but not GRO).

Quoted 9 lines

---
I'm not really familiar with macvlan so I'm not certain that this should be applied to all modes.

Ben.

  drivers/net/macvlan.c |    7 +++++++
  1 files changed, 7 insertions(+), 0 deletions(-)

But this patch assumes the macvlan is forwarding traffic to a guest via macvtap. Which is an assumption that may not be true.

It seems more appropriate for the macvtap driver to do these checks after all its the driver that may BUG() with LRO.

Quoted 7 lines
Quoted 3 lines

That's what I thought at first, but then I looked through what macvlan was doing and it certainly appears to re-transmit skbs in all modes. That's not valid when gso_size != 0 and gso_type == 0.

You can put an IP on a mac-vlan and receive packets on it like normal Ethernet interfaces. They wouldn't be re-transmitted in that case, would they?

Long story short.

With the macvlan driver the normal case is not to turn packets around but to go directly to the nic or to come directly from the nic.

In the case where packets are turned around and packets go from one software interface the design is that the drivers are supposed to do software emulation of hardware features like gro so that we don't have to take a performance hit when it happens.

If we are not doing proper software emulation of features like gro in macvtap that is a problem.

I am fuzzy about all of the details but last I looked we were doing proper software emulation of the features when just macvlan was involved. I also remember that the macvtap driver really wanted gro so that it could work efficiently with emulated hardware.

So I don't know why people are having a problem, but the correct solution is not to give up but to fix the silly software side of the drivers to actually handle things properly.

Disabling LRO on the lowerdev just so we can avoid writing the support in macvtap just sounds sad.

Eric

#5 lore raw
Quoted 11 lines · Eric W. Biederman
Quoted 9 lines · Ben Greear
Quoted 8 lines · Ben Hutchings
Quoted 7 lines · John Fastabend
Quoted 6 lines · Ben Hutchings

Large Receive Offload (LRO) is only appropriate for packets that are destined for the host, and should be disabled if received packets may be forwarded.

Further, macvtap_skb_to_vnet_hdr() will BUG() on a packet received with LRO (but not GRO).

[...]

Quoted 10 lines

Long story short.

With the macvlan driver the normal case is not to turn packets around but to go directly to the nic or to come directly from the nic.

In the case where packets are turned around and packets go from one software interface the design is that the drivers are supposed to do software emulation of hardware features like gro so that we don't have to take a performance hit when it happens.

Quoted 7 lines

If we are not doing proper software emulation of features like gro in macvtap that is a problem.

I am fuzzy about all of the details but last I looked we were doing proper software emulation of the features when just macvlan was involved. I also remember that the macvtap driver really wanted gro so that it could work efficiently with emulated hardware.

This doesn't disable GRO; you can still benefit from that.

Quoted 3 lines

So I don't know why people are having a problem, but the correct solution is not to give up but to fix the silly software side of the drivers to actually handle things properly.

This is not a deficiency in macvtap. Any skb received with LRO cannot be re-sent through dev_queue_xmit() or dev_hard_start_xmit().

Quoted 2 lines

Disabling LRO on the lowerdev just so we can avoid writing the support in macvtap just sounds sad.

The regular bridge driver and the IPv4 and IPv6 protocols already disable LRO when enabling forwarding on a device. This is 'normal'.

Now we could decide that the possible loss of some header information through LRO is acceptable and we should just require drivers using LRO to label their skbs with the proper gso_type for re-sending. Indeed, although GRO preserves packet boundaries they are actually lost in re-transmission as GSO/TSO re-segments at regular intervals. So that's already happening to an extent.

Ben.

Signature · 3 lines
Ben Hutchings, Staff Engineer, Solarflare
Not speaking for my employer; that's the marketing department's job.
They asked us to note that Solarflare product names are trademarked.