Skip to contentSkip to conversation

tipc: fix build issue when building without IPv6

PATCH Superseded Marcelo Ricardo Leitner 3 participants 9 messages Mar 19, 2015 – Mar 23, 2015

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 tipc: fix build issue when building without IPv6

We can't directly call ipv6_sock_mc_join() but should use the stub instead and protect it around IS_ENABLED.

Fixes d0f91938bede ("tipc: add ip/udp media type")
---
 net/tipc/udp_media.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)
net/tipc/udp_media.c +10 -1
index 04836dd70c2bb79906307ec40e0cbd7b2589978e..e64634062aff3633bd91064567fe7a914bd6df32 100644
@@ -44,6 +44,7 @@
 #include <net/sock.h>
 #include <net/ip.h>
 #include <net/udp_tunnel.h>
+#include <net/addrconf.h>
 #include <linux/tipc_netlink.h>
 #include "core.h"
 #include "bearer.h"
@@ -247,10 +248,13 @@ static int enable_mcast(struct udp_bearer *ub, struct udp_media_addr *remote)
 		mreqn.imr_multiaddr = remote->ipv4;
 		mreqn.imr_ifindex = ub->ifindex;
 		err = ip_mc_join_group(sk, &mreqn);
+#if IS_ENABLED(CONFIG_IPV6)
 	} else {
 		if (!ipv6_addr_is_multicast(&remote->ipv6))
 			return 0;
-		err = ipv6_sock_mc_join(sk, ub->ifindex, &remote->ipv6);
+		err = ipv6_stub->ipv6_sock_mc_join(sk, ub->ifindex,
+						   &remote->ipv6);
+#endif
 	}
 	return err;
 }
