Received: by 2002:ac0:946b:0:0:0:0:0 with SMTP id j40csp3938520imj; Tue, 12 Feb 2019 07:12:09 -0800 (PST) X-Google-Smtp-Source: AHgI3IYNUkbQUuDnRKsgjfiL7GORiFg4w8V32ERGF1fz9C6fwu9aNSMZH7s8MD3KBo7QtaUXXjz/ X-Received: by 2002:a17:902:8212:: with SMTP id x18mr1786980pln.217.1549984329514; Tue, 12 Feb 2019 07:12:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549984329; cv=none; d=google.com; s=arc-20160816; b=KwTxYjDpIoZcyAdhMSXmMmG4mNyKLpUwiGN1Dz4+2qad3kbhqgVzXXW+fAEQEfp+rg NNZPLzrwSXMhx7N3Cgq6K6MPU1YBkSzRG+o5LTXfDu5BEfY+tJp6iif0fYp9p5TSsMbW +ZEY+q5613BH2SoZMrv+h7KXyBgyYVm+vQdVcny2q1j2rH5UmH9fxCOB5drdAtTwGfrX lQWE3NyLiLfSSmDAHWtAdFNtKIhNvLcNEY2qnrOxuk7u00PNKW13Yc5nDnk+EY3GGrlK Ear4/+y8IMnCaW4E7kr5Ijgmyj+lc+4Vc6/R2p9TAtB1j4sgBFvztt4etSd54KLFsxKY 8ZYg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature; bh=a9rnqhx0MmyKplCHgTJzq9RDKPIlU/pbDmKII2ZnyvY=; b=MdheloXpDCoJlsUeL3hlltA2ridj8kfVMCSk3j86vLyEdcA4MuGDxHYt9uMF77TY+c guIvcES6nFWwfyRKvhUBtEeCY3QN/I3sBDXYiMd/Wuc9uHFaQSMV/m1a/SF0Ph+r+5Io p9YiYdmebO3cc7jY+uLYAjPlAazw6pOnISvF6skxMnV1VhQm3ZyeIBSH5RQErIeKse61 AJcmxmroh/8sAUAKcVJ1NByTgDf5pPWg0DE5eQM7gbFCQQXUKsCRuinZvQjeABYzztBv WFTyehJBaef8q0i5NFq1IzqJSZxXtzfhvJxQvTVODmpbFfC9cM9I6UY0sU/okj/kcJmX N1qw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=YEttoiCF; 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 x80si279209pfe.224.2019.02.12.07.11.52; Tue, 12 Feb 2019 07:12:09 -0800 (PST) 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=YEttoiCF; 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 S1729500AbfBLPL0 (ORCPT + 99 others); Tue, 12 Feb 2019 10:11:26 -0500 Received: from mail-yw1-f65.google.com ([209.85.161.65]:46326 "EHLO mail-yw1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726550AbfBLPL0 (ORCPT ); Tue, 12 Feb 2019 10:11:26 -0500 Received: by mail-yw1-f65.google.com with SMTP id n12so1103666ywn.13; Tue, 12 Feb 2019 07:11:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=a9rnqhx0MmyKplCHgTJzq9RDKPIlU/pbDmKII2ZnyvY=; b=YEttoiCFUkH/E5lWCMDuumnHb1uKzLal2uTYyQ7OZcwGLFWXYs/oGYbuF0XuAEpv9I 8ImIgdcnwXj2HCHwr3pOIqi7QkaWll1rcVlK9SL63ilz5ZB81Mpd1/7x9ZXOaUcNgV++ gkPIiq2vsukmsQkV0tM0Vi3lhU1pUNmfVeX7f3Oo+6Cm0cA1y7Phw628sbWxqZcSyLlh yfGuXS7JFRh6166ipkN/h/U5UPYT4PXq58IH51OYeGqoeNEcD6B0SuFTfgKgzHK9T4vE e+KryeiVnz8DW1i96+21jw6hg2DS41tkvEuFypfK7io24HdrSQQgC2NHWyFW80BfohZ9 05rg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=a9rnqhx0MmyKplCHgTJzq9RDKPIlU/pbDmKII2ZnyvY=; b=cog4GzMHQcqaFKXrAQ7ZzOJPQXWP4Cr/KhRO746VAhXVmjZgEIkJMqP0pfCpSyBiIm IFgDTCjZ+TMJHxr8SO9j5O82eRu1VndqypjW35CIOLRSNvu4a2BFSpccZ8Yzvb018Lhf kMdryYFuFPXd/qL3wUZ+ZuAsHRe/Wk5W47SbPGqfhcqPOTcWyOyWg6wplUy0pb5OE9vc XgxnYCpRWVwPmgDLXj+yRMGZTeIu49E18OOU3q4hNUrgHQ2DZZ2W2p2swgLrQEuho4VS NKvBFHE/p2pBobCsiuV8/G0CEu/th0FnEWPWl32OKXBiW/URtymH1cSQ3m6KUngQRJQt Zntg== X-Gm-Message-State: AHQUAuY1SDeh6cl3MPpSw3yMUmAF7sx3lh4U3wuLxxHHtlS+amybnfA2 4rzvQ5/rFq4u/hY7eLDRotk= X-Received: by 2002:a81:7d5:: with SMTP id 204mr397873ywh.143.1549984284018; Tue, 12 Feb 2019 07:11:24 -0800 (PST) Received: from [192.168.86.235] (c-73-241-150-70.hsd1.ca.comcast.net. [73.241.150.70]) by smtp.gmail.com with ESMTPSA id z2sm4893231ywe.32.2019.02.12.07.11.21 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 12 Feb 2019 07:11:22 -0800 (PST) Subject: Re: [bpf-next 2/2] bpf: add BPF_SOCK_OPS_STATS_CB for tcp_stats() To: Yafang Shao , daniel@iogearbox.net, ast@kernel.org Cc: yhs@fb.com, brakmo@fb.com, edumazet@google.com, davem@davemloft.net, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, shaoyafang@didiglobal.com References: <1549971097-12627-1-git-send-email-laoar.shao@gmail.com> <1549971097-12627-3-git-send-email-laoar.shao@gmail.com> From: Eric Dumazet Message-ID: Date: Tue, 12 Feb 2019 07:11:20 -0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: <1549971097-12627-3-git-send-email-laoar.shao@gmail.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 02/12/2019 03:31 AM, Yafang Shao wrote: > Introuce this new op BPF_SOCK_OPS_STATS_CB for tcp_stats() such that it > can be traced via BPF on a per socket basis. > There's one argument in BPF_SOCK_OPS_STATS_CB, which is Linux MIB index > LINUX_MIB_* to indicate the TCP event. > All these Linux MIBs are defined in include/uapi/linux/snmp.h. > > Signed-off-by: Yafang Shao > --- > include/uapi/linux/bpf.h | 5 +++++ > net/ipv4/tcp_input.c | 1 + > 2 files changed, 6 insertions(+) > > diff --git a/include/uapi/linux/bpf.h b/include/uapi/linux/bpf.h > index 1777fa0..0314ddd 100644 > --- a/include/uapi/linux/bpf.h > +++ b/include/uapi/linux/bpf.h > @@ -2894,6 +2894,11 @@ enum { > BPF_SOCK_OPS_TCP_LISTEN_CB, /* Called on listen(2), right after > * socket transition to LISTEN state. > */ > + BPF_SOCK_OPS_STATS_CB, /* > + * Called on tcp_stats(). > + * Arg1: Linux MIB index > + * LINUX_MIB_* > + */ > }; > > /* List of TCP states. There is a build check in net/ipv4/tcp.c to detect > diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c > index 88deb1f..4acf458 100644 > --- a/net/ipv4/tcp_input.c > +++ b/net/ipv4/tcp_input.c > @@ -3557,6 +3557,7 @@ static u32 tcp_newly_delivered(struct sock *sk, u32 prior_delivered, int flag) > static void tcp_stats(struct sock *sk, int mib_idx) > { > NET_INC_STATS(sock_net(sk), mib_idx); > + tcp_call_bpf(sk, BPF_SOCK_OPS_STATS_CB, 1, &mib_idx); > } > > /* This routine deals with incoming acks, but not outgoing ones. */ > If the plan is to add to all NET_INC_STATS() calls in TCP an additional tcp_call_bpf() I will say no. So far, tcp_call_bpf() has not been used in fast path.