File: run_freebsd.go

package info (click to toggle)
golang-github-containers-common 0.56.0%2Bds1-4
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 4,852 kB
  • sloc: makefile: 126; sh: 62
file content (19 lines) | stat: -rw-r--r-- 621 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
package cni

import (
	"os/exec"
)

// FreeBSD vnet adds the lo0 interface automatically - we just need to
// add the default address. Note: this will also add ::1 as a side
// effect.
func setupLoopback(namespacePath string) error {
	// Try to run the command using ifconfig's -j flag (supported in 13.3 and later)
	if err := exec.Command("ifconfig", "-j", namespacePath, "lo0", "inet", "127.0.0.1").Run(); err == nil {
		return nil
	}

	// Fall back to using the jexec wrapper to run the ifconfig command
	// inside the jail.
	return exec.Command("jexec", namespacePath, "ifconfig", "lo0", "inet", "127.0.0.1").Run()
}