Received: by 10.192.165.148 with SMTP id m20csp4237635imm; Mon, 23 Apr 2018 22:25:23 -0700 (PDT) X-Google-Smtp-Source: AB8JxZojdUREWgFApigPWs8b5h93YRO7p9WS1KdnFF83daCIhDD5E+gDEQk+ZfX/Vw+Co98D5Imc X-Received: by 2002:a17:902:aa03:: with SMTP id be3-v6mr2776978plb.215.1524547523662; Mon, 23 Apr 2018 22:25:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524547523; cv=none; d=google.com; s=arc-20160816; b=Q4hk9bPoTkkBRmcV4WIdNB9Pkb8bgIXxjarP24JsnNKvIryT9roxharIzGBlWSyyOb n239qjI3nAq/VN3uNSJz1m/S1hsMyzHL8Rd9lCSl1eTF50jSY7tfq0fF7XmdUaCbVwt4 UqOF+aFuTjviMZFKyFSS7tOj5/gcZVuf+QOQeTKyAmVff7CZDq9+oSgNEstW7eLCx8oR evZVwqUQ1+Mnbt0eWhOpVPQCfpkM5M2HGnWU95e2Nh6eJE1wkQolYmrCTrG3lQic+VHv pXeKcl4CL94/AeHWwARScs/hQL77k0z54iuIV8H5CLbt0T+Ifg/xgdKB05vZ+jyT079f GgEw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :references:in-reply-to:mime-version:dkim-signature :arc-authentication-results; bh=nsS4P0nKjTn19NIC2L/ODfY2VL8p1oj38uPWWflF1ik=; b=yAYZTCsRkbGZ8EKvUH5GnPBnRXBVWkLJd7B/A3lOXXk0pMq5Y0wmtkihl0YZ4/+BUl ZDBkiIFT/Aw6DWOzQ7Fl4vco4OqF9BxL/iWv82yF4KDFpPHFhpfxGZUyPSY+0+f/RLFv n9g9MPPjImBwUiD0UV+M20ZvtKxMW6eNbZDmShYY3zzMgYot+V/Ejz1F4RplCx06ebse 6NAsvOuOGvqhYgjgZK4sTk90uVm8vwQZYrLtSlTia1CiFjmellv8Erq3FRbuoUZ7u1VB S2llPEVO2C87GnfYeKiXo4YokNjKFja9SutnwabjxvPEaVvwRsBRRIBgFji2NPDGdiH8 5wXQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=Wxe9x2/M; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b6si12742222pfe.265.2018.04.23.22.24.56; Mon, 23 Apr 2018 22:25:23 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=Wxe9x2/M; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752197AbeDXEkI (ORCPT + 99 others); Tue, 24 Apr 2018 00:40:08 -0400 Received: from mail-io0-f195.google.com ([209.85.223.195]:34825 "EHLO mail-io0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751027AbeDXEkF (ORCPT ); Tue, 24 Apr 2018 00:40:05 -0400 Received: by mail-io0-f195.google.com with SMTP id d26-v6so21151840ioc.2; Mon, 23 Apr 2018 21:40:05 -0700 (PDT) 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 :cc; bh=nsS4P0nKjTn19NIC2L/ODfY2VL8p1oj38uPWWflF1ik=; b=Wxe9x2/M/T7sfWkarcVrRpw0mNhCsdWHotVwFfwjn1FMNlgV+c9QZrHHa5ulb9u/I2 SgXGhCncjciAVMBYD+M5AIHMLb7IqfMfF0Y8wbA+qFDeWXXt88J4YBt8h9S/aYaCRsDt +xunANl7UDsFg1Hn1bjRtCaVyrF2N6rF/eqnnpuJEUXIePDEqYRn3gl4HyIQtzv/urJo w5r/Vv5xmMxl/AF08nPYyCpLQv8Xu7jDlXUeLqsAJnBpkPlXbZ3KxMZWTdq8FszgzAXf 64QymhZkUGNrdweicf7WfKqNw2cdohk4jgj35N5r+0vE/tohs3M1Df4iO/I+7StTMVvc B9fQ== 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:cc; bh=nsS4P0nKjTn19NIC2L/ODfY2VL8p1oj38uPWWflF1ik=; b=QN2KguG3KKMxixMRzac+90eQNWIvB8blCOb4hNOfgNgD662cy7oTMrH9b7MwQZSagA 8VEaO0Cj56grVWAsHTlAZnapu2MNRX/pmU8QYlbfP0gZnpFp6hWpiGXL5YunV+pLwFVB DQXkxbzeXP41KpJTxrxFhJyqksSEY5MeyLs9U3JjKtqolwGJfDhPtm2BM11fbcizQ65y VOzEePHMk/wreV9TmvzQr2ZqsZYkOceqyNIRsfNcE9+ZpY1yThO+8MbJf4djtGdPczrm HZYWQPLYEtVQCw/x7Ku+Sc9KoBw3buFTrLKJKvTMwpTixwaynMpKFmx/t72l1uqisA/R JbRw== X-Gm-Message-State: ALQs6tBuXcsx152U1Yv9+36kE9EgqRfv5it/Pq3DVjhKHJLfQUm7UHkG TnRbF+D+k6bGFlrqvAZAboc8d1+AC7U0zAEbx4c62w== X-Received: by 2002:a6b:1741:: with SMTP id 62-v6mr172784iox.142.1524544805169; Mon, 23 Apr 2018 21:40:05 -0700 (PDT) MIME-Version: 1.0 Received: by 10.107.181.10 with HTTP; Mon, 23 Apr 2018 21:39:24 -0700 (PDT) In-Reply-To: <788ce3f1-6534-5c2e-1870-5ebd8ea4ae7f@gmail.com> References: <1524405004-10960-1-git-send-email-laoar.shao@gmail.com> <20180423.115821.640630949143585629.davem@davemloft.net> <788ce3f1-6534-5c2e-1870-5ebd8ea4ae7f@gmail.com> From: Yafang Shao Date: Tue, 24 Apr 2018 12:39:24 +0800 Message-ID: Subject: Re: [PATCH net-next] net: init sk_cookie for inet socket To: Eric Dumazet Cc: David Miller , Alexei Starovoitov , netdev@vger.kernel.org, LKML Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Apr 24, 2018 at 12:09 AM, Eric Dumazet wrote: > > > On 04/23/2018 08:58 AM, David Miller wrote: >> From: Yafang Shao >> Date: Sun, 22 Apr 2018 21:50:04 +0800 >> >>> With sk_cookie we can identify a socket, that is very helpful for >>> traceing and statistic, i.e. tcp tracepiont and ebpf. >>> So we'd better init it by default for inet socket. >>> When using it, we just need call atomic64_read(&sk->sk_cookie). >>> >>> Signed-off-by: Yafang Shao >> >> Applied, thank you. >> > > This is adding yet another atomic_inc on a global cache line. > That's a trade-off. > Most applications do not need the cookie being ever set. > > The existing mechanism was fine. Set it on demand. There are some drawback in the existing mechanism. - we have to set the net->cookie_gen and then sk->sk_cookie when we want to get the sk_cookie, that's a little expensive as well. After that change, sock_gen_cookie() could be replaced by atomic64_read(&sk->sk_cookie) in most places. - If the application want to get the sk_cookie, it must set it first. What if the application don't have the permision to write? Furthermore, maybe it is a security concern ? Thanks Yafang