portmap: fix nftables backend#1116
Conversation
2e32a3f to
92965ed
Compare
We can't use dnat from the input hook, depending on nftables (and kernel ?) version we get "Error: Could not process rule: Operation not supported" iptables backend also uses prerouting. Also 'ip6 protocol tcp' is invalid, so rework / simplify the rules Fixes 01a94e1 Signed-off-by: Etienne Champetier <[email protected]>
92965ed to
32d1489
Compare
|
Tested with |
| Name: "prerouting", | ||
| Type: knftables.PtrTo(knftables.NATType), | ||
| Hook: knftables.PtrTo(knftables.InputHook), | ||
| Hook: knftables.PtrTo(knftables.PreroutingHook), |
There was a problem hiding this comment.
OK, I think I know what I was confused about: in prerouting it hasn't yet decided where it's going to route the packet to, so you can't use oifname. I was thinking that meant you couldn't use fib daddr type either, but that's wrong; fib daddr type answers "what does the routing table say we should do with this packet?", not "what are we actually going to do with this packet?", so it doesn't depend on the routing decision.
| "th dport", e.HostPort, | ||
| "dnat", ipX, "addr . port", "to", containerNet.IP, ".", e.ContainerPort, | ||
| e.Protocol, "dport", e.HostPort, | ||
| "dnat to", net.JoinHostPort(containerNet.IP.String(), strconv.Itoa(e.ContainerPort)), |
There was a problem hiding this comment.
(yeah, this rule was complicated because it's derived from a kube-proxy rule where we look up the "addr . protocol . port" in a map rather than just having a static rule)
|
This PR introduced a regression. Let's say I want to forward incoming traffic to UDP port 53 to a pod with IP The The In my case this broke DNS resolution inside the pods. If I had forwarded TCP port 8080 I would have broken internal services using that port. |
You should open a new issue rather than commenting on a year-old PR. |
|
I'll try to have a look next week / compare with iptables behavior |
|
Thanks for the reply! I didn't open a new issue because I'm a bit burned trying to contribute to kubernetes core projects. Most of them demand a lot of work and then ignore it and make you keep on top of the issue/PR for months to years while appeasing the stale bot. I'll look into the issue next week, I suspect all that's needed is to add the Cheers! |
Looking at a system running iptables mode (with So yes we just need |
We can't use dnat from the input hook,
depending on nftables (and kernel ?) version we get
"Error: Could not process rule: Operation not supported"
iptables backend also uses prerouting.
Also 'ip6 protocol tcp' is invalid, so rework / simplify the rules
Fixes 01a94e1
Fixes #1115