Skip to content

Commit ba7af02

Browse files
committed
pkg/specgen/: Remove slirp
Signed-off-by: Lokesh Mandvekar <[email protected]>
1 parent 5eea11f commit ba7af02

File tree

11 files changed

+13
-88
lines changed

11 files changed

+13
-88
lines changed

pkg/specgen/generate/container.go

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -443,21 +443,6 @@ func ConfigToSpec(rt *libpod.Runtime, specg *specgen.SpecGenerator, containerID
443443
specg.Expose = toExpose
444444
specg.PortMappings = conf.PortMappings
445445
specg.NetNS = specgen.Namespace{NSMode: specgen.Bridge}
446-
case conf.NetMode.IsSlirp4netns():
447-
toExpose := make(map[uint16]string, len(conf.ExposedPorts))
448-
for _, expose := range []map[uint16][]string{conf.ExposedPorts} {
449-
for port, proto := range expose {
450-
toExpose[port] = strings.Join(proto, ",")
451-
}
452-
}
453-
specg.Expose = toExpose
454-
specg.PortMappings = conf.PortMappings
455-
netMode := strings.Split(string(conf.NetMode), ":")
456-
var val string
457-
if len(netMode) > 1 {
458-
val = netMode[1]
459-
}
460-
specg.NetNS = specgen.Namespace{NSMode: specgen.Slirp, Value: val}
461446
case conf.NetMode.IsPrivate():
462447
specg.NetNS = specgen.Namespace{NSMode: specgen.Private}
463448
case conf.NetMode.IsDefault():
@@ -631,7 +616,7 @@ func CheckName(rt *libpod.Runtime, n string, kind bool) string {
631616
// Note: Update `podman run --publish | -p` docs when modifying this function.
632617
func isPortMappingCompatibleNetNSMode(nsMode specgen.NamespaceMode) bool {
633618
switch nsMode {
634-
case specgen.Bridge, specgen.Slirp, specgen.Pasta:
619+
case specgen.Bridge, specgen.Pasta:
635620
return true
636621
default:
637622
return false

pkg/specgen/generate/container_create.go

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ import (
2323
"github.com/sirupsen/logrus"
2424
"go.podman.io/common/libimage"
2525
"go.podman.io/common/libnetwork/pasta"
26-
"go.podman.io/common/libnetwork/slirp4netns"
2726
"tags.cncf.io/container-device-interface/pkg/parser"
2827
)
2928

@@ -203,9 +202,7 @@ func MakeContainer(ctx context.Context, rt *libpod.Runtime, s *specgen.SpecGener
203202
return nil, nil, nil, err
204203
}
205204
switch conf.Network.DefaultRootlessNetworkCmd {
206-
case slirp4netns.BinaryName, "":
207-
s.NetNS.NSMode = specgen.Slirp
208-
case pasta.BinaryName:
205+
case pasta.BinaryName, "":
209206
s.NetNS.NSMode = specgen.Pasta
210207
default:
211208
return nil, nil, nil, fmt.Errorf("invalid default_rootless_network_cmd option %q",

pkg/specgen/generate/namespaces.go

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -322,12 +322,6 @@ func namespaceOptions(s *specgen.SpecGenerator, rt *libpod.Runtime, pod *libpod.
322322
} else {
323323
toReturn = append(toReturn, libpod.WithNetNSFrom(netCtr))
324324
}
325-
case specgen.Slirp:
326-
val := "slirp4netns"
327-
if s.NetNS.Value != "" {
328-
val = fmt.Sprintf("slirp4netns:%s", s.NetNS.Value)
329-
}
330-
toReturn = append(toReturn, libpod.WithNetNS(portMappings, postConfigureNetNS, val, nil))
331325
case specgen.Pasta:
332326
val := "pasta"
333327
toReturn = append(toReturn, libpod.WithNetNS(portMappings, postConfigureNetNS, val, nil))

pkg/specgen/generate/oci_linux.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ func canMountSys(isRootless, isNewUserns bool, s *specgen.SpecGenerator) bool {
5050
}
5151
if isNewUserns {
5252
switch s.NetNS.NSMode {
53-
case specgen.Slirp, specgen.Pasta, specgen.Private, specgen.NoNetwork, specgen.Bridge:
53+
case specgen.Pasta, specgen.Private, specgen.NoNetwork, specgen.Bridge:
5454
return true
5555
default:
5656
return false

pkg/specgen/generate/pod_create.go

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -203,12 +203,6 @@ func MapSpec(p *specgen.PodSpecGenerator) (*specgen.SpecGenerator, error) {
203203
return nil, fmt.Errorf("cannot set host network if network-related configuration is specified: %w", define.ErrInvalidArg)
204204
}
205205
spec.NetNS.NSMode = specgen.Host
206-
case specgen.Slirp:
207-
logrus.Debugf("Pod will use slirp4netns")
208-
if spec.NetNS.NSMode != specgen.Host {
209-
spec.NetworkOptions = p.NetworkOptions
210-
spec.NetNS.NSMode = specgen.Slirp
211-
}
212206
case specgen.Pasta:
213207
logrus.Debugf("Pod will use pasta")
214208
if spec.NetNS.NSMode != specgen.Host {

pkg/specgen/generate/pod_create_test.go

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -132,23 +132,6 @@ func TestMapSpecNetworkOptions(t *testing.T) {
132132
podSpec: createPodSpecWithNetworks(specgen.Host),
133133
mustError: true,
134134
},
135-
{
136-
name: "Slirp",
137-
podSpec: createPodSpec(specgen.Slirp),
138-
expectedNSMode: specgen.Slirp,
139-
},
140-
{
141-
name: "Slirp but if infra spec NS mode is Host",
142-
podSpec: specgen.PodSpecGenerator{
143-
InfraContainerSpec: &specgen.SpecGenerator{
144-
ContainerNetworkConfig: specgen.ContainerNetworkConfig{NetNS: specgen.Namespace{NSMode: host}},
145-
},
146-
PodNetworkConfig: specgen.PodNetworkConfig{
147-
NetNS: specgen.Namespace{NSMode: specgen.Slirp},
148-
},
149-
},
150-
expectedNSMode: specgen.Host,
151-
},
152135
{
153136
name: "Path",
154137
podSpec: createPodSpecWithNetNsPath("/var/run/netns/bla"),

pkg/specgen/namespaces.go

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,6 @@ const (
4949
// should be used.
5050
// Only used with the network namespace, invalid otherwise.
5151
Bridge NamespaceMode = "bridge"
52-
// Slirp indicates that a slirp4netns network stack should
53-
// be used.
54-
// Only used with the network namespace, invalid otherwise.
55-
Slirp NamespaceMode = "slirp4netns"
5652
// Pasta indicates that a pasta network stack should be used.
5753
// Only used with the network namespace, invalid otherwise.
5854
Pasta NamespaceMode = "pasta"
@@ -158,8 +154,6 @@ func validateNetNS(n *Namespace) error {
158154
return nil
159155
}
160156
switch n.NSMode {
161-
case Slirp:
162-
break
163157
case Pasta:
164158
// Check if we run rootless/in a userns. Do not use rootless.IsRootless() here.
165159
// Pasta switches to nobody when running as root which causes it to fail while
@@ -181,7 +175,7 @@ func validateNetNS(n *Namespace) error {
181175
if len(n.Value) < 1 {
182176
return fmt.Errorf("namespace mode %s requires a value", n.NSMode)
183177
}
184-
} else if n.NSMode != Slirp {
178+
} else {
185179
// All others except must NOT set a string value
186180
if len(n.Value) > 0 {
187181
return fmt.Errorf("namespace value %s cannot be provided with namespace mode %s", n.Value, n.NSMode)
@@ -211,7 +205,7 @@ func (n *Namespace) validate() error {
211205
switch n.NSMode {
212206
case "", Default, Host, Path, FromContainer, FromPod, Private:
213207
// Valid, do nothing
214-
case NoNetwork, Bridge, Slirp, Pasta:
208+
case NoNetwork, Bridge, Pasta:
215209
return errors.New("cannot use network modes with non-network namespace")
216210
default:
217211
return fmt.Errorf("invalid namespace type %s specified", n.NSMode)
@@ -337,13 +331,6 @@ func ParseNetworkFlag(networks []string) (Namespace, map[string]types.PerNetwork
337331
podmanNetworks := make(map[string]types.PerNetworkOptions)
338332

339333
switch {
340-
case ns == string(Slirp), strings.HasPrefix(ns, string(Slirp)+":"):
341-
key, options, hasOptions := strings.Cut(ns, ":")
342-
if hasOptions {
343-
networkOptions = make(map[string][]string)
344-
networkOptions[key] = strings.Split(options, ",")
345-
}
346-
toReturn.NSMode = Slirp
347334
case ns == string(FromPod):
348335
toReturn.NSMode = FromPod
349336
case ns == "" || ns == string(Default) || ns == string(Private):
@@ -416,7 +403,7 @@ func ParseNetworkFlag(networks []string) (Namespace, map[string]types.PerNetwork
416403
return toReturn, nil, nil, fmt.Errorf("network name cannot be empty: %w", define.ErrInvalidArg)
417404
}
418405
if slices.Contains([]string{
419-
string(Bridge), string(Slirp), string(Pasta), string(FromPod), string(NoNetwork),
406+
string(Bridge), string(Pasta), string(FromPod), string(NoNetwork),
420407
string(Default), string(Private), string(Path), string(FromContainer), string(Host),
421408
}, name) {
422409
return toReturn, nil, nil, fmt.Errorf("can only set extra network names, selected mode %s conflicts with bridge: %w", name, define.ErrInvalidArg)

pkg/specgen/namespaces_test.go

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -57,12 +57,6 @@ func TestParseNetworkFlag(t *testing.T) {
5757
defaultNetName: {},
5858
},
5959
},
60-
{
61-
name: "slirp4netns mode",
62-
args: []string{"slirp4netns"},
63-
nsmode: Namespace{NSMode: Slirp},
64-
networks: map[string]types.PerNetworkOptions{},
65-
},
6660
{
6761
name: "from pod mode",
6862
args: []string{"pod"},
@@ -87,15 +81,6 @@ func TestParseNetworkFlag(t *testing.T) {
8781
nsmode: Namespace{NSMode: Path, Value: "/path"},
8882
networks: map[string]types.PerNetworkOptions{},
8983
},
90-
{
91-
name: "slirp4netns mode with options",
92-
args: []string{"slirp4netns:cidr=10.0.0.0/24"},
93-
nsmode: Namespace{NSMode: Slirp},
94-
networks: map[string]types.PerNetworkOptions{},
95-
options: map[string][]string{
96-
"slirp4netns": {"cidr=10.0.0.0/24"},
97-
},
98-
},
9984
{
10085
name: "bridge mode with options 1",
10186
args: []string{"bridge:ip=10.0.0.1,mac=11:22:33:44:55:66"},

pkg/specgen/pod_validate.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,9 @@ func (p *PodSpecGenerator) Validate() error {
6464
return exclusivePodOptions("NoInfra", "NoManageResolvConf")
6565
}
6666
}
67-
if p.NetNS.NSMode != "" && p.NetNS.NSMode != Bridge && p.NetNS.NSMode != Slirp && p.NetNS.NSMode != Pasta && p.NetNS.NSMode != Default {
67+
if p.NetNS.NSMode != "" && p.NetNS.NSMode != Bridge && p.NetNS.NSMode != Pasta && p.NetNS.NSMode != Default {
6868
if len(p.PortMappings) > 0 {
69-
return errors.New("PortMappings can only be used with Bridge, slirp4netns, or pasta networking")
69+
return errors.New("PortMappings can only be used with Bridge, or pasta networking")
7070
}
7171
}
7272

pkg/specgen/podspecgen.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,13 +106,13 @@ type PodNetworkConfig struct {
106106
// containers in the pod.
107107
// Cannot be set to FromContainer and FromPod.
108108
// Setting this to anything except default conflicts with NoInfra=true.
109-
// Defaults to Bridge as root and Slirp as rootless.
109+
// Defaults to Bridge as root and Pasta as rootless.
110110
// Mandatory.
111111
NetNS Namespace `json:"netns"`
112112
// PortMappings is a set of ports to map into the infra container.
113113
// As, by default, containers share their network with the infra
114114
// container, this will forward the ports to the entire pod.
115-
// Only available if NetNS is set to Bridge, Slirp, or Pasta.
115+
// Only available if NetNS is set to Bridge, or Pasta.
116116
// Optional.
117117
PortMappings []types.PortMapping `json:"portmappings,omitempty"`
118118
// Map of networks names to ids the container should join to.

0 commit comments

Comments
 (0)