Skip to content

Commit

Permalink
vxlan: Improve vxlan headroom calculation.
Browse files Browse the repository at this point in the history
Rather than having static headroom calculation, adjust headroom
according to target device.

Signed-off-by: Pravin B Shelar <pshelar@nicira.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Pravin B Shelar authored and David S. Miller committed Aug 20, 2013
1 parent 4956053 commit 649c5b8
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions drivers/net/vxlan.c
Original file line number Diff line number Diff line change
Expand Up @@ -1130,13 +1130,22 @@ int vxlan_xmit_skb(struct net *net, struct vxlan_sock *vs,
{
struct vxlanhdr *vxh;
struct udphdr *uh;
int min_headroom;
int err;

if (!skb->encapsulation) {
skb_reset_inner_headers(skb);
skb->encapsulation = 1;
}

min_headroom = LL_RESERVED_SPACE(rt->dst.dev) + rt->dst.header_len
+ VXLAN_HLEN + sizeof(struct iphdr);

/* Need space for new headers (invalidates iph ptr) */
err = skb_cow_head(skb, min_headroom);
if (unlikely(err))
return err;

vxh = (struct vxlanhdr *) __skb_push(skb, sizeof(*vxh));
vxh->vx_flags = htonl(VXLAN_FLAGS);
vxh->vx_vni = vni;
Expand Down Expand Up @@ -1220,10 +1229,6 @@ static void vxlan_xmit_one(struct sk_buff *skb, struct net_device *dev,
goto drop;
}

/* Need space for new headers (invalidates iph ptr) */
if (skb_cow_head(skb, VXLAN_HEADROOM))
goto drop;

old_iph = ip_hdr(skb);

ttl = vxlan->ttl;
Expand Down

0 comments on commit 649c5b8

Please sign in to comment.