mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-02-05 05:20:32 +01:00
core: add nm_utils_ip6_route_metric_normalize() function
Kernel treats IPv6 route metrics with value zero (0) special. Add a utility function that helps accounting for that. Signed-off-by: Thomas Haller <thaller@redhat.com> https://bugzilla.gnome.org/show_bug.cgi?id=738590
This commit is contained in:
parent
0923769285
commit
22911696f4
2 changed files with 17 additions and 0 deletions
|
|
@ -33,6 +33,21 @@ gboolean nm_ethernet_address_is_valid (gconstpointer addr, gssize len);
|
|||
in_addr_t nm_utils_ip4_address_clear_host_address (in_addr_t addr, guint8 plen);
|
||||
void nm_utils_ip6_address_clear_host_address (struct in6_addr *dst, const struct in6_addr *src, guint8 plen);
|
||||
|
||||
/**
|
||||
* nm_utils_ip6_route_metric_normalize:
|
||||
* @metric: the route metric
|
||||
*
|
||||
* For IPv6 route, kernel treats the value 0 as IP6_RT_PRIO_USER (1024).
|
||||
* Thus, when comparing metric (values), we want to treat zero as NM_PLATFORM_ROUTE_METRIC_DEFAULT.
|
||||
*
|
||||
* Returns: @metric, if @metric is not zero, otherwise 1024.
|
||||
*/
|
||||
static inline guint32
|
||||
nm_utils_ip6_route_metric_normalize (guint32 metric)
|
||||
{
|
||||
return metric ? metric : 1024 /*NM_PLATFORM_ROUTE_METRIC_DEFAULT*/;
|
||||
}
|
||||
|
||||
int nm_spawn_process (const char *args);
|
||||
|
||||
/* macro to return strlen() of a compile time string. */
|
||||
|
|
|
|||
|
|
@ -216,6 +216,8 @@ G_STATIC_ASSERT (G_STRUCT_OFFSET (NMPlatformIPAddress, address_ptr) == G_STRUCT_
|
|||
#undef __NMPlatformIPAddress_COMMON
|
||||
|
||||
|
||||
/* Adding an IPv6 route with metric 0, kernel translates to IP6_RT_PRIO_USER (1024).
|
||||
* Thus, the value is not choosen arbitraily, but matches kernel IPv6 default. */
|
||||
#define NM_PLATFORM_ROUTE_METRIC_DEFAULT 1024
|
||||
|
||||
#define __NMPlatformIPRoute_COMMON \
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue