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

Only add 127.0.0.1 entry to /etc/hosts with --net=none #11605

Merged
merged 1 commit into from
Sep 16, 2021

Conversation

Luap99
Copy link
Member

@Luap99 Luap99 commented Sep 16, 2021

The check for net=none was wrong. It just assumed when we do not create
the netns but have one set that we use the none mode. This however also
applies to a container which joins the pod netns.
To correctly check for the none mode use config.NetMode.IsNone().

Fixes #11596

@openshift-ci openshift-ci bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Sep 16, 2021
Copy link
Member

@giuseppe giuseppe left a comment

Choose a reason for hiding this comment

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

LGTM

@openshift-ci
Copy link
Contributor

openshift-ci bot commented Sep 16, 2021

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: giuseppe, Luap99

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@@ -337,7 +337,7 @@ type NetworkMode string

// IsNone indicates whether container isn't using a network stack.
func (n NetworkMode) IsNone() bool {
return n == noneType
return n == noneType || n == ""
Copy link
Member

Choose a reason for hiding this comment

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

Is this accurate? "" could also be the default (bridge), couldn't it?

Copy link
Member Author

Choose a reason for hiding this comment

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

The thing is "none" is never set via the With... functions so all we have is an empty string for the NetMode.
Bridge and slirp4netns are set via WithNetNS which should set the mode correctly. There is a lot of code using NetMode.IsBridge() which only matches bridge so I think this is correct.

Copy link
Member

Choose a reason for hiding this comment

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

Alright. We really ought to make this more reliable in 4.0, having some cases not assign this is iffy.

Copy link
Member Author

Choose a reason for hiding this comment

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

OK, this might be a bigger problem than I thought. If a container is joined to a pod or another container it also has an empty NetworkMode.

@rhatdan
Copy link
Member

rhatdan commented Sep 16, 2021

Testing is not happy with this change.

The check for net=none was wrong. It just assumed when we do not create
the netns but have one set that we use the none mode. This however also
applies to a container which joins the pod netns.
To correctly check for the none mode use `config.NetMode.IsNone()`.

Fixes containers#11596

Signed-off-by: Paul Holzinger <[email protected]>
if ns.Type == spec.NetworkNamespace {
if ns.Path == "" && !c.config.CreateNetNS {
netNone = true
if c.config.NetNsCtr == "" && !c.config.CreateNetNS {
Copy link
Member

Choose a reason for hiding this comment

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

Honestly, this is probably safer...

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes we should fix this for the future so that we store the netmode in libpod. But now we are stucked with this forever if we want to support backwards compat.

@mheon
Copy link
Member

mheon commented Sep 16, 2021

LGTM

@rhatdan
Copy link
Member

rhatdan commented Sep 16, 2021

/lgtm

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Sep 16, 2021
@openshift-merge-robot openshift-merge-robot merged commit 0acf540 into containers:main Sep 16, 2021
@Luap99 Luap99 deleted the hosts branch September 17, 2021 08:35
@github-actions github-actions bot added the locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments. label Sep 22, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 22, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. lgtm Indicates that a PR is ready to be merged. locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Podman 3.3 adds 127.0.0.1 /etc/hosts record for hostname, breaking gethostbyaddr for the hostname
5 participants