Skip to content
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

[Orchagent] Recursive nexthop group enhancement #3105

Merged
merged 5 commits into from
May 18, 2024

Conversation

utpalkantpintoo
Copy link
Contributor

What I did

Implemented recursive nexthop group enhancement in Orchagent (NhgOrch). They have been proposed in:
sonic-net/SONiC#1636

Why I did it

These changes are required to handle a new field - "nexthop_group" in the App DB NEXT_HOP_GROUP_TABLE. Such nexthop groups are called recursive nexthop groups. This field contains the list of member (singleton) nexthop groups. Such recursive nexthop groups are represented by NEXT_HOP_GROUP objects.

How I verified it

Details if related

Copy link

linux-foundation-easycla bot commented Apr 7, 2024

CLA Signed

The committers listed above are authorized under a signed CLA.

@utpalkantpintoo
Copy link
Contributor Author

/azpw run Azure.sonic-swss

@mssonicbld
Copy link
Collaborator

/AzurePipelines run Azure.sonic-swss

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

}

/* Form nexthopgroup key with the nexthopgroup keys of available members */
nhgv = tokenize(nhgs, ',');

Choose a reason for hiding this comment

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

Can we use NHG_DELIMITER instead of ","

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

if (nhgs.empty())
nhgs = nhgm;
else
nhgs += ',' + nhgm;

Choose a reason for hiding this comment

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

Can we use NHG_DELIMITER instead of ","

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

