net/mgmt: Mask vs event should be verified part by part
It needs to check if current event matches: - cb's layer - cb's layer code - cb's command If none match, it will not raise the event. Fixing the unit test as layer must be always != 0. Jira: ZEP-1940 Change-Id: Iadd63e751fa6e534a10e7da9cae0f5bb5a384461 Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
This commit is contained in:
parent
8292dc16d4
commit
8108a608ff
2 changed files with 12 additions and 5 deletions
|
@ -111,13 +111,20 @@ static inline void mgmt_run_callbacks(struct mgmt_event_entry *mgmt_event)
|
|||
sys_snode_t *prev = NULL;
|
||||
struct net_mgmt_event_callback *cb, *tmp;
|
||||
|
||||
NET_DBG("Event layer %u code %u type %u",
|
||||
NET_DBG("Event layer %u code %u cmd %u",
|
||||
NET_MGMT_GET_LAYER(mgmt_event->event),
|
||||
NET_MGMT_GET_LAYER_CODE(mgmt_event->event),
|
||||
NET_MGMT_GET_COMMAND(mgmt_event->event));
|
||||
|
||||
SYS_SLIST_FOR_EACH_CONTAINER_SAFE(&event_callbacks, cb, tmp, node) {
|
||||
if ((mgmt_event->event & cb->event_mask) != mgmt_event->event) {
|
||||
if (!(NET_MGMT_GET_LAYER(mgmt_event->event) &
|
||||
NET_MGMT_GET_LAYER(cb->event_mask)) ||
|
||||
!(NET_MGMT_GET_LAYER_CODE(mgmt_event->event) &
|
||||
NET_MGMT_GET_LAYER_CODE(cb->event_mask)) ||
|
||||
(NET_MGMT_GET_COMMAND(mgmt_event->event) &&
|
||||
NET_MGMT_GET_COMMAND(cb->event_mask) &&
|
||||
!(NET_MGMT_GET_COMMAND(mgmt_event->event) &
|
||||
NET_MGMT_GET_COMMAND(cb->event_mask)))) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
|
|
@ -13,9 +13,9 @@
|
|||
#include <net/net_mgmt.h>
|
||||
#include <net/nbuf.h>
|
||||
|
||||
#define TEST_MGMT_REQUEST 0x07AB1234
|
||||
#define TEST_MGMT_EVENT 0x87AB1234
|
||||
#define TEST_MGMT_EVENT_UNHANDLED 0x87AB4321
|
||||
#define TEST_MGMT_REQUEST 0x17AB1234
|
||||
#define TEST_MGMT_EVENT 0x97AB1234
|
||||
#define TEST_MGMT_EVENT_UNHANDLED 0x97AB4321
|
||||
|
||||
/* Notifier infra */
|
||||
static uint32_t event2throw;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue