summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJonas Gorski <jonas.gorski@bisdn.de>2024-05-13 12:06:48 (GMT)
committerJonas Gorski <jonas.gorski@bisdn.de>2024-05-14 09:51:16 (GMT)
commit861fb8090c4bd670890b310b9761edfd1d12d916 (patch)
treeea9a64220f9335a21b5cf03afd8094f16da50f9c
parent8cf29d7b4a8f4dadcc68932edc23e05f5d0fee89 (diff)
downloadlibnl-861fb8090c4bd670890b310b9761edfd1d12d916.zip
libnl-861fb8090c4bd670890b310b9761edfd1d12d916.tar.gz
libnl-861fb8090c4bd670890b310b9761edfd1d12d916.tar.bz2
route: use the new helper function for comparing nexthops
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 <jonas.gorski@bisdn.de>
-rw-r--r--lib/route/route_obj.c16
1 files changed, 4 insertions, 12 deletions
diff --git a/lib/route/route_obj.c b/lib/route/route_obj.c
index aba1a1b..0a0c06d 100644
--- a/lib/route/route_obj.c
+++ b/lib/route/route_obj.c
@@ -449,7 +449,7 @@ static uint64_t route_compare(struct nl_object *_a, struct nl_object *_b,
found = 0;
nl_list_for_each_entry(nh_b, &b->rt_nexthops,
rtnh_list) {
- if (!rtnl_route_nh_compare(nh_a, nh_b, ~0, 0)) {
+ if (rtnl_route_nh_identical(nh_a, nh_b)) {
found = 1;
break;
}
@@ -464,7 +464,7 @@ static uint64_t route_compare(struct nl_object *_a, struct nl_object *_b,
found = 0;
nl_list_for_each_entry(nh_a, &a->rt_nexthops,
rtnh_list) {
- if (!rtnl_route_nh_compare(nh_a, nh_b, ~0, 0)) {
+ if (rtnl_route_nh_identical(nh_a, nh_b)) {
found = 1;
break;
}
@@ -538,7 +538,7 @@ static int route_update(struct nl_object *old_obj, struct nl_object *new_obj)
* Do not add the nexthop to old route if it was already added before
*/
nl_list_for_each_entry(old_nh, &old_route->rt_nexthops, rtnh_list) {
- if (!rtnl_route_nh_compare(old_nh, new_nh, ~0, 0)) {
+ if (rtnl_route_nh_identical(old_nh, new_nh)) {
return 0;
}
}
@@ -574,15 +574,7 @@ static int route_update(struct nl_object *old_obj, struct nl_object *new_obj)
*/
nl_list_for_each_entry(old_nh, &old_route->rt_nexthops,
rtnh_list) {
- /*
- * Since the new route has only one nexthop, it's not
- * an ECMP route and the nexthop won't have a weight.
- * Similarily, the nexthop might have been marked as
- * DEAD in its flags if it was deleted.
- * Therefore ignore NH_ATTR_FLAGS (= 0x1) and
- * NH_ATTR_WEIGHT (= 0x2) while comparing nexthops.
- */
- if (!rtnl_route_nh_compare(old_nh, new_nh, ~0x3, 0)) {
+ if (rtnl_route_nh_identical(old_nh, new_nh)) {
rtnl_route_remove_nexthop(old_route, old_nh);