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

port: add ChildIP #206

Merged
merged 1 commit into from Jan 21, 2021
Merged

Conversation

giuseppe
Copy link
Contributor

allow users to override the IP to use for the connection inside the
network namespace.

It is useful e.g. with slirp4netns to override the IP to "10.0.2.100".

Signed-off-by: Giuseppe Scrivano gscrivan@redhat.com

@giuseppe
Copy link
Contributor Author

it is needed for Podman: containers/podman#5138

@AkihiroSuda
Copy link
Member

it is needed for Podman: containers/podman#5138

This doesn't seem to be able to propagate src IP. Wouldn't this just make the src IP to 10.0.2.100 ?

@giuseppe
Copy link
Contributor Author

Yes, it won't propagate the srcIP but at least we can set it to something different than 127.0.0.1 that causes issues with some container images

@giuseppe
Copy link
Contributor Author

@AkihiroSuda are you fine with the change as it is?

Copy link
Member

@AkihiroSuda AkihiroSuda left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good but a couple of nits. Thanks

@@ -106,7 +106,11 @@ func (d *childDriver) handleConnectRequest(c *net.UnixConn, req *msg.Request) er
return errors.Errorf("unknown proto: %q", req.Proto)
}
var dialer net.Dialer
targetConn, err := dialer.Dial(req.Proto, fmt.Sprintf("127.0.0.1:%d", req.Port))
ip := req.IP
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to verify that this is a valid IPv4 string

if ip == "" {
ip = "127.0.0.1"
}
targetConn, err := dialer.Dial(req.Proto, fmt.Sprintf("%s:%d", ip, req.Port))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you also update pkg/port/{slirp4netns,socat}?

pkg/port/port.go Outdated
@@ -10,6 +10,7 @@ type Spec struct {
ParentIP string `json:"parentIP,omitempty"` // IPv4 address. can be empty (0.0.0.0).
ParentPort int `json:"parentPort,omitempty"`
ChildPort int `json:"childPort,omitempty"`
ChildIP string `json:"childIP,omitempty"`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add godoc comment to clarify that this defaults to 127.0.0.1

allow users to override the IP to use for the connection inside the
network namespace.

It is useful e.g. with slirp4netns to override the IP to "10.0.2.100".

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
@giuseppe
Copy link
Contributor Author

thanks for the review. I've addressed your comments and pushed a new version

Copy link
Member

@AkihiroSuda AkihiroSuda left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, I'll ship a new release tomorrow

@AkihiroSuda AkihiroSuda merged commit 7d41416 into rootless-containers:master Jan 21, 2021
AkihiroSuda added a commit to AkihiroSuda/rootlesskit that referenced this pull request Jan 22, 2021
Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
AkihiroSuda added a commit that referenced this pull request Jan 22, 2021
follow-up for "port: add ChildIP" (#206)   + release v0.12.0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants