From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46339) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aTPmR-0006au-9x for qemu-devel@nongnu.org; Wed, 10 Feb 2016 03:05:44 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aTPmO-0001w9-2v for qemu-devel@nongnu.org; Wed, 10 Feb 2016 03:05:43 -0500 Received: from mx1.redhat.com ([209.132.183.28]:49091) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aTPmN-0001w2-P7 for qemu-devel@nongnu.org; Wed, 10 Feb 2016 03:05:40 -0500 References: From: Thomas Huth Message-ID: <56BAEF4C.6090400@redhat.com> Date: Wed, 10 Feb 2016 09:05:32 +0100 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCHv7 4/9] slirp: Factorizing tcpiphdr structure with an union List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Samuel Thibault , qemu-devel@nongnu.org Cc: zhanghailiang , Li Zhijian , Stefan Hajnoczi , Jason Wang , Dave Gilbert , Vasiliy Tolstov , Huangpeng , Gonglei , Jan Kiszka , Guillaume Subiron On 08.02.2016 11:28, Samuel Thibault wrote: > From: Guillaume Subiron >=20 > This patch factorizes the tcpiphdr structure to put the IPv4 fields in > an union, for addition of version 6 in further patch. > Using some macros, retrocompatibility of the existing code is assured. >=20 > This patch also fixes the SLIRP_MSIZE and margin computation in various > functions, and makes them compatible with the new tcpiphdr structure, > whose size will be bigger than sizeof(struct tcphdr) + sizeof(struct ip= ) >=20 > Signed-off-by: Guillaume Subiron > Signed-off-by: Samuel Thibault > --- > slirp/if.h | 4 ++-- > slirp/mbuf.c | 3 ++- > slirp/slirp.c | 15 ++++++++------- > slirp/socket.c | 13 ++++++++++++- > slirp/tcp_input.c | 31 ++++++++++++++++++++----------- > slirp/tcp_output.c | 18 +++++++++++++----- > slirp/tcp_subr.c | 31 ++++++++++++++++++++++--------- > slirp/tcpip.h | 31 +++++++++++++++++++++++-------- > 8 files changed, 102 insertions(+), 44 deletions(-) >=20 > diff --git a/slirp/if.h b/slirp/if.h > index 3327023..c7a5c57 100644 > --- a/slirp/if.h > +++ b/slirp/if.h > @@ -17,7 +17,7 @@ > #define IF_MRU 1500 > #define IF_COMP IF_AUTOCOMP /* Flags for compression */ > =20 > -/* 2 for alignment, 14 for ethernet, 40 for TCP/IP */ > -#define IF_MAXLINKHDR (2 + 14 + 40) > +/* 2 for alignment, 14 for ethernet */ > +#define IF_MAXLINKHDR (2 + ETH_HLEN) > =20 > #endif > diff --git a/slirp/mbuf.c b/slirp/mbuf.c > index c959758..f081c69 100644 > --- a/slirp/mbuf.c > +++ b/slirp/mbuf.c > @@ -24,7 +24,8 @@ > * Find a nice value for msize > * XXX if_maxlinkhdr already in mtu > */ > -#define SLIRP_MSIZE (IF_MTU + IF_MAXLINKHDR + offsetof(struct mbuf, m_= dat) + 6) > +#define SLIRP_MSIZE\ > + (offsetof(struct mbuf, m_dat) + IF_MAXLINKHDR + TCPIPHDR_DELTA + I= F_MTU) I'm somehow having a hard time to understand why TCPIPHDR_DELTA is used here. As far as I understand, TCPIPHDR_DELTA is the difference between the size of struct tcpiphdr and the size of the IPv4 + TCP header. But if it's just the difference, where does the base size of the headers come from in this define, since the headers are stored in the mbuf, too, aren't they? ... I've got the feeling that I miss something here, could you enlighten me? Thomas