fib: Register multicast MAC with interface for accepting interfaces
Type: fix
Signed-off-by: Neale Ranns <nranns@cisco.com>
Change-Id: Ic6c76b65e2dcc08916373153944507a297c962c0
diff --git a/src/vnet/pg/stream.c b/src/vnet/pg/stream.c
index 88c8937..6ea8090 100644
--- a/src/vnet/pg/stream.c
+++ b/src/vnet/pg/stream.c
@@ -139,6 +139,39 @@
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 @@
.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 @@
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,