Skip to contentSkip to conversation

ip_gre headroom allocation

PATCH Timo Teräs 3 participants 8 messages Jun 11, 2009

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

I'm not entirely sure about this, but shouldn't we do something like the below to make ip_gre allocation enough headroom for paths where e.g. xfrm transformations take place (as a speed optimization)?

net/ipv4/ip_gre.c +1 -1
index e62510d..eb78dd9 100644
@@ -812,7 +812,7 @@ static int ipgre_tunnel_xmit(struct sk_buff *skb, struct net_device *dev)
                       tunnel->err_count = 0;
       }
 
-       max_headroom = LL_RESERVED_SPACE(tdev) + gre_hlen;
+       max_headroom = LL_RESERVED_SPACE(tdev) + gre_hlen + rt->u.dst.header_len;
 
       if (skb_headroom(skb) < max_headroom || skb_shared(skb)||
           (skb_cloned(skb) && !skb_clone_writable(skb, 0))) {
maintainer
#1 lore raw

From: Timo Teräs <[email protected]>
Date: Thu, 11 Jun 2009 11:22:34 +0300

Quoted 3 lines

I'm not entirely sure about this, but shouldn't we do something like the below to make ip_gre allocation enough headroom for paths where e.g. xfrm transformations take place (as a speed optimization)?

This should be handled by the code one level up that allocates the SKB.

And as routes get stacked, the MTUs and headroom values get adjusted up to the root.

At least that's how it's supposed to work :-)

Otherwise we'd need a similar hack in ipip.c too.

#2 lore raw
Quoted 7 lines · David Miller

From: Timo Teräs <[email protected]>
Date: Thu, 11 Jun 2009 11:22:34 +0300

Quoted 3 lines

I'm not entirely sure about this, but shouldn't we do something like the below to make ip_gre allocation enough headroom for paths where e.g. xfrm transformations take place (as a speed optimization)?

Quoted 7 lines

This should be handled by the code one level up that allocates the SKB.

And as routes get stacked, the MTUs and headroom values get adjusted up to the root.

At least that's how it's supposed to work :-)

Ok, that makes sense. I was just wondering if there's any corner cases were this would have helped.

Quoted 1 line

Otherwise we'd need a similar hack in ipip.c too.

I was under the impression that as we need to do the route lookup anyway we could take advantage of the information available from there fully.

But yes, your explanation makes perfect sense.

Thanks,
Timo

#3 lore raw
Quoted 7 lines · Timo Teräs
Quoted 2 lines

Otherwise we'd need a similar hack in ipip.c too.

I was under the impression that as we need to do the route lookup anyway we could take advantage of the information available from there fully.

But yes, your explanation makes perfect sense.

I think you're both right :)

We should include the IPsec head room here, but also in the dev->needed_headroom calculation so that most packets don't get reallocated in the first place.

And yes all tunnels are deficient in this regard.

Cheers,

Signature · 4 lines
Visit Openswan at http://www.openswan.org/
Email: Herbert Xu ~{PmV>HI~} <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
#4 lore raw
Quoted 5 lines · Herbert Xu
Quoted 4 lines · Timo Teräs
Quoted 1 line

Otherwise we'd need a similar hack in ipip.c too.

I was under the impression that as we need to do the route lookup anyway we could take advantage of the information available from there fully.

Quoted 7 lines
Quoted 1 line

But yes, your explanation makes perfect sense.

I think you're both right :)

We should include the IPsec head room here, but also in the dev->needed_headroom calculation so that most packets don't get reallocated in the first place.

I guess this is easy for point-to-point tunnels. But how about the multipoint gre tunnels? The needed_headroom can vary on destination basis depending on if they are NATted or not, and on the cipher/hash used.

Can we change the needed_headroom on-the-fly? Increase it when ever we encounter a larger path? But this also means some packages would get extra headroom allocated.

- Timo

#5 lore raw
Quoted 5 lines · Timo Teräs

I guess this is easy for point-to-point tunnels. But how about the multipoint gre tunnels? The needed_headroom can vary on destination basis depending on if they are NATted or not, and on the cipher/hash used.

I don't think we need to worry about NAT, well at least we don't worry about it on the normal path :)

Quoted 3 lines

Can we change the needed_headroom on-the-fly? Increase it when ever we encounter a larger path? But this also means some packages would get extra headroom allocated.

Just make it the maximum. It's OK to have extra head space. If the head space is huge then you've got bigger problems than wasted memory :)

Cheers,

Signature · 4 lines
Visit Openswan at http://www.openswan.org/
Email: Herbert Xu ~{PmV>HI~} <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
#6 lore raw
Quoted 8 lines · Herbert Xu
Quoted 4 lines · Timo Teräs

I guess this is easy for point-to-point tunnels. But how about the multipoint gre tunnels? The needed_headroom can vary on destination basis depending on if they are NATted or not, and on the cipher/hash used.

I don't think we need to worry about NAT, well at least we don't worry about it on the normal path :)

It affects if ESP or UDP-over-ESP encapsulation is used. This can vary on destination IP basis. This different needed_headroom size. This the case only for multi-point tunnels. But yes, we don't need to worry about it, it just one factor that can affect what the actual needed_headroom can end up being.

Quoted 7 lines
Quoted 3 lines

Can we change the needed_headroom on-the-fly? Increase it when ever we encounter a larger path? But this also means some packages would get extra headroom allocated.

Just make it the maximum. It's OK to have extra head space. If the head space is huge then you've got bigger problems than wasted memory :)

I guess so. The difference is not too many bytes. Is it ok to just change the dev->needed_headroom from xmit routine?

- Timo

#7 lore raw
Quoted 3 lines · Timo Teräs

I guess so. The difference is not too many bytes. Is it ok to just change the dev->needed_headroom from xmit routine?

I don't see why not. Also we only need to change it in xmit if we hit an skb that needs to be reallocated.

Cheers,

Signature · 4 lines
Visit Openswan at http://www.openswan.org/
Email: Herbert Xu ~{PmV>HI~} <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt