summaryrefslogtreecommitdiffstats
path: root/src/vnet/pg/stream.c
diff options
context:
space:
mode:
authorNeale Ranns <nranns@cisco.com>2020-10-05 12:26:47 +0000
committerDamjan Marion <dmarion@me.com>2020-10-08 06:11:07 +0000
commit21fb4f71ee3824c8f177045f21fea258ece602a9 (patch)
tree8ef415f172df0de141a11169cfbbd87072a0aa54 /src/vnet/pg/stream.c
parent27c35e30569c3904e977e7f841b8bc56f16aeb9f (diff)
fib: Register multicast MAC with interface for accepting interfaces
Type: fix Signed-off-by: Neale Ranns <nranns@cisco.com> Change-Id: Ic6c76b65e2dcc08916373153944507a297c962c0
Diffstat (limited to 'src/vnet/pg/stream.c')
-rw-r--r--src/vnet/pg/stream.c37
1 files changed, 37 insertions, 0 deletions
diff --git a/src/vnet/pg/stream.c b/src/vnet/pg/stream.c
index 88c89371c6c..6ea80903de0 100644
--- a/src/vnet/pg/stream.c
+++ b/src/vnet/pg/stream.c
@@ -139,6 +139,39 @@ pg_interface_admin_up_down (vnet_main_t * vnm, u32 hw_if_index, u32 flags)
return 0;
}
+static int
+pg_mac_address_cmp (const mac_address_t * m1, const mac_address_t * m2)
+{
+ return (!mac_address_cmp (m1, m2));
+}
+
+static clib_error_t *
+pg_add_del_mac_address (vnet_hw_interface_t * hi,
+ const u8 * address, u8 is_add)
+{
+ pg_main_t *pg = &pg_main;
+
+ if (ethernet_address_cast (address))
+ {
+ mac_address_t mac;
+ pg_interface_t *pi;
+
+ pi = pool_elt_at_index (pg->interfaces, hi->dev_instance);
+
+ mac_address_from_bytes (&mac, address);
+ if (is_add)
+ vec_add1 (pi->allowed_mcast_macs, mac);
+ else
+ {
+ u32 pos = vec_search_with_function (pi->allowed_mcast_macs, &mac,
+ pg_mac_address_cmp);
+ if (~0 != pos)
+ vec_del1 (pi->allowed_mcast_macs, pos);
+ }
+ }
+ return (NULL);
+}
+
/* *INDENT-OFF* */
VNET_DEVICE_CLASS (pg_dev_class) = {
.name = "pg",
@@ -146,6 +179,7 @@ VNET_DEVICE_CLASS (pg_dev_class) = {
.format_device_name = format_pg_interface_name,
.format_tx_trace = format_pg_output_trace,
.admin_up_down_function = pg_interface_admin_up_down,
+ .mac_addr_add_del_function = pg_add_del_mac_address,
};
/* *INDENT-ON* */
@@ -245,6 +279,9 @@ pg_interface_add_or_get (pg_main_t * pg, uword if_id, u8 gso_enabled,
hash_set (pg->if_index_by_if_id, if_id, i);
+ vec_validate (pg->if_id_by_sw_if_index, hi->sw_if_index);
+ pg->if_id_by_sw_if_index[hi->sw_if_index] = i;
+
if (vlib_num_workers ())
{
pi->lockp = clib_mem_alloc_aligned (CLIB_CACHE_LINE_BYTES,