diff options
author | baude <bbaude@redhat.com> | 2019-10-17 13:28:38 -0500 |
---|---|---|
committer | baude <bbaude@redhat.com> | 2019-10-17 13:28:38 -0500 |
commit | 7343de24e5961c33158f4002964e6b0178d8b740 (patch) | |
tree | 8772a20ea6f97769ca67a8c2c9ff5e60da22f3d9 /pkg/network/devices.go | |
parent | f2d9a9d2abd1405d8ea5fb7b94715f6f87618226 (diff) | |
download | podman-7343de24e5961c33158f4002964e6b0178d8b740.tar.gz podman-7343de24e5961c33158f4002964e6b0178d8b740.tar.bz2 podman-7343de24e5961c33158f4002964e6b0178d8b740.zip |
check existing bridge names when creating networks
when creating a new networking, we should check existing networks for
their bridge names and make sure the proposed new name is not part of
this. reported by QE.
Signed-off-by: baude <bbaude@redhat.com>
Diffstat (limited to 'pkg/network/devices.go')
-rw-r--r-- | pkg/network/devices.go | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/pkg/network/devices.go b/pkg/network/devices.go index 85068a7d1..78e1a5aa5 100644 --- a/pkg/network/devices.go +++ b/pkg/network/devices.go @@ -24,19 +24,26 @@ func GetFreeDeviceName() (string, error) { if err != nil { return "", err } + bridgeNames, err := GetBridgeNamesFromFileSystem() + if err != nil { + return "", err + } for { deviceName = fmt.Sprintf("%s%d", CNIDeviceName, deviceNum) - logrus.Debugf("checking if device name %s exists in other cni networks", deviceName) + logrus.Debugf("checking if device name %q exists in other cni networks", deviceName) if util.StringInSlice(deviceName, networkNames) { deviceNum++ continue } - logrus.Debugf("checking if device name %s exists in live networks", deviceName) - if !util.StringInSlice(deviceName, liveNetworksNames) { + logrus.Debugf("checking if device name %q exists in live networks", deviceName) + if util.StringInSlice(deviceName, liveNetworksNames) { + deviceNum++ + continue + } + logrus.Debugf("checking if device name %q already exists as a bridge name ", deviceName) + if !util.StringInSlice(deviceName, bridgeNames) { break } - // TODO Still need to check the bridge names for a conflict but I dont know - // how to get them yet! deviceNum++ } return deviceName, nil |