Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support IPv6 port forwarding (libslirp 4.5) #253

Open
AkihiroSuda opened this issue Feb 4, 2021 · 12 comments
Open

Support IPv6 port forwarding (libslirp 4.5) #253

AkihiroSuda opened this issue Feb 4, 2021 · 12 comments
Labels
area/ipv6 IPv6 enhancement New feature or request help wanted Extra attention is needed

Comments

@AkihiroSuda
Copy link
Member

AkihiroSuda commented Feb 4, 2021

libslirp@master recently gained support for IPv6 port forwarding.

https://gitlab.freedesktop.org/slirp/libslirp/-/commit/0624fbe7d39b5433d7084a5096d1effc1df74e39

https://gitlab.freedesktop.org/slirp/libslirp/-/merge_requests/75/diffs

slirp4netns should support this.

@pfandl
Copy link

pfandl commented Apr 5, 2021

@AkihiroSuda hi, i could as a test get it working but it needs a patch to libslirp as well, as we possibly are listening to ipv4 already the bind with ipv6 has to happen with IPV6_V6ONLY socket option. Another option would be to listen to ipv6 in the guest only, and forward ipv4 there.

The guest ipv6 for the forwarding is also hardcoded to fd00::100 because we get the actual random? ip after we are trying to forward the ports, and it would probably need another ready fd or whatever mechanism to get this working on the guest ip.

@AkihiroSuda
Copy link
Member Author

Thanks for working on this.
I think we want to avoid hard coding IPv6 addresses: #259

@AkihiroSuda
Copy link
Member Author

And I think we want to prioritize IPv6-to-IPv4 forwarding rather than IPv6-to-IPv6 forwarding, although we will eventually need both.

@pfandl
Copy link

pfandl commented Apr 5, 2021

Thanks for working on this.
I think we want to avoid hard coding IPv6 addresses: #259

I saw that and tried to follow it first but I think there is much more work needed for it.
When I tried to read the IPv6 address from /proc/net/if_inet6 or whatever the path
was, can't remember, at the point of where we would bind the ports, the address is not
yet available. It comes later after NDP router advertisement. Therefore we kind of would
need to remember what ports we want to bind and delay it for after that moment and
also then I guess we want to inform the user that the IPv6 stack is ready?

Mind me being new to this and probably I got something wrong, that was my experience
so far.

EDIT:

It seems only the Global ID has to be random, the subnet and interface ID dont have to be, right?
If we can randomize the Global ID at startup and just add :100 to that for the internal interface
IP we should be good to go. Alternatively we can let the user choose a self generated random
prefix and possible even the internal interface IP and work with that. Then we would have to stop
the initial router advertisement so that we don't end up with two subnets, the automatic (currently)
one and the one the user chose.

pfandl pushed a commit to pfandl/slirp4netns that referenced this issue Apr 12, 2021
pfandl pushed a commit to pfandl/slirp4netns that referenced this issue Apr 16, 2021
- fix listen address;
- list addresses in api call;
- --cidr6 parameter;
- add test;

- fix api test script;
@pfandl
Copy link

pfandl commented Apr 16, 2021

And I think we want to prioritize IPv6-to-IPv4 forwarding rather than IPv6-to-IPv6 forwarding, although we will eventually need both.

There is a problem when forwarding IPv6 to IPv4, the whole device gets kind of reset, and has no ip addresses anymore
as soon as you write something to the port. I am not sure where the problem is, could be in libslirp.

Anyway what works so far:

  • we can pass --cidr6=fd00::/64 and a fd00:aaaa:.... network will be generated
    • we take the mac of "lo" device for random id generation, it is zero, we need something else
  • we can pass --cidr6=fd00:aaaa:bbbb:cccc::/64 and this will be the network
  • IPv6 to IPv6 forwarding works with a patch to libslirp.txt

Not sure how to proceed, any input?

Also, if somebody wants to take it from here, please just say so and go ahead.

pfandl pushed a commit to pfandl/slirp4netns that referenced this issue Sep 11, 2021
pfandl pushed a commit to pfandl/slirp4netns that referenced this issue Sep 11, 2021
pfandl pushed a commit to pfandl/slirp4netns that referenced this issue Sep 11, 2021
- fix listen address;
- list addresses in api call;
- --cidr6 parameter;
- add test;

- fix api test script;

Signed-off-by: fassl <[email protected]>
pfandl added a commit to pfandl/slirp4netns that referenced this issue Sep 11, 2021
pfandl pushed a commit to pfandl/slirp4netns that referenced this issue Sep 11, 2021
- implement forwarding
- implement random CIDR

Signed-off-by: fassl <[email protected]>

IPv6 test ref rootless-containers#253

Signed-off-by: fassl <[email protected]>

