diff options
author | Pravin B Shelar <pshelar@nicira.com> | 2013-08-19 14:23:22 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2013-08-20 03:15:43 -0400 |
commit | 649c5b8bdd8d5c8c9c50882e3a789030fb99b75c (patch) | |
tree | 4eec659e1a322796ad045cd997c138e9251614c6 /drivers/net/vxlan.c | |
parent | 49560532d74962608526121ecb0d2ad0c87f9cc0 (diff) |
vxlan: Improve vxlan headroom calculation.
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>
Diffstat (limited to 'drivers/net/vxlan.c')
-rw-r--r-- | drivers/net/vxlan.c | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/drivers/net/vxlan.c b/drivers/net/vxlan.c index f3496e995302..73e255788fae 100644 --- a/drivers/net/vxlan.c +++ b/drivers/net/vxlan.c | |||
@@ -1130,6 +1130,7 @@ int vxlan_xmit_skb(struct net *net, struct vxlan_sock *vs, | |||
1130 | { | 1130 | { |
1131 | struct vxlanhdr *vxh; | 1131 | struct vxlanhdr *vxh; |
1132 | struct udphdr *uh; | 1132 | struct udphdr *uh; |
1133 | int min_headroom; | ||
1133 | int err; | 1134 | int err; |
1134 | 1135 | ||
1135 | if (!skb->encapsulation) { | 1136 | if (!skb->encapsulation) { |
@@ -1137,6 +1138,14 @@ int vxlan_xmit_skb(struct net *net, struct vxlan_sock *vs, | |||
1137 | skb->encapsulation = 1; | 1138 | skb->encapsulation = 1; |
1138 | } | 1139 | } |
1139 | 1140 | ||
1141 | min_headroom = LL_RESERVED_SPACE(rt->dst.dev) + rt->dst.header_len | ||
1142 | + VXLAN_HLEN + sizeof(struct iphdr); | ||
1143 | |||
1144 | /* Need space for new headers (invalidates iph ptr) */ | ||
1145 | err = skb_cow_head(skb, min_headroom); | ||
1146 | if (unlikely(err)) | ||
1147 | return err; | ||
1148 | |||
1140 | vxh = (struct vxlanhdr *) __skb_push(skb, sizeof(*vxh)); | 1149 | vxh = (struct vxlanhdr *) __skb_push(skb, sizeof(*vxh)); |
1141 | vxh->vx_flags = htonl(VXLAN_FLAGS); | 1150 | vxh->vx_flags = htonl(VXLAN_FLAGS); |
1142 | vxh->vx_vni = vni; | 1151 | vxh->vx_vni = vni; |
@@ -1220,10 +1229,6 @@ static void vxlan_xmit_one(struct sk_buff *skb, struct net_device *dev, | |||
1220 | goto drop; | 1229 | goto drop; |
1221 | } | 1230 | } |
1222 | 1231 | ||
1223 | /* Need space for new headers (invalidates iph ptr) */ | ||
1224 | if (skb_cow_head(skb, VXLAN_HEADROOM)) | ||
1225 | goto drop; | ||
1226 | |||
1227 | old_iph = ip_hdr(skb); | 1232 | old_iph = ip_hdr(skb); |
1228 | 1233 | ||
1229 | ttl = vxlan->ttl; | 1234 | ttl = vxlan->ttl; |