Skip to contentSkip to conversation

IPVS IPv6: code and data structure reuse

DISCUSSION Julius Volz 2 participants 5 messages Apr 24, 2008 IPVS

lore
Share & tools
lore
#0 lore raw

Hi,

As promised a while ago, here come some random newbie thoughts and questions :) Whilst doing some exploratory and dirty hacking on extending IPVS code to support IPv6, I stumbled over a couple of issues that should have been obvious, but that I hadn't really thought of before (being a kernel novice):

If you want to make code depend on something that may be compiled as a module (in this case, general IPv6 support), your code must be compilable as a module too (well, duh!). So before thinking about that, I wanted to have only a Y/N option for the IPVS IPv6 support, but this will obviously not work out with that in mind.

This means that all IPv6 specific IPVS code would have to be very cleanly separated from the old code (and not "interwoven" in some parts) in order to live in separate modules. I first thought about some functions or modules (say, IPVS schedulers) being able to support both IPv4 and IPv6 in the same module (and even differentiating within some of the same functions, data structures, etc.), so as to reduce code duplication, but that seems harder now...

Would it still be ok to use some of the same data structures for both IP versions, by optionally including IPv6 address fields and address family specifiers in them? Like this:

union ip_vs_addr {
        __be32                  v4;
#ifdef CONFIG_IP_VS_IPV6
        struct in6_addr         v6;

#endif
};

struct some_ip_vs_struct {
        __u16 af;        /* address family */
        ...
        union ip_vs_addr caddr;
        union ip_vs_addr vaddr;
        union ip_vs_addr daddr;
        ...
};

The problem with this is that the IPv6 fields would still be in there, wasting space, if the IPVS IPv6 code is configured as a module, but not loaded. And in any case, IPv4 entries would be larger than needed with the support for IPv6 enabled. That would probably be suboptimal too, so would you have to duplicate all these data structures? You could make them address-family agnostic and use opaque pointers to the actual addresses, but that also adds some overhead.

Another option might be to have _all_ of IPVS depend on CONFIG_IPV6 once you enable IPv6 support for IPVS (and have that only as a Y/N option). That way, you could still have easier and more reuse within IPVS, but would that be acceptable?

After thinking about all this, it seems IPv6 in IPVS should be a collection of separate modules anyways, right? Even if that means a lot of duplication and extra maintenance (and maybe later, refactoring to reduce the duplication)...

I'd be glad to hear any thoughts on this! Or if I'm basically on the right track with my last statement...

Thanks,
Julius

Signature · 1 line
Google Switzerland GmbH
#1 lore raw

On Thu, 24 Apr 2008, Julius Volz wrote:

Hi Julius,

I'm replying in case no one else does, not because I have any good answers.

How is the coding done in netfilter/ipv6? How about *BSD?

Quoted 1 line

This means that all IPv6 specific IPVS code would have to be very cleanly separated from the old code

I would think it better to have code that works, that has asthetic problems, than to have a whole pile of perfectly written code that never got released because you ran out of time. Someone else can clean it up later if the asthetics are that big a problem.

Quoted 10 lines

Would it still be ok to use some of the same data structures for both IP versions, by optionally including IPv6 address fields and address family specifiers in them? Like this:

union ip_vs_addr {
       __be32                  v4;
#ifdef CONFIG_IP_VS_IPV6
       struct in6_addr         v6;

#endif
};

kernel people moan about #ifdefs but I don't know what they do to get around them.

What if IPV6 in not turned on in NETWORKING and you don't have an #ifdef here, will in6_addr wind up being some NULL struct which will/can be ignored?

Quoted 1 line

The problem with this is that the IPv6 fields would still be in there, wasting space,

the kernel is so large now, I don't think there can be any realistic claims on not wasting space.

Quoted 1 line

Another option might be to have _all_ of IPVS depend on CONFIG_IPV6 once you enable IPv6 support for IPVS (and have that only as a Y/N option). That way, you could still have easier and more reuse within IPVS, but would that be acceptable?

sounds good to me. I wouldn't worry about this a whole lot just yet. I would be quite happy if in the first version ipv6 for ipvs came out with no user options - it's turned on whether the user wants it or not. The next iteration would be if IPV6 is turned on in NETWORKING, then ipv6 is turned on in ipvs. I wouldn't go beyond that - you want the kernel config to be as simple as possible. Anyone who wants ipv6 off in ipvs(), while turning on IPV6 in NETWORKING can go figure it out for themselves.

