From patchwork Tue Mar 13 04:01:59 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Dumazet X-Patchwork-Id: 146329 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 06942B6EE7 for ; Tue, 13 Mar 2012 15:02:08 +1100 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750802Ab2CMECF (ORCPT ); Tue, 13 Mar 2012 00:02:05 -0400 Received: from mail-gx0-f174.google.com ([209.85.161.174]:35600 "EHLO mail-gx0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750721Ab2CMECD (ORCPT ); Tue, 13 Mar 2012 00:02:03 -0400 Received: by gghe5 with SMTP id e5so119265ggh.19 for ; Mon, 12 Mar 2012 21:02:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=subject:from:to:cc:in-reply-to:references:content-type:date :message-id:mime-version:x-mailer:content-transfer-encoding; bh=sIpQFaq4xHJWGta9jqrhV0ABx0B/Q3vjaQtSPJTYlpA=; b=Qbpw+ut4GnC+oFM48ah1sgvEt4q/t7q2+NEdZAOws3PEWb0shZPoQoYWplZhVtbHfO DKjXHK7Ksy8et4f5bVSbDo3u6gIXbxUe6lqxhbPBitYNdWl2EmERzbg4WJ+Lh3xT+QLN YklXLmV0eD7R3D+eXjv7PhrK3Uxl9A6AdlAXe3RFAL4PS8p2+bOohUVHYFJLv3W+0CBv fk5fvJop/tDwwWBBMKlaM3urisQ/bzV1x6QaGkixFkiTECJLwny1poeac02TLIegyBOf 5sueMB3b0ubHkA2wvRD0qNPHmzeT9cgO4BgYr8EV+hEA6aVu4n82m45gP3gwC5MNV+U+ PpPg== Received: by 10.182.119.98 with SMTP id kt2mr10377470obb.9.1331611322372; Mon, 12 Mar 2012 21:02:02 -0700 (PDT) Received: from [172.19.248.17] ([216.239.45.130]) by mx.google.com with ESMTPS id a6sm13650593oea.13.2012.03.12.21.02.00 (version=SSLv3 cipher=OTHER); Mon, 12 Mar 2012 21:02:01 -0700 (PDT) Subject: Re: [PATCH] net: Provide SYN packet for passive connections From: Eric Dumazet To: David Miller Cc: therbert@google.com, netdev@vger.kernel.org In-Reply-To: <20120311.211424.996831768685832926.davem@davemloft.net> References: <20120311.195542.1995263719633128071.davem@davemloft.net> <20120311.211424.996831768685832926.davem@davemloft.net> Date: Mon, 12 Mar 2012 21:01:59 -0700 Message-ID: <1331611319.7787.37.camel@edumazet-glaptop> Mime-Version: 1.0 X-Mailer: Evolution 2.28.3 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org On Sun, 2012-03-11 at 21:14 -0700, David Miller wrote: > From: Tom Herbert > Date: Sun, 11 Mar 2012 21:08:38 -0700 > > > For inet_connection_sock I believe there are fields that would only be > > used for a listeners(e.g. icsk_accept_queue), and fields that would > > only be used for a real connection (e.g. icsk_retransmits). Would it > > be worth it to split these into a union? > > Indeed, it might. OK I took a look at this idea, and it seems safe right now. [PATCH net-next] inet: embed icsk_accept_queue in an union icsk_accept_queue is currently used only for LISTEN sockets. We could share its space with fields used for other kind of inet sockets. For active connections, this area is zeroed in socket setup, and for passive ones, we clear the whole area in inet_csk_clone_lock() to make sure we dont use content inherited from (listener) parent. /* Deinitialize accept_queue to trap illegal accesses. */ memset(&newicsk->icsk_accept_queue, 0, sizeof(newicsk->icsk_accept_queue)); For 100% safety, we could do the same in inet_csk_listen_stop(), or we can double check that fields added in this union later are only accessed by non LISTEN sockets. All these fields must have a null default value. Signed-off-by: Eric Dumazet Suggested-by: Tom Herbert --- include/net/inet_connection_sock.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/include/net/inet_connection_sock.h b/include/net/inet_connection_sock.h index dbf9aab..d3ccaf9 100644 --- a/include/net/inet_connection_sock.h +++ b/include/net/inet_connection_sock.h @@ -86,7 +86,9 @@ struct inet_connection_sock_af_ops { struct inet_connection_sock { /* inet_sock has to be the first member! */ struct inet_sock icsk_inet; - struct request_sock_queue icsk_accept_queue; + union { + struct request_sock_queue icsk_accept_queue; + }; struct inet_bind_bucket *icsk_bind_hash; unsigned long icsk_timeout; struct timer_list icsk_retransmit_timer;