diff options
author | Thomas Haller <thaller@redhat.com> | 2020-07-21 18:18:18 +0200 |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2020-07-21 18:32:34 +0200 |
commit | 0f488ba8ee229a9da291cc00dd567b817b5d6f72 (patch) | |
tree | a2353761a9a2e13fe26ac9acf4262b887a83b701 | |
parent | ff75c1a9bd2347a0baf5d31ddd671ebb3c020da5 (diff) | |
download | NetworkManager-0f488ba8ee229a9da291cc00dd567b817b5d6f72.tar.gz |
platform: add nmp_object_ip_route_is_best_defaut_route() helper
-rw-r--r-- | src/platform/nmp-object.h | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/src/platform/nmp-object.h b/src/platform/nmp-object.h index cef25ea79b..dd00522064 100644 --- a/src/platform/nmp-object.h +++ b/src/platform/nmp-object.h @@ -1039,4 +1039,22 @@ nmp_object_link_get_ifname (const NMPObject *obj) return NMP_OBJECT_CAST_LINK (obj)->name; } +static inline gboolean +nmp_object_ip_route_is_best_defaut_route (const NMPObject *obj) +{ + const NMPlatformIPRoute *r = NMP_OBJECT_CAST_IP_ROUTE (obj); + + /* return whether @obj is considered a default-route. + * + * NMIP4Config/NMIP6Config tracks the (best) default-route explicitly, because + * at various places we act differently depending on whether there is a default-route + * configured. + * + * Note that this only considers the main routing table. */ + return r + && NM_PLATFORM_IP_ROUTE_IS_DEFAULT (r) + && nm_platform_route_table_is_main (r->table_coerced) + && r->type_coerced == nm_platform_route_type_coerce (1 /* RTN_UNICAST */); +} + #endif /* __NMP_OBJECT_H__ */ |