aboutsummaryrefslogtreecommitdiffstats
path: root/src/vnet
diff options
context:
space:
mode:
Diffstat (limited to 'src/vnet')
-rw-r--r--src/vnet/devices/virtio/virtio.h10
-rw-r--r--src/vnet/devices/virtio/virtio_pci_modern.c10
2 files changed, 13 insertions, 7 deletions
diff --git a/src/vnet/devices/virtio/virtio.h b/src/vnet/devices/virtio/virtio.h
index f1eaa07fe5d..b00e1eceb85 100644
--- a/src/vnet/devices/virtio/virtio.h
+++ b/src/vnet/devices/virtio/virtio.h
@@ -129,7 +129,15 @@ typedef struct
/* error */
clib_error_t *error;
- u8 mac_addr[6];
+ union
+ {
+ struct
+ {
+ u32 mac_addr32;
+ u16 mac_addr16;
+ };
+ u8 mac_addr[6];
+ };
union
{
struct /* tun/tap interface */
diff --git a/src/vnet/devices/virtio/virtio_pci_modern.c b/src/vnet/devices/virtio/virtio_pci_modern.c
index 0d86ff2acda..4eb0ff102ae 100644
--- a/src/vnet/devices/virtio/virtio_pci_modern.c
+++ b/src/vnet/devices/virtio/virtio_pci_modern.c
@@ -311,19 +311,17 @@ virtio_pci_modern_del_queue (vlib_main_t * vm, virtio_if_t * vif,
static void
virtio_pci_modern_get_device_mac (vlib_main_t * vm, virtio_if_t * vif)
{
- *((u32 *) vif->mac_addr) =
- virtio_pci_reg_read_u32 (vif, VIRTIO_MAC_OFFSET (vif));
- *((u16 *) (vif->mac_addr + 4)) =
+ vif->mac_addr32 = virtio_pci_reg_read_u32 (vif, VIRTIO_MAC_OFFSET (vif));
+ vif->mac_addr16 =
virtio_pci_reg_read_u16 (vif, VIRTIO_MAC_OFFSET (vif) + 4);
}
static void
virtio_pci_modern_set_device_mac (vlib_main_t * vm, virtio_if_t * vif)
{
- virtio_pci_reg_write_u32 (vif, VIRTIO_MAC_OFFSET (vif),
- *((u32 *) vif->mac_addr));
+ virtio_pci_reg_write_u32 (vif, VIRTIO_MAC_OFFSET (vif), vif->mac_addr32);
virtio_pci_reg_write_u16 (vif, VIRTIO_MAC_OFFSET (vif) + 4,
- *((u16 *) (vif->mac_addr + 4)));
+ vif->mac_addr16);
}
static u16