@@ -201,6 +201,16 @@ func testLinkAddDel(t *testing.T, link Link) {
201201 if macv .Mode != other .Mode {
202202 t .Fatalf ("Got unexpected mode: %d, expected: %d" , other .Mode , macv .Mode )
203203 }
204+ if other .BCQueueLen > 0 || other .UsedBCQueueLen > 0 {
205+ if other .UsedBCQueueLen < other .BCQueueLen {
206+ t .Fatalf ("UsedBCQueueLen (%d) is smaller than BCQueueLen (%d)" , other .UsedBCQueueLen , other .BCQueueLen )
207+ }
208+ }
209+ if macv .BCQueueLen > 0 {
210+ if macv .BCQueueLen != other .BCQueueLen {
211+ t .Fatalf ("BCQueueLen not set correctly: %d, expected: %d" , other .BCQueueLen , macv .BCQueueLen )
212+ }
213+ }
204214 }
205215
206216 if macv , ok := link .(* Macvtap ); ok {
@@ -211,6 +221,16 @@ func testLinkAddDel(t *testing.T, link Link) {
211221 if macv .Mode != other .Mode {
212222 t .Fatalf ("Got unexpected mode: %d, expected: %d" , other .Mode , macv .Mode )
213223 }
224+ if other .BCQueueLen > 0 || other .UsedBCQueueLen > 0 {
225+ if other .UsedBCQueueLen < other .BCQueueLen {
226+ t .Fatalf ("UsedBCQueueLen (%d) is smaller than BCQueueLen (%d)" , other .UsedBCQueueLen , other .BCQueueLen )
227+ }
228+ }
229+ if macv .BCQueueLen > 0 {
230+ if macv .BCQueueLen != other .BCQueueLen {
231+ t .Fatalf ("BCQueueLen not set correctly: %d, expected: %d" , other .BCQueueLen , macv .BCQueueLen )
232+ }
233+ }
214234 }
215235
216236 if _ , ok := link .(* Vti ); ok {
@@ -916,6 +936,36 @@ func TestLinkAddDelMacvtap(t *testing.T) {
916936 }
917937}
918938
939+ func TestLinkMacvBCQueueLen (t * testing.T ) {
940+ minKernelRequired (t , 5 , 11 )
941+
942+ tearDown := setUpNetlinkTest (t )
943+ defer tearDown ()
944+
945+ parent := & Dummy {LinkAttrs {Name : "foo" }}
946+ if err := LinkAdd (parent ); err != nil {
947+ t .Fatal (err )
948+ }
949+
950+ testLinkAddDel (t , & Macvlan {
951+ LinkAttrs : LinkAttrs {Name : "bar" , ParentIndex : parent .Attrs ().Index },
952+ Mode : MACVLAN_MODE_PRIVATE ,
953+ BCQueueLen : 10000 ,
954+ })
955+
956+ testLinkAddDel (t , & Macvtap {
957+ Macvlan : Macvlan {
958+ LinkAttrs : LinkAttrs {Name : "bar" , ParentIndex : parent .Attrs ().Index },
959+ Mode : MACVLAN_MODE_PRIVATE ,
960+ BCQueueLen : 10000 ,
961+ },
962+ })
963+
964+ if err := LinkDel (parent ); err != nil {
965+ t .Fatal (err )
966+ }
967+ }
968+
919969func TestNetkitPeerNs (t * testing.T ) {
920970 minKernelRequired (t , 6 , 7 )
921971 tearDown := setUpNetlinkTest (t )
0 commit comments