diff options
author | Daniel J Walsh <dwalsh@redhat.com> | 2021-11-23 10:39:32 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-11-23 10:39:32 -0500 |
commit | 400ccc62059849fa17e82da981caedd5c2fb3ca9 (patch) | |
tree | 020dcd548a7e321b2b7da83da2cde1c9474a08db /pkg | |
parent | ee612806655d0d0a0a3d2a782a000ea5c6b08f33 (diff) | |
parent | ab56a7c4b75e3f4c083da420cc9b7a85be4303c8 (diff) | |
download | podman-400ccc62059849fa17e82da981caedd5c2fb3ca9.tar.gz podman-400ccc62059849fa17e82da981caedd5c2fb3ca9.tar.bz2 podman-400ccc62059849fa17e82da981caedd5c2fb3ca9.zip |
Merge pull request #12328 from serverwentdown/fix-compat-ipaddress
compat: Add subnet mask behind IP address to match Docker API
Diffstat (limited to 'pkg')
-rw-r--r-- | pkg/api/handlers/compat/networks.go | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/pkg/api/handlers/compat/networks.go b/pkg/api/handlers/compat/networks.go index dd28f6deb..8aab29658 100644 --- a/pkg/api/handlers/compat/networks.go +++ b/pkg/api/handlers/compat/networks.go @@ -2,6 +2,7 @@ package compat import ( "encoding/json" + "fmt" "net" "net/http" @@ -69,12 +70,20 @@ func convertLibpodNetworktoDockerNetwork(runtime *libpod.Runtime, network nettyp return nil, err } if netData, ok := data.NetworkSettings.Networks[network.Name]; ok { + ipv4Address := "" + if netData.IPAddress != "" { + ipv4Address = fmt.Sprintf("%s/%d", netData.IPAddress, netData.IPPrefixLen) + } + ipv6Address := "" + if netData.GlobalIPv6Address != "" { + ipv6Address = fmt.Sprintf("%s/%d", netData.GlobalIPv6Address, netData.GlobalIPv6PrefixLen) + } containerEndpoint := types.EndpointResource{ - Name: netData.NetworkID, + Name: con.Name(), EndpointID: netData.EndpointID, MacAddress: netData.MacAddress, - IPv4Address: netData.IPAddress, - IPv6Address: netData.GlobalIPv6Address, + IPv4Address: ipv4Address, + IPv6Address: ipv6Address, } containerEndpoints[con.ID()] = containerEndpoint } |