diff options
Diffstat (limited to 'pkg')
-rw-r--r-- | pkg/domain/entities/types.go | 2 | ||||
-rw-r--r-- | pkg/namespaces/namespaces.go | 24 | ||||
-rw-r--r-- | pkg/specgen/generate/namespaces.go | 5 | ||||
-rw-r--r-- | pkg/specgen/namespaces.go | 14 | ||||
-rw-r--r-- | pkg/specgen/specgen.go | 3 |
5 files changed, 9 insertions, 39 deletions
diff --git a/pkg/domain/entities/types.go b/pkg/domain/entities/types.go index 7e910ff61..b313e5f8b 100644 --- a/pkg/domain/entities/types.go +++ b/pkg/domain/entities/types.go @@ -42,6 +42,8 @@ type NetOptions struct { PublishPorts []specgen.PortMapping StaticIP *net.IP StaticMAC *net.HardwareAddr + // NetworkOptions are additional options for each network + NetworkOptions map[string][]string } // All CLI inspect commands and inspect sub-commands use the same options diff --git a/pkg/namespaces/namespaces.go b/pkg/namespaces/namespaces.go index b4ec04699..7831af8f9 100644 --- a/pkg/namespaces/namespaces.go +++ b/pkg/namespaces/namespaces.go @@ -17,9 +17,7 @@ const ( nsType = "ns" podType = "pod" privateType = "private" - rlkFwdType = "port_handler=rootlesskit" shareableType = "shareable" - slirpFwdType = "port_handler=slirp4netns" slirpType = "slirp4netns" ) @@ -390,28 +388,6 @@ func (n NetworkMode) IsSlirp4netns() bool { return n == slirpType || strings.HasPrefix(string(n), slirpType+":") } -// IsPortForwardViaRootlessKit indicates if we are doing rootless port-forwarding via rootlesskit/rootlessport -func (n NetworkMode) IsPortForwardViaRootlessKit() bool { - if !n.IsSlirp4netns() { - return false - } - parts := strings.SplitN(string(n), ":", 2) - if len(parts) == 2 { - return parts[1] == rlkFwdType - } - return true -} - -// IsPortForwardViaSlirpHostFwd indicates if we are doing rootless port-forwarding via slirp4netns add_hostfwd() -func (n NetworkMode) IsPortForwardViaSlirpHostFwd() bool { - if !n.IsSlirp4netns() { - return false - } - // below here, implied IsSlirp4netns() == true - parts := strings.SplitN(string(n), ":", 2) - return len(parts) > 1 && parts[1] == slirpFwdType -} - // IsNS indicates a network namespace passed in by path (ns:<path>) func (n NetworkMode) IsNS() bool { return strings.HasPrefix(string(n), nsType) diff --git a/pkg/specgen/generate/namespaces.go b/pkg/specgen/generate/namespaces.go index e038fc84e..a19009bc2 100644 --- a/pkg/specgen/generate/namespaces.go +++ b/pkg/specgen/generate/namespaces.go @@ -266,6 +266,9 @@ func namespaceOptions(ctx context.Context, s *specgen.SpecGenerator, rt *libpod. if s.StaticMAC != nil { toReturn = append(toReturn, libpod.WithStaticMAC(*s.StaticMAC)) } + if s.NetworkOptions != nil { + toReturn = append(toReturn, libpod.WithNetworkOptions(s.NetworkOptions)) + } return toReturn, nil } @@ -470,7 +473,7 @@ func GetNamespaceOptions(ns []string) ([]libpod.PodCreateOption, error) { case "pid": options = append(options, libpod.WithPodPID()) case "user": - return erroredOptions, errors.Errorf("User sharing functionality not supported on pod level") + continue case "ipc": options = append(options, libpod.WithPodIPC()) case "uts": diff --git a/pkg/specgen/namespaces.go b/pkg/specgen/namespaces.go index e62c8b709..9bf2c5d05 100644 --- a/pkg/specgen/namespaces.go +++ b/pkg/specgen/namespaces.go @@ -109,16 +109,6 @@ func validateNetNS(n *Namespace) error { } switch n.NSMode { case Slirp: - if n.Value != "" { - parts := strings.Split(n.Value, ",") - for _, p := range parts { - switch p { - case "port_handler=slirp4netns", "port_handler=rootlesskit": - default: - return errors.Errorf("invalid value for slirp %q", n.Value) - } - } - } break case "", Default, Host, Path, FromContainer, FromPod, Private, NoNetwork, Bridge: break @@ -263,11 +253,7 @@ func ParseNetworkNamespace(ns string) (Namespace, []string, error) { // Net defaults to Slirp on rootless switch { case ns == "slirp4netns", strings.HasPrefix(ns, "slirp4netns:"): - split := strings.SplitN(ns, ":", 2) toReturn.NSMode = Slirp - if len(split) > 1 { - toReturn.Value = split[1] - } case ns == "pod": toReturn.NSMode = FromPod case ns == "": diff --git a/pkg/specgen/specgen.go b/pkg/specgen/specgen.go index 16d4b7c8c..3331bf8c8 100644 --- a/pkg/specgen/specgen.go +++ b/pkg/specgen/specgen.go @@ -378,6 +378,9 @@ type ContainerNetworkConfig struct { // Conflicts with UseImageHosts. // Optional. HostAdd []string `json:"hostadd,omitempty"` + // NetworkOptions are additional options for each network + // Optional. + NetworkOptions map[string][]string `json:"network_options,omitempty"` } // ContainerResourceConfig contains information on container resource limits. |