Skip to content

[EVPN-MH] Added new APP_L2_NEXTHOP_GROUP_TABLE_NAME table in APPL_DB#952

Open
kishorekunal01 wants to merge 9 commits intosonic-net:masterfrom
kishorekunal01:evpn_mh_nhg_support
Open

[EVPN-MH] Added new APP_L2_NEXTHOP_GROUP_TABLE_NAME table in APPL_DB#952
kishorekunal01 wants to merge 9 commits intosonic-net:masterfrom
kishorekunal01:evpn_mh_nhg_support

Conversation

@kishorekunal01
Copy link
Contributor

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

@adyeung
Copy link

adyeung commented Nov 14, 2024

@pbrisset please have someone from CSCO to help review

And support to register and de-register raw netlink msg

Signed-off-by: Kishore Kunal <kishore.kunal@broadcom.com>
@liuh-80
Copy link
Contributor

liuh-80 commented Nov 18, 2024

@kishorekunal01 , can you improve code coverage by add new test case?

@liuh-80 liuh-80 self-requested a review November 18, 2024 02:09
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";
Copy link
Contributor

Choose a reason for hiding this comment

The 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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The 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_handlers.erase(it);
}

void NetDispatcher::registerRawMessageHandler(int nlmsg_type, NetMsg *callback)
Copy link
Contributor

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.

Copy link
Contributor Author

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.

@liuh-80
Copy link
Contributor

liuh-80 commented Dec 9, 2024

@kishorekunal01 , you need add new test case to cover code change:

Total: 20 lines
Missing: 20 lines
Coverage: 0%
Threshold: 80%

@kishorekunal01
Copy link
Contributor Author

@kishorekunal01 , you need add new test case to cover code change:

Total: 20 lines Missing: 20 lines Coverage: 0% Threshold: 80%

Sure.

return;

reg_callback = (NetMsg *)callback->second;
reg_callback->onMsgRaw(nlmsghdr);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 *)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 *)
{

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants