summaryrefslogtreecommitdiffstats
path: root/src/vnet/ethernet/node.c
diff options
context:
space:
mode:
authorBenoît Ganne <bganne@cisco.com>2020-10-20 16:24:17 +0200
committerDamjan Marion <dmarion@me.com>2020-11-13 11:17:50 +0000
commitb44c77d01dcf9ebf80d7bcab097515ad8135bc05 (patch)
tree71070f6ea6b5dc989730e1775f6c7916a07938fc /src/vnet/ethernet/node.c
parent41c0f45a56d4db5b2ee4ae4fff7f3f0571a23189 (diff)
ethernet: mac must support 64-bits loads
ethernet dataplane loads MAC addresses as 64-bits loads for efficiency. We must make sure it is valid, especially for the vector of secondary MACs. Type: fix Change-Id: I851e319b8a973c154e85ff9f05f3b8e385939788 Signed-off-by: Benoît Ganne <bganne@cisco.com>
Diffstat (limited to 'src/vnet/ethernet/node.c')
-rw-r--r--src/vnet/ethernet/node.c19
1 files changed, 13 insertions, 6 deletions
diff --git a/src/vnet/ethernet/node.c b/src/vnet/ethernet/node.c
index 73e9eec71ae..efe7290d19a 100644
--- a/src/vnet/ethernet/node.c
+++ b/src/vnet/ethernet/node.c
@@ -694,9 +694,11 @@ ethernet_input_inline_dmac_check (vnet_hw_interface_t * hi,
u32 n_packets, ethernet_interface_t * ei,
u8 have_sec_dmac)
{
- u64 hwaddr = (*(u64 *) hi->hw_address) & DMAC_MASK;
+ u64 hwaddr = ei->address.as_u64;
u8 bad = 0;
+ ASSERT (0 == ei->address.zero);
+
dmacs_bad[0] = is_dmac_bad (dmacs[0], hwaddr);
dmacs_bad[1] = ((n_packets > 1) & is_dmac_bad (dmacs[1], hwaddr));
@@ -704,11 +706,12 @@ ethernet_input_inline_dmac_check (vnet_hw_interface_t * hi,
if (PREDICT_FALSE (bad && have_sec_dmac))
{
- mac_address_t *sec_addr;
+ ethernet_interface_address_t *sec_addr;
vec_foreach (sec_addr, ei->secondary_addrs)
{
- hwaddr = (*(u64 *) sec_addr) & DMAC_MASK;
+ ASSERT (0 == sec_addr->zero);
+ hwaddr = sec_addr->as_u64;
bad = (eth_input_sec_dmac_check_x1 (hwaddr, dmacs, dmacs_bad) |
eth_input_sec_dmac_check_x1 (hwaddr, dmacs + 1,
@@ -726,12 +729,14 @@ eth_input_process_frame_dmac_check (vnet_hw_interface_t * hi,
u32 n_packets, ethernet_interface_t * ei,
u8 have_sec_dmac)
{
- u64 hwaddr = (*(u64 *) hi->hw_address) & DMAC_MASK;
+ u64 hwaddr = ei->address.as_u64;
u64 *dmac = dmacs;
u8 *dmac_bad = dmacs_bad;
u32 bad = 0;
i32 n_left = n_packets;
+ ASSERT (0 == ei->address.zero);
+
#ifdef CLIB_HAVE_VEC256
while (n_left > 0)
{
@@ -760,15 +765,17 @@ eth_input_process_frame_dmac_check (vnet_hw_interface_t * hi,
if (have_sec_dmac && bad)
{
- mac_address_t *addr;
+ ethernet_interface_address_t *addr;
vec_foreach (addr, ei->secondary_addrs)
{
- u64 hwaddr = ((u64 *) addr)[0] & DMAC_MASK;
+ u64 hwaddr = addr->as_u64;
i32 n_left = n_packets;
u64 *dmac = dmacs;
u8 *dmac_bad = dmacs_bad;
+ ASSERT (0 == addr->zero);
+
bad = 0;
while (n_left > 0)