summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2014-12-22 17:06:13 +0100
committerThomas Haller <thaller@redhat.com>2015-01-11 13:08:34 +0100
commit06e4eee0ce782460274ffab3c83bb8369f73d834 (patch)
treed98f3bca18001d093b277614bc81d2b61e6f06e9
parent4ba8df425f749adb606979b64ab03af9ff890ae3 (diff)
downloadNetworkManager-06e4eee0ce782460274ffab3c83bb8369f73d834.tar.gz
platform: fix IPv6 route methods for metric 0
Handling a route with metric 0 effectively means a metric of 1024 (user default). Adjust the add(), delete() and exist() functions to consider routes with metric 0 as 1024.
-rw-r--r--src/platform/nm-linux-platform.c6
-rw-r--r--src/platform/tests/test-route.c7
2 files changed, 10 insertions, 3 deletions
diff --git a/src/platform/nm-linux-platform.c b/src/platform/nm-linux-platform.c
index 6fe1d466d2..0cf743b453 100644
--- a/src/platform/nm-linux-platform.c
+++ b/src/platform/nm-linux-platform.c
@@ -3845,6 +3845,8 @@ ip6_route_add (NMPlatform *platform, int ifindex, NMIPConfigSource source,
struct in6_addr network, int plen, struct in6_addr gateway,
guint32 metric, guint32 mss)
{
+ metric = nm_utils_ip6_route_metric_normalize (metric);
+
return add_object (platform, build_rtnl_route (AF_INET6, ifindex, source, &network, plen, &gateway, NULL, metric, mss));
}
@@ -3962,6 +3964,8 @@ ip6_route_delete (NMPlatform *platform, int ifindex, struct in6_addr network, in
{
struct in6_addr gateway = IN6ADDR_ANY_INIT;
+ metric = nm_utils_ip6_route_metric_normalize (metric);
+
return delete_object (platform, build_rtnl_route (AF_INET6, ifindex, NM_IP_CONFIG_SOURCE_UNKNOWN ,&network, plen, &gateway, NULL, metric, 0), FALSE) &&
refresh_route (platform, AF_INET6, ifindex, &network, plen, metric);
}
@@ -3989,6 +3993,8 @@ ip4_route_exists (NMPlatform *platform, int ifindex, in_addr_t network, int plen
static gboolean
ip6_route_exists (NMPlatform *platform, int ifindex, struct in6_addr network, int plen, guint32 metric)
{
+ metric = nm_utils_ip6_route_metric_normalize (metric);
+
return ip_route_exists (platform, AF_INET6, ifindex, &network, plen, metric);
}
diff --git a/src/platform/tests/test-route.c b/src/platform/tests/test-route.c
index 2c70b412bb..9ccca0a0f6 100644
--- a/src/platform/tests/test-route.c
+++ b/src/platform/tests/test-route.c
@@ -2,6 +2,7 @@
#include "test-common.h"
#include "nm-test-utils.h"
+#include "NetworkManagerUtils.h"
#define DEVICE_NAME "nm-test-device"
@@ -205,21 +206,21 @@ test_ip6_route (void)
rts[0].plen = 128;
rts[0].ifindex = ifindex;
rts[0].gateway = in6addr_any;
- rts[0].metric = metric;
+ rts[0].metric = nm_utils_ip6_route_metric_normalize (metric);
rts[0].mss = mss;
rts[1].source = NM_IP_CONFIG_SOURCE_USER;
rts[1].network = network;
rts[1].plen = plen;
rts[1].ifindex = ifindex;
rts[1].gateway = gateway;
- rts[1].metric = metric;
+ rts[1].metric = nm_utils_ip6_route_metric_normalize (metric);
rts[1].mss = mss;
rts[2].source = NM_IP_CONFIG_SOURCE_USER;
rts[2].network = in6addr_any;
rts[2].plen = 0;
rts[2].ifindex = ifindex;
rts[2].gateway = gateway;
- rts[2].metric = metric;
+ rts[2].metric = nm_utils_ip6_route_metric_normalize (metric);
rts[2].mss = mss;
g_assert_cmpint (routes->len, ==, 3);
g_assert (!memcmp (routes->data, rts, sizeof (rts)));