Skip to content

Commit

Permalink
Support moveing VF which is eth0 on the host to the namespace
Browse files Browse the repository at this point in the history
When using multus pluing the first interface will be eth0 and
    the others will be netX. We need to make sure that before
    we move VF which is eth0 to the container namespace it should
    first be renamed to temp name before moving to the namespace.
    This is to avoid conflict with the eth0 interface which already
    exist in the namespace.

    Fixes #40
  • Loading branch information
Mmduh-483 authored and ahalimx86 committed Jan 24, 2019
1 parent 8da832f commit 63b44a3
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions sriov/sriov.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,15 @@ func moveIfToNetns(ifname string, netns ns.NetNS) error {
return fmt.Errorf("failed to lookup vf device %v: %q", ifname, err)
}

if err = netlink.LinkSetDown(vfDev); err != nil {
return fmt.Errorf("failed to down vf device %q: %v", ifname, err)
}
index := vfDev.Attrs().Index
vfName := fmt.Sprintf("dev%d", index)
if renameLink(ifname, vfName); err != nil {
return fmt.Errorf("failed to rename vf device %q to %q: %v", ifname, vfName, err)
}

if err = netlink.LinkSetUp(vfDev); err != nil {
return fmt.Errorf("failed to setup netlink device %v %q", ifname, err)
}
Expand Down

0 comments on commit 63b44a3

Please sign in to comment.