On Fri, Dec 03, 2010 at 04:14:37PM +0100, Alexander Bluhm wrote: > On Fri, Dec 03, 2010 at 01:12:57PM +0100, Claudio Jeker wrote: > > Window size scaling is disabled when an application is issuing a > > setsockopt() changing SO_SNDBUF or SO_RCVBUF. > > tcp_update_sndspace() still rounds up to tp->t_maxseg even if > SO_SNDBUF has been set. > > I was always wondering why the code in tcp_update_sndspace() > is different from tcp_update_rcvspace(). > > tcp_update_sndspace() > ... > /* round to MSS boundary */ > nmax = roundup(nmax, tp->t_maxseg); > > if (nmax != so->so_snd.sb_hiwat) > sbreserve(&so->so_snd, nmax); > } > > tcp_update_rcvspace() > ... > if (nmax == so->so_rcv.sb_hiwat) > return; > > /* round to MSS boundary */ > nmax = roundup(nmax, tp->t_maxseg); > sbreserve(&so->so_rcv, nmax); > } >
IIRC I changed the rcvspace version because else it would alternate between sb_hiwat and roundup(sb_hiwat, tp->t_maxseg). The problem was that roundup(sb_max, tp->t_maxseg) was bigger then sb_max and so the sbreserve() would be called everytime. I guess tcp_update_sndspace() may have a similar issue but it needs to be fixed differently because the two algorithms are too different. Btw. the scaling functions are probably not perfect and if people can come up with a better algorithm I'm happy to test it but I'm currently to busy with other stuff to do it myself. -- :wq Claudio
