On Fri, 26 Oct 2018 15:02:19 +1300
Brodie Greenfield <brodie.greenfi...@alliedtelesis.co.nz> wrote:

> 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 <brodie.greenfi...@alliedtelesis.co.nz>
> ---
>  Documentation/networking/ip-sysctl.txt | 7 +++++++
>  include/net/netns/ipv4.h               | 1 +
>  include/uapi/linux/sysctl.h            | 1 +
>  kernel/sysctl_binary.c                 | 1 +
>  net/ipv4/af_inet.c                     | 2 ++
>  net/ipv4/ipmr.c                        | 4 +++-
>  net/ipv4/sysctl_net_ipv4.c             | 7 +++++++
>  7 files changed, 22 insertions(+), 1 deletion(-)
> 
> diff --git a/Documentation/networking/ip-sysctl.txt 
> b/Documentation/networking/ip-sysctl.txt
> index 960de8fe3f40..dfc70ef6c42b 100644
> --- a/Documentation/networking/ip-sysctl.txt
> +++ b/Documentation/networking/ip-sysctl.txt
> @@ -864,6 +864,13 @@ ip_local_reserved_ports - list of comma separated ranges
>  
>       Default: Empty
>  
> +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 this causes an O(n) traversal of the same size when
> +     the queue is full. This should be considered if increasing.
> +     Default: 10
>

Thanks for updating documentation.  The second two sentences aren't clear.
Does it mean that setting queue length causes O(n) traversal or that each
multicast packet received causes O(n) traversal

>  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 e47503b4e4d1..1ca5cabe2d3b 100644
> --- a/include/net/netns/ipv4.h
> +++ b/include/net/netns/ipv4.h
> @@ -184,6 +184,7 @@ struct netns_ipv4 {
>       int sysctl_igmp_max_msf;
>       int sysctl_igmp_llm_reports;
>       int sysctl_igmp_qrv;
> +     int sysctl_ip_mr_cache_queue_length;

Maybe unsigned because negative value is not meaningful.

>  
>       struct ping_group_range ping_group_range;
>  
> diff --git a/include/uapi/linux/sysctl.h b/include/uapi/linux/sysctl.h
> index d71013fffaf6..32e32d4904cd 100644
> --- a/include/uapi/linux/sysctl.h
> +++ b/include/uapi/linux/sysctl.h
> @@ -425,6 +425,7 @@ enum
>       NET_TCP_ALLOWED_CONG_CONTROL=123,
>       NET_TCP_MAX_SSTHRESH=124,
>       NET_TCP_FRTO_RESPONSE=125,
> +     NET_IPV4_IP_MR_CACHE_QUEUE_LENGTH=126,
>  };

The numeric sysctl enum is considered deprecated, new sysctl's
need not be added here.

>  enum {
> diff --git a/kernel/sysctl_binary.c b/kernel/sysctl_binary.c
> index 07148b497451..8db94e8d97ed 100644
> --- a/kernel/sysctl_binary.c
> +++ b/kernel/sysctl_binary.c
> @@ -367,6 +367,7 @@ static const struct bin_table bin_net_ipv4_table[] = {
>       { CTL_INT,      NET_IPV4_LOCAL_PORT_RANGE,              
> "ip_local_port_range" },
>       { CTL_INT,      NET_IPV4_IGMP_MAX_MEMBERSHIPS,          
> "igmp_max_memberships" },
>       { CTL_INT,      NET_IPV4_IGMP_MAX_MSF,                  "igmp_max_msf" 
> },
> +     { CTL_INT,      NET_IPV4_IP_MR_CACHE_QUEUE_LENGTH,      
> "ip_mr_cache_queue_length" },
>       { CTL_INT,      NET_IPV4_INET_PEER_THRESHOLD,           
> "inet_peer_threshold" },
>       { CTL_INT,      NET_IPV4_INET_PEER_MINTTL,              
> "inet_peer_minttl" },
>       { CTL_INT,      NET_IPV4_INET_PEER_MAXTTL,              
> "inet_peer_maxttl" },
> diff --git a/net/ipv4/af_inet.c b/net/ipv4/af_inet.c
> index 1fbe2f815474..4b78d12aca36 100644
> --- a/net/ipv4/af_inet.c
> +++ b/net/ipv4/af_inet.c
> @@ -1818,6 +1818,8 @@ static __net_init int inet_init_net(struct net *net)
>       net->ipv4.sysctl_igmp_llm_reports = 1;
>       net->ipv4.sysctl_igmp_qrv = 2;
>  
> +     /* ipmr unresolved queue length max */
> +     net->ipv4.sysctl_ip_mr_cache_queue_length = 10;

Comment here is not necessary, is obvious.

>       return 0;
>  }
>  
> diff --git a/net/ipv4/ipmr.c b/net/ipv4/ipmr.c
> index 5660adcf7a04..2864f80e2f2a 100644
> --- a/net/ipv4/ipmr.c
> +++ b/net/ipv4/ipmr.c
> @@ -1128,6 +1128,7 @@ static int ipmr_cache_unresolved(struct mr_table *mrt, 
> vifi_t vifi,
>       struct mfc_cache *c;
>       bool found = false;
>       int err;
> +     struct net *net = dev_net(dev);

The network layer coding style is to use reverse christmas tree
style declarations, move this up.

>  
>       spin_lock_bh(&mfc_unres_lock);
>       list_for_each_entry(c, &mrt->mfc_unres_queue, _c.list) {
> @@ -1140,7 +1141,8 @@ static int ipmr_cache_unresolved(struct mr_table *mrt, 
> vifi_t vifi,
>  
>       if (!found) {
>               /* Create a new entry if allowable */
> -             if (atomic_read(&mrt->cache_resolve_queue_len) >= 10 ||
> +             if (atomic_read(&mrt->cache_resolve_queue_len) >=
> +                 net->ipv4.sysctl_ip_mr_cache_queue_length ||
>                   (c = ipmr_cache_alloc_unres()) == NULL) {
>                       spin_unlock_bh(&mfc_unres_lock);
>  
> diff --git a/net/ipv4/sysctl_net_ipv4.c b/net/ipv4/sysctl_net_ipv4.c
> index 891ed2f91467..b249932ee24e 100644
> --- a/net/ipv4/sysctl_net_ipv4.c
> +++ b/net/ipv4/sysctl_net_ipv4.c
> @@ -772,6 +772,13 @@ static struct ctl_table ipv4_net_table[] = {
>               .mode           = 0644,
>               .proc_handler   = proc_dointvec
>       },
> +     {
> +             .procname       = "ip_mr_cache_queue_length",
> +             .data           = 
> &init_net.ipv4.sysctl_ip_mr_cache_queue_length,
> +             .maxlen         = sizeof(int),
> +             .mode           = 0644,
> +             .proc_handler   = proc_dointvec
> +     },
>  #ifdef CONFIG_IP_MULTICAST
>       {
>               .procname       = "igmp_qrv",

This sysctl is not needed if CONFIG_IP_MULTICAST is not defined.

Reply via email to