summaryrefslogtreecommitdiff
path: root/usr/src/uts/common/io/mac/mac.c
diff options
context:
space:
mode:
Diffstat (limited to 'usr/src/uts/common/io/mac/mac.c')
-rw-r--r--usr/src/uts/common/io/mac/mac.c28
1 files changed, 24 insertions, 4 deletions
diff --git a/usr/src/uts/common/io/mac/mac.c b/usr/src/uts/common/io/mac/mac.c
index f4074a2b91..d698862d81 100644
--- a/usr/src/uts/common/io/mac/mac.c
+++ b/usr/src/uts/common/io/mac/mac.c
@@ -21,7 +21,7 @@
/*
* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
- * Copyright 2019 Joyent, Inc.
+ * Copyright 2020 Joyent, Inc.
* Copyright 2015 Garrett D'Amore <garrett@damore.org>
*/
@@ -1648,7 +1648,8 @@ mac_hwrings_idx_get(mac_handle_t mh, uint_t idx, mac_group_handle_t *hwgh,
if (rtype == MAC_RING_TYPE_RX) {
grp = mip->mi_rx_groups;
- } else if (rtype == MAC_RING_TYPE_TX) {
+ } else {
+ ASSERT(rtype == MAC_RING_TYPE_TX);
grp = mip->mi_tx_groups;
}
@@ -5536,6 +5537,11 @@ mac_add_macaddr_vlan(mac_impl_t *mip, mac_group_t *group, uint8_t *addr,
return (0);
}
+ /*
+ * We failed to set promisc mode and we are about to free 'map'.
+ */
+ map->ma_nusers = 0;
+
bail:
if (hw_vlan) {
int err2 = mac_group_remvlan(group, vid);
@@ -5591,6 +5597,8 @@ mac_remove_macaddr_vlan(mac_address_t *map, uint16_t vid)
if (map->ma_nusers > 0)
return (0);
+ VERIFY3S(map->ma_nusers, ==, 0);
+
/*
* The MAC address is no longer used by any MAC client, so
* remove it from its associated group. Turn off promiscuous
@@ -5615,7 +5623,16 @@ mac_remove_macaddr_vlan(mac_address_t *map, uint16_t vid)
* If we fail to remove the MAC address HW
* filter but then also fail to re-add the
* VLAN HW filter then we are in a busted
- * state and should just crash.
+ * state. We do our best by logging a warning
+ * and returning the original 'err' that got
+ * us here. At this point, traffic for this
+ * address + VLAN combination will be dropped
+ * until the user reboots the system. In the
+ * future, it would be nice to have a system
+ * that can compare the state of expected
+ * classification according to mac to the
+ * actual state of the provider, and report
+ * and fix any inconsistencies.
*/
if (MAC_GROUP_HW_VLAN(group)) {
int err2;
@@ -5629,6 +5646,7 @@ mac_remove_macaddr_vlan(mac_address_t *map, uint16_t vid)
}
}
+ map->ma_nusers = 1;
return (err);
}
@@ -5642,8 +5660,10 @@ mac_remove_macaddr_vlan(mac_address_t *map, uint16_t vid)
map->ma_type, __FILE__, __LINE__);
}
- if (err != 0)
+ if (err != 0) {
+ map->ma_nusers = 1;
return (err);
+ }
/*
* We created MAC address for the primary one at registration, so we