Ipv6; Support ipset with "family inet6" #538
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Handle ipset for ipv4, ipv6 and dual-stack
For ipv6 and dual-stack support the
IPSet
is altered. An effort is made to be compatible with existing ipv4-only code while allowing an easy switch to ipv6-only. Dual-stack is considered in the sense that instances ofIPSet
for ipv4 and ipv6 can exist in paralell.This PR is preliminary and intended for discussions on how to introduce ipv6-only and dual-stack, but it is a serious effort and my hope is that it will be accepted eventually.
NewIPSet
An
isIpv6
flag is added toIPSet
and is passed on creation;All other calls to functions in
IPSet
will remain the same, so to switch to ipv6-only should be simple.For dual-stack all functions calls must go to both an ipv4 and ipv6 instance of
IPSet
. So perhaps it would be better to pass an enum;ipv4/ipv6/dual-stack
toNewIPSet(operation)
. But then again, it is hard for me to decide at this early stage, another abstraction layer may be better(?). The current flag is sufficient for ipv6-only and can easily be changed for dual-stack if needed.The
family
options becomes invalid for any set operation to theIPSet
(since it is implicit). I do not consider that as a problem.Ipset name-space
Unlike
iptables
the sameipset
is used for both ipv4 and ipv6. This means that the sets must have different names for ipv4 and ipv6. This makes it impossible to intantiate twoIPSet
for dual-stack with the same set names. For coding in higher levels this becomes a mess so instead a prefixinet6:
is silently added to all set names if theIPSet
is of ipv6 type.Save/Restore/Flush
These operations seem to be imported from other code (the "file" comments) and not fully adapted. It works on all ipsets. For instance a
IPSet.Save()
operation will "slurp-in" all ipset's on the host to theIPSet
(example).This must be fixed in some way, but this is a larger job and not really necessary for ipv6-only. So I postpone this for now.
An idea may be to pass a regexp to
NewIPSet()
that filters the ipset to only names allowed.Test
For now the ipv6 tests are manual. IMO the most important is that ipv4-only still works in the same way as before, including upgrades, so regression tests are very important.
For the future ipv6, and ultimately dual-stack, tests are needed. There are updates in this area initiated for Kubernetes that hopefully can be used.
The current status is that I have temporary hard-coded
NewIPSet(true)
to get the CNI part ofkube-router
up and running for ipv6-only. Ipset's are created ok;But the
gobgp
can't be started;and re-tries continue forever. This indicates that port is not properly closed on cleanup of some earlier failure. But I will take that in a later PR.