Quoted 1 line

After thinking about all this, it seems IPv6 in IPVS should be a collection of separate modules anyways, right? Even if that means a lot of duplication and extra maintenance (and maybe later, refactoring to reduce the duplication)...

you can't count on maintenance (the big cost in code is not writing it, but maintaining it). There's not a lot of people paying attention to ipvs() and you should plan on any code you submit to be in there unchanged for quite some time. You can see how few other people have wanted to tackle ipv6 for ipvs(). I would have/use as much code from the IPV6 layer as possible, where other people will maintain it, and have as little new code in ipvs() as possible, presumably just duplicated lines (with #ifdefs) making the ipv6 rather than ipv4 call.

ipvs() is basically one module now. I wouldn't code up a collection of modules. The user will have to go figure out all the modules to load to get ipvs_ipv6 to work. This is a lot to ask. I think keeping ipvs() as one module would be best. Next option would be having an ipvs() and an ipvs_ipv6().

Thanks for plugging away at this.

Joe

Signature · 4 lines
Joseph Mack NA3T EME(B,D), FM05lw North Carolina
jmack (at) wm7d (dot) net - azimuthal equidistant map
generator at http://www.wm7d.net/azproj.shtml
Homepage http://www.austintek.com/ It's GNU/Linux!
#2 lore raw

Hi Joe,

Quoted 2 lines · On Thu, Apr 24, 2008, Joseph Mack NA3T wrote:

On Thu, 24 Apr 2008, Julius Volz wrote:
I'm replying in case no one else does, not because I have any good answers.

Thanks! Any conversation helps clarify things!

Quoted 1 line

How is the coding done in netfilter/ipv6? How about *BSD?

Don't know about *BSD, but from my quick look at Netfilter, they seem to basically duplicate everything for IPv6...

Quoted 8 lines
Quoted 1 line

This means that all IPv6 specific IPVS code would have to be very cleanly

separated from the old code

Quoted 1 line

I would think it better to have code that works, that has asthetic
problems, than to have a whole pile of perfectly written code that never got released because you ran out of time. Someone else can clean it up later if the asthetics are that big a problem.

Yeah, with "cleanly separated" I actually really meant just separating it in a way that actually compiles, links and works somehow when it depends on a modular CONFIG_IPV6, not really worrying about aesthetics yet.

About running out of time: The good thing is that I can still continue on this regardless of my current employer, since the project is interesting by itself ;)

Quoted 12 lines
Quoted 11 lines

Would it still be ok to use some of the same data structures for both IP versions, by optionally including IPv6 address fields and address family specifiers in them? Like this:

union ip_vs_addr {
      __be32                  v4;
#ifdef CONFIG_IP_VS_IPV6
      struct in6_addr         v6;

#endif
};

Quoted 2 lines

kernel people moan about #ifdefs but I don't know what they do to get
around them.

The #ifdef in this case isn't so bad in itself, no. It's just that the optional block will still be included if the code for the corresponding CONFIG variable has been compiled as a module, but not been loaded. Nothing would break, there just would be some wasted space.

Quoted 3 lines

What if IPV6 in not turned on in NETWORKING and you don't have an #ifdef
here, will in6_addr wind up being some NULL struct which will/can be ignored?

In that case, the union would just always be bigger than necessary as it contains enough space for an IPv6 address. Since IPv6 code wouldn't be loaded, the IPv6 union member would just never be accessed, so nothing bad would happen.

Quoted 6 lines
Quoted 1 line

The problem with this is that the IPv6 fields would still be in there,

wasting space,

Quoted 1 line

the kernel is so large now, I don't think there can be any realistic claims
on not wasting space.

Yeah, I guess the only place where this could add a relevant (but still small) size increase is in the connection table, since that can hold a lot of entries. But then again, connection entries are pretty big already anyways.

Quoted 7 lines

sounds good to me. I wouldn't worry about this a whole lot just yet. I
would be quite happy if in the first version ipv6 for ipvs came out with no user options - it's turned on whether the user wants it or not. The next iteration would be if IPV6 is turned on in NETWORKING, then ipv6 is turned on in ipvs. I wouldn't go beyond that - you want the kernel config to be as simple as possible. Anyone who wants ipv6 off in ipvs(), while turning on IPV6 in NETWORKING can go figure it out for themselves.

