summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrew Yourtchenko <ayourtch@gmail.com>2022-08-30 11:22:09 +0000
committerAndrew Yourtchenko <ayourtch@gmail.com>2022-08-30 11:40:37 +0000
commit966e6ff173f3ef2f426052fa76c9bffc393c53e1 (patch)
treec9b5168fea623e48bfeb9c9524173866b3e7ae25
parenta9bfef73a7b866eccf2a39b19c12ec46d41e484e (diff)
ethernet: refactor the redundant code
Following the discussion during the review of b46a4e69e5db18ef792415439d04a0ab22c59386, remove the redundant ei0. This resulted in realization that in order for this code to do anything useful, the ei must be always non-zero, so rewrite the logical condition for it. Also, make it a conjunction which seems simpler to understand. Type: improvement Change-Id: Ibd7b2a63e4aeaf97eb1a98af8e69aed2ff7dd577 Signed-off-by: Andrew Yourtchenko <ayourtch@gmail.com>
-rw-r--r--src/vnet/ethernet/node.c15
1 files changed, 7 insertions, 8 deletions
diff --git a/src/vnet/ethernet/node.c b/src/vnet/ethernet/node.c
index 21346a80658..c1a8e0d4ce6 100644
--- a/src/vnet/ethernet/node.c
+++ b/src/vnet/ethernet/node.c
@@ -225,25 +225,24 @@ identify_subint (ethernet_main_t * em,
// A unicast packet arriving on an L3 interface must have a dmac
// matching the interface mac. If interface has STATUS_L3 bit set
// mac filter is already done.
- if (!(*is_l2 || (ei && (ei->flags & ETHERNET_INTERFACE_FLAG_STATUS_L3))))
+ if ((!*is_l2) && ei &&
+ (!(ei->flags & ETHERNET_INTERFACE_FLAG_STATUS_L3)))
{
u64 dmacs[2];
u8 dmacs_bad[2];
ethernet_header_t *e0;
- ethernet_interface_t *ei0;
e0 = (void *) (b0->data + vnet_buffer (b0)->l2_hdr_offset);
dmacs[0] = *(u64 *) e0;
- ei0 = ethernet_get_interface (&ethernet_main, hi->hw_if_index);
- if (ei0 && vec_len (ei0->secondary_addrs))
+ if (vec_len (ei->secondary_addrs))
ethernet_input_inline_dmac_check (hi, dmacs, dmacs_bad,
- 1 /* n_packets */ , ei0,
- 1 /* have_sec_dmac */ );
+ 1 /* n_packets */, ei,
+ 1 /* have_sec_dmac */);
else
ethernet_input_inline_dmac_check (hi, dmacs, dmacs_bad,
- 1 /* n_packets */ , ei0,
- 0 /* have_sec_dmac */ );
+ 1 /* n_packets */, ei,
+ 0 /* have_sec_dmac */);
if (dmacs_bad[0])
*error0 = ETHERNET_ERROR_L3_MAC_MISMATCH;
}