Skip to contentSkip to conversation

ipv6: separate out procfs code from mcast.c

PATCH In review Cong Wang 5 participants 13 messages Apr 23, 2013 – Apr 24, 2013

Subsystems (3)
lore
Share & tools
lore

Cong Wang

author
#0 lore raw

PATCH 1/1 ipv6: separate out procfs code from mcast.c

From: Cong Wang <[email protected]>

They well deserve a separated unit.

Cc "David S. Miller" <[email protected]>
Cc Hideaki YOSHIFUJI <[email protected]>
---
 net/ipv6/Makefile     |    2 
 net/ipv6/mcast.c      |  370 -----------------------------------------------
 net/ipv6/mcast_proc.c |  386 ++++++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 387 insertions(+), 371 deletions(-)
net/ipv6/Makefile +1 -1
index 309af19..157b5e7 100644
@@ -19,7 +19,7 @@ ipv6-$(CONFIG_XFRM) += xfrm6_policy.o xfrm6_state.o xfrm6_input.o \
 	xfrm6_output.o
 ipv6-$(CONFIG_NETFILTER) += netfilter.o
 ipv6-$(CONFIG_IPV6_MULTIPLE_TABLES) += fib6_rules.o
-ipv6-$(CONFIG_PROC_FS) += proc.o
+ipv6-$(CONFIG_PROC_FS) += proc.o mcast_proc.o
 ipv6-$(CONFIG_SYN_COOKIES) += syncookies.o
 
 ipv6-objs += $(ipv6-y)
net/ipv6/mcast.c +0 -370

385 lines not on this page · raw message

net/ipv6/mcast_proc.c new file +386 -0

386 lines not on this page · raw message

maintainer
#1 lore raw

From: Cong Wang <[email protected]>
Date: Tue, 23 Apr 2013 15:07:00 +0800

Quoted 7 lines

From: Cong Wang <[email protected]>

They well deserve a separated unit.

Cc "David S. Miller" <[email protected]>
Cc Hideaki YOSHIFUJI <[email protected]>

Cong, I'm not even reading these patches.

You're on this idea that you can just keep the sysfs and procfs bits of ipv6 modular, and make the rest of ipv6 statically linked into the kernel.

I'm not going to facilitate nor take this seriously.

Sorry.

author
#2 lore raw
Quoted 11 lines · David Miller

From: Cong Wang <[email protected]>
Date: Tue, 23 Apr 2013 15:07:00 +0800

Quoted 7 lines

From: Cong Wang <[email protected]>

They well deserve a separated unit.

Cc "David S. Miller" <[email protected]>
Cc Hideaki YOSHIFUJI <[email protected]>
Quoted 5 lines

Cong, I'm not even reading these patches.

You're on this idea that you can just keep the sysfs and procfs bits of ipv6 modular, and make the rest of ipv6 statically linked into the kernel.

I am trying that only for mcast.c, not for the whole IPv6.

maintainer
#3 lore raw

From: Cong Wang <[email protected]>
Date: Tue, 23 Apr 2013 15:15:02 +0800

Quoted 12 lines · David Miller
Quoted 11 lines

From: Cong Wang <[email protected]>
Date: Tue, 23 Apr 2013 15:07:00 +0800

Quoted 7 lines

From: Cong Wang <[email protected]>

They well deserve a separated unit.

Cc "David S. Miller" <[email protected]>
Cc Hideaki YOSHIFUJI <[email protected]>
Quoted 7 lines
Quoted 5 lines

Cong, I'm not even reading these patches.

You're on this idea that you can just keep the sysfs and procfs bits of ipv6 modular, and make the rest of ipv6 statically linked into the kernel.

I am trying that only for mcast.c, not for the whole IPv6.

The multicast stuff does route lookups, how are you going to accomplish this?

Besides you should move the statically-needed code into a new file (mcast_core.c or something like that, following the existing model and conventions for doing this) rather than the other way around.

And that patch should be posted in a series with the user that needs this (your vxlan ipv6 patches), not by itself.

author
#4 lore raw
Quoted 17 lines · David Miller

From: Cong Wang <[email protected]>
Date: Tue, 23 Apr 2013 15:15:02 +0800

Quoted 14 lines · David Miller
Quoted 13 lines

From: Cong Wang <[email protected]>
Date: Tue, 23 Apr 2013 15:07:00 +0800

Quoted 7 lines

From: Cong Wang <[email protected]>

They well deserve a separated unit.

