On 08.02.2016 11:28, Samuel Thibault wrote: > From: Guillaume Subiron <maet...@subiron.org> > > 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. > > 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) > > Signed-off-by: Guillaume Subiron <maet...@subiron.org> > Signed-off-by: Samuel Thibault <samuel.thiba...@ens-lyon.org> > --- > 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(-) > > 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 */ > > -/* 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) > > #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 + IF_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