network, macvtap bind mech: configure domXML mac addr via a method
@@ -1247,13 +1247,7 @@ func (b *MacvtapBindMechanism) discoverPodNetworkInterface() error {
return err
}
b.podNicLink = link
- if b.mac != nil {
- b.virtIface.MAC = &api.MAC{MAC: b.mac.String()}
- } else {
- // Get interface MAC address
- b.virtIface.MAC = &api.MAC{MAC: b.podNicLink.Attrs().HardwareAddr.String()}
- }
-
+ b.virtIface.MAC = &api.MAC{MAC: b.podIfaceMAC()}
b.virtIface.MTU = &api.MTU{Size: strconv.Itoa(b.podNicLink.Attrs().MTU)}
b.virtIface.Target = &api.InterfaceTarget{
Device: b.podInterfaceName,
@@ -1263,6 +1257,14 @@ func (b *MacvtapBindMechanism) discoverPodNetworkInterface() error {
return nil
}
+func (b *MacvtapBindMechanism) podIfaceMAC() string {
+ if b.mac != nil {
+ return b.mac.String()
+ } else {
+ return b.podNicLink.Attrs().HardwareAddr.String()
+ }
+}
+
func (b *MacvtapBindMechanism) preparePodNetworkInterfaces(_ uint32, _ int) error {
return nil
}