IPv6: pseudo random id generator rootless-containers#259 rootless-containers#253

Signed-off-by: fassl <[email protected]>

IPv6 port forwarding: rootless-containers#259 rootless-containers#253
- fix listen address;
- list addresses in api call;
- --cidr6 parameter;
- add test;

- fix api test script;

Signed-off-by: fassl <[email protected]>

handle protocol version in api: rootless-containers#253 rootless-containers#259

Signed-off-by: fassl <[email protected]>

add --ipv6-random flag: rootless-containers#259

Signed-off-by: fassl <[email protected]>

use strnXXX functions: rootless-containers#259

Signed-off-by: fassl <[email protected]>

try read mac of tap0 and fallback to /dev/Xrandom: rootless-containers#259

Signed-off-by: fassl <[email protected]>

man page and bump libslirp veresion: rootless-containers#259

Signed-off-by: fassl <[email protected]>

fix Docker builds: rootless-containers#259

Signed-off-by: fassl <[email protected]>
pfandl pushed a commit to pfandl/slirp4netns that referenced this issue Sep 11, 2021
- implement forwarding
- implement random CIDR

Signed-off-by: fassl <[email protected]>
pfandl added a commit to pfandl/slirp4netns that referenced this issue Sep 11, 2021
- implement forwarding
- implement random CIDR

Signed-off-by: fassl <[email protected]>
pfandl added a commit to pfandl/slirp4netns that referenced this issue Sep 11, 2021
- skip ipv6 tests on old libslirp versions
- install openssl-devel on centos box
- use *hostfwd functions on old libslirp versions

Signed-off-by: fassl <[email protected]>
pfandl added a commit to pfandl/slirp4netns that referenced this issue Sep 11, 2021
- fix missing SLIRP_CONFIG_VERSION_MAX in test scripts
pfandl added a commit to pfandl/slirp4netns that referenced this issue Sep 11, 2021
- implement forwarding
- implement random CIDR

Signed-off-by: fassl <[email protected]>
pfandl added a commit to pfandl/slirp4netns that referenced this issue Sep 12, 2021
- implement forwarding
- implement random CIDR

Signed-off-by: fassl <[email protected]>
pfandl added a commit to pfandl/slirp4netns that referenced this issue Sep 12, 2021
- implement forwarding
- implement random CIDR

Signed-off-by: Jasmin Fazlic <[email protected]>
@53c70r
Copy link

53c70r commented May 5, 2023

What is the status of this important issue?

@53c70r
Copy link

53c70r commented May 5, 2023

If there is another way to seamlessly signal the correct remote IP to the inner container and support IPv4 + IPv6 I would appreciate to know the solution.

@AkihiroSuda
Copy link
Member Author

What is the status of this important issue?

Waiting for a PR

@su-ex
Copy link

su-ex commented May 5, 2023

If there is another way to seamlessly signal the correct remote IP to the inner container and support IPv4 + IPv6 I would appreciate to know the solution.

I guess pasta is the way to go: containers/podman#16141 🍝

@53c70r
Copy link

53c70r commented May 6, 2023

That's it, thx. @su-ex

@mstrauss
Copy link

I guess pasta is the way to go: containers/podman#16141 🍝

Little OT, but I have gone this road. I tested pasta this week and had nothing but troubles with it. Failed inbound TCP connections (with HAproxy), flapping services (falsely) reported by Nagios and so on. The only thing I got working fine so far under Pasta was hitch+varnish (with IPv6 on the frontend, yes!).

So please, I would really like to encourage the devs/maintainers of slirp4netns to tackle this important IPv6 related issue. Thank you.

@AkihiroSuda
Copy link
Member Author

So please, I would really like to encourage the devs/maintainers of slirp4netns to tackle this important IPv6 related issue.

Feel free to submit a PR.

DigitalDJ pushed a commit to DigitalDJ/slirp4netns that referenced this issue Mar 3, 2024
- implement forwarding
- implement random CIDR

Signed-off-by: Jasmin Fazlic <[email protected]>
DigitalDJ pushed a commit to DigitalDJ/slirp4netns that referenced this issue Mar 3, 2024
- implement forwarding
- implement random CIDR

Signed-off-by: Jasmin Fazlic <[email protected]>
DigitalDJ pushed a commit to DigitalDJ/slirp4netns that referenced this issue Apr 26, 2024
- implement forwarding
- implement random CIDR

Signed-off-by: Jasmin Fazlic <[email protected]>
DigitalDJ pushed a commit to DigitalDJ/slirp4netns that referenced this issue May 12, 2024
- implement forwarding
- implement random CIDR

Signed-off-by: Jasmin Fazlic <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/ipv6 IPv6 enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

5 participants