@@ -387,6 +391,11 @@ static int tipc_udp_enable(struct net *net, struct tipc_bearer *b,
 	tuncfg.encap_destroy = NULL;
 	setup_udp_tunnel_sock(net, ub->ubsock, &tuncfg);
 
+	/* At this point, IPv6 module should have been loaded in
+	 * udp_sock_create/sock_create_kern().
+	 */
+	BUG_ON(!ipv6_stub);
+
 	if (enable_mcast(ub, remote))
 		goto err;
 	return 0;
Signature · 1 line
2.1.0
maintainer
#1 lore raw

From: Marcelo Ricardo Leitner <[email protected]>
Date: Thu, 19 Mar 2015 12:13:43 -0300

net/tipc/udp_media.c static int tipc_udp_enable(struct net *net, struct tipc_bearer *b, · line 398

Quoted 9 lines
net/tipc/udp_media.c +5 -0
@@ -387,6 +391,11 @@ static int tipc_udp_enable(struct net *net, struct tipc_bearer *b,
 	tuncfg.encap_destroy = NULL;
 	setup_udp_tunnel_sock(net, ub->ubsock, &tuncfg);
 
+	/* At this point, IPv6 module should have been loaded in
+	 * udp_sock_create/sock_create_kern().
+	 */
+	BUG_ON(!ipv6_stub);
+

If IPV6=n this will be NULL no matter what.

And if the module load gets an error, this will be NULL as well.

#2 lore raw
Quoted 15 lines · David Miller

From: Marcelo Ricardo Leitner <[email protected]>
Date: Thu, 19 Mar 2015 12:13:43 -0300

net/tipc/udp_media.c static int tipc_udp_enable(struct net *net, struct tipc_bearer *b, · line 398

Quoted 9 lines
net/tipc/udp_media.c +5 -0
@@ -387,6 +391,11 @@ static int tipc_udp_enable(struct net *net, struct tipc_bearer *b,
  	tuncfg.encap_destroy = NULL;
  	setup_udp_tunnel_sock(net, ub->ubsock, &tuncfg);
 
+	/* At this point, IPv6 module should have been loaded in
+	 * udp_sock_create/sock_create_kern().
+	 */
+	BUG_ON(!ipv6_stub);
+

If IPV6=n this will be NULL no matter what.

Quoted 2 lines

And if the module load gets an error, this will be NULL as well.

Oh indeed, and it (whatever check) should have been placed in a ipv6-only path, like vxlan used to do.

Will fix, thanks.

Marcelo

#3 lore raw

PATCH v2 1/1 tipc: fix build issue when building without IPv6

In reply to David Miller

We can't directly call ipv6_sock_mc_join() but should use the stub instead and protect it around IS_ENABLED.

Fixes d0f91938bede ("tipc: add ip/udp media type")

---

Notes:
The BUG_ON I had placed is completelly unnecessary:
- with IPV6=n, the code it was trying to protect won't exist
- if the module load fails, the socket creation a bit above enable_mcast() call will return an error and it will bail out before reaching that code.
And thus, just removed in this v2.

 net/tipc/udp_media.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
net/tipc/udp_media.c +5 -1
index 04836dd70c2bb79906307ec40e0cbd7b2589978e..ac89101e5d1b62165cbdb070d9f4bebe287fc583 100644
@@ -44,6 +44,7 @@
 #include <net/sock.h>
 #include <net/ip.h>
 #include <net/udp_tunnel.h>
+#include <net/addrconf.h>
 #include <linux/tipc_netlink.h>
 #include "core.h"
 #include "bearer.h"
@@ -247,10 +248,13 @@ static int enable_mcast(struct udp_bearer *ub, struct udp_media_addr *remote)
 		mreqn.imr_multiaddr = remote->ipv4;
 		mreqn.imr_ifindex = ub->ifindex;
 		err = ip_mc_join_group(sk, &mreqn);
+#if IS_ENABLED(CONFIG_IPV6)
 	} else {
 		if (!ipv6_addr_is_multicast(&remote->ipv6))
 			return 0;
-		err = ipv6_sock_mc_join(sk, ub->ifindex, &remote->ipv6);
+		err = ipv6_stub->ipv6_sock_mc_join(sk, ub->ifindex,
+						   &remote->ipv6);
+#endif
 	}
 	return err;
 }
Signature · 1 line
2.1.0
#5 lore raw
Quoted 9 lines · David Miller

From: Marcelo Ricardo Leitner <[email protected]>
Date: Thu, 19 Mar 2015 16:47:58 -0300

Quoted 5 lines

We can't directly call ipv6_sock_mc_join() but should use the stub instead and protect it around IS_ENABLED.

Fixes d0f91938bede ("tipc: add ip/udp media type")

Sorry, this patch doesn't work at all especially when IPV6=m and TIPC=y. For example, when we use the combination of the kernel config options, error appears like:

net/built-in.o: In function `tipc_udp_send_msg':
/home/ying/work/tipc/tipc2.0/net-next-2.6-debug/net/tipc/udp_media.c:196:
undefined reference to `ip6_dst_lookup'
make: *** [vmlinux] Error 1

Instead, I ever tried to fix the issue several days ago. Please refer to the thread:

https://patchwork.ozlabs.org/patch/448836/

According to the suggestion David gave lastly, we should separate the UDP media as an independent module, make TIPC_MEDIA_UDP depend on (IPV6 || IPV6=n), and mark TIPC_MEDIA_UDP tristate. Now I am busy doing this following the proposal.

Regards,
Ying

Quoted 7 lines

This works better, applied, thanks.
--
To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

author
#6 lore raw
Quoted 11 lines · Ying Xue
Quoted 9 lines · David Miller

From: Marcelo Ricardo Leitner <[email protected]>
Date: Thu, 19 Mar 2015 16:47:58 -0300

Quoted 5 lines

We can't directly call ipv6_sock_mc_join() but should use the stub instead and protect it around IS_ENABLED.

Fixes d0f91938bede ("tipc: add ip/udp media type")
Quoted 8 lines

Sorry, this patch doesn't work at all especially when IPV6=m and TIPC=y. For
example, when we use the combination of the kernel config options, error appears
like:

net/built-in.o: In function `tipc_udp_send_msg':

/home/ying/work/tipc/tipc2.0/net-next-2.6-debug/net/tipc/udp_media.c:196:

Quoted 9 lines

undefined reference to `ip6_dst_lookup'
make: *** [vmlinux] Error 1

Instead, I ever tried to fix the issue several days ago. Please refer to the thread:

https://patchwork.ozlabs.org/patch/448836/

According to the suggestion David gave lastly, we should separate the

UDP

Quoted 2 lines

media
as an independent module, make TIPC_MEDIA_UDP depend on (IPV6 ||

IPV6=n),

Quoted 3 lines

and
mark TIPC_MEDIA_UDP tristate. Now I am busy doing this following the proposal.

I missed your work on the issue, Ying, sorry, otherwise I would have replied
to that thread instead of posting the patch.

I think David and Willem suggestion were more about the dependencies than fixing the build issue itself. I mean, if some part of TIPC really needs IPv6 in order to work or something like that.

So if all we want to do if fix the build issue, I have another suggestion. When we have IPV6=m and TIPC=y, just have to use the stub too.

(cut & pasted)

net/tipc/udp_media.c +0 -0
@@ -193,7 +193,7 @@ static int tipc_udp_send_msg(struct net *net, struct

sk_buff *skb,

                        .saddr = src->ipv6,
                        .flowi6_proto = IPPROTO_UDP
                };
-               err = ip6_dst_lookup(ub->ubsock->sk, &ndst, &fl6);
+               err = ipv6_stub->ipv6_dst_lookup(ub->ubsock->sk, &ndst,
&fl6);
                if (err)
                        goto tx_error;
                ttl = ip6_dst_hoplimit(ndst);

then it builds fine here. That is, assuming that you can't reach this code while
ipv6 module is unloaded.. (I didn't check that) what do you think?

Regards,
Marcelo

#7 lore raw
Quoted 22 lines · Marcelo

I think David and Willem suggestion were more about the dependencies than fixing the build issue itself. I mean, if some part of TIPC really needs IPv6 in order to work or something like that.

So if all we want to do if fix the build issue, I have another suggestion. When we have IPV6=m and TIPC=y, just have to use the stub too.

(cut & pasted)

net/tipc/udp_media.c +1 -1
@@ -193,7 +193,7 @@ static int tipc_udp_send_msg(struct net *net, struct
 sk_buff *skb,
                        .saddr = src->ipv6,
                        .flowi6_proto = IPPROTO_UDP
                };
-               err = ip6_dst_lookup(ub->ubsock->sk, &ndst, &fl6);
+               err = ipv6_stub->ipv6_dst_lookup(ub->ubsock->sk, &ndst,
 &fl6);
                if (err)
                        goto tx_error;
                ttl = ip6_dst_hoplimit(ndst);
Quoted 3 lines

then it builds fine here. That is, assuming that you can't reach this code while
ipv6 module is unloaded.. (I didn't check that) what do you think?

It seems that your above change is useless to kill the error. For instance, when I apply it into my project, below build error appears:

net/tipc/udp_media.c: In function ‘tipc_udp_send_msg’:
net/tipc/udp_media.c:196:18: error: ‘const struct ipv6_stub’ has no member named ‘ip6_dst_lookup’
make[2]: *** [net/tipc/udp_media.o] Error 1
make[1]: *** [net/tipc] Error 2
make: *** [net] Error 2

In my opinion, we have to follow David's suggestion dividing the udp_media.c as an separate module.

Regards,
Ying

#8 lore raw
Quoted 37 lines · Ying Xue
Quoted 22 lines · Marcelo

I think David and Willem suggestion were more about the dependencies than fixing the build issue itself. I mean, if some part of TIPC really needs IPv6 in order to work or something like that.

So if all we want to do if fix the build issue, I have another suggestion. When we have IPV6=m and TIPC=y, just have to use the stub too.

(cut & pasted)

net/tipc/udp_media.c +1 -1
@@ -193,7 +193,7 @@ static int tipc_udp_send_msg(struct net *net, struct
 sk_buff *skb,
                         .saddr = src->ipv6,
                         .flowi6_proto = IPPROTO_UDP
                 };
-               err = ip6_dst_lookup(ub->ubsock->sk, &ndst, &fl6);
+               err = ipv6_stub->ipv6_dst_lookup(ub->ubsock->sk, &ndst,
 &fl6);
                 if (err)
                         goto tx_error;
                 ttl = ip6_dst_hoplimit(ndst);
Quoted 3 lines

then it builds fine here. That is, assuming that you can't reach this code while
ipv6 module is unloaded.. (I didn't check that) what do you think?

It seems that your above change is useless to kill the error. For instance, when I apply it into my project, below build error appears:

net/tipc/udp_media.c: In function ‘tipc_udp_send_msg’:
net/tipc/udp_media.c:196:18: error: ‘const struct ipv6_stub’ has no member named ‘ip6_dst_lookup’
make[2]: *** [net/tipc/udp_media.o] Error 1
make[1]: *** [net/tipc] Error 2
make: *** [net] Error 2

Quoted 2 lines

In my opinion, we have to follow David's suggestion dividing the udp_media.c as an separate module.

If you had checked which members ipv6_stub has, you would have noticed the member name has an extra 'v' than the actual function name. ip6_ -> ipv6_

How it goes then?

Regards,
Marcelo