Hi Samuel, Should I add an assert for ih_x1? It sounds like a bug that caller set up a right src and dst address and without set right ih_x1.
On Thu, Apr 27, 2017 at 6:21 AM, Samuel Thibault <samuel.thiba...@gnu.org> wrote: > Hello, > > Thomas Huth, on lun. 24 avril 2017 11:15:56 +0200, wrote: > > On 20.04.2017 22:43, Tao Wu wrote: > > > The current code looks buggy, we zero ti_i while we access > > > ti_dst/ti_src later. > > Indeed. > > > > Signed-off-by: Tao Wu <lep...@google.com> > > > > *mtod(m, struct tcpiphdr *) = *ti; > > > ti = mtod(m, struct tcpiphdr *); > > > - memset(&ti->ti, 0, sizeof(ti->ti)); > > But then we don't make sure that ih_x1 is 0, which is needed for the > checksum to be correct, but possibly not set by the caller. > > So please replace the memset call with setting the proper ih_x1 field to > 0 (which thus needs the introductino of a switch over af like below in > the code). > > Samuel >