[EVPN-MH] Added new APP_L2_NEXTHOP_GROUP_TABLE_NAME table in APPL_DB#952
[EVPN-MH] Added new APP_L2_NEXTHOP_GROUP_TABLE_NAME table in APPL_DB#952kishorekunal01 wants to merge 9 commits intosonic-net:masterfrom
Conversation
|
@pbrisset please have someone from CSCO to help review |
ca41f0e to
cfb5c77
Compare
And support to register and de-register raw netlink msg Signed-off-by: Kishore Kunal <kishore.kunal@broadcom.com>
cfb5c77 to
d747b97
Compare
|
@kishorekunal01 , can you improve code coverage by add new test case? |
| 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.
better to throw specific exception type like runtime_error instead of string literals.
There was a problem hiding this comment.
This is similar to the method registerMessageHandler. Hence similar error handling is done.
| m_handlers.erase(it); | ||
| } | ||
|
|
||
| void NetDispatcher::registerRawMessageHandler(int nlmsg_type, NetMsg *callback) |
There was a problem hiding this comment.
is m_rawhandlers protected by m_mutex? as well as unregisterRawMessageHandler() function.
There was a problem hiding this comment.
Good catch, Sure I will put this in mutex as well.
And support to register and de-register raw netlink msg Signed-off-by: Kishore Kunal <kishore.kunal@broadcom.com>
Evpn mh nhg support
|
@kishorekunal01 , you need add new test case to cover code change: Total: 20 lines |
Sure. |
| return; | ||
|
|
||
| reg_callback = (NetMsg *)callback->second; | ||
| reg_callback->onMsgRaw(nlmsghdr); |
There was a problem hiding this comment.
If m_rawhandlers[nlmsg_type] somehow contains nullptr, this will segfault.
| virtual void onMsg(int nlmsg_type, struct nl_object *obj) = 0; | ||
|
|
||
| /* Called by NetDispatcher when raw msg is send for matches filters */ | ||
| virtual void onMsgRaw(struct nlmsghdr *) |
There was a problem hiding this comment.
Issue: Class has virtual methods but no virtual destructor.
- If a derived class is deleted through a NetMsg* pointer, undefined behavior occurs
- Memory leaks or incorrect destructor calls in derived classes
|
|
||
| /* Called by NetDispatcher when raw msg is send for matches filters */ | ||
| virtual void onMsgRaw(struct nlmsghdr *) | ||
| { |
There was a problem hiding this comment.
Issue: Empty default implementation means:
- Caller registers a raw handler but forgets to override onMsgRaw() → silently does nothing
- No compile-time or runtime error/warning
- Hard to debug missing implementation
virtual void onMsgRaw(struct nlmsghdr *) {
SWSS_LOG_WARN("onMsgRaw called but not overridden in derived class");
}
or
virtual void onMsgRaw(struct nlmsghdr *) = 0;
Why I did it
Added the new APP_L2_NEXTHOP_GROUP_TABLE_NAME table in APPL_DB, along with support for registering and deregistering raw Netlink messages.
Direct handling of raw Netlink messages is required because libnl3 does not support Next Hop Group (NHG) message processing. Therefore, fdbsyncd needs to decode Kernel NHG messages to update the L2_NEXTHOP_GROUP_TABLE.
Check HLD: sonic-net/SONiC#1702
Signed-off-by: Kishore Kunal kishore.kunal@broadcom.com