diff options
author | Paul Holzinger <pholzing@redhat.com> | 2021-12-17 14:46:15 +0100 |
---|---|---|
committer | Paul Holzinger <pholzing@redhat.com> | 2022-01-12 17:07:30 +0100 |
commit | 495884b3195de482dc610a2a002db7e053188a32 (patch) | |
tree | 2a6f23db066cd52aa366991b0b34d7b919368ddc /libpod/network/internal/util/bridge.go | |
parent | 2cdab5d53923784e72020d70ee9375518f19f9b6 (diff) | |
download | podman-495884b3195de482dc610a2a002db7e053188a32.tar.gz podman-495884b3195de482dc610a2a002db7e053188a32.tar.bz2 podman-495884b3195de482dc610a2a002db7e053188a32.zip |
use libnetwork from c/common
The libpod/network packages were moved to c/common so that buildah can
use it as well. To prevent duplication use it in podman as well and
remove it from here.
Signed-off-by: Paul Holzinger <pholzing@redhat.com>
Diffstat (limited to 'libpod/network/internal/util/bridge.go')
-rw-r--r-- | libpod/network/internal/util/bridge.go | 69 |
1 files changed, 0 insertions, 69 deletions
diff --git a/libpod/network/internal/util/bridge.go b/libpod/network/internal/util/bridge.go deleted file mode 100644 index 476557050..000000000 --- a/libpod/network/internal/util/bridge.go +++ /dev/null @@ -1,69 +0,0 @@ -package util - -import ( - "net" - - "github.com/containers/podman/v3/libpod/define" - "github.com/containers/podman/v3/libpod/network/types" - "github.com/containers/podman/v3/libpod/network/util" - pkgutil "github.com/containers/podman/v3/pkg/util" - "github.com/pkg/errors" -) - -func CreateBridge(n NetUtil, network *types.Network, usedNetworks []*net.IPNet) error { - if network.NetworkInterface != "" { - bridges := GetBridgeInterfaceNames(n) - if pkgutil.StringInSlice(network.NetworkInterface, bridges) { - return errors.Errorf("bridge name %s already in use", network.NetworkInterface) - } - if !define.NameRegex.MatchString(network.NetworkInterface) { - return errors.Wrapf(define.RegexError, "bridge name %s invalid", network.NetworkInterface) - } - } else { - var err error - network.NetworkInterface, err = GetFreeDeviceName(n) - if err != nil { - return err - } - } - - if network.IPAMOptions["driver"] != types.DHCPIPAMDriver { - if len(network.Subnets) == 0 { - freeSubnet, err := GetFreeIPv4NetworkSubnet(usedNetworks) - if err != nil { - return err - } - network.Subnets = append(network.Subnets, *freeSubnet) - } - // ipv6 enabled means dual stack, check if we already have - // a ipv4 or ipv6 subnet and add one if not. - if network.IPv6Enabled { - ipv4 := false - ipv6 := false - for _, subnet := range network.Subnets { - if util.IsIPv6(subnet.Subnet.IP) { - ipv6 = true - } - if util.IsIPv4(subnet.Subnet.IP) { - ipv4 = true - } - } - if !ipv4 { - freeSubnet, err := GetFreeIPv4NetworkSubnet(usedNetworks) - if err != nil { - return err - } - network.Subnets = append(network.Subnets, *freeSubnet) - } - if !ipv6 { - freeSubnet, err := GetFreeIPv6NetworkSubnet(usedNetworks) - if err != nil { - return err - } - network.Subnets = append(network.Subnets, *freeSubnet) - } - } - network.IPAMOptions["driver"] = types.HostLocalIPAMDriver - } - return nil -} |