Received: by 2002:a05:6a10:9e8c:0:0:0:0 with SMTP id y12csp191719pxx; Mon, 26 Oct 2020 06:32:59 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxSMLwIlZk7znIFvSBI/DlDNIejXDFK5f61SvGs7Id2Cyux0c8yqfiyp7aobOaYSJG7/xzY X-Received: by 2002:a05:6402:1ad9:: with SMTP id ba25mr16103429edb.120.1603719179301; Mon, 26 Oct 2020 06:32:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603719179; cv=none; d=google.com; s=arc-20160816; b=zMVdUFjfInWjebg+gmooXszosHD72s+QU5j6o9PcU9goOp3B/5MRTB6s9FVhExtyKL oLv/VeYNo1fr64fdMHYcK2lEUdBs5Jl34m8+/XGj5JmXSGWaL8h3ULZDM/wF5Lh+T+jC D3aPGydWuQDUQvTKQRFdjujtuIM/KhnGeUAls8eLEzH2+tznBlNpQ9Qg3DjHJZn10Rjt QeQ3AbFV3hd+LOEE64sjIb6ehslVyKG0HX/SmB0F3FJb/v6l92/fkBMwxqg80fHvJYLd RYzg1ojITftYRPPkrfcTkcP4hlisHg4UMf8z9Zc+zQyznwX/T5St85LKJAMVbIn/7Iyf rYVw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=krigQ3i6dCn+qzXzyflYkj7VuDlk3im8wf3RIOQnyu0=; b=MP/lFfKn1CkhLK5PV3xYb9yjsYDNTs7LhcCTtFPze/8bH2Der0JA5sRffkZAs175Mh n3pIrT6CFG/hp2Y97FGkrRrldPpJREuKumRFr3MZYHeA8LXHQ/09HIVvu2thn9A6ny0S sC95FJk9BJeUbi+mnJlFRUJCN+D7KcevdDRaQpcJJt7Kt7McIAktRULVGjzUtfOlKLiu QaKFMOgI/clMU9O2hz/MsWPgC5ouY01NR1ZaOBgcwuRPku7wUjMgv6Ex0QKaYtFtBuBr qB0hywOd8N9+M9XLEH7na9cyehhAlV6IoNtX+48y+ocYiMnl20q9Oh+YfNlysB+wx9dS kNzA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=pxj7fdi5; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id p17si7074828edy.143.2020.10.26.06.32.36; Mon, 26 Oct 2020 06:32:59 -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=@gmail.com header.s=20161025 header.b=pxj7fdi5; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1775410AbgJZMrQ (ORCPT + 99 others); Mon, 26 Oct 2020 08:47:16 -0400 Received: from mail-yb1-f193.google.com ([209.85.219.193]:36019 "EHLO mail-yb1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1775403AbgJZMrP (ORCPT ); Mon, 26 Oct 2020 08:47:15 -0400 Received: by mail-yb1-f193.google.com with SMTP id f140so7537490ybg.3; Mon, 26 Oct 2020 05:47:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=krigQ3i6dCn+qzXzyflYkj7VuDlk3im8wf3RIOQnyu0=; b=pxj7fdi5TwNz1sp0SG2lcxXmD0z87mAO+WmV/PZXXxNp/FMCekwhBBg0DHy3OdGuOX i31VsFgafs/VXGMZUvU6Biuar+lcVhGWctnL8wjUeER61KPnR/SQugSNcYNzTaweDqih qMjYLUlUqfM6NUJ5Pt6dg8gnQMpOHvJF1ftBOrJrlCJGfDwMZ7OlyVIovhKARNYMfQZu bdAx3bT4z5bDwJiEArnxN7p9prYUm3scJeMUnVVN8kF7wc0xSxdJNr4hOwYvfJgk5OlI hoWBzGVln/nxok/OLuvN2VTGyymqZyPVj2wB17u+epv6X58lCuoMBJHhV888Sisqjtn3 G7kg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=krigQ3i6dCn+qzXzyflYkj7VuDlk3im8wf3RIOQnyu0=; b=UpL5IQp0KFjCDqpOXvACVdLGU9aPzh/qFcDxojT737Du/2C6OiyMNAVDfPzH8/piox qlIVDh3JkXUUn+F9mx00cjjfnq8Dwpu5qgPOPZkhKjhyAF+SNGuoF1edwkVcqKsgymmC +t4bcD8MCZLj1JkUt+TMJGWWvL5MJCj/GDWUbEm2Wmj8og/Z2Jr5K2cotDkdLGu8nTyn P7XxlDxgrfbCUMUSI99bapD9slu6YttM8V6LdbsglsPDbsIwrs9/kLcpWkahuQOGjiQH aPNYx5XfA2r7U+aIVYF/JrDc6lhB5rdsTh//wNGpFcwztH1oCxmSsgiCskkBqt0daLZ/ GXaQ== X-Gm-Message-State: AOAM533wuzqxsWRoZ36rtgQ9oe0v6VYvn7U0oxfY3c0+2UxPGuXtWWUm sBsOa1rhNngwMXxpXt7AtE2izWLgbU2w1ROKeTXR3nrNEcQ= X-Received: by 2002:a25:2e4c:: with SMTP id b12mr20497894ybn.336.1603716433785; Mon, 26 Oct 2020 05:47:13 -0700 (PDT) MIME-Version: 1.0 References: <20201026093907.13799-1-menglong8.dong@gmail.com> In-Reply-To: From: Menglong Dong Date: Mon, 26 Oct 2020 20:47:01 +0800 Message-ID: Subject: Re: [PATCH] net: udp: increase UDP_MIB_RCVBUFERRORS when ENOBUFS To: Paolo Abeni , davem@davemloft.net Cc: kuznet@ms2.inr.ac.ru, yoshfuji@linux-ipv6.org, kuba@kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hello~ On Mon, Oct 26, 2020 at 5:52 PM Paolo Abeni wrote: > > Hello, > > On Mon, 2020-10-26 at 17:39 +0800, Menglong Dong wrote: > > The error returned from __udp_enqueue_schedule_skb is ENOMEM or ENOBUFS. > > For now, only ENOMEM is counted into UDP_MIB_RCVBUFERRORS in > > __udp_queue_rcv_skb. UDP_MIB_RCVBUFERRORS should count all of the > > failed skb because of memory errors during udp receiving, not just because of the limit of sock receive queue. We can see this > > in __udp4_lib_mcast_deliver: > > > > nskb = skb_clone(skb, GFP_ATOMIC); > > > > if (unlikely(!nskb)) { > > atomic_inc(&sk->sk_drops); > > __UDP_INC_STATS(net, UDP_MIB_RCVBUFERRORS, > > IS_UDPLITE(sk)); > > __UDP_INC_STATS(net, UDP_MIB_INERRORS, > > IS_UDPLITE(sk)); > > continue; > > } > > > > See, UDP_MIB_RCVBUFERRORS is increased when skb clone failed. From this > > point, ENOBUFS from __udp_enqueue_schedule_skb should be counted, too. > > It means that the buffer used by all of the UDP sock is to the limit, and > > it ought to be counted. > > > > Signed-off-by: Menglong Dong > > --- > > net/ipv4/udp.c | 4 +--- > > net/ipv6/udp.c | 4 +--- > > 2 files changed, 2 insertions(+), 6 deletions(-) > > > > diff --git a/net/ipv4/udp.c b/net/ipv4/udp.c > > index 09f0a23d1a01..49a69d8d55b3 100644 > > --- a/net/ipv4/udp.c > > +++ b/net/ipv4/udp.c > > @@ -2035,9 +2035,7 @@ static int __udp_queue_rcv_skb(struct sock *sk, struct sk_buff *skb) > > int is_udplite = IS_UDPLITE(sk); > > > > /* Note that an ENOMEM error is charged twice */ > > - if (rc == -ENOMEM) > > - UDP_INC_STATS(sock_net(sk), UDP_MIB_RCVBUFERRORS, > > - is_udplite); > > + UDP_INC_STATS(sock_net(sk), UDP_MIB_RCVBUFERRORS, is_udplite); > > UDP_INC_STATS(sock_net(sk), UDP_MIB_INERRORS, is_udplite); > > kfree_skb(skb); > > trace_udp_fail_queue_rcv_skb(rc, sk); > > diff --git a/net/ipv6/udp.c b/net/ipv6/udp.c > > index 29d9691359b9..d5e23b150fd9 100644 > > --- a/net/ipv6/udp.c > > +++ b/net/ipv6/udp.c > > @@ -634,9 +634,7 @@ static int __udpv6_queue_rcv_skb(struct sock *sk, struct sk_buff *skb) > > int is_udplite = IS_UDPLITE(sk); > > > > /* Note that an ENOMEM error is charged twice */ > > - if (rc == -ENOMEM) > > - UDP6_INC_STATS(sock_net(sk), > > - UDP_MIB_RCVBUFERRORS, is_udplite); > > + UDP6_INC_STATS(sock_net(sk), UDP_MIB_RCVBUFERRORS, is_udplite); > > UDP6_INC_STATS(sock_net(sk), UDP_MIB_INERRORS, is_udplite); > > kfree_skb(skb); > > return -1; > > The diffstat is nice, but I'm unsure we can do this kind of change > (well, I really think we should not do it): it will fool any kind of > existing users (application, scripts, admin) currently reading the > above counters and expecting UDP_MIB_RCVBUFERRORS being increased with > the existing schema. > > Cheers, > > Paolo > Well, your words make sense, this change isn't friendly for the existing users. It really puzzled me when this ENOBUFS happened, no counters were done and I hardly figured out what happened. So, is it a good idea to introduce a 'UDP_MIB_MEMERRORS'? Cheers, Menglong Dong