diff options
author | Daniel J Walsh <dwalsh@redhat.com> | 2019-10-28 13:02:27 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-10-28 13:02:27 -0400 |
commit | f438b2cc09d5b6eef3d09e8b8e3d3dcf2c6727df (patch) | |
tree | 9575b1f02ec7247d4adc84f9cf5cf78e2394ad02 /pkg/network/devices.go | |
parent | ac73fd3fe5dcbf2647d589f9c9f37fe9531ed663 (diff) | |
parent | 7343de24e5961c33158f4002964e6b0178d8b740 (diff) | |
download | podman-f438b2cc09d5b6eef3d09e8b8e3d3dcf2c6727df.tar.gz podman-f438b2cc09d5b6eef3d09e8b8e3d3dcf2c6727df.tar.bz2 podman-f438b2cc09d5b6eef3d09e8b8e3d3dcf2c6727df.zip |
Merge pull request #4291 from baude/networkcreatecheckbridge
check existing bridge names when creating networks
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 |