From abebc340ccecffc6c54c46b26fb787383b0a8df5 Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Sun, 5 Jul 2015 13:25:49 +0200 Subject: [PATCH] platform: add optional @metric argument to route_add() function Allow overwriting the route metric. (cherry picked from commit 09fdf58f4d79a3ca4536b16c8d9b17c19403dbe4) --- src/nm-route-manager.c | 4 ++-- src/platform/nm-platform.c | 8 ++++---- src/platform/nm-platform.h | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/nm-route-manager.c b/src/nm-route-manager.c index a828b5da1a..22d7028a7f 100644 --- a/src/nm-route-manager.c +++ b/src/nm-route-manager.c @@ -612,7 +612,7 @@ _vx_route_sync (const VTableIP *vtable, NMRouteManager *self, int ifindex, const * device routes, on the second the others (gateway routes). */ continue; } - vtable->vt->route_add (priv->platform, 0, rest_route); + vtable->vt->route_add (priv->platform, 0, rest_route, -1); } } g_array_unref (to_restore_routes); @@ -656,7 +656,7 @@ _vx_route_sync (const VTableIP *vtable, NMRouteManager *self, int ifindex, const || route_id_cmp_result != 0 || !_route_equals_ignoring_ifindex (vtable, cur_plat_route, cur_ipx_route)) { - if (!vtable->vt->route_add (priv->platform, ifindex, cur_ipx_route)) { + if (!vtable->vt->route_add (priv->platform, ifindex, cur_ipx_route, -1)) { if (cur_ipx_route->rx.source < NM_IP_CONFIG_SOURCE_USER) { _LOGD (vtable->vt->addr_family, "ignore error adding IPv%c route to kernel: %s", diff --git a/src/platform/nm-platform.c b/src/platform/nm-platform.c index 7225c5b856..05accd36c2 100644 --- a/src/platform/nm-platform.c +++ b/src/platform/nm-platform.c @@ -2941,7 +2941,7 @@ log_ip6_route (NMPlatform *self, NMPObjectType obj_type, int ifindex, NMPlatform /******************************************************************/ static gboolean -_vtr_v4_route_add (NMPlatform *self, int ifindex, const NMPlatformIPXRoute *route) +_vtr_v4_route_add (NMPlatform *self, int ifindex, const NMPlatformIPXRoute *route, gint64 metric) { return nm_platform_ip4_route_add (self, ifindex > 0 ? ifindex : route->rx.ifindex, @@ -2950,12 +2950,12 @@ _vtr_v4_route_add (NMPlatform *self, int ifindex, const NMPlatformIPXRoute *rout route->rx.plen, route->r4.gateway, route->r4.pref_src, - route->rx.metric, + metric >= 0 ? (guint32) metric : route->rx.metric, route->rx.mss); } static gboolean -_vtr_v6_route_add (NMPlatform *self, int ifindex, const NMPlatformIPXRoute *route) +_vtr_v6_route_add (NMPlatform *self, int ifindex, const NMPlatformIPXRoute *route, gint64 metric) { return nm_platform_ip6_route_add (self, ifindex > 0 ? ifindex : route->rx.ifindex, @@ -2963,7 +2963,7 @@ _vtr_v6_route_add (NMPlatform *self, int ifindex, const NMPlatformIPXRoute *rout route->r6.network, route->rx.plen, route->r6.gateway, - route->rx.metric, + metric >= 0 ? (guint32) metric : route->rx.metric, route->rx.mss); } diff --git a/src/platform/nm-platform.h b/src/platform/nm-platform.h index 1c0adf0576..9892015578 100644 --- a/src/platform/nm-platform.h +++ b/src/platform/nm-platform.h @@ -315,7 +315,7 @@ typedef struct { int (*route_cmp) (const NMPlatformIPXRoute *a, const NMPlatformIPXRoute *b); const char *(*route_to_string) (const NMPlatformIPXRoute *route); GArray *(*route_get_all) (NMPlatform *self, int ifindex, NMPlatformGetRouteFlags flags); - gboolean (*route_add) (NMPlatform *self, int ifindex, const NMPlatformIPXRoute *route); + gboolean (*route_add) (NMPlatform *self, int ifindex, const NMPlatformIPXRoute *route, gint64 metric); gboolean (*route_delete) (NMPlatform *self, int ifindex, const NMPlatformIPXRoute *route); gboolean (*route_delete_default) (NMPlatform *self, int ifindex, guint32 metric); guint32 (*metric_normalize) (guint32 metric);