diff options
author | dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com> | 2019-09-30 12:45:40 +0000 |
---|---|---|
committer | Valentin Rothberg <rothberg@redhat.com> | 2019-10-01 12:07:26 +0200 |
commit | 2b7a7a084e2adcd1a104aafbee02f824bb428052 (patch) | |
tree | e0052dba6ddac2ff510475dc1e29cb5944af738a /vendor/github.com/containernetworking/plugins/pkg | |
parent | d7eba026876e4a6a362464dcf08fe6757ebedd1a (diff) | |
download | podman-2b7a7a084e2adcd1a104aafbee02f824bb428052.tar.gz podman-2b7a7a084e2adcd1a104aafbee02f824bb428052.tar.bz2 podman-2b7a7a084e2adcd1a104aafbee02f824bb428052.zip |
Bump github.com/containernetworking/plugins from 0.8.1 to 0.8.2
Bumps [github.com/containernetworking/plugins](https://github.com/containernetworking/plugins) from 0.8.1 to 0.8.2.
- [Release notes](https://github.com/containernetworking/plugins/releases)
- [Commits](https://github.com/containernetworking/plugins/compare/v0.8.1...v0.8.2)
Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
Diffstat (limited to 'vendor/github.com/containernetworking/plugins/pkg')
-rw-r--r-- | vendor/github.com/containernetworking/plugins/pkg/ip/link_linux.go | 33 |
1 files changed, 23 insertions, 10 deletions
diff --git a/vendor/github.com/containernetworking/plugins/pkg/ip/link_linux.go b/vendor/github.com/containernetworking/plugins/pkg/ip/link_linux.go index 909afd04e..c0053cabe 100644 --- a/vendor/github.com/containernetworking/plugins/pkg/ip/link_linux.go +++ b/vendor/github.com/containernetworking/plugins/pkg/ip/link_linux.go @@ -60,11 +60,15 @@ func peerExists(name string) bool { return true } -func makeVeth(name string, mtu int) (peerName string, veth netlink.Link, err error) { +func makeVeth(name, vethPeerName string, mtu int) (peerName string, veth netlink.Link, err error) { for i := 0; i < 10; i++ { - peerName, err = RandomVethName() - if err != nil { - return + if vethPeerName != "" { + peerName = vethPeerName + } else { + peerName, err = RandomVethName() + if err != nil { + return + } } veth, err = makeVethPair(name, peerName, mtu) @@ -73,7 +77,7 @@ func makeVeth(name string, mtu int) (peerName string, veth netlink.Link, err err return case os.IsExist(err): - if peerExists(peerName) { + if peerExists(peerName) && vethPeerName == "" { continue } err = fmt.Errorf("container veth name provided (%v) already exists", name) @@ -121,12 +125,13 @@ func ifaceFromNetlinkLink(l netlink.Link) net.Interface { } } -// SetupVeth sets up a pair of virtual ethernet devices. -// Call SetupVeth from inside the container netns. It will create both veth +// SetupVethWithName sets up a pair of virtual ethernet devices. +// Call SetupVethWithName from inside the container netns. It will create both veth // devices and move the host-side veth into the provided hostNS namespace. -// On success, SetupVeth returns (hostVeth, containerVeth, nil) -func SetupVeth(contVethName string, mtu int, hostNS ns.NetNS) (net.Interface, net.Interface, error) { - hostVethName, contVeth, err := makeVeth(contVethName, mtu) +// hostVethName: If hostVethName is not specified, the host-side veth name will use a random string. +// On success, SetupVethWithName returns (hostVeth, containerVeth, nil) +func SetupVethWithName(contVethName, hostVethName string, mtu int, hostNS ns.NetNS) (net.Interface, net.Interface, error) { + hostVethName, contVeth, err := makeVeth(contVethName, hostVethName, mtu) if err != nil { return net.Interface{}, net.Interface{}, err } @@ -161,6 +166,14 @@ func SetupVeth(contVethName string, mtu int, hostNS ns.NetNS) (net.Interface, ne return ifaceFromNetlinkLink(hostVeth), ifaceFromNetlinkLink(contVeth), nil } +// SetupVeth sets up a pair of virtual ethernet devices. +// Call SetupVeth from inside the container netns. It will create both veth +// devices and move the host-side veth into the provided hostNS namespace. +// On success, SetupVeth returns (hostVeth, containerVeth, nil) +func SetupVeth(contVethName string, mtu int, hostNS ns.NetNS) (net.Interface, net.Interface, error) { + return SetupVethWithName(contVethName, "", mtu, hostNS) +} + // DelLinkByName removes an interface link. func DelLinkByName(ifName string) error { iface, err := netlink.LinkByName(ifName) |