-
Notifications
You must be signed in to change notification settings - Fork 109
Build tags omit network drivers #533
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
fahedouch
wants to merge
1
commit into
rootless-containers:master
Choose a base branch
from
fahedouch:build-tags-omit-network-drivers
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| # Building RootlessKit | ||
|
|
||
| This document describes build-time options, including Go build tags for omitting certain network and port drivers. | ||
|
|
||
| ## Build tags to omit drivers | ||
|
|
||
| To exclude specific drivers at compilation time, use Go build tags: | ||
|
|
||
| - Tag `no_vpnkit`: omits the VPNKit network driver implementation. | ||
| - Tag `no_gvisortapvsock`: omits the gvisor-tap-vsock network driver implementation and its port driver. | ||
| - Tag `no_slirp4netns`: omits the slirp4netns network driver implementation and its port driver. | ||
| - Tag `no_lxcusernic`: omits the lxc-user-nic network driver implementation. | ||
|
|
||
| Example: | ||
|
|
||
| - Build without VPNKit support: | ||
| go build -tags no_vpnkit ./cmd/rootlesskit | ||
|
|
||
| Notes: | ||
| - If a disabled driver is selected at runtime (e.g., `--net=vpnkit` when built with `-tags no_vpnkit`), RootlessKit returns an error indicating that the driver was disabled at build time. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,48 @@ | ||
| //go:build no_gvisortapvsock | ||
| // +build no_gvisortapvsock | ||
|
|
||
| package gvisortapvsock | ||
|
|
||
| import ( | ||
| "context" | ||
| "errors" | ||
| "io" | ||
| "net" | ||
|
|
||
| "github.com/rootless-containers/rootlesskit/v3/pkg/api" | ||
| "github.com/rootless-containers/rootlesskit/v3/pkg/messages" | ||
| "github.com/rootless-containers/rootlesskit/v3/pkg/network" | ||
| ) | ||
|
|
||
| // NewParentDriver returns a stub when built with the no_gvisortapvsock tag. | ||
| func NewParentDriver(logWriter io.Writer, mtu int, ipnet *net.IPNet, ifname string, disableHostLoopback bool, enableIPv6 bool) (network.ParentDriver, error) { | ||
| return &disabledParent{}, errors.New("gvisor-tap-vsock network driver disabled by build tag no_gvisortapvsock") | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Omitted drivers should not appear in
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. fixed |
||
| } | ||
|
|
||
| type disabledParent struct{} | ||
|
|
||
| func (d *disabledParent) Info(ctx context.Context) (*api.NetworkDriverInfo, error) { | ||
| return nil, errors.New("gvisor-tap-vsock network driver disabled by build tag no_gvisortapvsock") | ||
| } | ||
|
|
||
| func (d *disabledParent) MTU() int { return 0 } | ||
|
|
||
| func (d *disabledParent) ConfigureNetwork(childPID int, stateDir string, detachedNetNSPath string) (*messages.ParentInitNetworkDriverCompleted, func() error, error) { | ||
| return nil, func() error { return nil }, errors.New("gvisor-tap-vsock network driver disabled by build tag no_gvisortapvsock") | ||
| } | ||
|
|
||
| // NewChildDriver returns a stub when built with the no_gvisortapvsock tag. | ||
| func NewChildDriver() network.ChildDriver { return &disabledChild{} } | ||
|
|
||
| type disabledChild struct{} | ||
|
|
||
| func (d *disabledChild) ChildDriverInfo() (*network.ChildDriverInfo, error) { | ||
| return &network.ChildDriverInfo{ConfiguresInterface: false}, nil | ||
| } | ||
|
|
||
| func (d *disabledChild) ConfigureNetworkChild(netmsg *messages.ParentInitNetworkDriverCompleted, detachedNetNSPath string) (string, error) { | ||
| return "", errors.New("gvisor-tap-vsock network driver disabled by build tag no_gvisortapvsock") | ||
| } | ||
|
|
||
| // Available indicates whether this driver is compiled in (used for generating help text) | ||
| const Available = false | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,46 @@ | ||
| //go:build no_lxcusernic | ||
| // +build no_lxcusernic | ||
|
|
||
| package lxcusernic | ||
|
|
||
| import ( | ||
| "context" | ||
| "errors" | ||
|
|
||
| "github.com/rootless-containers/rootlesskit/v3/pkg/api" | ||
| "github.com/rootless-containers/rootlesskit/v3/pkg/messages" | ||
| "github.com/rootless-containers/rootlesskit/v3/pkg/network" | ||
| ) | ||
|
|
||
| // NewParentDriver returns a stub when built with the no_lxcusernic tag. | ||
| func NewParentDriver(binary string, mtu int, bridge string, ifname string) (network.ParentDriver, error) { | ||
| return &disabledParent{}, errors.New("lxc-user-nic network driver disabled by build tag no_lxcusernic") | ||
| } | ||
|
|
||
| type disabledParent struct{} | ||
|
|
||
| func (d *disabledParent) Info(ctx context.Context) (*api.NetworkDriverInfo, error) { | ||
| return nil, errors.New("lxc-user-nic network driver disabled by build tag no_lxcusernic") | ||
| } | ||
|
|
||
| func (d *disabledParent) MTU() int { return 0 } | ||
|
|
||
| func (d *disabledParent) ConfigureNetwork(childPID int, stateDir string, detachedNetNSPath string) (*messages.ParentInitNetworkDriverCompleted, func() error, error) { | ||
| return nil, func() error { return nil }, errors.New("lxc-user-nic network driver disabled by build tag no_lxcusernic") | ||
| } | ||
|
|
||
| // NewChildDriver returns a stub when built with the no_lxcusernic tag. | ||
| func NewChildDriver() network.ChildDriver { return &disabledChild{} } | ||
|
|
||
| type disabledChild struct{} | ||
|
|
||
| func (d *disabledChild) ChildDriverInfo() (*network.ChildDriverInfo, error) { | ||
| return &network.ChildDriverInfo{ConfiguresInterface: false}, nil | ||
| } | ||
|
|
||
| func (d *disabledChild) ConfigureNetworkChild(netmsg *messages.ParentInitNetworkDriverCompleted, detachedNetNSPath string) (string, error) { | ||
| return "", errors.New("lxc-user-nic network driver disabled by build tag no_lxcusernic") | ||
| } | ||
|
|
||
| // Available indicates whether this driver is compiled in (used for generating help text) | ||
| const Available = false |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,75 @@ | ||
| //go:build no_slirp4netns | ||
| // +build no_slirp4netns | ||
|
|
||
| package slirp4netns | ||
|
|
||
| import ( | ||
| "context" | ||
| "errors" | ||
| "io" | ||
| "net" | ||
|
|
||
| "github.com/rootless-containers/rootlesskit/v3/pkg/api" | ||
| "github.com/rootless-containers/rootlesskit/v3/pkg/messages" | ||
| "github.com/rootless-containers/rootlesskit/v3/pkg/network" | ||
| ) | ||
|
|
||
| // Features is defined to satisfy references from cmd when the slirp4netns | ||
| // network driver is disabled via the no_slirp4netns build tag. | ||
| // It mirrors the shape of the real Features struct. | ||
| type Features struct { | ||
| // SupportsEnableIPv6 --enable-ipv6 (v0.2.0) | ||
| SupportsEnableIPv6 bool | ||
| // SupportsCIDR --cidr (v0.3.0) | ||
| SupportsCIDR bool | ||
| // SupportsDisableHostLoopback --disable-host-loopback (v0.3.0) | ||
| SupportsDisableHostLoopback bool | ||
| // SupportsAPISocket --api-socket (v0.3.0) | ||
| SupportsAPISocket bool | ||
| // SupportsEnableSandbox --enable-sandbox (v0.4.0) | ||
| SupportsEnableSandbox bool | ||
| // SupportsEnableSeccomp --enable-seccomp (v0.4.0) | ||
| SupportsEnableSeccomp bool | ||
| // KernelSupportsEnableSeccomp whether the kernel supports slirp4netns --enable-seccomp | ||
| KernelSupportsEnableSeccomp bool | ||
| } | ||
|
|
||
| // DetectFeatures is a stub used when the slirp4netns network driver is | ||
| // disabled via the no_slirp4netns build tag. It always returns an error so | ||
| // callers can gracefully handle the lack of support at runtime. | ||
| func DetectFeatures(binary string) (*Features, error) { | ||
| return nil, errors.New("slirp4netns network driver disabled by build tag no_slirp4netns") | ||
| } | ||
|
|
||
| // NewParentDriver returns a stub when built with the no_slirp4netns tag. | ||
| 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) { | ||
| return &disabledParent{}, errors.New("slirp4netns network driver disabled by build tag no_slirp4netns") | ||
| } | ||
|
|
||
| type disabledParent struct{} | ||
|
|
||
| func (d *disabledParent) Info(ctx context.Context) (*api.NetworkDriverInfo, error) { | ||
| return nil, errors.New("slirp4netns network driver disabled by build tag no_slirp4netns") | ||
| } | ||
|
|
||
| func (d *disabledParent) MTU() int { return 0 } | ||
|
|
||
| func (d *disabledParent) ConfigureNetwork(childPID int, stateDir string, detachedNetNSPath string) (*messages.ParentInitNetworkDriverCompleted, func() error, error) { | ||
| return nil, func() error { return nil }, errors.New("slirp4netns network driver disabled by build tag no_slirp4netns") | ||
| } | ||
|
|
||
| // NewChildDriver returns a stub when built with the no_slirp4netns tag. | ||
| func NewChildDriver() network.ChildDriver { return &disabledChild{} } | ||
|
|
||
| type disabledChild struct{} | ||
|
|
||
| func (d *disabledChild) ChildDriverInfo() (*network.ChildDriverInfo, error) { | ||
| return &network.ChildDriverInfo{ConfiguresInterface: false}, nil | ||
| } | ||
|
|
||
| func (d *disabledChild) ConfigureNetworkChild(netmsg *messages.ParentInitNetworkDriverCompleted, detachedNetNSPath string) (string, error) { | ||
| return "", errors.New("slirp4netns network driver disabled by build tag no_slirp4netns") | ||
| } | ||
|
|
||
| // Available indicates whether this driver is compiled in (used for generating help text) | ||
| const Available = false |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,46 @@ | ||
| //go:build no_vpnkit | ||
| // +build no_vpnkit | ||
|
|
||
| package vpnkit | ||
|
|
||
| import ( | ||
| "context" | ||
| "errors" | ||
|
|
||
| "github.com/rootless-containers/rootlesskit/v3/pkg/api" | ||
| "github.com/rootless-containers/rootlesskit/v3/pkg/messages" | ||
| "github.com/rootless-containers/rootlesskit/v3/pkg/network" | ||
| ) | ||
|
|
||
| // NewParentDriver returns a stub when built with the no_vpnkit tag. | ||
| func NewParentDriver(binary string, mtu int, ifname string, disableHostLoopback bool) network.ParentDriver { | ||
| return &disabledParent{} | ||
| } | ||
|
|
||
| type disabledParent struct{} | ||
|
|
||
| func (d *disabledParent) Info(ctx context.Context) (*api.NetworkDriverInfo, error) { | ||
| return nil, errors.New("vpnkit network driver disabled by build tag no_vpnkit") | ||
| } | ||
|
|
||
| func (d *disabledParent) MTU() int { return 0 } | ||
|
|
||
| func (d *disabledParent) ConfigureNetwork(childPID int, stateDir, detachedNetNSPath string) (*messages.ParentInitNetworkDriverCompleted, func() error, error) { | ||
| return nil, func() error { return nil }, errors.New("vpnkit network driver disabled by build tag no_vpnkit") | ||
| } | ||
|
|
||
| // NewChildDriver returns a stub when built with the no_vpnkit tag. | ||
| func NewChildDriver() network.ChildDriver { return &disabledChild{} } | ||
|
|
||
| type disabledChild struct{} | ||
|
|
||
| func (d *disabledChild) ChildDriverInfo() (*network.ChildDriverInfo, error) { | ||
| return &network.ChildDriverInfo{ConfiguresInterface: false}, nil | ||
| } | ||
|
|
||
| func (d *disabledChild) ConfigureNetworkChild(netmsg *messages.ParentInitNetworkDriverCompleted, detachedNetNSPath string) (string, error) { | ||
| return "", errors.New("vpnkit network driver disabled by build tag no_vpnkit") | ||
| } | ||
|
|
||
| // Available indicates whether this driver is compiled in (used for generating help text) | ||
| const Available = false |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be probably in
/BUILDING.mdThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed