-
Notifications
You must be signed in to change notification settings - Fork 276
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[EVPN-MH] Added new APP_L2_NEXTHOP_GROUP_TABLE_NAME table in APPL_DB #952
base: master
Are you sure you want to change the base?
Changes from 3 commits
d747b97
304b98b
2026423
e821947
77db804
561b61a
025bbd9
5e72b77
cd32cfd
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -35,12 +35,45 @@ void NetDispatcher::unregisterMessageHandler(int nlmsg_type) | |
m_handlers.erase(it); | ||
} | ||
|
||
void NetDispatcher::registerRawMessageHandler(int nlmsg_type, NetMsg *callback) | ||
{ | ||
if (m_rawhandlers.find(nlmsg_type) != m_rawhandlers.end()) | ||
throw "Trying to registered on already registerd netlink message"; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. better to throw specific exception type like runtime_error instead of string literals. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is similar to the method registerMessageHandler. Hence similar error handling is done. |
||
|
||
m_rawhandlers[nlmsg_type] = callback; | ||
} | ||
|
||
void NetDispatcher::unregisterRawMessageHandler(int nlmsg_type) | ||
{ | ||
auto it = m_rawhandlers.find(nlmsg_type); | ||
|
||
if (it == m_rawhandlers.end()) | ||
throw "Trying to unregister non existing handler"; | ||
|
||
m_rawhandlers.erase(it); | ||
|
||
} | ||
|
||
void NetDispatcher::nlCallback(struct nl_object *obj, void *context) | ||
{ | ||
NetMsg *callback = (NetMsg *)context; | ||
callback->onMsg(nl_object_get_msgtype(obj), obj); | ||
} | ||
|
||
void NetDispatcher::onNetlinkMessageRaw(struct nl_msg *msg) | ||
{ | ||
struct nlmsghdr *nlmsghdr = nlmsg_hdr(msg); | ||
liuh-80 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
NetMsg *reg_callback = NULL; | ||
auto callback = m_rawhandlers.find(nlmsghdr->nlmsg_type); | ||
|
||
/* Drop not registered messages */ | ||
if (callback == m_rawhandlers.end()) | ||
return; | ||
|
||
reg_callback = (NetMsg *)callback->second; | ||
reg_callback->onMsgRaw(nlmsghdr); | ||
} | ||
|
||
NetMsg* NetDispatcher::getCallback(int nlmsg_type) | ||
{ | ||
MUTEX; | ||
|
@@ -61,7 +94,9 @@ void NetDispatcher::onNetlinkMessage(struct nl_msg *msg) | |
|
||
/* Drop not registered messages */ | ||
if (callback == nullptr) | ||
{ | ||
onNetlinkMessageRaw(msg); | ||
return; | ||
|
||
} | ||
nl_msg_parse(msg, NetDispatcher::nlCallback, (callback)); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is m_rawhandlers protected by m_mutex? as well as unregisterRawMessageHandler() function.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch, Sure I will put this in mutex as well.