Commit b71121b4 authored by Shiraz Saleem's avatar Shiraz Saleem Committed by Doug Ledford

i40iw: Receive notification events correctly

Device notifications are not received after the first interface is
closed; since there is an unregister for notifications on every
interface close. Correct this by unregistering for device
notifications only when the last interface is closed. Also, make
all operations on the i40iw_notifiers_registered atomic as it
can be read/modified concurrently.

Fixes: 8e06af71 ("i40iw: add main, hdr, status")
Signed-off-by: default avatarMustafa Ismail <mustafa.ismail@intel.com>
Signed-off-by: default avatarShiraz Saleem <shiraz.saleem@intel.com>
Signed-off-by: default avatarDoug Ledford <dledford@redhat.com>
parent 866e0f4d
...@@ -100,7 +100,7 @@ static struct notifier_block i40iw_net_notifier = { ...@@ -100,7 +100,7 @@ static struct notifier_block i40iw_net_notifier = {
.notifier_call = i40iw_net_event .notifier_call = i40iw_net_event
}; };
static int i40iw_notifiers_registered; static atomic_t i40iw_notifiers_registered;
/** /**
* i40iw_find_i40e_handler - find a handler given a client info * i40iw_find_i40e_handler - find a handler given a client info
...@@ -1342,12 +1342,11 @@ static enum i40iw_status_code i40iw_initialize_dev(struct i40iw_device *iwdev, ...@@ -1342,12 +1342,11 @@ static enum i40iw_status_code i40iw_initialize_dev(struct i40iw_device *iwdev,
*/ */
static void i40iw_register_notifiers(void) static void i40iw_register_notifiers(void)
{ {
if (!i40iw_notifiers_registered) { if (atomic_inc_return(&i40iw_notifiers_registered) == 1) {
register_inetaddr_notifier(&i40iw_inetaddr_notifier); register_inetaddr_notifier(&i40iw_inetaddr_notifier);
register_inet6addr_notifier(&i40iw_inetaddr6_notifier); register_inet6addr_notifier(&i40iw_inetaddr6_notifier);
register_netevent_notifier(&i40iw_net_notifier); register_netevent_notifier(&i40iw_net_notifier);
} }
i40iw_notifiers_registered++;
} }
/** /**
...@@ -1429,8 +1428,7 @@ static void i40iw_deinit_device(struct i40iw_device *iwdev, bool reset, bool del ...@@ -1429,8 +1428,7 @@ static void i40iw_deinit_device(struct i40iw_device *iwdev, bool reset, bool del
i40iw_del_macip_entry(iwdev, (u8)iwdev->mac_ip_table_idx); i40iw_del_macip_entry(iwdev, (u8)iwdev->mac_ip_table_idx);
/* fallthrough */ /* fallthrough */
case INET_NOTIFIER: case INET_NOTIFIER:
if (i40iw_notifiers_registered > 0) { if (!atomic_dec_return(&i40iw_notifiers_registered)) {
i40iw_notifiers_registered--;
unregister_netevent_notifier(&i40iw_net_notifier); unregister_netevent_notifier(&i40iw_net_notifier);
unregister_inetaddr_notifier(&i40iw_inetaddr_notifier); unregister_inetaddr_notifier(&i40iw_inetaddr_notifier);
unregister_inet6addr_notifier(&i40iw_inetaddr6_notifier); unregister_inet6addr_notifier(&i40iw_inetaddr6_notifier);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment