Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 6 Feb 2017 13:54:26 -0500
From:      Ryan Stone <rysto32@gmail.com>
To:        "<freebsd-transport@freebsd.org>" <freebsd-transport@freebsd.org>
Subject:   struct tcpcb padding is insane
Message-ID:  <CAFMmRNzx=Fd7cb2a2C3YRd1VP4mJdB25cbPFCdvh5tfo-1PAXA@mail.gmail.com>

next in thread | raw e-mail | index | archive | help
https://svnweb.freebsd.org/base/head/sys/netinet/tcp_var.h?revision=313330&view=markup#l279

I was just looking to try and add a field in struct tcpcb, and I was quite
unhappy that it has recently turned into a mess of ifdefs:

#if defined(_KERNEL) && defined(TCP_RFC7413)
	uint32_t t_ispare[6];		/* 5 UTO, 1 TBD */
	uint64_t t_tfo_cookie;		/* TCP Fast Open cookie */
#else
	uint32_t t_ispare[8];		/* 5 UTO, 3 TBD */
#endif
	struct tcp_function_block *t_fb;/* TCP function call block */
	void	*t_fb_ptr;		/* Pointer to t_fb specific data */
#if defined(_KERNEL) && defined(TCP_RFC7413)
	unsigned int *t_tfo_pending;	/* TCP Fast Open pending counter */
	void	*t_pspare2[1];		/* 1 TCP_SIGNATURE */
#else
	void	*t_pspare2[2];		/* 1 TCP_SIGNATURE, 1 TBD */
#endif
#if defined(_KERNEL) && defined(TCPPCAP)
	struct mbufq t_inpkts;		/* List of saved input packets. */
	struct mbufq t_outpkts;		/* List of saved output packets. */
#ifdef _LP64
	uint64_t _pad[0];		/* all used! */
#else
	uint64_t _pad[2];		/* 2 are available */
#endif /* _LP64 */
#else
	uint64_t _pad[6];
#endif /* defined(_KERNEL) && defined(TCPPCAP) */

This is unmaintainable,, unreadable unextendable and completely
unnecessary.  I don't see value in leaving spare fields spare if the
corresponding kernel feature is unused;
it isn't as though we can reuse the field for anything else.  If
nobody has any objections, I'll prepare a patch to eliminate the ifdef
soup (with the lamentable exception
of the _LP64 ifdef, which is necessary)



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CAFMmRNzx=Fd7cb2a2C3YRd1VP4mJdB25cbPFCdvh5tfo-1PAXA>