summaryrefslogtreecommitdiff
path: root/cmd/rootlessport/main.go
diff options
context:
space:
mode:
authorJason T. Greene <jason.greene@redhat.com>2022-04-25 15:55:42 -0500
committerJason T. Greene <jason.greene@redhat.com>2022-04-29 17:03:45 -0500
commit772ead25318dfa340541197e92322bd2346df087 (patch)
tree0bc9b5f5f004e55876616684c11d1041169f9dd0 /cmd/rootlessport/main.go
parent5ac00a7287e4a9e6292f4a6ca5dfa9a02e5ca907 (diff)
downloadpodman-772ead25318dfa340541197e92322bd2346df087.tar.gz
podman-772ead25318dfa340541197e92322bd2346df087.tar.bz2
podman-772ead25318dfa340541197e92322bd2346df087.zip
Use simulated dual-stack binds when using WSL
Resolves a WSL problem where traffic from only one stack is relayed Signed-off-by: Jason T. Greene <jason.greene@redhat.com>
Diffstat (limited to 'cmd/rootlessport/main.go')
-rw-r--r--cmd/rootlessport/main.go24
1 files changed, 19 insertions, 5 deletions
diff --git a/cmd/rootlessport/main.go b/cmd/rootlessport/main.go
index e9ab8b076..5bd35a985 100644
--- a/cmd/rootlessport/main.go
+++ b/cmd/rootlessport/main.go
@@ -1,3 +1,6 @@
+//go:build linux
+// +build linux
+
package main
import (
@@ -307,11 +310,11 @@ func exposePorts(pm rkport.Manager, portMappings []types.PortMapping, childIP st
ChildPort: int(port.ContainerPort + i),
ChildIP: childIP,
}
- if err := rkportutil.ValidatePortSpec(spec, nil); err != nil {
- return err
- }
- if _, err := pm.AddPort(ctx, spec); err != nil {
- return err
+
+ for _, spec = range splitDualStackSpecIfWsl(spec) {
+ if err := validateAndAddPort(ctx, pm, spec); err != nil {
+ return err
+ }
}
}
}
@@ -319,6 +322,17 @@ func exposePorts(pm rkport.Manager, portMappings []types.PortMapping, childIP st
return nil
}
+func validateAndAddPort(ctx context.Context, pm rkport.Manager, spec rkport.Spec) error {
+ if err := rkportutil.ValidatePortSpec(spec, nil); err != nil {
+ return err
+ }
+ if _, err := pm.AddPort(ctx, spec); err != nil {
+ return err
+ }
+
+ return nil
+}
+
func child() error {
// load the config from the parent
var opaque map[string]string