-
Notifications
You must be signed in to change notification settings - Fork 139
pesto: target address mapping and netavark integration #1004
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
Open
Honny1
wants to merge
3
commits into
podman-container-tools:main
Choose a base branch
from
Honny1:passta-and-pessto
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -36,6 +36,26 @@ const ( | |
| // mapGuestAddrIpv4 static ip used as forwarder address inside the netns to reach the host, | ||
| // given this is a "link local" ip it should be very unlikely that it causes conflicts. | ||
| mapGuestAddrIpv4 = "169.254.1.2" | ||
|
|
||
| // mapGuestAddrIpv6 static ip used as IPv6 forwarder address inside the netns to reach the host. | ||
| mapGuestAddrIpv6 = "fc00::2" | ||
|
|
||
| // gatewayIpv6 is the IPv6 default gateway for the guest. pasta uses this as the source | ||
| // address for inbound IPv6 forwarding. Must differ from mapGuestAddrIpv6 to avoid | ||
| // --map-guest-addr intercepting reply traffic. | ||
| // See: https://bugs.passt.top/show_bug.cgi?id=217 | ||
| gatewayIpv6 = "fc00::1" | ||
|
|
||
| // guestAddrIpv6 is assigned to the guest interface so the IPv6 gateway is reachable. | ||
| guestAddrIpv6 = "fc00::3" | ||
| ) | ||
|
|
||
| // Exported IPv6 address constants for use by the rootless netns setup. | ||
| const ( | ||
| MapGuestAddrIpv4 = mapGuestAddrIpv4 | ||
| MapGuestAddrIpv6 = mapGuestAddrIpv6 | ||
| GatewayIpv6 = gatewayIpv6 | ||
| GuestAddrIpv6 = guestAddrIpv6 | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I suppose you might as well just export the variable without a second reassignment but that is just a minor style thing not worth blocking on. |
||
| ) | ||
|
|
||
| type SetupOptions struct { | ||
|
|
@@ -67,39 +87,24 @@ func Setup(opts *SetupOptions) (*SetupResult, error) { | |
|
|
||
| logrus.Debugf("pasta arguments: %s", strings.Join(cmdArgs, " ")) | ||
|
|
||
| for { | ||
| // pasta forks once ready, and quits once we delete the target namespace | ||
| out, err := exec.Command(path, cmdArgs...).CombinedOutput() | ||
| if err != nil { | ||
| exitErr := &exec.ExitError{} | ||
| if errors.As(err, &exitErr) { | ||
| // special backwards compat check, --map-guest-addr was added in pasta version 20240814 so we | ||
| // cannot hard require it yet. Once we are confident that the update is most distros we can remove it. | ||
| if exitErr.ExitCode() == 1 && | ||
| strings.Contains(string(out), "unrecognized option '"+mapGuestAddrOpt) && | ||
| len(mapGuestAddrIPs) == 1 && mapGuestAddrIPs[0] == mapGuestAddrIpv4 { | ||
| // we did add the default --map-guest-addr option, if users set something different we want | ||
| // to get to the error below. We have to unset mapGuestAddrIPs here to avoid a infinite loop. | ||
| mapGuestAddrIPs = nil | ||
| // Trim off last two args which are --map-guest-addr 169.254.1.2. | ||
| cmdArgs = cmdArgs[:len(cmdArgs)-2] | ||
| continue | ||
| } | ||
| return nil, fmt.Errorf("pasta failed with exit code %d:\n%s", | ||
| exitErr.ExitCode(), string(out)) | ||
| } | ||
| return nil, fmt.Errorf("failed to start pasta: %w", err) | ||
| // pasta forks once ready, and quits once we delete the target namespace | ||
| out, err := exec.Command(path, cmdArgs...).CombinedOutput() | ||
| if err != nil { | ||
| exitErr := &exec.ExitError{} | ||
| if errors.As(err, &exitErr) { | ||
| return nil, fmt.Errorf("pasta failed with exit code %d:\n%s", | ||
| exitErr.ExitCode(), string(out)) | ||
| } | ||
| return nil, fmt.Errorf("failed to start pasta: %w", err) | ||
| } | ||
|
|
||
| if len(out) > 0 { | ||
| // TODO: This should be warning but as of August 2024 pasta still prints | ||
| // things with --quiet that we do not care about. In podman CI I still see | ||
| // "Couldn't get any nameserver address" so until this is fixed we cannot | ||
| // enable it. For now info is fine and we can bump it up later, it is only a | ||
| // nice to have. | ||
| logrus.Infof("pasta logged warnings: %q", strings.TrimSpace(string(out))) | ||
| } | ||
| break | ||
| if len(out) > 0 { | ||
| // TODO: This should be warning but as of August 2024 pasta still prints | ||
| // things with --quiet that we do not care about. In podman CI I still see | ||
| // "Couldn't get any nameserver address" so until this is fixed we cannot | ||
| // enable it. For now info is fine and we can bump it up later, it is only a | ||
| // nice to have. | ||
| logrus.Infof("pasta logged warnings: %q", strings.TrimSpace(string(out))) | ||
| } | ||
|
|
||
| var ipv4, ipv6 bool | ||
|
|
@@ -265,15 +270,12 @@ func createPastaArgs(opts *SetupOptions) ([]string, []string, []string, error) { | |
| cmdArgs = append(cmdArgs, "--quiet") | ||
| } | ||
|
|
||
| cmdArgs = append(cmdArgs, "--netns", opts.Netns) | ||
|
|
||
| // do this as last arg so we can easily trim them off in the error case when we have an older version | ||
| if len(mapGuestAddrIPs) == 0 { | ||
| // the user did not request custom --map-guest-addr so add our own so that we can use this | ||
| // for our own host.containers.internal host entry. | ||
| cmdArgs = append(cmdArgs, mapGuestAddrOpt, mapGuestAddrIpv4) | ||
| mapGuestAddrIPs = append(mapGuestAddrIPs, mapGuestAddrIpv4) | ||
| } | ||
|
|
||
| cmdArgs = append(cmdArgs, "--netns", opts.Netns) | ||
|
|
||
| return cmdArgs, dnsForwardIPs, mapGuestAddrIPs, nil | ||
| } | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I missed this is the first round of review but so far I tried to keep the full config out of the network interface as we lookup the netavark path once at the beginning and then store it as string instead.
I guess the is not strict reason to not have it so I am fine to add this here but it would allow us some cleanup/removal of fields above in theory. (anyhow lets not make this PR more complicated I guess, we can do that as some cleanup in the future)