Skip to content

pesto: target address mapping and netavark integration#1004

Open
Honny1 wants to merge 3 commits into
podman-container-tools:mainfrom
Honny1:passta-and-pessto
Open

pesto: target address mapping and netavark integration#1004
Honny1 wants to merge 3 commits into
podman-container-tools:mainfrom
Honny1:passta-and-pessto

Conversation

@Honny1

@Honny1 Honny1 commented Jul 21, 2026

Copy link
Copy Markdown
Contributor
  • Add target address mapping to pesto CLI args so pasta forwards traffic directly to container IPs, removing the need for netavark DNAT rules.
  • portMappingsToPestoArgs now generates -t hostIP/hostPort:containerIP/containerPort
  • Add IPv6 --map-guest-addr for forwarding
  • Call PestoAddPorts/PestoDeletePorts from netavark Setup/Teardown
  • Skip netavark DNAT rules when pesto mode is active

Fixes: podman-container-tools/podman#28769
Fixes: podman-container-tools/podman#28770
Fixes: podman-container-tools/podman#28771

@github-actions github-actions Bot added the common Related to "common" package label Jul 21, 2026
@Honny1
Honny1 force-pushed the passta-and-pessto branch 2 times, most recently from c17020c to 5b996c5 Compare July 21, 2026 13:31
@Honny1
Honny1 marked this pull request as ready for review July 21, 2026 13:52
@Honny1
Honny1 force-pushed the passta-and-pessto branch from 5b996c5 to 1b2918e Compare July 21, 2026 14:57
Comment thread common/libnetwork/netavark/run.go Outdated
Comment on lines +168 to +169
logrus.Errorf("pesto: reading addr state: %v", err)
return

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.

I feel like it would be better if return an actual error in this function and then in the end just let the caller log it once, that way we can skip the pesto prefix from each log here and just have the prefix once on the caller side.

// firstIPsWithNetwork picks the first IPv4 and IPv6 from the network IPs
// map (sorted by network name), returning the IP and the owning network.
func firstIPsWithNetwork(netIPs map[string]pestoNetworkIPs) (ipv4, ipv4Net, ipv6, ipv6Net string) {
for _, name := range sortedNetworkNames(netIPs) {

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 have a network order more or less given via the input network that are sorted I think we should respect that order and not sort based on the names.

Comment on lines +15 to +19
// pestoAddrState tracks which container IPs are currently used for pesto
// port forwarding. Stored as a per-container JSON file in the rootless
// netns directory so connect/disconnect operations can detect whether
// ports are already published and remap when necessary.
type pestoAddrState struct {

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.

so I am thinking if we can avoid yet another extra way to keep the state here via the josn file, the podman db already carries the network result as state so I feel like adding onto that seems better as we then only store it in one location.

Of course it means we then need to pass the state from the podman db back into the teardown/setup functions but I feel like this could be a bit cleaner?

cc @mheon

Comment thread common/libnetwork/netavark/run.go Outdated
Comment on lines +172 to +175
if state == nil {
// Migration fallback: no state file means this container was set up
// before state tracking existed. Best-effort delete using IPAM IPs.
ipv4, ipv6 := containerIPsFromNetOpts(opts)

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.

I don't think this will gain us anything? The port format has changed so pasta would not consider them to be the same I think?

I guess there is not much do be done, we marked it as experimental so I am fine telling users they need to stop all containers after the update and only then start the new one which should kill and restart pasta to clean out the stale ports. (OR well just let them reboot)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yes, that is leftover after my mistake. I will drop that.

Comment thread common/libnetwork/netavark/run.go Outdated
Comment on lines +304 to +308
// In pesto mode, pasta handles the full forwarding path including target
// address mapping, so netavark doesn't need DNAT rules at all. Clear port
// mappings from the payload to avoid unnecessary iptables/nftables rules.
if n.rootlessPortForwarder == config.RootlessPortForwarderPasta && n.networkRootless {
opts.PortMappings = nil

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.

I would not drop the ports here, a user could still use podman unshare --rootless-netns curl 127.0.0.1:80 for example and that shoudl work. With nftables we batch update all rules anyway so this will not gain us anything noticeably

Comment thread common/libnetwork/pasta/pasta_linux.go Outdated
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
len(mapGuestAddrIPs) == 2 && mapGuestAddrIPs[0] == mapGuestAddrIpv4 && mapGuestAddrIPs[1] == mapGuestAddrIpv6 {

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.

I think pasta has supported --map-guest-addr for long enough now that we can hard depend on it. I would first simplify this by removing the retry code path. And then we do not need to special case this new argument here

@Honny1
Honny1 force-pushed the passta-and-pessto branch 2 times, most recently from abc89b3 to 8aa86af Compare July 23, 2026 15:54
@Honny1
Honny1 requested a review from Luap99 July 23, 2026 16:02
@Honny1
Honny1 force-pushed the passta-and-pessto branch from 8aa86af to c7b86fe Compare July 23, 2026 19:04
@Honny1

Honny1 commented Jul 23, 2026

Copy link
Copy Markdown
Contributor Author

PTAL @Luap99

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

common Related to "common" package

Projects

None yet

Development

Successfully merging this pull request may close these issues.

IPv6 forwarding issues Destination address mapping in pesto Move pesto into libnetwork/netavark Setup()/Teardown()

2 participants