summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2015-07-05 13:25:49 +0200
committerThomas Haller <thaller@redhat.com>2015-07-05 13:28:37 +0200
commitf58421eb0ecfe7429e00a5a5deeb8758b87f559d (patch)
treea377c8ef6f9c357d5a350ab1088d00ca7c05b443
parent9271d0c65b4b8282de6988a2124862265ba853a1 (diff)
downloadNetworkManager-f58421eb0ecfe7429e00a5a5deeb8758b87f559d.tar.gz
platform: add optional @metric argument to route_add() function
Allow overwriting the route metric.
-rw-r--r--src/nm-route-manager.c4
-rw-r--r--src/platform/nm-platform.c8
-rw-r--r--src/platform/nm-platform.h2
3 files changed, 7 insertions, 7 deletions
diff --git a/src/nm-route-manager.c b/src/nm-route-manager.c
index 7ef0c0b3aa..8042e89b87 100644
--- a/src/nm-route-manager.c
+++ b/src/nm-route-manager.c
@@ -609,7 +609,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);
@@ -653,7 +653,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 ed0d3c4340..b534b273d2 100644
--- a/src/platform/nm-platform.c
+++ b/src/platform/nm-platform.c
@@ -2947,7 +2947,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,
@@ -2956,12 +2956,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,
@@ -2969,7 +2969,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 9bfb22b1a7..1b5bfb1575 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);