[PATCH 1/1] vxlan: insert ipv6 macro

Subsystems: networking drivers, the rest

STALE3601d

6 messages, 2 authors, 2016-10-13 · open the first message on its own page

[PATCH 1/1] vxlan: insert ipv6 macro

From: zyjzyj2000@gmail.com
Date: 2016-10-11 13:22:05

From: Zhu Yanjun <zyjzyj2000@gmail.com>

The source code is related with ipv6. As such, it is better to insert
ipv6 macro.

Signed-off-by: Zhu Yanjun <zyjzyj2000@gmail.com>
---
 drivers/net/vxlan.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/net/vxlan.c b/drivers/net/vxlan.c
index e7d1668..9af6600 100644
--- 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;
-	}
 
 	udp_conf.local_udp_port = port;
 
-- 
2.7.4

Re: [PATCH 1/1] vxlan: insert ipv6 macro

From: Jiri Benc <hidden>
Date: 2016-10-11 14:16:45

On Tue, 11 Oct 2016 16:23:31 +0800, zyjzyj2000@gmail.com wrote:
quoted hunk
--- 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

Re: [PATCH 1/1] vxlan: insert ipv6 macro

From: zhuyj <zyjzyj2000@gmail.com>
Date: 2016-10-12 13:01:55

Hi, Jiri

How to explain the following source code? As you mentioned,  are the
#ifdefs in the following source pointless?
As to the previous patch, I will compile and analyze it. But now I am
busy with something else. After I draw a conclusion, I will let you
know.

Thanks for your reply.

 static void vxlan_sock_release(struct vxlan_dev *vxlan)
{
        bool ipv4 = __vxlan_sock_release_prep(vxlan->vn4_sock);
#if IS_ENABLED(CONFIG_IPV6)
        bool ipv6 = __vxlan_sock_release_prep(vxlan->vn6_sock);
#endif
        synchronize_net();
        if (ipv4) {
                udp_tunnel_sock_release(vxlan->vn4_sock->sock);
                kfree(vxlan->vn4_sock);
        }
#if IS_ENABLED(CONFIG_IPV6)
        if (ipv6) {
                udp_tunnel_sock_release(vxlan->vn6_sock->sock);
                kfree(vxlan->vn6_sock);
        }
#endif
}

On Tue, Oct 11, 2016 at 10:06 PM, Jiri Benc [off-list ref] wrote:
On Tue, 11 Oct 2016 16:23:31 +0800, zyjzyj2000@gmail.com wrote:
quoted
--- 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

Re: [PATCH 1/1] vxlan: insert ipv6 macro

From: Jiri Benc <hidden>
Date: 2016-10-12 13:17:30

On Wed, 12 Oct 2016 21:01:54 +0800, zhuyj wrote:
How to explain the following source code? As you mentioned,  are the
#ifdefs in the following source pointless?
They are not, the code would not compile without them. Look how struct
vxlan_dev is defined.

Those are really basic questions you have. I suggest you try yourself
before asking such questions next time. In this case, you could
trivially remove the #ifdef and see for yourself, as I explained in the
previous email. Please do not try to offload your homework to other
people. It's very obvious you didn't even try to understand this, even
after the feedback you received.

And do not top post.

Thanks,

 Jiri

Re: [PATCH 1/1] vxlan: insert ipv6 macro

From: zhuyj <zyjzyj2000@gmail.com>
Date: 2016-10-13 05:28:34

 Hi,  Jiri

The dumped source code is in the attachment. Please check it. I think
this file can explain all.

If anything, please just let me know.
Thanks a lot.

On Wed, Oct 12, 2016 at 9:16 PM, Jiri Benc [off-list ref] wrote:
On Wed, 12 Oct 2016 21:01:54 +0800, zhuyj wrote:
quoted
How to explain the following source code? As you mentioned,  are the
#ifdefs in the following source pointless?
They are not, the code would not compile without them. Look how struct
vxlan_dev is defined.

Those are really basic questions you have. I suggest you try yourself
before asking such questions next time. In this case, you could
trivially remove the #ifdef and see for yourself, as I explained in the
previous email. Please do not try to offload your homework to other
people. It's very obvious you didn't even try to understand this, even
after the feedback you received.

And do not top post.

Thanks,

 Jiri

Re: [PATCH 1/1] vxlan: insert ipv6 macro

From: zhuyj <zyjzyj2000@gmail.com>
Date: 2016-10-13 05:30:44

 Soon I will analyze the previous patch. I will let you know.

Thanks a lot.

On Thu, Oct 13, 2016 at 1:28 PM, zhuyj [off-list ref] wrote:
 Hi,  Jiri

The dumped source code is in the attachment. Please check it. I think
this file can explain all.

If anything, please just let me know.
Thanks a lot.

On Wed, Oct 12, 2016 at 9:16 PM, Jiri Benc [off-list ref] wrote:
quoted
On Wed, 12 Oct 2016 21:01:54 +0800, zhuyj wrote:
quoted
How to explain the following source code? As you mentioned,  are the
#ifdefs in the following source pointless?
They are not, the code would not compile without them. Look how struct
vxlan_dev is defined.

Those are really basic questions you have. I suggest you try yourself
before asking such questions next time. In this case, you could
trivially remove the #ifdef and see for yourself, as I explained in the
previous email. Please do not try to offload your homework to other
people. It's very obvious you didn't even try to understand this, even
after the feedback you received.

And do not top post.

Thanks,

 Jiri
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help