Re: [XFRM]: Improve MTU estimation

2006-08-04 Thread Herbert Xu
On Fri, Aug 04, 2006 at 01:51:24PM +0200, Patrick McHardy wrote: > > + if (!x->props.mode) > + mtu -= blksize - 4; You probably want to check for overflows here since mtu is unsigned. Cheers, -- Visit Openswan at http://www.openswan.org/ Email: Herbert Xu ~{PmV>HI~} <[EMAIL PROTE

Re: [XFRM]: Improve MTU estimation

2006-08-04 Thread Herbert Xu
On Fri, Aug 04, 2006 at 01:50:15PM +0200, Patrick McHardy wrote: > > Now I get it, thanks :) I missed that the IP header isn't part of the > length when it is aligned. So the worst-case increases by block-size > - 4 (- 8 for IPv6). How does this look? That should work. If you want to be fancy yo

Re: [XFRM]: Improve MTU estimation

2006-08-04 Thread Patrick McHardy
Patrick McHardy wrote: > Now I get it, thanks :) I missed that the IP header isn't part of the > length when it is aligned. So the worst-case increases by block-size > - 4 (- 8 for IPv6). How does this look? Forgot the patch .. diff --git a/include/net/xfrm.h b/include/net/xfrm.h index 9c5ee9f

Re: [XFRM]: Improve MTU estimation

2006-08-04 Thread Patrick McHardy
Herbert Xu wrote: > I've reread your patches and your handling of ESP padding is spot on. > It's anyone's guess whether the current code gets it right or not :) > > However, I believe that the transport mode handling does run into > problems with IP options. Basically, your calculation returns a

Re: [XFRM]: Improve MTU estimation

2006-08-04 Thread Herbert Xu
On Fri, Aug 04, 2006 at 09:16:04PM +1000, herbert wrote: > > Are you talking about the ESP padding case, or transport mode in > general? I've reread your patches and your handling of ESP padding is spot on. It's anyone's guess whether the current code gets it right or not :) However, I believe th

Re: [XFRM]: Improve MTU estimation

2006-08-04 Thread Patrick McHardy
Herbert Xu wrote: > On Fri, Aug 04, 2006 at 01:11:19PM +0200, Patrick McHardy wrote: > >>>Of course it gets hairier if you have ESP padding. I'm not even sure >>>if the current code gets that right. >> >>Unless I'm missing something, the padding caused by IP options >>is always less than the wors

Re: [XFRM]: Improve MTU estimation

2006-08-04 Thread Herbert Xu
On Fri, Aug 04, 2006 at 01:11:19PM +0200, Patrick McHardy wrote: > > > Of course it gets hairier if you have ESP padding. I'm not even sure > > if the current code gets that right. > > Unless I'm missing something, the padding caused by IP options > is always less than the worst case that can hap

Re: [XFRM]: Improve MTU estimation

2006-08-04 Thread Patrick McHardy
Herbert Xu wrote: > On Fri, Aug 04, 2006 at 12:09:18PM +0200, Patrick McHardy wrote: > >>I was wondering why the old code distinguished between transport mode >>and tunnel mode, I couldn't spot anything that would be affected. I'll >>look into the transport mode case again. > > > The problem is

Re: [XFRM]: Improve MTU estimation

2006-08-04 Thread Herbert Xu
On Fri, Aug 04, 2006 at 12:09:18PM +0200, Patrick McHardy wrote: > > I was wondering why the old code distinguished between transport mode > and tunnel mode, I couldn't spot anything that would be affected. I'll > look into the transport mode case again. The problem is basically you don't know a

Re: [XFRM]: Improve MTU estimation

2006-08-04 Thread Patrick McHardy
Herbert Xu wrote: > On Fri, Aug 04, 2006 at 11:27:11AM +0200, Patrick McHardy wrote: > >>-static u32 esp4_get_max_size(struct xfrm_state *x, int mtu) >>+static u32 esp4_get_mtu(struct xfrm_state *x, int mtu) >> { >> struct esp_data *esp = x->data; >>- u32 blksize = ALIGN(crypto_tfm_alg_bl

Re: [XFRM]: Improve MTU estimation

2006-08-04 Thread Herbert Xu
On Fri, Aug 04, 2006 at 11:27:11AM +0200, Patrick McHardy wrote: > > [XFRM]: Improve MTU estimation > > Replace the probing based MTU estimation, which usually takes 2-3 > iterations to find a fitting value and may underestimate the MTU, > by an exact calculation. Thank

Re: [XFRM]: Improve MTU estimation

2006-08-04 Thread Patrick McHardy
> + if (x->km.state == XFRM_STATE_VALID && > + x->type && x->type->get_mtu) > + res = x->type->get_mtu(x, mtu); > + else > + res = mtu; > + spin_unlock_bh(&x->lock); > return res; > }

[XFRM]: Improve MTU estimation

2006-08-04 Thread Patrick McHardy
by two bytes with ESP and should be a bit faster, so it still looks useful. [XFRM]: Improve MTU estimation Replace the probing based MTU estimation, which usually takes 2-3 iterations to find a fitting value and may underestimate the MTU, by an exact calculation. Signed-off-by: Patrick McHardy