From 1882f691758f4b22778cd57b371c36b22c91b885 Mon Sep 17 00:00:00 2001 From: Amit Krishnan Date: Fri, 4 Mar 2016 14:13:12 -0800 Subject: [PATCH] Get libnetwork to build on Solaris Signed-off-by: Amit Krishnan --- default_gateway_solaris.go | 7 ++++++ drivers_solaris.go | 5 ++++ ipams/builtin/builtin_unix.go | 2 +- ipamutils/utils_solaris.go | 31 +++++++++++++++++++++++ osl/interface_solaris.go | 4 +++ osl/neigh_solaris.go | 4 +++ sandbox_externalkey_solaris.go | 45 ++++++++++++++++++++++++++++++++++ 7 files changed, 97 insertions(+), 1 deletion(-) create mode 100644 default_gateway_solaris.go create mode 100644 drivers_solaris.go create mode 100644 ipamutils/utils_solaris.go create mode 100644 osl/interface_solaris.go create mode 100644 osl/neigh_solaris.go create mode 100644 sandbox_externalkey_solaris.go diff --git a/default_gateway_solaris.go b/default_gateway_solaris.go new file mode 100644 index 00000000..104781aa --- /dev/null +++ b/default_gateway_solaris.go @@ -0,0 +1,7 @@ +package libnetwork + +import "github.com/docker/libnetwork/types" + +func (c *controller) createGWNetwork() (Network, error) { + return nil, types.NotImplementedErrorf("default gateway functionality is not implemented in solaris") +} diff --git a/drivers_solaris.go b/drivers_solaris.go new file mode 100644 index 00000000..89ae42c5 --- /dev/null +++ b/drivers_solaris.go @@ -0,0 +1,5 @@ +package libnetwork + +func getInitializers() []initializer { + return []initializer{} +} diff --git a/ipams/builtin/builtin_unix.go b/ipams/builtin/builtin_unix.go index c47674aa..092f9832 100644 --- a/ipams/builtin/builtin_unix.go +++ b/ipams/builtin/builtin_unix.go @@ -1,4 +1,4 @@ -// +build linux freebsd +// +build linux freebsd solaris package builtin diff --git a/ipamutils/utils_solaris.go b/ipamutils/utils_solaris.go new file mode 100644 index 00000000..f6bbaefc --- /dev/null +++ b/ipamutils/utils_solaris.go @@ -0,0 +1,31 @@ +// Package ipamutils provides utililty functions for ipam management +package ipamutils + +// Solaris: TODO + +import ( + "net" +) + +// ElectInterfaceAddresses looks for an interface on the OS with the specified name +// and returns its IPv4 and IPv6 addresses in CIDR form. If the interface does not exist, +// it chooses from a predifined list the first IPv4 address which does not conflict +// with other interfaces on the system. +func ElectInterfaceAddresses(name string) (*net.IPNet, []*net.IPNet, error) { + var ( + v4Net *net.IPNet + err error + ) + + v4Net, err = FindAvailableNetwork(PredefinedBroadNetworks) + if err != nil { + return nil, nil, err + } + return v4Net, nil, nil +} + +// FindAvailableNetwork returns a network from the passed list which does not +// overlap with existing interfaces in the system +func FindAvailableNetwork(list []*net.IPNet) (*net.IPNet, error) { + return list[0], nil +} diff --git a/osl/interface_solaris.go b/osl/interface_solaris.go new file mode 100644 index 00000000..9c0141fd --- /dev/null +++ b/osl/interface_solaris.go @@ -0,0 +1,4 @@ +package osl + +// IfaceOption is a function option type to set interface options +type IfaceOption func() diff --git a/osl/neigh_solaris.go b/osl/neigh_solaris.go new file mode 100644 index 00000000..ffa8d753 --- /dev/null +++ b/osl/neigh_solaris.go @@ -0,0 +1,4 @@ +package osl + +// NeighOption is a function option type to set interface options +type NeighOption func() diff --git a/sandbox_externalkey_solaris.go b/sandbox_externalkey_solaris.go new file mode 100644 index 00000000..7569e46b --- /dev/null +++ b/sandbox_externalkey_solaris.go @@ -0,0 +1,45 @@ +// +build solaris + +package libnetwork + +import ( + "io" + "net" + + "github.com/docker/libnetwork/types" +) + +// processSetKeyReexec is a private function that must be called only on an reexec path +// It expects 3 args { [0] = "libnetwork-setkey", [1] = , [2] = } +// It also expects libcontainer.State as a json string in +// Refer to https://github.com/opencontainers/runc/pull/160/ for more information +func processSetKeyReexec() { +} + +// SetExternalKey provides a convenient way to set an External key to a sandbox +func SetExternalKey(controllerID string, containerID string, key string) error { + return types.NotImplementedErrorf("SetExternalKey isn't supported on non linux systems") +} + +func sendKey(c net.Conn, data setKeyData) error { + return types.NotImplementedErrorf("sendKey isn't supported on non linux systems") +} + +func processReturn(r io.Reader) error { + return types.NotImplementedErrorf("processReturn isn't supported on non linux systems") +} + +// no-op on non linux systems +func (c *controller) startExternalKeyListener() error { + return nil +} + +func (c *controller) acceptClientConnections(sock string, l net.Listener) { +} + +func (c *controller) processExternalKey(conn net.Conn) error { + return types.NotImplementedErrorf("processExternalKey isn't supported on non linux systems") +} + +func (c *controller) stopExternalKeyListener() { +}