mirror of
https://github.com/vishvananda/netlink.git
synced 2025-10-26 17:30:27 +08:00
Add devlink port function set attribute
Add ability to set port function attributes such as state and hardware address. Signed-off-by: Parav Pandit <parav@nvidia.com>
This commit is contained in:
committed by
Alessandro Boch
parent
22c099edb4
commit
77f3f25cb4
@@ -3,8 +3,9 @@
|
||||
package netlink
|
||||
|
||||
import (
|
||||
"testing"
|
||||
"flag"
|
||||
"net"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestDevLinkGetDeviceList(t *testing.T) {
|
||||
@@ -77,7 +78,62 @@ func TestDevLinkAddDelSfPort(t *testing.T) {
|
||||
}
|
||||
t.Log(*port)
|
||||
if port.Fn != nil {
|
||||
t.Log("function attributes = " , *port.Fn)
|
||||
t.Log("function attributes = ", *port.Fn)
|
||||
}
|
||||
err2 = DevLinkPortDel(dev.BusName, dev.DeviceName, port.PortIndex)
|
||||
if err2 != nil {
|
||||
t.Fatal(err2)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDevLinkSfPortFnSet(t *testing.T) {
|
||||
var addAttrs DevLinkPortAddAttrs
|
||||
var stateAttr DevlinkPortFnSetAttrs
|
||||
|
||||
minKernelRequired(t, 5, 12)
|
||||
if bus == "" || device == "" {
|
||||
t.Log("devlink bus and device are empty, skipping test")
|
||||
return
|
||||
}
|
||||
|
||||
dev, err := DevLinkGetDeviceByName(bus, device)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
return
|
||||
}
|
||||
addAttrs.SfNumberValid = true
|
||||
addAttrs.SfNumber = uint32(sfnum)
|
||||
addAttrs.PfNumber = 0
|
||||
port, err2 := DevLinkPortAdd(dev.BusName, dev.DeviceName, 7, addAttrs)
|
||||
if err2 != nil {
|
||||
t.Fatal(err2)
|
||||
return
|
||||
}
|
||||
t.Log(*port)
|
||||
if port.Fn != nil {
|
||||
t.Log("function attributes = ", *port.Fn)
|
||||
}
|
||||
macAttr := DevlinkPortFnSetAttrs{
|
||||
FnAttrs: DevlinkPortFn{
|
||||
HwAddr: net.HardwareAddr{0x00, 0x11, 0x22, 0x33, 0x44, 0x55},
|
||||
},
|
||||
HwAddrValid: true,
|
||||
}
|
||||
err2 = DevlinkPortFnSet(dev.BusName, dev.DeviceName, port.PortIndex, macAttr)
|
||||
if err2 != nil {
|
||||
t.Log("function mac set err = ", err2)
|
||||
}
|
||||
stateAttr.FnAttrs.State = 1
|
||||
stateAttr.StateValid = true
|
||||
err2 = DevlinkPortFnSet(dev.BusName, dev.DeviceName, port.PortIndex, stateAttr)
|
||||
if err2 != nil {
|
||||
t.Log("function state set err = ", err2)
|
||||
}
|
||||
|
||||
port, err3 := DevLinkGetPortByIndex(dev.BusName, dev.DeviceName, port.PortIndex)
|
||||
if err3 == nil {
|
||||
t.Log(*port)
|
||||
t.Log(*port.Fn)
|
||||
}
|
||||
err2 = DevLinkPortDel(dev.BusName, dev.DeviceName, port.PortIndex)
|
||||
if err2 != nil {
|
||||
@@ -90,7 +146,7 @@ var device string
|
||||
var sfnum uint
|
||||
|
||||
func init() {
|
||||
flag.StringVar(&bus, "bus", "", "devlink device bus name")
|
||||
flag.StringVar(&device, "device", "", "devlink device devicename")
|
||||
flag.UintVar(&sfnum, "sfnum", 0, "devlink port sfnumber")
|
||||
flag.StringVar(&bus, "bus", "", "devlink device bus name")
|
||||
flag.StringVar(&device, "device", "", "devlink device devicename")
|
||||
flag.UintVar(&sfnum, "sfnum", 0, "devlink port sfnumber")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user