Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp3672405pxv; Mon, 26 Jul 2021 09:07:52 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwUmv8XInyBrPjabEs8SWiGMzQogpS1mHh6kEWfoUWqx3Z/4wU0jovhHEYy0qMMJU0C7KmN X-Received: by 2002:a05:6402:40cf:: with SMTP id z15mr23386467edb.175.1627315672614; Mon, 26 Jul 2021 09:07:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1627315672; cv=none; d=google.com; s=arc-20160816; b=OyPyUeRH7Y1E/D6U2FOxb5QNYnqoOGGSDndeJaKWe4vVSAqwO7BVoxZ71GC2iqFAu8 lj7dPxg3yfSVmGPQzDLPdW3GkaMq3vcfEtKcWq0RyPUqnRzwatejN7XIdU3Yek3AFklO l65bxpRBKT3eRm2bPa6M2oRbaaCTFrUAvDon+8Vcj4cygoKJqBAM9NVc/wNfUBlfG7Ui GOnUGLZ35zNhd7gGaVYlmPryoJsJQlF+7oZ26Ejfp8dAETYPaRQJ9nNrftuAWDGixR4N jJDTZIpnFzGXakcHD3FDdAE78Pz/3s9lZTpIxt04gPGhXkXvidgYd54LsAmG/sQ33rwb KbGg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=5xjN+cwHNnhqNl8AJJ266DoHW2hEEZKl9GUe2q99TDs=; b=FvqKEfvgBEWDU6kjttaWJ4ysXEDb3CbNmiyCpcgWuHi5MaiCI4snP/718oy1QglGmI x52m7ccl8p/ctwz0RI2Z+OGCD7vDGnYidIUKbDCYp2LblF9WIFzQriRm4r7Y+sWiGkQ0 wid799p9eBE4kbvUFmEpwm7odhB2809BrDALn98MVHgcgy7rg5SvfnCKjt0gu+Vwh9eE Nd6p1R3WX7KPDl02Ux9gWNPpjuIDe09JceEHkK1LmtIIwHr3Hz1ltyonoVzKRp+H5ing +nIrMho3aTTynPTH4TjD7kDUkA509qSPEnCub7euFD3iDUmxf7IsphC4ZmogCXN+y65H weUA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=NeeCdo4E; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id u15si346035edt.211.2021.07.26.09.07.29; Mon, 26 Jul 2021 09:07:52 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=NeeCdo4E; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237496AbhGZPXM (ORCPT + 99 others); Mon, 26 Jul 2021 11:23:12 -0400 Received: from mail.kernel.org ([198.145.29.99]:54394 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237461AbhGZPPs (ORCPT ); Mon, 26 Jul 2021 11:15:48 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 43E0F60FA0; Mon, 26 Jul 2021 15:56:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1627314972; bh=ykBmaihdzcKrVAtunhV0Q2SmtFMw9ytREoNZZNF6fMs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=NeeCdo4EUtZMrduE7xL3JvnQe3Non06TfOKDh8nQ8e8sZ+68Jbzrf8117gXYeVphj jlPOxjcT3F3bQmUFC7Y9VYlZpM4ik4c2AR9Eb79jHenXlyLOzYdU2Z+FEW1jBaiqXc niL/X6LPotmJrGD9W8rbAHGIDyICOdgRka37x5oI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jakub Sitnicki , John Fastabend , Daniel Borkmann , Cong Wang , Sasha Levin Subject: [PATCH 5.4 039/108] bpf, sockmap, tcp: sk_prot needs inuse_idx set for proc stats Date: Mon, 26 Jul 2021 17:38:40 +0200 Message-Id: <20210726153832.944650532@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210726153831.696295003@linuxfoundation.org> References: <20210726153831.696295003@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: John Fastabend [ Upstream commit 228a4a7ba8e99bb9ef980b62f71e3be33f4aae69 ] The proc socket stats use sk_prot->inuse_idx value to record inuse sock stats. We currently do not set this correctly from sockmap side. The result is reading sock stats '/proc/net/sockstat' gives incorrect values. The socket counter is incremented correctly, but because we don't set the counter correctly when we replace sk_prot we may omit the decrement. To get the correct inuse_idx value move the core_initcall that initializes the TCP proto handlers to late_initcall. This way it is initialized after TCP has the chance to assign the inuse_idx value from the register protocol handler. Fixes: 604326b41a6fb ("bpf, sockmap: convert to generic sk_msg interface") Suggested-by: Jakub Sitnicki Signed-off-by: John Fastabend Signed-off-by: Daniel Borkmann Reviewed-by: Cong Wang Link: https://lore.kernel.org/bpf/20210712195546.423990-3-john.fastabend@gmail.com Signed-off-by: Sasha Levin --- net/ipv4/tcp_bpf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/ipv4/tcp_bpf.c b/net/ipv4/tcp_bpf.c index 819255ee4e42..6a0c4326d9cf 100644 --- a/net/ipv4/tcp_bpf.c +++ b/net/ipv4/tcp_bpf.c @@ -636,7 +636,7 @@ static int __init tcp_bpf_v4_build_proto(void) tcp_bpf_rebuild_protos(tcp_bpf_prots[TCP_BPF_IPV4], &tcp_prot); return 0; } -core_initcall(tcp_bpf_v4_build_proto); +late_initcall(tcp_bpf_v4_build_proto); static void tcp_bpf_update_sk_prot(struct sock *sk, struct sk_psock *psock) { -- 2.30.2