Skip to content

Commit 2c435a0

Browse files
committed
libpod/: Remove slirp
Signed-off-by: Lokesh Mandvekar <[email protected]>
1 parent ba7af02 commit 2c435a0

14 files changed

+11
-178
lines changed

cmd/podman/system/service_abi.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,6 @@ func restService(flags *pflag.FlagSet, cfg *entities.PodmanConfig, opts entities
125125

126126
maybeMoveToSubCgroup()
127127

128-
maybeStartServiceReaper()
129128
infra.StartWatcher(libpodRuntime)
130129
server, err := api.NewServerWithSettings(libpodRuntime, listener, opts)
131130
if err != nil {

cmd/podman/system/service_abi_linux.go

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,8 @@ package system
55
import (
66
"github.com/sirupsen/logrus"
77
"go.podman.io/common/pkg/cgroups"
8-
"go.podman.io/common/pkg/servicereaper"
98
)
109

11-
// Currently, we only need servicereaper on Linux to support slirp4netns.
12-
func maybeStartServiceReaper() {
13-
servicereaper.Start()
14-
}
15-
1610
func maybeMoveToSubCgroup() {
1711
if err := cgroups.MaybeMoveToSubCgroup(); err != nil {
1812
// it is a best effort operation, so just print the

libpod/container.go

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -107,9 +107,6 @@ type Container struct {
107107
runtime *Runtime
108108
ociRuntime OCIRuntime
109109

110-
rootlessSlirpSyncR *os.File
111-
rootlessSlirpSyncW *os.File
112-
113110
rootlessPortSyncR *os.File
114111
rootlessPortSyncW *os.File
115112

@@ -126,8 +123,7 @@ type Container struct {
126123
// This is true if a container is restored from a checkpoint.
127124
restoreFromCheckpoint bool
128125

129-
slirp4netnsSubnet *net.IPNet
130-
pastaResult *pasta.SetupResult
126+
pastaResult *pasta.SetupResult
131127
}
132128

133129
// ContainerState contains the current state of the container

libpod/container_api.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -928,7 +928,7 @@ func (c *Container) Sync() error {
928928
// reloaded, and existing rules have been wiped out. It is expected that some
929929
// downtime will result, as the rules are destroyed as part of this process.
930930
// At present, this only works on root containers; it may be expanded to restart
931-
// slirp4netns in the future to work with rootless containers as well.
931+
// pasta(?) in the future to work with rootless containers as well.
932932
// Requires that the container must be running or created.
933933
func (c *Container) ReloadNetwork() error {
934934
if !c.batched {

libpod/container_internal_common.go

Lines changed: 5 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2262,7 +2262,7 @@ func (c *Container) addResolvConf() error {
22622262
// add the nameservers from the networks status
22632263
nameservers = networkNameServers
22642264
} else {
2265-
// pasta and slirp4netns have a built in DNS forwarder.
2265+
// pasta has a built in DNS forwarder.
22662266
nameservers = c.addSpecialDNS(nameservers)
22672267
}
22682268
}
@@ -2318,11 +2318,7 @@ func (c *Container) checkForIPv6(netStatus map[string]types.StatusBlock) bool {
23182318
}
23192319
}
23202320

2321-
if c.pastaResult != nil {
2322-
return c.pastaResult.IPv6
2323-
}
2324-
2325-
return c.isSlirp4netnsIPv6()
2321+
return c.pastaResult.IPv6
23262322
}
23272323

23282324
// Add a new nameserver to the container's resolv.conf, ensuring that it is the
@@ -2373,7 +2369,7 @@ func getLocalhostHostEntry(c *Container) etchosts.HostEntries {
23732369
}
23742370

23752371
// getHostsEntries returns the container ip host entries for the correct netmode
2376-
func (c *Container) getHostsEntries() (etchosts.HostEntries, error) {
2372+
func (c *Container) getHostsEntries() etchosts.HostEntries {
23772373
var entries etchosts.HostEntries
23782374
names := []string{c.Hostname(), c.config.Name}
23792375
switch {
@@ -2384,18 +2380,12 @@ func (c *Container) getHostsEntries() (etchosts.HostEntries, error) {
23842380
if len(c.pastaResult.IPAddresses) > 0 {
23852381
entries = etchosts.HostEntries{{IP: c.pastaResult.IPAddresses[0].String(), Names: names}}
23862382
}
2387-
case c.config.NetMode.IsSlirp4netns():
2388-
ip, err := getSlirp4netnsIP(c.slirp4netnsSubnet)
2389-
if err != nil {
2390-
return nil, err
2391-
}
2392-
entries = etchosts.HostEntries{{IP: ip.String(), Names: names}}
23932383
default:
23942384
if c.hasNetNone() {
23952385
entries = etchosts.HostEntries{{IP: "127.0.0.1", Names: names}}
23962386
}
23972387
}
2398-
return entries, nil
2388+
return entries
23992389
}
24002390

24012391
func (c *Container) createHostsFile() error {
@@ -2414,10 +2404,7 @@ func (c *Container) addHosts() error {
24142404
// no host file nothing to do
24152405
return nil
24162406
}
2417-
containerIPsEntries, err := c.getHostsEntries()
2418-
if err != nil {
2419-
return fmt.Errorf("failed to get container ip host entries: %w", err)
2420-
}
2407+
containerIPsEntries := c.getHostsEntries()
24212408

24222409
// Consider container level BaseHostsFile configuration first.
24232410
// If it is empty, fallback to containers.conf level configuration.

libpod/container_internal_freebsd.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -296,10 +296,6 @@ func (c *Container) addSpecialDNS(nameservers []string) []string {
296296
return nameservers
297297
}
298298

299-
func (c *Container) isSlirp4netnsIPv6() bool {
300-
return false
301-
}
302-
303299
// check for net=none
304300
func (c *Container) hasNetNone() bool {
305301
return c.state.NetNS == ""

libpod/container_internal_linux.go

Lines changed: 1 addition & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ import (
2222
"github.com/opencontainers/runtime-tools/generate"
2323
"github.com/opencontainers/selinux/go-selinux/label"
2424
"github.com/sirupsen/logrus"
25-
"go.podman.io/common/libnetwork/slirp4netns"
2625
"go.podman.io/common/libnetwork/types"
2726
"go.podman.io/common/pkg/cgroups"
2827
"go.podman.io/common/pkg/config"
@@ -557,7 +556,7 @@ func (c *Container) setCgroupsPath(g *generate.Generator) error {
557556
return nil
558557
}
559558

560-
// addSpecialDNS adds special dns servers for slirp4netns and pasta
559+
// addSpecialDNS adds special dns servers for pasta
561560
func (c *Container) addSpecialDNS(nameservers []string) []string {
562561
switch {
563562
case c.config.NetMode.IsBridge():
@@ -567,42 +566,10 @@ func (c *Container) addSpecialDNS(nameservers []string) []string {
567566
}
568567
case c.pastaResult != nil:
569568
nameservers = append(nameservers, c.pastaResult.DNSForwardIPs...)
570-
case c.config.NetMode.IsSlirp4netns():
571-
// slirp4netns has a built in DNS forwarder.
572-
slirp4netnsDNS, err := slirp4netns.GetDNS(c.slirp4netnsSubnet)
573-
if err != nil {
574-
logrus.Warn("Failed to determine Slirp4netns DNS: ", err.Error())
575-
} else {
576-
nameservers = append(nameservers, slirp4netnsDNS.String())
577-
}
578569
}
579570
return nameservers
580571
}
581572

582-
func (c *Container) isSlirp4netnsIPv6() bool {
583-
if c.config.NetMode.IsSlirp4netns() {
584-
extraOptions := c.config.NetworkOptions[slirp4netns.BinaryName]
585-
options := make([]string, 0, len(c.runtime.config.Engine.NetworkCmdOptions.Get())+len(extraOptions))
586-
options = append(options, c.runtime.config.Engine.NetworkCmdOptions.Get()...)
587-
options = append(options, extraOptions...)
588-
589-
// loop backwards as the last argument wins and we can exit early
590-
// This should be kept in sync with c/common/libnetwork/slirp4netns.
591-
for i := len(options) - 1; i >= 0; i-- {
592-
switch options[i] {
593-
case "enable_ipv6=true":
594-
return true
595-
case "enable_ipv6=false":
596-
return false
597-
}
598-
}
599-
// default is true
600-
return true
601-
}
602-
603-
return false
604-
}
605-
606573
// check for net=none
607574
func (c *Container) hasNetNone() bool {
608575
if !c.config.CreateNetNS {

libpod/define/info.go

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -52,13 +52,12 @@ type HostInfo struct {
5252
OS string `json:"os"`
5353
// RemoteSocket returns the UNIX domain socket the Podman service is listening on
5454
RemoteSocket *RemoteSocket `json:"remoteSocket,omitempty"`
55-
// RootlessNetworkCmd returns the default rootless network command (slirp4netns or pasta)
55+
// RootlessNetworkCmd returns the default rootless network command (pasta)
5656
RootlessNetworkCmd string `json:"rootlessNetworkCmd"`
5757
RuntimeInfo map[string]any `json:"runtimeInfo,omitempty"`
5858
// ServiceIsRemote is true when the podman/libpod service is remote to the client
5959
ServiceIsRemote bool `json:"serviceIsRemote"`
6060
Security SecurityInfo `json:"security"`
61-
Slirp4NetNS SlirpInfo `json:"slirp4netns"`
6261
Pasta PastaInfo `json:"pasta"`
6362

6463
SwapFree int64 `json:"swapFree"`
@@ -76,13 +75,6 @@ type RemoteSocket struct {
7675
Exists bool `json:"exists"`
7776
}
7877

79-
// SlirpInfo describes the slirp executable that is being used
80-
type SlirpInfo struct {
81-
Executable string `json:"executable"`
82-
Package string `json:"package"`
83-
Version string `json:"version"`
84-
}
85-
8678
// PastaInfo describes the pasta executable that is being used
8779
type PastaInfo struct {
8880
Executable string `json:"executable"`

libpod/info_linux.go

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ import (
1616
"github.com/opencontainers/selinux/go-selinux"
1717
"github.com/sirupsen/logrus"
1818
"go.podman.io/common/libnetwork/pasta"
19-
"go.podman.io/common/libnetwork/slirp4netns"
2019
"go.podman.io/common/pkg/apparmor"
2120
"go.podman.io/common/pkg/cgroups"
2221
"go.podman.io/common/pkg/seccomp"
@@ -49,27 +48,9 @@ func (r *Runtime) setPlatformHostInfo(info *define.HostInfo) error {
4948
SECCOMPProfilePath: seccompProfilePath,
5049
SELinuxEnabled: selinux.GetEnabled(),
5150
}
52-
info.Slirp4NetNS = define.SlirpInfo{}
5351

5452
info.CgroupsVersion = "v2"
5553

56-
slirp4netnsPath := r.config.Engine.NetworkCmdPath
57-
if slirp4netnsPath == "" {
58-
slirp4netnsPath, _ = r.config.FindHelperBinary(slirp4netns.BinaryName, true)
59-
}
60-
if slirp4netnsPath != "" {
61-
ver, err := version.Program(slirp4netnsPath)
62-
if err != nil {
63-
logrus.Warnf("Failed to retrieve program version for %s: %v", slirp4netnsPath, err)
64-
}
65-
program := define.SlirpInfo{
66-
Executable: slirp4netnsPath,
67-
Package: version.Package(slirp4netnsPath),
68-
Version: ver,
69-
}
70-
info.Slirp4NetNS = program
71-
}
72-
7354
pastaPath, _ := r.config.FindHelperBinary(pasta.BinaryName, true)
7455
if pastaPath != "" {
7556
ver, err := version.Program(pastaPath)

libpod/networking_common.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -111,8 +111,7 @@ func (r *Runtime) teardownNetwork(ctr *Container) error {
111111
return err
112112
}
113113

114-
if !ctr.config.NetMode.IsSlirp4netns() &&
115-
!ctr.config.NetMode.IsPasta() && len(networks) > 0 {
114+
if !ctr.config.NetMode.IsPasta() && len(networks) > 0 {
116115
netOpts := ctr.getNetworkOptions(networks)
117116
return r.teardownNetworkBackend(ctr.state.NetNS, netOpts)
118117
}
@@ -134,7 +133,7 @@ func isBridgeNetMode(n namespaces.NetworkMode) error {
134133
// firewall configuration.
135134
// Efforts will be made to preserve MAC and IP addresses.
136135
// Only works on containers with bridge networking at present, though in the future we could
137-
// extend this to stop + restart slirp4netns
136+
// extend this to stop + restart pasta (?)
138137
func (r *Runtime) reloadContainerNetwork(ctr *Container) (map[string]types.StatusBlock, error) {
139138
if ctr.state.NetNS == "" {
140139
return nil, fmt.Errorf("container %s network is not configured, refusing to reload: %w", ctr.ID(), define.ErrCtrStateInvalid)

0 commit comments

Comments
 (0)