Skip to content

Commit 4e968b8

Browse files
committed
slirp4netns: add stub features and detection for disabled driver
Signed-off-by: fahed dorgaa <[email protected]>
1 parent 14bfe1e commit 4e968b8

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

pkg/network/slirp4netns/slirp4netns_disabled.go

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,33 @@ import (
1414
"github.com/rootless-containers/rootlesskit/v3/pkg/network"
1515
)
1616

17+
// Features is defined to satisfy references from cmd when the slirp4netns
18+
// network driver is disabled via the no_slirp4netns build tag.
19+
// It mirrors the shape of the real Features struct.
20+
type Features struct {
21+
// SupportsEnableIPv6 --enable-ipv6 (v0.2.0)
22+
SupportsEnableIPv6 bool
23+
// SupportsCIDR --cidr (v0.3.0)
24+
SupportsCIDR bool
25+
// SupportsDisableHostLoopback --disable-host-loopback (v0.3.0)
26+
SupportsDisableHostLoopback bool
27+
// SupportsAPISocket --api-socket (v0.3.0)
28+
SupportsAPISocket bool
29+
// SupportsEnableSandbox --enable-sandbox (v0.4.0)
30+
SupportsEnableSandbox bool
31+
// SupportsEnableSeccomp --enable-seccomp (v0.4.0)
32+
SupportsEnableSeccomp bool
33+
// KernelSupportsEnableSeccomp whether the kernel supports slirp4netns --enable-seccomp
34+
KernelSupportsEnableSeccomp bool
35+
}
36+
37+
// DetectFeatures is a stub used when the slirp4netns network driver is
38+
// disabled via the no_slirp4netns build tag. It always returns an error so
39+
// callers can gracefully handle the lack of support at runtime.
40+
func DetectFeatures(binary string) (*Features, error) {
41+
return nil, errors.New("slirp4netns network driver disabled by build tag no_slirp4netns")
42+
}
43+
1744
// NewParentDriver returns a stub when built with the no_slirp4netns tag.
1845
func NewParentDriver(logWriter io.Writer, binary string, mtu int, ipnet *net.IPNet, ifname string, disableHostLoopback bool, apiSocketPath string, enableSandbox bool, enableSeccomp bool, enableIPv6 bool) (network.ParentDriver, error) {
1946
return &disabledParent{}, errors.New("slirp4netns network driver disabled by build tag no_slirp4netns")

0 commit comments

Comments
 (0)