@@ -687,6 +807,9 @@ bool NextHopGroup::syncMembers(const std::set<NextHopKey>& nh_keys)
{
SWSS_LOG_ENTER();

/* This method should not be called for single-membered non-recursive nexthop groups */
assert(isRecursive() || (m_members.size() > 1));

Choose a reason for hiding this comment

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

Instead of assert can we handle as exception?

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 in-line with similar error handling elsewhere in the code. We do not have a way to gracefully handle once we end up here for a non-recursive singleton nhg. There are necessary checks in caller fn.

*/
if (m_is_temp)
/* If the group is non-recursive with single member, the group ID will be the only member's NH ID */
if (!isRecursive() && (m_members.size() == 1))

Choose a reason for hiding this comment

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

Do we need m_is_temp check?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That'll be redundant as the current check will be true for "temp" nhgs as well.

{
nh_id = gIntfsOrch->getRouterIntfsId(m_key.alias);

if ((nh_id == SAI_NULL_OBJECT_ID) &&

Choose a reason for hiding this comment

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

We don't consider loopback as nexthop and trap packet to CPU during route add https://github.com/sonic-net/sonic-swss/blob/master/orchagent/routeorch.cpp#L1789, so do we need to add this CPU port for NHG?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Will make the NhgOrch behavior in-line with RouteOrch handling.
But I see an issue where if we receive such a msg, we'll end up holding the msgs in the corres. m_toSync queue(s) till the route is withdrawn.

Copy link
Contributor

Choose a reason for hiding this comment

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

We install IP2ME for loopback IPs, right? I think, we can safely ignore the message with error log if we get a NHG with loopback interface.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If the NHG is not created, the route msg will be retained waiting for the NHG. This may require creating a dummy NHG with just the key so that route msg can also be ignored.
This should be addressed in both the NhgOrch and RouteOrch as a defect fix.

for (uint32_t i = 0; i < ipv.size(); i++)
/* Keeps track of any non-existing member of a recursive nexthop group */
bool non_existent_member = false;

Copy link
Contributor

Choose a reason for hiding this comment

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

Do we need to throw a warning if ipv.size() is non-zero when is_recursive is set?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

}
nhg_str += ipv[i] + NH_DELIMITER + alsv[i];
}

Copy link
Contributor

Choose a reason for hiding this comment

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

Can we add a SWSS_LOG_DEBUG for nhg_str?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

@utpalkantpintoo utpalkantpintoo force-pushed the recursive_nhg branch 2 times, most recently from 4f972b0 to 166785d Compare May 15, 2024 09:13
@adyeung
Copy link

adyeung commented May 16, 2024

@venkatmahalingam @Gokulnath-Raja pls signoff if you have no further comments

Implemented recursive nexthop group enhancement in Orchagent (NhgOrch).
They have been proposed in:
sonic-net/SONiC#1636

Why I did it:

These changes are required to handle a new field - "nexthop_group" in the
App DB NEXT_HOP_GROUP_TABLE. Such nexthop groups are called recursive
nexthop groups. This field contains the list of member (singleton) nexthop groups.
Such recursive nexthop groups are represented by NEXT_HOP_GROUP objects.
Implemented recursive nexthop group enhancement in Orchagent (NhgOrch).
They have been proposed in:
sonic-net/SONiC#1636

Why I did it:

These changes are required to handle a new field - "nexthop_group" in the
App DB NEXT_HOP_GROUP_TABLE. Such nexthop groups are called recursive
nexthop groups. This field contains the list of member (singleton) nexthop groups.
Such recursive nexthop groups are represented by NEXT_HOP_GROUP objects.
Implemented recursive nexthop group enhancement in Orchagent (NhgOrch).
They have been proposed in:
sonic-net/SONiC#1636

Why I did it:

These changes are required to handle a new field - "nexthop_group" in the
App DB NEXT_HOP_GROUP_TABLE. Such nexthop groups are called recursive
nexthop groups. This field contains the list of member (singleton) nexthop groups.
Such recursive nexthop groups are represented by NEXT_HOP_GROUP objects.
Implemented recursive nexthop group enhancement in Orchagent (NhgOrch).
They have been proposed in:
sonic-net/SONiC#1636

Why I did it:

These changes are required to handle a new field - "nexthop_group" in the
App DB NEXT_HOP_GROUP_TABLE. Such nexthop groups are called recursive
nexthop groups. This field contains the list of member (singleton) nexthop groups.
Such recursive nexthop groups are represented by NEXT_HOP_GROUP objects.
/* A NHG should not have both regular(ip/alias) and recursive fields */
if (is_recursive && (!ips.empty() || !aliases.empty()))
{
SWSS_LOG_ERROR("Nexthop group %s has both regular(ip/alias) and recursive fields", index.c_str());

Choose a reason for hiding this comment

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

Can we move this to info log ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Since the nexthop-group is not created due to this check, it's better to log this as error.

@srj102 srj102 merged commit 536f43a into sonic-net:master May 18, 2024
17 checks passed
@utpalkantpintoo utpalkantpintoo deleted the recursive_nhg branch May 18, 2024 16:40
@goomadao
Copy link

Besides, there might be two issues that:

  1. If a route points to a singleton NEXTHOP_GROUP and it becomes non-singleton later, the route will still refer to the SAI ID of the NEXTHOP instead of the newly created NEXTHOP_GROUP
  2. For recursive situations, how to update NEXTHOP_GROUP recursively? For example, NEXTHOP_GROUP_TABLE:ID1 points to ID2 & ID3, ID2 refers to NEXTHOP NHa & NHb. When ID2 is updated to refer to NHa, NHb & NHc, how can we add member NHc to NEXTHOP_GROUP_TABLE:ID1 simultaneously?

@utpalkantpintoo
Copy link
Contributor Author

Hi @goomadao

Thanks for the comments. Please find below my response:

  1. For any nexthop-group update which changes its SAI-ID, it is expected that the routing app update the associated routes as well. This is expected behavior with FRR.
    Handling it in Orchagent (NhgOrch/RouteOrch) will require maintaining a nexthop-group to route entries data-structure.

  2. With recursive nexthop-group scheme, it is expected that the routing app resolve the recursive nexthop-groups and provide a recursive nexthop-group with ultimate nexthop member(s) which are not recursive themselves. This is expected behavior with FRR.

@goomadao
Copy link

goomadao commented Jun 6, 2024

@utpalkantpintoo Thanks for your explanation. You're right, I missed that there is an upper application where the update could be triggered.

Could you please take a look at the pending review I raised before? I still can't figure out any situation to get into those two conditions.

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.

8 participants