Skip to content

Commit 5c0d22b

Browse files
committed
pasta: add IPv6 --map-guest-addr
Signed-off-by: Jan Rodák <hony.com@seznam.cz>
1 parent ae0a340 commit 5c0d22b

1 file changed

Lines changed: 10 additions & 6 deletions

File tree

common/libnetwork/pasta/pasta_linux.go

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,10 @@ const (
3636
// mapGuestAddrIpv4 static ip used as forwarder address inside the netns to reach the host,
3737
// given this is a "link local" ip it should be very unlikely that it causes conflicts.
3838
mapGuestAddrIpv4 = "169.254.1.2"
39+
40+
// mapGuestAddrIpv6 static ip used as IPv6 forwarder address inside the netns to reach the host,
41+
// pasta uses this to provide a routable source for inbound IPv6 connections forwarded via pesto.
42+
mapGuestAddrIpv6 = "fc00::1"
3943
)
4044

4145
type SetupOptions struct {
@@ -77,12 +81,12 @@ func Setup(opts *SetupOptions) (*SetupResult, error) {
7781
// cannot hard require it yet. Once we are confident that the update is most distros we can remove it.
7882
if exitErr.ExitCode() == 1 &&
7983
strings.Contains(string(out), "unrecognized option '"+mapGuestAddrOpt) &&
80-
len(mapGuestAddrIPs) == 1 && mapGuestAddrIPs[0] == mapGuestAddrIpv4 {
81-
// we did add the default --map-guest-addr option, if users set something different we want
84+
len(mapGuestAddrIPs) == 2 && mapGuestAddrIPs[0] == mapGuestAddrIpv4 && mapGuestAddrIPs[1] == mapGuestAddrIpv6 {
85+
// we did add the default --map-guest-addr options, if users set something different we want
8286
// to get to the error below. We have to unset mapGuestAddrIPs here to avoid a infinite loop.
8387
mapGuestAddrIPs = nil
84-
// Trim off last two args which are --map-guest-addr 169.254.1.2.
85-
cmdArgs = cmdArgs[:len(cmdArgs)-2]
88+
// Trim off last four args which are --map-guest-addr 169.254.1.2 --map-guest-addr fc00::1.
89+
cmdArgs = cmdArgs[:len(cmdArgs)-4]
8690
continue
8791
}
8892
return nil, fmt.Errorf("pasta failed with exit code %d:\n%s",
@@ -271,8 +275,8 @@ func createPastaArgs(opts *SetupOptions) ([]string, []string, []string, error) {
271275
if len(mapGuestAddrIPs) == 0 {
272276
// the user did not request custom --map-guest-addr so add our own so that we can use this
273277
// for our own host.containers.internal host entry.
274-
cmdArgs = append(cmdArgs, mapGuestAddrOpt, mapGuestAddrIpv4)
275-
mapGuestAddrIPs = append(mapGuestAddrIPs, mapGuestAddrIpv4)
278+
cmdArgs = append(cmdArgs, mapGuestAddrOpt, mapGuestAddrIpv4, mapGuestAddrOpt, mapGuestAddrIpv6)
279+
mapGuestAddrIPs = append(mapGuestAddrIPs, mapGuestAddrIpv4, mapGuestAddrIpv6)
276280
}
277281

278282
return cmdArgs, dnsForwardIPs, mapGuestAddrIPs, nil

0 commit comments

Comments
 (0)