Configure numrxqueues/numtxqueues on veth peer (fixes #536)

This commit is contained in:
Alex Forster 2020-05-04 14:12:33 -05:00 committed by Alessandro Boch
parent 96dce1cb9f
commit 27f2b32dc6
2 changed files with 12 additions and 0 deletions

View File

@ -1282,6 +1282,12 @@ func (h *Handle) linkModify(link Link, flags int) error {
if base.TxQLen >= 0 {
peer.AddRtAttr(unix.IFLA_TXQLEN, nl.Uint32Attr(uint32(base.TxQLen)))
}
if base.NumTxQueues > 0 {
peer.AddRtAttr(unix.IFLA_NUM_TX_QUEUES, nl.Uint32Attr(uint32(base.NumTxQueues)))
}
if base.NumRxQueues > 0 {
peer.AddRtAttr(unix.IFLA_NUM_RX_QUEUES, nl.Uint32Attr(uint32(base.NumRxQueues)))
}
if base.MTU > 0 {
peer.AddRtAttr(unix.IFLA_MTU, nl.Uint32Attr(uint32(base.MTU)))
}

View File

@ -93,6 +93,12 @@ func testLinkAddDel(t *testing.T, link Link) {
if peer.TxQLen != testTxQLen {
t.Fatalf("TxQLen of peer is %d, should be %d", peer.TxQLen, testTxQLen)
}
if peer.NumTxQueues != testTxQueues {
t.Fatalf("NumTxQueues of peer is %d, should be %d", peer.NumTxQueues, testTxQueues)
}
if peer.NumRxQueues != testRxQueues {
t.Fatalf("NumRxQueues of peer is %d, should be %d", peer.NumRxQueues, testRxQueues)
}
if !bytes.Equal(peer.Attrs().HardwareAddr, original.PeerHardwareAddr) {
t.Fatalf("Peer MAC addr is %s, should be %s", peer.Attrs().HardwareAddr, original.PeerHardwareAddr)
}