Cc "David S. Miller" <[email protected]>
Cc Hideaki YOSHIFUJI <[email protected]>

Cong, I'm not even reading these patches.

Quoted 8 lines
Quoted 5 lines
Quoted 3 lines

You're on this idea that you can just keep the sysfs and procfs bits of ipv6 modular, and make the rest of ipv6 statically linked into the kernel.

I am trying that only for mcast.c, not for the whole IPv6.

The multicast stuff does route lookups, how are you going to accomplish this?

This is hard to do, as in the email I replied to Stephen. So I prefer to just add a Kconfig dependency, at least for now.

Quoted 5 lines

Besides you should move the statically-needed code into a new file (mcast_core.c or something like that, following the existing model and conventions for doing this) rather than the other way around.

Yes, this is half-done and is also why I sent it alone rather than in the VXLAN series.

Thanks.

maintainer
#5 lore raw

From: Cong Wang <[email protected]>
Date: Tue, 23 Apr 2013 15:30:20 +0800

Quoted 2 lines

This is hard to do, as in the email I replied to Stephen. So I prefer to just add a Kconfig dependency, at least for now.

A Kconfig hack is exactly what I've told you is an unacceptable solution.

author
#6 lore raw
Quoted 8 lines · David Miller

From: Cong Wang <[email protected]>
Date: Tue, 23 Apr 2013 15:30:20 +0800

Quoted 2 lines

This is hard to do, as in the email I replied to Stephen. So I prefer to just add a Kconfig dependency, at least for now.

A Kconfig hack is exactly what I've told you is an unacceptable solution.

Please enlighten me for a third solution. :)

#7 lore raw
Quoted 11 lines · Cong Wang
Quoted 8 lines · David Miller

From: Cong Wang <[email protected]>
Date: Tue, 23 Apr 2013 15:30:20 +0800

Quoted 2 lines

This is hard to do, as in the email I replied to Stephen. So I prefer to just add a Kconfig dependency, at least for now.

A Kconfig hack is exactly what I've told you is an unacceptable solution.

Please enlighten me for a third solution. :)

This is an completely untested idea....

I note that vxlan_init_net requires a successful sock_create_kern(). That implies a request_module("net-pf-...") followed by try_module_get.

So if the sock_create_kern(PF_INET6, ..) succeeds then you *know* you have IPv6. If it fails with -EAFNOSUPPORT, then you could fall back to sock_create_kern(PF_INET, ..) and set a flag indicating that runtime IPv6 support is disabled. Then use this flag to allow/deny configuring any IPv6 destinations.

You may also have to protect the IPv6 modular symbols you use with symbol_request() or similar to prevent vxlan from depending on IPv6. I dunno...

If nothing else, I believe this is a crazy enough hack that David may want to reconsider one of your other two solutions :)

Bjørn

#8 lore raw
Quoted 25 lines · Bjørn Mork
Quoted 11 lines · Cong Wang
Quoted 8 lines · David Miller

From: Cong Wang <[email protected]>
Date: Tue, 23 Apr 2013 15:30:20 +0800

Quoted 2 lines

This is hard to do, as in the email I replied to Stephen. So I prefer to just add a Kconfig dependency, at least for now.

A Kconfig hack is exactly what I've told you is an unacceptable solution.

Please enlighten me for a third solution. :)

This is an completely untested idea....

I note that vxlan_init_net requires a successful sock_create_kern(). That implies a request_module("net-pf-...") followed by try_module_get.

So if the sock_create_kern(PF_INET6, ..) succeeds then you *know* you have IPv6. If it fails with -EAFNOSUPPORT, then you could fall back to sock_create_kern(PF_INET, ..) and set a flag indicating that runtime IPv6 support is disabled. Then use this flag to allow/deny configuring any IPv6 destinations.

Quoted 6 lines

You may also have to protect the IPv6 modular symbols you use with symbol_request() or similar to prevent vxlan from depending on IPv6. I dunno...

If nothing else, I believe this is a crazy enough hack that David may want to reconsider one of your other two solutions :)

A more type-safe approach would be to define something like:

/* net/ipv6.h */

struct ipv6_mcast_ops {
	...
};

extern const struct ipv6_mcast_ops *ipv6_mcast_ops;

/* net/ipv6/addrconf_core.c */
const struct ipv6_mcast_ops *ipv6_mcast_ops;
EXPORT_SYMBOL_GPL(ipv6_mcast_ops);

/* net/ipv6/af_inet6.c */

