Skip to content

Commit

Permalink
openvswitch: use hard_header_len instead of hardcoded ETH_HLEN
Browse files Browse the repository at this point in the history
On tx, use hard_header_len while deciding whether to refragment or drop the
packet. That way, all combinations are calculated correctly:

* L2 packet going to L2 interface (the L2 header len is subtracted),
* L2 packet going to L3 interface (the L2 header is included in the packet
  lenght),
* L3 packet going to L3 interface.

Signed-off-by: Jiri Benc <jbenc@redhat.com>
Acked-by: Pravin B Shelar <pshelar@ovn.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Jiri Benc authored and David S. Miller committed Nov 13, 2016
1 parent c540594 commit 738314a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
3 changes: 2 additions & 1 deletion net/openvswitch/actions.c
Original file line number Diff line number Diff line change
Expand Up @@ -791,7 +791,8 @@ static void do_output(struct datapath *dp, struct sk_buff *skb, int out_port,
pskb_trim(skb, ETH_HLEN);
}

if (likely(!mru || (skb->len <= mru + ETH_HLEN))) {
if (likely(!mru ||
(skb->len <= mru + vport->dev->hard_header_len))) {
ovs_vport_send(vport, skb);
} else if (mru <= vport->dev->mtu) {
struct net *net = read_pnet(&dp->net);
Expand Down
10 changes: 6 additions & 4 deletions net/openvswitch/vport.c
Original file line number Diff line number Diff line change
Expand Up @@ -464,9 +464,10 @@ int ovs_vport_receive(struct vport *vport, struct sk_buff *skb,
return 0;
}

static unsigned int packet_length(const struct sk_buff *skb)
static unsigned int packet_length(const struct sk_buff *skb,
struct net_device *dev)
{
unsigned int length = skb->len - ETH_HLEN;
unsigned int length = skb->len - dev->hard_header_len;

if (!skb_vlan_tag_present(skb) &&
eth_type_vlan(skb->protocol))
Expand All @@ -484,10 +485,11 @@ void ovs_vport_send(struct vport *vport, struct sk_buff *skb)
{
int mtu = vport->dev->mtu;

if (unlikely(packet_length(skb) > mtu && !skb_is_gso(skb))) {
if (unlikely(packet_length(skb, vport->dev) > mtu &&
!skb_is_gso(skb))) {
net_warn_ratelimited("%s: dropped over-mtu packet: %d > %d\n",
vport->dev->name,
packet_length(skb), mtu);
packet_length(skb, vport->dev), mtu);
vport->dev->stats.tx_errors++;
goto drop;
}
Expand Down

0 comments on commit 738314a

Please sign in to comment.