From cc6f0e85f994cab66fb63c4dd8b77b4332151748 Mon Sep 17 00:00:00 2001 From: baude Date: Wed, 4 Jul 2018 10:51:20 -0500 Subject: more changes to compile darwin this should represent the last major changes to get darwin to **compile**. again, the purpose here is to get darwin to compile so that we can eventually implement a ci task that would protect against regressions for darwin compilation. i have left the manual darwin compilation largely static still and in fact now only interject (manually) two build tags to assist with the build. trevor king has great ideas on how to make this better and i will defer final implementation of those to him. Signed-off-by: baude Closes: #1047 Approved by: rhatdan --- libpod/networking_linux.go | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) (limited to 'libpod/networking_linux.go') diff --git a/libpod/networking_linux.go b/libpod/networking_linux.go index ee90b765c..59666b534 100644 --- a/libpod/networking_linux.go +++ b/libpod/networking_linux.go @@ -8,6 +8,7 @@ import ( "net" "os" "path/filepath" + "strconv" "strings" "syscall" @@ -15,6 +16,7 @@ import ( "github.com/containernetworking/plugins/pkg/ns" "github.com/cri-o/ocicni/pkg/ocicni" "github.com/pkg/errors" + "github.com/projectatomic/libpod/pkg/inspect" "github.com/projectatomic/libpod/utils" "github.com/sirupsen/logrus" "github.com/vishvananda/netlink" @@ -228,3 +230,34 @@ func getContainerNetIO(ctr *Container) (*netlink.LinkStatistics, error) { }) return netStats, err } + +func (c *Container) getContainerNetworkInfo(data *inspect.ContainerInspectData) *inspect.ContainerInspectData { + if c.state.NetNS != nil { + // Go through our IP addresses + for _, ctrIP := range c.state.IPs { + ipWithMask := ctrIP.Address.String() + splitIP := strings.Split(ipWithMask, "/") + mask, _ := strconv.Atoi(splitIP[1]) + if ctrIP.Version == "4" { + data.NetworkSettings.IPAddress = splitIP[0] + data.NetworkSettings.IPPrefixLen = mask + data.NetworkSettings.Gateway = ctrIP.Gateway.String() + } else { + data.NetworkSettings.GlobalIPv6Address = splitIP[0] + data.NetworkSettings.GlobalIPv6PrefixLen = mask + data.NetworkSettings.IPv6Gateway = ctrIP.Gateway.String() + } + } + + // Set network namespace path + data.NetworkSettings.SandboxKey = c.state.NetNS.Path() + + // Set MAC address of interface linked with network namespace path + for _, i := range c.state.Interfaces { + if i.Sandbox == data.NetworkSettings.SandboxKey { + data.NetworkSettings.MacAddress = i.Mac + } + } + } + return data +} -- cgit v1.2.3-54-g00ecf