mirror of https://github.com/vishvananda/netlink
Change LinkSetMaster's master argument type. (*Bridge -> Link)
LinkSetMaster also works with Bond device. So this PR changes the type of master argument to Link.
This commit is contained in:
parent
ac5f4df047
commit
2ec5bdc52b
|
@ -709,13 +709,13 @@ func (h *Handle) LinkSetVfGUID(link Link, vf int, vfGuid net.HardwareAddr, guidT
|
|||
|
||||
// LinkSetMaster sets the master of the link device.
|
||||
// Equivalent to: `ip link set $link master $master`
|
||||
func LinkSetMaster(link Link, master *Bridge) error {
|
||||
func LinkSetMaster(link Link, master Link) error {
|
||||
return pkgHandle.LinkSetMaster(link, master)
|
||||
}
|
||||
|
||||
// LinkSetMaster sets the master of the link device.
|
||||
// Equivalent to: `ip link set $link master $master`
|
||||
func (h *Handle) LinkSetMaster(link Link, master *Bridge) error {
|
||||
func (h *Handle) LinkSetMaster(link Link, master Link) error {
|
||||
index := 0
|
||||
if master != nil {
|
||||
masterBase := master.Attrs()
|
||||
|
|
59
link_test.go
59
link_test.go
|
@ -857,20 +857,7 @@ func TestLinkAddDelBridgeMaster(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
func TestLinkSetUnsetResetMaster(t *testing.T) {
|
||||
tearDown := setUpNetlinkTest(t)
|
||||
defer tearDown()
|
||||
|
||||
master := &Bridge{LinkAttrs: LinkAttrs{Name: "foo"}}
|
||||
if err := LinkAdd(master); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
newmaster := &Bridge{LinkAttrs: LinkAttrs{Name: "bar"}}
|
||||
if err := LinkAdd(newmaster); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
func testLinkSetUnsetResetMaster(t *testing.T, master, newmaster Link) {
|
||||
slave := &Dummy{LinkAttrs{Name: "baz"}}
|
||||
if err := LinkAdd(slave); err != nil {
|
||||
t.Fatal(err)
|
||||
|
@ -923,6 +910,50 @@ func TestLinkSetUnsetResetMaster(t *testing.T) {
|
|||
if err := LinkDel(slave); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestLinkSetUnsetResetMaster(t *testing.T) {
|
||||
tearDown := setUpNetlinkTest(t)
|
||||
defer tearDown()
|
||||
|
||||
master := &Bridge{LinkAttrs: LinkAttrs{Name: "foo"}}
|
||||
if err := LinkAdd(master); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
newmaster := &Bridge{LinkAttrs: LinkAttrs{Name: "bar"}}
|
||||
if err := LinkAdd(newmaster); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
testLinkSetUnsetResetMaster(t, master, newmaster)
|
||||
|
||||
if err := LinkDel(newmaster); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
if err := LinkDel(master); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestLinkSetUnsetResetMasterBond(t *testing.T) {
|
||||
tearDown := setUpNetlinkTest(t)
|
||||
defer tearDown()
|
||||
|
||||
master := NewLinkBond(LinkAttrs{Name: "foo"})
|
||||
master.Mode = BOND_MODE_BALANCE_RR
|
||||
if err := LinkAdd(master); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
newmaster := NewLinkBond(LinkAttrs{Name: "bar"})
|
||||
newmaster.Mode = BOND_MODE_BALANCE_RR
|
||||
if err := LinkAdd(newmaster); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
testLinkSetUnsetResetMaster(t, master, newmaster)
|
||||
|
||||
if err := LinkDel(newmaster); err != nil {
|
||||
t.Fatal(err)
|
||||
|
|
Loading…
Reference in New Issue