Subject: Re: [PATCH net-next] net: Add sysctl to toggle early demux for tcp and udp

From: Stephen Hemminger <[email-masked]>
Date: Thu, 9 Mar 2017 15:50:37 -0800

On Thu,  9 Mar 2017 14:09:18 -0700
Subash Abhinov Kasiviswanathan <[email-masked]> wrote:

> Certain system process significant unconnected UDP workload.
> It would be preferrable to disable UDP early demux for those systems
> and enable it for TCP only.
> 
> Signed-off-by: Subash Abhinov Kasiviswanathan <[email-masked]>
> Suggested-by: Eric Dumazet <[email-masked]>
> ---

This makes sense.

> diff --git a/net/ipv4/ip_input.c b/net/ipv4/ip_input.c
> index d6feabb..187feae 100644
> --- a/net/ipv4/ip_input.c
> +++ b/net/ipv4/ip_input.c
> @@ -329,7 +329,7 @@ static int ip_rcv_finish(struct net *net, struct sock *sk, struct sk_buff *skb)
>  		int protocol = iph->protocol;
>  
>  		ipprot = rcu_dereference(inet_protos[protocol]);
> -		if (ipprot && ipprot->early_demux) {
> +		if (ipprot && ipprot->early_demux && *ipprot->early_demux_enabled) {
>  			ipprot->early_demux(skb);
>  			/* must reload iph, skb->head might have changed */
>  			iph = ip_hdr(skb);

Another possible option would be change the function pointer for early_demux instead of having
an additional conditional test (and cache line read).  The downside of doing it that way
is the code to turn the sysctl on/off gets more complicated than simple standard proc_int_vec.