From patchwork Fri Dec 14 22:40:05 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Paasch X-Patchwork-Id: 1013754 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming-netdev@ozlabs.org Delivered-To: patchwork-incoming-netdev@ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=quarantine dis=none) header.from=apple.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=apple.com header.i=@apple.com header.b="DZ9vEpPJ"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 43GlrL1xlCz9s1c for ; Sat, 15 Dec 2018 09:40:50 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730701AbeLNWks (ORCPT ); Fri, 14 Dec 2018 17:40:48 -0500 Received: from nwk-aaemail-lapp01.apple.com ([17.151.62.66]:59438 "EHLO nwk-aaemail-lapp01.apple.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730634AbeLNWks (ORCPT ); Fri, 14 Dec 2018 17:40:48 -0500 Received: from pps.filterd (nwk-aaemail-lapp01.apple.com [127.0.0.1]) by nwk-aaemail-lapp01.apple.com (8.16.0.22/8.16.0.22) with SMTP id wBEMW0dF051119; Fri, 14 Dec 2018 14:40:44 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=apple.com; h=content-transfer-encoding : sender : from : to : cc : subject : date : message-id : in-reply-to : references; s=20180706; bh=EwrMr/TdvK6YlFvT8cdD1GVU3NlRZfgGwklFkD1ewkY=; b=DZ9vEpPJ43eWxI/MkYlrcVVEG79b2yHOX5/dr5Kw3OpQC13iqJ4V6LMqyS+GOlh3IyCT VeEldvimaFgeDup9tIKR/QQ4JQHFHp0t01WB2RYkSlV/SLcsjiHQZwDxyipL8UYsIuRv 2KKsrqLXFTF99lSCs69AePEVwozHRPbxYIEuVOmKZhk7jMJJZLl4PZ2P00BY043aRsup mCDWdekDVzmFyUDef12A6yUjmMS3WvJsbzYIZo9CJ3/vNp6H5LbbV2YzT2edgrJrZVDC yYpdQwIa4dPhiR+gwoFZoSO6dyHs2JWfAUBKrGPuDsgzhnAx4AHxZHJu+nWk/2q300C9 Bg== Received: from mr2-mtap-s01.rno.apple.com (mr2-mtap-s01.rno.apple.com [17.179.226.133]) by nwk-aaemail-lapp01.apple.com with ESMTP id 2p8dsaqtyx-3 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NO); Fri, 14 Dec 2018 14:40:44 -0800 Content-transfer-encoding: 7BIT Received: from nwk-mmpp-sz09.apple.com (nwk-mmpp-sz09.apple.com [17.128.115.80]) by mr2-mtap-s01.rno.apple.com (Oracle Communications Messaging Server 8.0.2.3.20181024 64bit (built Oct 24 2018)) with ESMTPS id <0PJR000EF0BLJE90@mr2-mtap-s01.rno.apple.com>; Fri, 14 Dec 2018 14:40:33 -0800 (PST) Received: from process_viserion-daemon.nwk-mmpp-sz09.apple.com by nwk-mmpp-sz09.apple.com (Oracle Communications Messaging Server 8.0.2.3.20181024 64bit (built Oct 24 2018)) id <0PJQ00B00Z1EGU00@nwk-mmpp-sz09.apple.com>; Fri, 14 Dec 2018 14:40:33 -0800 (PST) X-Va-A: X-Va-T-CD: 4b1e0bf36502e052fc75ad21b706ed24 X-Va-E-CD: 3089812386ca7b59ac37036f9009cb92 X-Va-R-CD: 482b616a1c5773988125f3aaf43b0f24 X-Va-CD: 0 X-Va-ID: eee54f6a-5e98-430b-b3de-ad457e125c27 X-V-A: X-V-T-CD: 5c1d590bbb3e9640019563b4ec412a7e X-V-E-CD: 3089812386ca7b59ac37036f9009cb92 X-V-R-CD: 482b616a1c5773988125f3aaf43b0f24 X-V-CD: 0 X-V-ID: 0410d6e9-cfb6-465f-aef4-b40e0046f13b Received: from process_milters-daemon.nwk-mmpp-sz09.apple.com by nwk-mmpp-sz09.apple.com (Oracle Communications Messaging Server 8.0.2.3.20181024 64bit (built Oct 24 2018)) id <0PJR00F0009AI500@nwk-mmpp-sz09.apple.com>; Fri, 14 Dec 2018 14:40:31 -0800 (PST) X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2018-12-14_13:,, signatures=0 Received: from localhost ([17.192.155.217]) by nwk-mmpp-sz09.apple.com (Oracle Communications Messaging Server 8.0.2.3.20181024 64bit (built Oct 24 2018)) with ESMTPSA id <0PJR00GB60BISV00@nwk-mmpp-sz09.apple.com>; Fri, 14 Dec 2018 14:40:30 -0800 (PST) From: Christoph Paasch To: netdev@vger.kernel.org Cc: Eric Dumazet , Yuchung Cheng , David Miller Subject: [PATCH net-next 3/5] tcp: Print list of TFO-keys from proc Date: Fri, 14 Dec 2018 14:40:05 -0800 Message-id: <20181214224007.54813-4-cpaasch@apple.com> X-Mailer: git-send-email 2.16.2 In-reply-to: <20181214224007.54813-1-cpaasch@apple.com> References: <20181214224007.54813-1-cpaasch@apple.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:, , definitions=2018-12-14_13:, , signatures=0 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Print the list of the TFO-keys with a comma separated. For setting the keys, we still only allow a single one to be set. Signed-off-by: Christoph Paasch --- net/ipv4/sysctl_net_ipv4.c | 41 ++++++++++++++++++++++++++++++----------- 1 file changed, 30 insertions(+), 11 deletions(-) diff --git a/net/ipv4/sysctl_net_ipv4.c b/net/ipv4/sysctl_net_ipv4.c index ba0fc4b18465..f0806bab5562 100644 --- a/net/ipv4/sysctl_net_ipv4.c +++ b/net/ipv4/sysctl_net_ipv4.c @@ -282,11 +282,15 @@ static int proc_tcp_fastopen_key(struct ctl_table *table, int write, { struct net *net = container_of(table->data, struct net, ipv4.sysctl_tcp_fastopen); - struct ctl_table tbl = { .maxlen = (TCP_FASTOPEN_KEY_LENGTH * 2 + 10) }; + /* maxlen to print the list of keys in hex (*2), with a comma + * in between (+ TCP_FASTOPEN_CTXT_LEN) + */ + struct ctl_table tbl = { .maxlen = (TCP_FASTOPEN_KEY_LENGTH * 2 * TCP_FASTOPEN_CTXT_LEN + + TCP_FASTOPEN_CTXT_LEN + 10) }; struct tcp_fastopen_context *ctxt; - u32 user_key[4]; /* 16 bytes, matching TCP_FASTOPEN_KEY_LENGTH */ - __le32 key[4]; - int ret, i; + u32 user_key[TCP_FASTOPEN_CTXT_LEN * 4]; + __le32 key[TCP_FASTOPEN_CTXT_LEN * 4]; + int ret, i = 0, off = 0; tbl.data = kmalloc(tbl.maxlen, GFP_KERNEL); if (!tbl.data) @@ -294,17 +298,28 @@ static int proc_tcp_fastopen_key(struct ctl_table *table, int write, rcu_read_lock(); ctxt = rcu_dereference(net->ipv4.tcp_fastopen_ctx); - if (ctxt) - memcpy(key, ctxt->key, TCP_FASTOPEN_KEY_LENGTH); - else - memset(key, 0, sizeof(key)); + while (ctxt) { + memcpy(&key[i], ctxt->key, TCP_FASTOPEN_KEY_LENGTH); + i += 4; + ctxt = rcu_dereference(ctxt->next); + } rcu_read_unlock(); + memset(&key[i], 0, sizeof(key) - i * sizeof(u32)); + for (i = 0; i < ARRAY_SIZE(key); i++) user_key[i] = le32_to_cpu(key[i]); - snprintf(tbl.data, tbl.maxlen, "%08x-%08x-%08x-%08x", - user_key[0], user_key[1], user_key[2], user_key[3]); + for (i = 0; i < TCP_FASTOPEN_CTXT_LEN; i++) { + off += snprintf(tbl.data + off, tbl.maxlen - off, + "%08x-%08x-%08x-%08x", + user_key[i * 4], + user_key[i * 4 + 1], + user_key[i * 4 + 2], + user_key[i * 4 + 3]); + if (i + 1 < TCP_FASTOPEN_CTXT_LEN) + off += snprintf(tbl.data + off, tbl.maxlen - off, ","); + } ret = proc_dostring(&tbl, write, buffer, lenp, ppos); if (write && ret == 0) { @@ -923,7 +938,11 @@ static struct ctl_table ipv4_net_table[] = { .procname = "tcp_fastopen_key", .mode = 0600, .data = &init_net.ipv4.sysctl_tcp_fastopen, - .maxlen = ((TCP_FASTOPEN_KEY_LENGTH * 2) + 10), + /* maxlen to print the list of keys in hex (*2), with a comma + * in between (+ TCP_FASTOPEN_CTXT_LEN) + */ + .maxlen = ((TCP_FASTOPEN_KEY_LENGTH * 2 * TCP_FASTOPEN_CTXT_LEN) + + TCP_FASTOPEN_CTXT_LEN + 10), .proc_handler = proc_tcp_fastopen_key, }, {