Well, to turn on IPv6 in IPVS, you really _have_ to turn on IPv6 in the kernel in general, since you'll be using and linking against that code. So your first suggestion wouldn't be possible, but the other ones sound fine and I might take that path!

Quoted 10 lines
Quoted 1 line

After thinking about all this, it seems IPv6 in IPVS should be a

collection of separate modules anyways, right? Even if that means a lot of duplication and extra maintenance (and maybe later, refactoring to reduce the duplication)...

Quoted 1 line

you can't count on maintenance (the big cost in code is not writing it, but
maintaining it). There's not a lot of people paying attention to ipvs() and you should plan on any code you submit to be in there unchanged for quite some time. You can see how few other people have wanted to tackle ipv6 for

That's fine. Usually people only change things if they really find something that doesn't work for them and they need it desperately. Having less fluctuation in that part of the kernel makes it easier to start hacking on though.

Quoted 4 lines

ipvs(). I would have/use as much code from the IPV6 layer as possible, where other people will maintain it, and have as little new code in ipvs() as possible, presumably just duplicated lines (with #ifdefs) making the ipv6 rather than ipv4 call.

Sure, the plan was to keep the IPv6 code similar to the old version, but with the IPv4 calls replaced by ones to the IPv6 layer. As IPv6 isn't only about bigger addresses, some of the mechanisms (different ICMPv6 messages, different fragmentation issues, various types of extension headers) will also have to be adjusted, but that can also evolve over time as it is noticed. I don't know all of the correct replacements yet, but I guess we'll figure them out as we go along.

Quoted 5 lines

ipvs() is basically one module now. I wouldn't code up a collection of
modules. The user will have to go figure out all the modules to load to get ipvs_ipv6 to work. This is a lot to ask. I think keeping ipvs() as one module would be best. Next option would be having an ipvs() and an ipvs_ipv6().

Well, we have a collection of modules already, one for the IPVS core, one for each scheduler and one for the FTP protocol helper. So having a couple more is not too bad and they should be loaded automatically when needed anyways ;)

Quoted 1 line

Thanks for plugging away at this.

I'm doing what I can :) Thanks for the support!

Julius

Signature · 1 line
Google Switzerland GmbH
#3 lore raw
Quoted 3 lines · Julius Volz

About running out of time: The good thing is that I can still continue on this regardless of my current employer, since the project is interesting by itself ;)

well you may have time in the future, but don't count on it. Things happen, your car needs repair, you go on vacation, someone calls you up with a neat idea and you'll find you have 3 months of ipvs_ipv6 code sitting on the shelf which isn't going anywhere. Plan on writing code to your current horizon and if that winds up being what time you have, then you won't have done all that work for nothing. If you can keep going, then there's no harm done.

THere's been two previous efforts to move the ipvs() hook from LOCAL_IN which have produced no code in the outside world, for what I presume is running out of time. The guy who did the original IPV6 port for LVS a long time ago, just disappeared. Presumably he didn't have time to update it.

Joe

Signature · 4 lines
Joseph Mack NA3T EME(B,D), FM05lw North Carolina
jmack (at) wm7d (dot) net - azimuthal equidistant map
generator at http://www.wm7d.net/azproj.shtml
Homepage http://www.austintek.com/ It's GNU/Linux!
#4 lore raw
Quoted 7 lines · On Thu, Apr 24, 2008, Joseph Mack NA3T wrote:

well you may have time in the future, but don't count on it. Things happen,
your car needs repair, you go on vacation, someone calls you up with a neat idea and you'll find you have 3 months of ipvs_ipv6 code sitting on the shelf which isn't going anywhere. Plan on writing code to your current horizon and if that winds up being what time you have, then you won't have done all that work for nothing. If you can keep going, then there's no harm done.

Very true, I will keep that in mind. The goal is to have a workable version in my time here anyways, for lots of other reasons. I guess for kernel inclusion, it has to reach a somewhat decent level of quality, though.

I'll sadly be working on other things next week, but I will go on after that!

Julius

Signature · 1 line
Google Switzerland GmbH