Skip to content

port: add ChildIP#206

Merged
AkihiroSuda merged 1 commit into
rootless-containers:masterfrom
giuseppe:port-ip
Jan 21, 2021
Merged

port: add ChildIP#206
AkihiroSuda merged 1 commit into
rootless-containers:masterfrom
giuseppe:port-ip

Conversation

@giuseppe

Copy link
Copy Markdown
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 [email protected]

@giuseppe

Copy link
Copy Markdown
Contributor Author

it is needed for Podman: podman-container-tools/podman#5138

@AkihiroSuda

Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
Contributor Author

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

@AkihiroSuda AkihiroSuda left a comment

Copy link
Copy Markdown
Member

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

}
var dialer net.Dialer
targetConn, err := dialer.Dial(req.Proto, fmt.Sprintf("127.0.0.1:%d", req.Port))
ip := req.IP

Copy link
Copy Markdown
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
Copy Markdown
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}?

Comment thread pkg/port/port.go Outdated
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
Copy Markdown
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 <[email protected]>
@giuseppe

Copy link
Copy Markdown
Contributor Author

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

@AkihiroSuda AkihiroSuda left a comment

Copy link
Copy Markdown
Member

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
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.

2 participants