From owner-freebsd-transport@freebsd.org Mon Feb 6 18:54:27 2017 Return-Path: Delivered-To: freebsd-transport@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id A7784CD3A89 for ; Mon, 6 Feb 2017 18:54:27 +0000 (UTC) (envelope-from rysto32@gmail.com) Received: from mail-io0-x230.google.com (mail-io0-x230.google.com [IPv6:2607:f8b0:4001:c06::230]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 740961737 for ; Mon, 6 Feb 2017 18:54:27 +0000 (UTC) (envelope-from rysto32@gmail.com) Received: by mail-io0-x230.google.com with SMTP id l66so72755982ioi.1 for ; Mon, 06 Feb 2017 10:54:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:from:date:message-id:subject:to; bh=MVyAnHmZ89b9MwbdMbRn+0wCpLgAJbPgC8mm9gtKAtU=; b=GY6Z6R+UEPxprhsK965dSj+EhH+uRoeBgWjxjxdtD/19vzd2dpTKyaVqnJuZt75gB6 o5vkHx23mehkK390UDUFdgaXw3Ni6O6DOwvCKZ1xdxHuqL/R2nrCxlvb7YxULw3Sxk2B +/8NRhVHTlESlq/E4wPybKxqUCmZMUFnK3L5O3Py/HU5PXsJD3FvL5x00s7PxMMqSCS1 +Dia4a2dfQdpBtCwefUwVlBjlQfLe/y0AFvDnmTKtL1t632CUcwtaqCFhw7m/NGxepU1 imkk2rQCaccFy8bIdvpXfZARCXPALgvP10/N25yqSUSngQpESUGuTSb6+ozj3kACMuct qvOA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=MVyAnHmZ89b9MwbdMbRn+0wCpLgAJbPgC8mm9gtKAtU=; b=NQtYUKXPrOi4eUDKFaUq4htT0vOTB8i1yhg90p+ACB6V2YQOX9gUWgkM9Y5lWaZNZs 1JzzXO4aVUGrkRtsZsE9nkgsRiwvmFPWjl16OCBfIyry6F1FnJkxqXa/94MKExltGxYP H8sMOytbsLT3I2FRdPBDyvnJO6Ez6vy+FhTUjXWIzOuqy2CZIvwxWyICsh/H6nrMWuh1 YG8tjgqLniequM/68LIAai8gKdBFIkbd2O5ZB1+6cZIlwTRc+3DhyRIvdsXBXoMbtfNb 5EO/HBYbMbgrpsXEXT5pqWLIT05Ag5WBM9yJf09mLYVcaxVH3JuUj54QR7oGHLyGjqYQ DVbw== X-Gm-Message-State: AMke39nvxPTWQHpw4NeBBPrFBvbFvPiPjcvtvxlNUT918kzb/5mWXHYgiTMZrKohxRLrKWrYOlRPaGSvj67bIQ== X-Received: by 10.107.15.70 with SMTP id x67mr792511ioi.103.1486407266777; Mon, 06 Feb 2017 10:54:26 -0800 (PST) MIME-Version: 1.0 Received: by 10.107.190.71 with HTTP; Mon, 6 Feb 2017 10:54:26 -0800 (PST) From: Ryan Stone Date: Mon, 6 Feb 2017 13:54:26 -0500 Message-ID: Subject: struct tcpcb padding is insane To: "" Content-Type: text/plain; charset=UTF-8 X-Content-Filtered-By: Mailman/MimeDel 2.1.23 X-BeenThere: freebsd-transport@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Discussions of transport level network protocols in FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 06 Feb 2017 18:54:27 -0000 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) From owner-freebsd-transport@freebsd.org Mon Feb 6 23:37:50 2017 Return-Path: Delivered-To: freebsd-transport@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id A25F1CB46E5 for ; Mon, 6 Feb 2017 23:37:50 +0000 (UTC) (envelope-from rysto32@gmail.com) Received: from mail-it0-x234.google.com (mail-it0-x234.google.com [IPv6:2607:f8b0:4001:c0b::234]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 761FDC10 for ; Mon, 6 Feb 2017 23:37:50 +0000 (UTC) (envelope-from rysto32@gmail.com) Received: by mail-it0-x234.google.com with SMTP id c7so68209535itd.1 for ; Mon, 06 Feb 2017 15:37:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to; bh=f+24AHhSpe3zaFn4t6W21sV50K+J4GYi1aYqwngFl8c=; b=YPn+ZVW9zxeys4+V4Puvi+s5jKu4B8iNb9vDsjvXf2g+XzKtOP1WciUKF205kI6hDR n3KDTae2RxNR+YzVFzSOD/W2zEVMzDaUUlP9/8KuhUkcyXjNcEJE5BGafmsau+Cj4CJO cgc3VQ5x3Kq1GDCrbpd4xt2a7vepjxzJRivp08vEKkVGCEKzcBGATqkMGD22KQaMTpZE RvJKCxmVGdo1hpWfb7l5ge32unPzAVCfcFB6Mtexqt+hAf7+iSEtz5X6vz0QRo54HiLu QFp1KDinOSBpas4QSSns/bBPLk2ofM0QFwxPv991yLdwcDe09s6pSxGcZ6cb3RFvZvk2 SbBA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to; bh=f+24AHhSpe3zaFn4t6W21sV50K+J4GYi1aYqwngFl8c=; b=bTwFdmhEMC9SLHwjyrB5lxFdrzlV3DVuwQ8bEesy2Yp9/Rs/UmR4y9Owta8GAEiC9N 94H2lA79ADeMdYnrb6Xlf/ulrx+HXh7ccIlAskGs+oL/87DWle3zMYCOo89KeiTe51at NpLX2hMSvVoCrARM3jQzkUDmcEzRCN2y9HttaBHhx8sDOmq8y3L+ENbpuwifFz4y1S5h nA/uuTa5yREyFIeFNt0BH7/AyFX/yCYjR7I+bXFP5UAxHF/ykpE//yaGD9I7hefqlicu w3xEirvxnpE1OMkIXNjBzUe+wTSqwnPIp4zCrl+ud/AzkH3RnR2nMVgPvOHLtCacvDxe 8CBQ== X-Gm-Message-State: AIkVDXIThAk4Eip0ms85UED0GzOlDOCtqpw4usxaJ7ui3OMmb9fivYxy7WRcHDCZxvFFDKwD3D/qJPpQiqjyWg== X-Received: by 10.36.1.147 with SMTP id 141mr9734491itk.65.1486424269673; Mon, 06 Feb 2017 15:37:49 -0800 (PST) MIME-Version: 1.0 Received: by 10.107.190.71 with HTTP; Mon, 6 Feb 2017 15:37:49 -0800 (PST) In-Reply-To: References: From: Ryan Stone Date: Mon, 6 Feb 2017 18:37:49 -0500 Message-ID: Subject: Re: struct tcpcb padding is insane To: "" Content-Type: text/plain; charset=UTF-8 X-Content-Filtered-By: Mailman/MimeDel 2.1.23 X-BeenThere: freebsd-transport@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Discussions of transport level network protocols in FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 06 Feb 2017 23:37:50 -0000 I've put in a review for this: https://reviews.freebsd.org/D9465 Unfortunately the TCPPCAP stuff isn't as easy to excise because it's trying to avoid exposing struct mbufq to userland.