static const struct ipv6_mcast_ops ipv6_mcast_ops_impl = {
	...
};
static int __init inet6_init(void)
{
	...
	ipv6_mcast_ops = &ipv6_mcast_ops_impl;
	return 0;
	...
}
static void __exit inet6_exit(void)
{
	...
	ipv6_mcast_ops = NULL;
	...
}

Ben.

Signature · 3 lines
Ben Hutchings, Staff Engineer, Solarflare
Not speaking for my employer; that's the marketing department's job.
They asked us to note that Solarflare product names are trademarked.
author
#9 lore raw
Quoted 14 lines · Ben Hutchings

A more type-safe approach would be to define something like:

/* net/ipv6.h */

struct ipv6_mcast_ops {
	...
};

extern const struct ipv6_mcast_ops *ipv6_mcast_ops;

/* net/ipv6/addrconf_core.c */
const struct ipv6_mcast_ops *ipv6_mcast_ops;
EXPORT_SYMBOL_GPL(ipv6_mcast_ops);

/* net/ipv6/af_inet6.c */

Quoted 16 lines
static const struct ipv6_mcast_ops ipv6_mcast_ops_impl = {
	...
};
static int __init inet6_init(void)
{
	...
	ipv6_mcast_ops = &ipv6_mcast_ops_impl;
	return 0;
	...
}
static void __exit inet6_exit(void)
{
	...
	ipv6_mcast_ops = NULL;
	...
}

Yeah! That's a nice stub! I think this is the only doable and acceptable solution so far.

Thanks a lot!

#10 lore raw
In reply to Bjørn Mork

[email protected] wrote on 04/23/2013 08:33:57 AM:

Quoted 4 lines

From: Bjørn Mork <[email protected]>

Cong Wang <[email protected]> writes:

Quoted 8 lines

I note that vxlan_init_net requires a successful sock_create_kern(). That implies a request_module("net-pf-...") followed by try_module_get.

So if the sock_create_kern(PF_INET6, ..) succeeds then you *know* you have IPv6. If it fails with -EAFNOSUPPORT, then you could fall back to sock_create_kern(PF_INET, ..) and set a flag indicating that runtime IPv6 support is disabled. Then use this flag to allow/deny configuring any IPv6 destinations.

BTW, another thing I thought of after I sent my patch comments -- you also need to consider the state of net.ipv6.bindv6only. When v6 is enabled, you use one socket for v4 and v6, but if bindv6only=1, you actually need a separate socket for v4 receives. If you want to support both v4 and v6 with bindv6only=1, you need two sockets. Or even if you want to support v4-only VXLAN and the sysadmin has set bindv6only=1.

                                                                +-DLS
author
#11 lore raw
Quoted 7 lines · David Stevens

BTW, another thing I thought of after I sent my patch comments -- you also need to consider the state of net.ipv6.bindv6only. When v6 is enabled, you use one socket for v4 and v6, but if bindv6only=1, you actually need a separate socket for v4 receives. If you want to support both v4 and v6 with bindv6only=1, you need two sockets. Or even if you want to support v4-only VXLAN and the sysadmin has set bindv6only=1.

Good point!

Actually the initial version of my patch did use two sockets for v4 and v6. I am adding this to my TODO list.

Thanks!

author
#12 lore raw
In reply to Bjørn Mork
Quoted 16 lines · Bjørn Mork
Quoted 11 lines · Cong Wang
Quoted 8 lines · David Miller

From: Cong Wang <[email protected]>
Date: Tue, 23 Apr 2013 15:30:20 +0800

Quoted 2 lines

This is hard to do, as in the email I replied to Stephen. So I prefer to just add a Kconfig dependency, at least for now.

A Kconfig hack is exactly what I've told you is an unacceptable solution.

Please enlighten me for a third solution. :)

This is an completely untested idea....

Quoted 8 lines

I note that vxlan_init_net requires a successful sock_create_kern(). That implies a request_module("net-pf-...") followed by try_module_get.

So if the sock_create_kern(PF_INET6, ..) succeeds then you *know* you have IPv6. If it fails with -EAFNOSUPPORT, then you could fall back to sock_create_kern(PF_INET, ..) and set a flag indicating that runtime IPv6 support is disabled. Then use this flag to allow/deny configuring any IPv6 destinations.

Excellent point! You are certainly right. I will give it a try.

Quoted 5 lines

You may also have to protect the IPv6 modular symbols you use with symbol_request() or similar to prevent vxlan from depending on IPv6. I dunno...

This sounds a bit crazy.