mirror of
https://github.com/containers/podman.git
synced 2025-08-15 20:00:26 +08:00
Switch to using libnetwork's resolvconf package
Libnetwork provides a well-tested package for generating resolv.conf from the host's that has some features our current implementation does not. Swap to using their code and remove our built-in implementation. Signed-off-by: Matthew Heon <matthew.heon@gmail.com>
This commit is contained in:
50
vendor/github.com/docker/libnetwork/netutils/utils_linux.go
generated
vendored
Normal file
50
vendor/github.com/docker/libnetwork/netutils/utils_linux.go
generated
vendored
Normal file
@ -0,0 +1,50 @@
|
||||
// +build linux
|
||||
// Network utility functions.
|
||||
|
||||
package netutils
|
||||
|
||||
import (
|
||||
"net"
|
||||
"strings"
|
||||
|
||||
"github.com/docker/libnetwork/types"
|
||||
"github.com/vishvananda/netlink"
|
||||
)
|
||||
|
||||
var (
|
||||
networkGetRoutesFct = netlink.RouteList
|
||||
)
|
||||
|
||||
// CheckRouteOverlaps checks whether the passed network overlaps with any existing routes
|
||||
func CheckRouteOverlaps(toCheck *net.IPNet) error {
|
||||
networks, err := networkGetRoutesFct(nil, netlink.FAMILY_V4)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
for _, network := range networks {
|
||||
if network.Dst != nil && NetworkOverlaps(toCheck, network.Dst) {
|
||||
return ErrNetworkOverlaps
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// GenerateIfaceName returns an interface name using the passed in
|
||||
// prefix and the length of random bytes. The api ensures that the
|
||||
// there are is no interface which exists with that name.
|
||||
func GenerateIfaceName(prefix string, len int) (string, error) {
|
||||
for i := 0; i < 3; i++ {
|
||||
name, err := GenerateRandomName(prefix, len)
|
||||
if err != nil {
|
||||
continue
|
||||
}
|
||||
if _, err := netlink.LinkByName(name); err != nil {
|
||||
if strings.Contains(err.Error(), "not found") {
|
||||
return name, nil
|
||||
}
|
||||
return "", err
|
||||
}
|
||||
}
|
||||
return "", types.InternalErrorf("could not generate interface name")
|
||||
}
|
Reference in New Issue
Block a user