Skip to content

Commit

Permalink
podman: Add binary file from helper_binaries_dir to find slirp4netns
Browse files Browse the repository at this point in the history
[NO NEW TESTS NEEDED]

Fixes: containers#18568

Signed-off-by: binghongtao <[email protected]>
  • Loading branch information
HirazawaUi committed May 18, 2023
1 parent abea786 commit a4428ea
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
3 changes: 1 addition & 2 deletions libpod/info_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"fmt"
"math"
"os"
"os/exec"
"strconv"
"strings"

Expand Down Expand Up @@ -57,7 +56,7 @@ func (r *Runtime) setPlatformHostInfo(info *define.HostInfo) error {

slirp4netnsPath := r.config.Engine.NetworkCmdPath
if slirp4netnsPath == "" {
slirp4netnsPath, _ = exec.LookPath("slirp4netns")
slirp4netnsPath, _ = r.config.FindHelperBinary(slirp4netnsBinaryName, true)
}
if slirp4netnsPath != "" {
version, err := programVersion(slirp4netnsPath)
Expand Down
2 changes: 1 addition & 1 deletion libpod/networking_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,7 @@ func (r *Runtime) GetRootlessNetNs(new bool) (*RootlessNetNS, error) {
path := r.config.Engine.NetworkCmdPath
if path == "" {
var err error
path, err = exec.LookPath("slirp4netns")
path, err = r.config.FindHelperBinary(slirp4netnsBinaryName, true)
if err != nil {
return nil, err
}
Expand Down
9 changes: 6 additions & 3 deletions libpod/networking_slirp4netns.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,10 @@ type slirp4netnsNetworkOptions struct {
outboundAddr6 string
}

const ipv6ConfDefaultAcceptDadSysctl = "/proc/sys/net/ipv6/conf/default/accept_dad"
const (
ipv6ConfDefaultAcceptDadSysctl = "/proc/sys/net/ipv6/conf/default/accept_dad"
slirp4netnsBinaryName = "slirp4netns"
)

func checkSlirpFlags(path string) (*slirpFeatures, error) {
cmd := exec.Command(path, "--help")
Expand Down Expand Up @@ -216,7 +219,7 @@ func (r *Runtime) setupSlirp4netns(ctr *Container, netns string) error {
path := r.config.Engine.NetworkCmdPath
if path == "" {
var err error
path, err = exec.LookPath("slirp4netns")
path, err = r.config.FindHelperBinary(slirp4netnsBinaryName, true)
if err != nil {
return fmt.Errorf("could not find slirp4netns, the network namespace can't be configured: %w", err)
}
Expand All @@ -234,7 +237,7 @@ func (r *Runtime) setupSlirp4netns(ctr *Container, netns string) error {

ctrNetworkSlipOpts := []string{}
if ctr.config.NetworkOptions != nil {
ctrNetworkSlipOpts = append(ctrNetworkSlipOpts, ctr.config.NetworkOptions["slirp4netns"]...)
ctrNetworkSlipOpts = append(ctrNetworkSlipOpts, ctr.config.NetworkOptions[slirp4netnsBinaryName]...)
}
netOptions, err := parseSlirp4netnsNetworkOptions(r, ctrNetworkSlipOpts)
if err != nil {
Expand Down

0 comments on commit a4428ea

Please sign in to comment.