netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jiri Benc <jbenc@redhat.com>
To: zyjzyj2000@gmail.com
Cc: netdev@vger.kernel.org, pabeni@redhat.com, daniel@iogearbox.net,
	pshelar@nicira.com, aduyck@mirantis.com,
	hannes@stressinduktion.org, davem@davemloft.net
Subject: Re: [PATCH 1/1] vxlan: insert ipv6 macro
Date: Tue, 11 Oct 2016 16:06:15 +0200	[thread overview]
Message-ID: <20161011160615.7f7f7746@griffin> (raw)
In-Reply-To: <1476174211-9358-1-git-send-email-zyjzyj2000@gmail.com>

On Tue, 11 Oct 2016 16:23:31 +0800, zyjzyj2000@gmail.com wrote:
> --- a/drivers/net/vxlan.c
> +++ b/drivers/net/vxlan.c
> @@ -2647,15 +2647,15 @@ static struct socket *vxlan_create_sock(struct net *net, bool ipv6,
>  	int err;
>  
>  	memset(&udp_conf, 0, sizeof(udp_conf));
> -
> +#if IS_ENABLED(CONFIG_IPV6)
>  	if (ipv6) {
>  		udp_conf.family = AF_INET6;
>  		udp_conf.use_udp6_rx_checksums =
>  		    !(flags & VXLAN_F_UDP_ZERO_CSUM6_RX);
>  		udp_conf.ipv6_v6only = 1;
> -	} else {
> +	} else 
> +#endif
>  		udp_conf.family = AF_INET;
> -	}

Zhu Yanjun, before posting patches such as the previous ones or
this one, please test whether they make any difference. In this case,
try to compile the code with IPv6 disabled before and after this patch,
disassemble and compare the results. You'll see that this patch is
pointless.

It's pretty obvious from the code but to be really sure, I've just
quickly built the vxlan module with IPv6 disabled. And indeed, as
expected, the compiler just inlined everything into vxlan_open. The
whole chain vxlan_open -> vxlan_sock_add -> __vxlan_sock_add (note that
there's only a single caller of __vxlan_sock_add with IPv6 disabled) ->
vxlan_socket_create -> vxlan_create_sock is inlined.

It also means the code in the "if (ipv6)" branch is completely
eliminated by the compiler even without ugly #ifdefs.

 Jiri

  reply	other threads:[~2016-10-11 14:16 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-10-11  8:23 [PATCH 1/1] vxlan: insert ipv6 macro zyjzyj2000
2016-10-11 14:06 ` Jiri Benc [this message]
2016-10-12 13:01   ` zhuyj
2016-10-12 13:16     ` Jiri Benc
2016-10-13  5:28       ` zhuyj
2016-10-13  5:30         ` zhuyj

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20161011160615.7f7f7746@griffin \
    --to=jbenc@redhat.com \
    --cc=aduyck@mirantis.com \
    --cc=daniel@iogearbox.net \
    --cc=davem@davemloft.net \
    --cc=hannes@stressinduktion.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=pshelar@nicira.com \
    --cc=zyjzyj2000@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).