@@ -15,6 +15,10 @@ import (
15
15
"github.com/j-keck/arping"
16
16
)
17
17
18
+ const (
19
+ InvalidMacAddress = "00:00:00:00:00:00"
20
+ )
21
+
18
22
func createIpvlanInterface (dnet * danmtypes.DanmNet , ep * danmtypes.DanmEp ) error {
19
23
host , err := os .Hostname ()
20
24
if err != nil {
@@ -273,7 +277,6 @@ func deleteEp(ep *danmtypes.DanmEp) error {
273
277
274
278
func createDummyInterface (ep * danmtypes.DanmEp , dnet * danmtypes.DanmNet ) error {
275
279
origDummyName := ep .Spec .Iface .Name
276
- origDummyMac ,_ := net .ParseMAC (ep .Spec .Iface .MacAddress )
277
280
if dnet .Spec .Options .Vlan != 0 {
278
281
origDummyName = ep .ObjectMeta .Name [0 :14 ]
279
282
}
@@ -282,12 +285,16 @@ func createDummyInterface(ep *danmtypes.DanmEp, dnet *danmtypes.DanmNet) error {
282
285
Name : origDummyName ,
283
286
},
284
287
}
285
- if origDummyMac .String () != "" {
288
+ origDummyMac ,_ := net .ParseMAC (ep .Spec .Iface .MacAddress )
289
+ origDummyMacStr := origDummyMac .String ()
290
+ //It is observed VFIO bound VFs do not always retain their original MAC address for some reason
291
+ //To avoid failing Pod instantiation in this case we only force MAC address on dummy if the VF looks "healthy"
292
+ if origDummyMacStr != "" && origDummyMacStr != InvalidMacAddress {
286
293
dummy .LinkAttrs .HardwareAddr = origDummyMac
287
294
}
288
295
err := netlink .LinkAdd (dummy )
289
296
if err != nil {
290
- return errors .New ("cannot create dummy interface for DPDK because:" + err .Error ())
297
+ return errors .New ("cannot create dummy interface with MAC:" + origDummyMacStr + " for DPDK because:" + err .Error ())
291
298
}
292
299
if dnet .Spec .Options .Vlan == 0 {
293
300
err = netlink .LinkSetAlias (dummy , ep .Spec .Iface .DeviceID )
@@ -304,20 +311,19 @@ func createDummyInterface(ep *danmtypes.DanmEp, dnet *danmtypes.DanmNet) error {
304
311
if err != nil {
305
312
return errors .New ("cannot find freshly created dummy interface because:" + err .Error ())
306
313
}
307
- vfMac , _ := net .ParseMAC (ep .Spec .Iface .MacAddress )
308
314
dummyVlan := & netlink.Vlan {
309
315
VlanId : dnet .Spec .Options .Vlan ,
310
316
LinkAttrs : netlink.LinkAttrs {
311
317
ParentIndex : iface .Attrs ().Index ,
312
318
Name : ep .Spec .Iface .Name ,
313
319
},
314
320
}
315
- if vfMac . String () != "" {
316
- dummyVlan .LinkAttrs .HardwareAddr = vfMac
321
+ if origDummyMacStr != "" && origDummyMacStr != InvalidMacAddress {
322
+ dummyVlan .LinkAttrs .HardwareAddr = origDummyMac
317
323
}
318
324
err = netlink .LinkAdd (dummyVlan )
319
325
if err != nil {
320
- return errors .New ("cannot create VLAN on dummy interface for DPDK because:" + err .Error ())
326
+ return errors .New ("cannot create VLAN on dummy interface with MAC:" + origDummyMacStr + " for DPDK because:" + err .Error ())
321
327
}
322
328
err = netlink .LinkSetAlias (dummyVlan , ep .Spec .Iface .DeviceID )
323
329
if err != nil {
0 commit comments