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

route: ignore flags and weight of nexthops when doing a strict route comparison #384

Merged
merged 2 commits into from
May 14, 2024

Conversation

KanjiMonster
Copy link
Contributor

When a route is created while the interface has no link, we get a
notification with the route and the nexthop having the flag LINKDOWN.

If the interface later gets a link, we do not get a route notification
about it, so the route and nexthop stay at LINKDOWN in the libnl cache.

If the route then gets removed again, the to be removed route will not
have the LINKDOWN flag anymore, which then can break comparison of the
nexthop(s).

So add a new helper for ignoring FLAGS and WEIGHT for nexthops, and use it
everywhere we want to tell if it's the same nexthop, but not necessarily
in the same state.

For loose comparisons, we still need to use the old function, as else e.g.
route lookup will require specifying exact nexthops, and just filtering for
all routes on a certain interfaces would break.

@@ -136,6 +136,14 @@ int rtnl_route_nh_compare(struct rtnl_nexthop *a, struct rtnl_nexthop *b,
return diff;
}

int rtnl_route_nh_identical(struct rtnl_nexthop *a, struct rtnl_nexthop *b)
Copy link
Owner

Choose a reason for hiding this comment

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

could you please add a short doc-text for public API?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure thing, will add one

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added one (loosely based on nl_object_identical()'s).

Not all attributes of a nexthop are id attributes, e.g. the flags will
contain state (LINKDOWN, DEAD) of the attached link about which the
kernel will not send route updates.

Likewise, the weight may not exist when processing an ECMP IPv6 route
update which only contains a single nexthop.

Since rtnl_nexthop isn't a first class cache object, we cannot use
nl_object_identical(), so add a separate identical helper function which
compares only fixed attributes.

Signed-off-by: Jonas Gorski <[email protected]>
When a route is created while the interface has no link, we get a
notification with the route and the nexthop having the flag LINKDOWN.

If the interface later gets a link, we do not get a route notification
about it, so the route and nexthop stay at LINKDOWN in the libnl cache.

If the route then gets removed again, the to be removed route will not
have the LINKDOWN flag anymore, which then can break comparison of the
nexthop(s).

So use the new nexthop identical helper to avoid this scenario.

Signed-off-by: Jonas Gorski <[email protected]>
@thom311 thom311 merged commit 6db8536 into thom311:main May 14, 2024
4 checks passed
@thom311
Copy link
Owner

thom311 commented May 14, 2024

merged. thank you!!!

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.

2 participants