diff options
Diffstat (limited to 'libpod/container.go')
-rw-r--r-- | libpod/container.go | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/libpod/container.go b/libpod/container.go index 9009a4ec8..4b9e6a5ba 100644 --- a/libpod/container.go +++ b/libpod/container.go @@ -206,6 +206,10 @@ type ContainerState struct { // and not delegated to the OCI runtime. ExtensionStageHooks map[string][]spec.Hook `json:"extensionStageHooks,omitempty"` + // NetInterfaceDescriptions describe the relationship between a CNI + // network and an interface names + NetInterfaceDescriptions ContainerNetworkDescriptions `json:"networkDescriptions,omitempty"` + // containerPlatformState holds platform-specific container state. containerPlatformState } @@ -244,6 +248,10 @@ type ContainerImageVolume struct { ReadWrite bool `json:"rw"` } +// ContainerNetworkDescriptions describes the relationship between the CNI +// network and the ethN where N is an integer +type ContainerNetworkDescriptions map[string]int + // Config accessors // Unlocked @@ -1102,3 +1110,19 @@ func (c *Container) networksByNameIndex() (map[string]int, error) { } return networkNamesByIndex, nil } + +// add puts the new given CNI network name into the tracking map +// and assigns it a new integer based on the map length +func (d ContainerNetworkDescriptions) add(networkName string) { + d[networkName] = len(d) +} + +// getInterfaceByName returns a formatted interface name for a given +// network along with a bool as to whether the network existed +func (d ContainerNetworkDescriptions) getInterfaceByName(networkName string) (string, bool) { + val, exists := d[networkName] + if !exists { + return "", exists + } + return fmt.Sprintf("eth%d", val), exists +} |