1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00

Include Endpoint List for Shared Endpoints

Do not allow sharing of container network with hyperv containers

Signed-off-by: Madhan Raj Mookkandy <madhanm@microsoft.com>
This commit is contained in:
Madhan Raj Mookkandy 2017-06-12 15:20:23 -07:00
parent 9d95740dbf
commit 349913ce9f
6 changed files with 54 additions and 5 deletions

View file

@ -107,7 +107,8 @@ type Container struct {
NoNewPrivileges bool
// Fields here are specific to Windows
NetworkSharedContainerID string
NetworkSharedContainerID string `json:"-"`
SharedEndpointList []string `json:"-"`
}
// NewBaseContainer creates a new container with its

View file

@ -886,7 +886,12 @@ func (daemon *Daemon) initializeNetworking(container *container.Container) error
if err != nil {
return err
}
initializeNetworkingPaths(container, nc)
err = daemon.initializeNetworkingPaths(container, nc)
if err != nil {
return err
}
container.Config.Hostname = nc.Config.Hostname
container.Config.Domainname = nc.Config.Domainname
return nil

View file

@ -42,5 +42,6 @@ func setupPathsAndSandboxOptions(container *container.Container, sboxOptions *[]
return nil
}
func initializeNetworkingPaths(container *container.Container, nc *container.Container) {
func (daemon *Daemon) initializeNetworkingPaths(container *container.Container, nc *container.Container) error {
return nil
}

View file

@ -349,8 +349,9 @@ func setupPathsAndSandboxOptions(container *container.Container, sboxOptions *[]
return nil
}
func initializeNetworkingPaths(container *container.Container, nc *container.Container) {
func (daemon *Daemon) initializeNetworkingPaths(container *container.Container, nc *container.Container) error {
container.HostnamePath = nc.HostnamePath
container.HostsPath = nc.HostsPath
container.ResolvConfPath = nc.ResolvConfPath
return nil
}

View file

@ -160,6 +160,43 @@ func setupPathsAndSandboxOptions(container *container.Container, sboxOptions *[]
return nil
}
func initializeNetworkingPaths(container *container.Container, nc *container.Container) {
func (daemon *Daemon) initializeNetworkingPaths(container *container.Container, nc *container.Container) error {
if nc.HostConfig.Isolation.IsHyperV() {
return fmt.Errorf("sharing of hyperv containers network is not supported")
}
container.NetworkSharedContainerID = nc.ID
if nc.NetworkSettings != nil {
for n := range nc.NetworkSettings.Networks {
sn, err := daemon.FindNetwork(n)
if err != nil {
continue
}
ep, err := nc.GetEndpointInNetwork(sn)
if err != nil {
continue
}
data, err := ep.DriverInfo()
if err != nil {
continue
}
if data["GW_INFO"] != nil {
gwInfo := data["GW_INFO"].(map[string]interface{})
if gwInfo["hnsid"] != nil {
container.SharedEndpointList = append(container.SharedEndpointList, gwInfo["hnsid"].(string))
}
}
if data["hnsid"] != nil {
container.SharedEndpointList = append(container.SharedEndpointList, data["hnsid"].(string))
}
}
}
return nil
}

View file

@ -150,7 +150,11 @@ func (daemon *Daemon) getLibcontainerdCreateOptions(container *container.Contain
var networkSharedContainerID string
if container.HostConfig.NetworkMode.IsContainer() {
networkSharedContainerID = container.NetworkSharedContainerID
for _, ep := range container.SharedEndpointList {
epList = append(epList, ep)
}
}
createOptions = append(createOptions, &libcontainerd.NetworkEndpointsOption{
Endpoints: epList,
AllowUnqualifiedDNSQuery: AllowUnqualifiedDNSQuery,