Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Drop dependency on iproute #11404

Merged
merged 1 commit into from
Sep 2, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 3 additions & 7 deletions libpod/network/devices.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,11 @@ package network

import (
"fmt"
"os/exec"

"github.com/containers/common/pkg/config"
"github.com/containers/podman/v3/pkg/util"
"github.com/containers/podman/v3/utils"
"github.com/sirupsen/logrus"
"github.com/vishvananda/netlink"
)

// GetFreeDeviceName returns a device name that is unused; used when no network
Expand Down Expand Up @@ -52,12 +51,9 @@ func GetFreeDeviceName(config *config.Config) (string, error) {

// RemoveInterface removes an interface by the given name
func RemoveInterface(interfaceName string) error {
// Make sure we have the ip command on the system
ipPath, err := exec.LookPath("ip")
link, err := netlink.LinkByName(interfaceName)
if err != nil {
return err
}
// Delete the network interface
_, err = utils.ExecCmd(ipPath, []string{"link", "del", interfaceName}...)
return err
return netlink.LinkDel(link)
}
5 changes: 3 additions & 2 deletions libpod/network/network.go
Original file line number Diff line number Diff line change
Expand Up @@ -194,8 +194,9 @@ func removeNetwork(config *config.Config, name string) error {
return errors.Wrapf(err, "failed to get live network names")
}
if util.StringInSlice(interfaceName, liveNetworkNames) {
if err := RemoveInterface(interfaceName); err != nil {
return errors.Wrapf(err, "failed to delete the network interface %q", interfaceName)
if err = RemoveInterface(interfaceName); err != nil {
// only log the error, it is not fatal
logrus.Infof("failed to remove network interface %s: %v", interfaceName, err)
}
}
}
Expand Down