commit 85ac507cf5c0c86c33db0bc589bec708e40449ad
parent 2ec069fc98afb92c02be379cd269c7398b13cf82
Author: Broadcom SDK Release <sdk.releases@broadcom.com>
Date: Fri, 11 Oct 2019 12:20:22 -0700
SDK-192589: In previous releases, segmentation fault was observed when invoki...
Devices: 56980_A0
Module: L2
Symptom:
Seg fault observed in _bcm_l2_register_callback() when
bcm_l2_addr_unregister is issued while traffic is on
In previous releases, segmentation fault was observed when invoking
bcm_l2_addr_unregister while traffic was running. In this release, this
issue has been fixed.
Diffstat:
1 file changed, 37 insertions(+), 5 deletions(-)
diff --git a/sdk-6.5.16/src/bcm/tomahawk3/l2.c b/sdk-6.5.16/src/bcm/tomahawk3/l2.c
@@ -49,6 +49,7 @@
int _th3_l2_init[BCM_MAX_NUM_UNITS];
static _bcm_l2_match_ctrl_t *_bcm_th3_l2_match_ctrl[BCM_MAX_NUM_UNITS];
+static sal_sem_t _bcm_th3_l2_cb_check[BCM_MAX_NUM_UNITS];
/****************************************************************************
*
@@ -293,6 +294,14 @@ bcm_tomahawk3_l2_init(int unit)
}
#endif /* BCM_WARM_BOOT_SUPPORT */
+ if (_bcm_th3_l2_cb_check[unit] == NULL) {
+ _bcm_th3_l2_cb_check[unit] = sal_sem_create("l2 callback check",
+ sal_sem_BINARY, 1);
+ if (_bcm_th3_l2_cb_check[unit] == NULL) {
+ return BCM_E_MEMORY;
+ }
+ }
+
_th3_l2_init[unit] = 1;
return BCM_E_NONE;
}
@@ -330,6 +339,11 @@ bcm_tomahawk3_l2_detach(int unit)
*/
SOC_IF_ERROR_RETURN(mbcm_driver[unit]->mbcm_l2_term(unit));
+ if (_bcm_th3_l2_cb_check[unit] != NULL) {
+ sal_sem_destroy(_bcm_th3_l2_cb_check[unit]);
+ _bcm_th3_l2_cb_check[unit] = NULL;
+ }
+
_th3_l2_init[unit] = 0;
return BCM_E_NONE;
@@ -642,10 +656,16 @@ _bcm_th3_l2_register_callback(int unit,
}
}
- /* The entries are now set up. Make the callbacks */
+ if (_bcm_th3_l2_cb_check[unit] != NULL) {
+ sal_sem_take(_bcm_th3_l2_cb_check[unit], sal_sem_FOREVER);
+ }
+
+ /* The entries are now set up. Make the callbacks */
if (entry_del != NULL) {
- _bcm_th3_l2_cbs[unit](unit, &l2addr_del, 0,
- _bcm_th3_l2_cb_data[unit]);
+ if (_bcm_th3_l2_cbs[unit] != NULL) {
+ _bcm_th3_l2_cbs[unit](unit, &l2addr_del, 0,
+ _bcm_th3_l2_cb_data[unit]);
+ }
}
if (pflags & SOC_L2X_ENTRY_OVERFLOW) {
@@ -653,8 +673,14 @@ _bcm_th3_l2_register_callback(int unit,
}
if (entry_add != NULL) {
- _bcm_th3_l2_cbs[unit](unit, &l2addr_add, 1,
- _bcm_th3_l2_cb_data[unit]);
+ if (_bcm_th3_l2_cbs[unit] != NULL) {
+ _bcm_th3_l2_cbs[unit](unit, &l2addr_add, 1,
+ _bcm_th3_l2_cb_data[unit]);
+ }
+ }
+
+ if (_bcm_th3_l2_cb_check[unit] != NULL) {
+ sal_sem_give(_bcm_th3_l2_cb_check[unit]);
}
}
}
@@ -3578,6 +3604,9 @@ bcm_tomahawk3_l2_addr_unregister(int unit,
TH3_L2_INIT(unit);
L2_MUTEX(unit);
+ if (_bcm_th3_l2_cb_check[unit] != NULL) {
+ sal_sem_take(_bcm_th3_l2_cb_check[unit], sal_sem_FOREVER);
+ }
L2_LOCK(unit);
for (i = 0; i < L2_CB_MAX; i++) {
@@ -3600,6 +3629,9 @@ bcm_tomahawk3_l2_addr_unregister(int unit,
}
L2_UNLOCK(unit);
+ if (_bcm_th3_l2_cb_check[unit] != NULL) {
+ sal_sem_give(_bcm_th3_l2_cb_check[unit]);
+ }
return (rv);
}