Received: by 2002:ac0:aed5:0:0:0:0:0 with SMTP id t21csp4686550imb; Wed, 6 Mar 2019 21:01:47 -0800 (PST) X-Google-Smtp-Source: APXvYqzF5QLU7WipPZlAWwwyke8OxSjmuGUCieYChJWs8SrgZ4p/zYOXKyP/hDqzJG/n6iUhmpSq X-Received: by 2002:a63:1b4f:: with SMTP id b15mr1703418pgm.83.1551934907628; Wed, 06 Mar 2019 21:01:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1551934907; cv=none; d=google.com; s=arc-20160816; b=L4iyRT/WdHVH+iGYsm7tcWqHdECLFKWKE8Dtmphi0ntQ/TmmVxef2EPR8y4Us+W+zx wUEuIV/ctqfZywXtiupysHVSSPnlngnwtvgRL/q/lt3Lnk3FJ0zgkeurHSyTD9A3AY57 ZmuFwa/M4KMdamCbaYrQABKnwE6QfofOXqDLsPqzbBZQs0BMLC3Ca6Yo37aueOisbT9G hfmlRyVcUG18xh+KbjU3YIQjKVwJfxqYuJwSXWzguho4f4TWdbV4Yw6rPuHISGWxt4E8 DJEblHFjwlpHhNubYP9wyEHKs/3fztqR1kn2uf8sn7qvrCc3KBczAPLLgCVFWUNa7qVU 7Gjw== 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:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=/ncGicRhpT0Jrx1YkKh+dSzX+9GKtXbzCjm1aNfcRSU=; b=BE1sFCsPWXXW7k1wwsoG+AjMK5+rLqZ8NV3wEVasXOBUiT0pQ0o0aFmaD76f28Ap9n GsO1tImBPbX7716ZBSOr2oeIosENW8suXddAedPoGiWYgpg7yTunNSaNEonPe4n2Yf7s /qlHff41CGcQ4lejRQdQ7IRYz9zAjohI5OA/Aqy+yCPIgTJU2Rw5EG8Waruf0kW27+vK iB75eqm9hQ5cYCm2MV2yeekP+aRy+N6uN7cjXyIXE2oi1/xfIO2fCphs+c6amylzSsi6 iinx9kN4JlYbvumfwzTuyI47anTjva6kOppR7a9MOF5i/ogB/puoZVehvfbi6jsB/p3S yZgA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@alliedtelesis.co.nz header.s=mail181024 header.b=n9KAPBva; 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=NONE dis=NONE) header.from=alliedtelesis.co.nz Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r2si3038650pgo.454.2019.03.06.21.01.31; Wed, 06 Mar 2019 21:01:47 -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=@alliedtelesis.co.nz header.s=mail181024 header.b=n9KAPBva; 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=NONE dis=NONE) header.from=alliedtelesis.co.nz Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726477AbfCGE5i (ORCPT + 99 others); Wed, 6 Mar 2019 23:57:38 -0500 Received: from gate2.alliedtelesis.co.nz ([202.36.163.20]:60592 "EHLO gate2.alliedtelesis.co.nz" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726439AbfCGE5h (ORCPT ); Wed, 6 Mar 2019 23:57:37 -0500 Received: from mmarshal3.atlnz.lc (mmarshal3.atlnz.lc [10.32.18.43]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by gate2.alliedtelesis.co.nz (Postfix) with ESMTPS id 5CBD9891A8; Thu, 7 Mar 2019 17:57:33 +1300 (NZDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=alliedtelesis.co.nz; s=mail181024; t=1551934653; bh=/ncGicRhpT0Jrx1YkKh+dSzX+9GKtXbzCjm1aNfcRSU=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=n9KAPBvavYyD02eiecddhrAWviSIYoQ+xgP9zccYXyBjrpDSCxoP2/AyT+txAj1sV wIrUlctugDnFhnaztIUVxo4u0WMfVDEtdL5wRx8AhtdD4I43lb3Sal6KJgjC9KvTLx gsqoHozDtAUvmbmcac+PaKg6yI8RYj6sBPpB7dw5haIQZTAsjm43eWs2lDxEKSzAc2 2ZMrPzlUP7vXAdQYXrKzGDlDVVv/WKwIZvOAwx+bqmL3SFzsSB+JJwATM4EUxQt3Co IlNf+GF3tq+vYS5/eGbGCWR0xhImh8stHMTnH8Pzsb7++b4SqQrCwR5jMbxAYJc6YT FOV81yQBDi5zA== Received: from smtp (Not Verified[10.32.16.33]) by mmarshal3.atlnz.lc with Trustwave SEG (v7,5,8,10121) id ; Thu, 07 Mar 2019 17:57:32 +1300 Received: from brodieg-dl.ws.atlnz.lc (brodieg-dl.ws.atlnz.lc [10.33.22.16]) by smtp (Postfix) with ESMTP id 5B5E213EED5; Thu, 7 Mar 2019 17:57:33 +1300 (NZDT) Received: by brodieg-dl.ws.atlnz.lc (Postfix, from userid 1718) id 1B47B500285; Thu, 7 Mar 2019 17:57:33 +1300 (NZDT) From: Brodie Greenfield To: davem@davemloft.net, stephen@networkplumber.org, kuznet@ms2.inr.ac.ru, yoshfuji@linux-ipv6.org, netdev@vger.kernel.org Cc: linux-kernel@vger.kernel.org, chris.packham@alliedtelesis.co.nz, luuk.paulussen@alliedtelesis.co.nz, Brodie Greenfield Subject: [PATCH 1/2] ipmr: Make cache queue length configurable Date: Thu, 7 Mar 2019 17:57:28 +1300 Message-Id: <20190307045729.14972-2-brodie.greenfield@alliedtelesis.co.nz> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190307045729.14972-1-brodie.greenfield@alliedtelesis.co.nz> References: <20190307045729.14972-1-brodie.greenfield@alliedtelesis.co.nz> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable x-atlnz-ls: pat Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org We want to be able to keep more spaces available in our queue for processing incoming multicast traffic (adding (S,G) entries) - this lets us learn more groups faster, rather than dropping them at this stage. Signed-off-by: Brodie Greenfield --- Documentation/networking/ip-sysctl.txt | 8 ++++++++ include/net/netns/ipv4.h | 1 + net/ipv4/af_inet.c | 1 + net/ipv4/ipmr.c | 4 +++- net/ipv4/sysctl_net_ipv4.c | 7 +++++++ 5 files changed, 20 insertions(+), 1 deletion(-) diff --git a/Documentation/networking/ip-sysctl.txt b/Documentation/netwo= rking/ip-sysctl.txt index acdfb5d2bcaa..02f77e932adf 100644 --- a/Documentation/networking/ip-sysctl.txt +++ b/Documentation/networking/ip-sysctl.txt @@ -887,6 +887,14 @@ ip_local_reserved_ports - list of comma separated ra= nges =20 Default: Empty =20 +ip_mr_cache_queue_length - INTEGER + Limit the number of multicast packets we can have in the queue to be + resolved. + Bear in mind that when an unresolved multicast packet is received, + there is an O(n) traversal of the queue. This should be considered + if increasing. + Default: 10 + ip_unprivileged_port_start - INTEGER This is a per-namespace sysctl. It defines the first unprivileged port in the network namespace. Privileged ports diff --git a/include/net/netns/ipv4.h b/include/net/netns/ipv4.h index 104a6669e344..3411d3f18d51 100644 --- a/include/net/netns/ipv4.h +++ b/include/net/netns/ipv4.h @@ -187,6 +187,7 @@ struct netns_ipv4 { int sysctl_igmp_max_msf; int sysctl_igmp_llm_reports; int sysctl_igmp_qrv; + unsigned int sysctl_ip_mr_cache_queue_length; =20 struct ping_group_range ping_group_range; =20 diff --git a/net/ipv4/af_inet.c b/net/ipv4/af_inet.c index 0dfb72c46671..8e25538bdb1e 100644 --- a/net/ipv4/af_inet.c +++ b/net/ipv4/af_inet.c @@ -1827,6 +1827,7 @@ static __net_init int inet_init_net(struct net *net= ) net->ipv4.sysctl_igmp_llm_reports =3D 1; net->ipv4.sysctl_igmp_qrv =3D 2; =20 + net->ipv4.sysctl_ip_mr_cache_queue_length =3D 10; return 0; } =20 diff --git a/net/ipv4/ipmr.c b/net/ipv4/ipmr.c index ddbf8c9a1abb..c6a6c3e453a9 100644 --- a/net/ipv4/ipmr.c +++ b/net/ipv4/ipmr.c @@ -1127,6 +1127,7 @@ static int ipmr_cache_unresolved(struct mr_table *m= rt, vifi_t vifi, struct sk_buff *skb, struct net_device *dev) { const struct iphdr *iph =3D ip_hdr(skb); + struct net *net =3D dev_net(dev); struct mfc_cache *c; bool found =3D false; int err; @@ -1142,7 +1143,8 @@ static int ipmr_cache_unresolved(struct mr_table *m= rt, vifi_t vifi, =20 if (!found) { /* Create a new entry if allowable */ - if (atomic_read(&mrt->cache_resolve_queue_len) >=3D 10 || + if (atomic_read(&mrt->cache_resolve_queue_len) >=3D + net->ipv4.sysctl_ip_mr_cache_queue_length || (c =3D ipmr_cache_alloc_unres()) =3D=3D NULL) { spin_unlock_bh(&mfc_unres_lock); =20 diff --git a/net/ipv4/sysctl_net_ipv4.c b/net/ipv4/sysctl_net_ipv4.c index ba0fc4b18465..78ae86e8c6cb 100644 --- a/net/ipv4/sysctl_net_ipv4.c +++ b/net/ipv4/sysctl_net_ipv4.c @@ -784,6 +784,13 @@ static struct ctl_table ipv4_net_table[] =3D { .proc_handler =3D proc_dointvec }, #ifdef CONFIG_IP_MULTICAST + { + .procname =3D "ip_mr_cache_queue_length", + .data =3D &init_net.ipv4.sysctl_ip_mr_cache_queue_length, + .maxlen =3D sizeof(int), + .mode =3D 0644, + .proc_handler =3D proc_dointvec + }, { .procname =3D "igmp_qrv", .data =3D &init_net.ipv4.sysctl_igmp_qrv, --=20 2.21.0