summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2015-04-06 20:01:05 +0200
committerThomas Haller <thaller@redhat.com>2015-06-12 16:30:35 +0200
commitcf95e1efc374cec7ea1b154f5da28aca953a6148 (patch)
tree9426f03abe9ded0fce47743ed8ea944682a1ce2f
parent109b0714e59bd54e25b0b04b10e3e0950275c416 (diff)
downloadNetworkManager-cf95e1efc374cec7ea1b154f5da28aca953a6148.tar.gz
platform: add _NM_IP_CONFIG_SOURCE_RTPROT_KERNEL source
Later we will need this flag to distinguish routes from kernel that have source RTPROT_KERNEL. This flag is still unused.
-rw-r--r--src/nm-types.h4
-rw-r--r--src/platform/nm-linux-platform.c12
-rw-r--r--src/platform/nm-platform.c2
3 files changed, 14 insertions, 4 deletions
diff --git a/src/nm-types.h b/src/nm-types.h
index 3fa587932e..ddcee4daba 100644
--- a/src/nm-types.h
+++ b/src/nm-types.h
@@ -51,6 +51,10 @@ typedef struct _NMSleepMonitor NMSleepMonitor;
typedef enum {
/* In priority order; higher number == higher priority */
NM_IP_CONFIG_SOURCE_UNKNOWN,
+
+ /* platform internal flag used to mark routes with protocol RTPROT_KERNEL. */
+ _NM_IP_CONFIG_SOURCE_RTPROT_KERNEL,
+
NM_IP_CONFIG_SOURCE_KERNEL,
NM_IP_CONFIG_SOURCE_SHARED,
NM_IP_CONFIG_SOURCE_IP4LL,
diff --git a/src/platform/nm-linux-platform.c b/src/platform/nm-linux-platform.c
index 41a84b8ade..d326108a06 100644
--- a/src/platform/nm-linux-platform.c
+++ b/src/platform/nm-linux-platform.c
@@ -1277,6 +1277,7 @@ source_to_rtprot (NMIPConfigSource source)
case NM_IP_CONFIG_SOURCE_UNKNOWN:
return RTPROT_UNSPEC;
case NM_IP_CONFIG_SOURCE_KERNEL:
+ case _NM_IP_CONFIG_SOURCE_RTPROT_KERNEL:
return RTPROT_KERNEL;
case NM_IP_CONFIG_SOURCE_DHCP:
return RTPROT_DHCP;
@@ -1289,13 +1290,16 @@ source_to_rtprot (NMIPConfigSource source)
}
static NMIPConfigSource
-rtprot_to_source (guint rtprot)
+rtprot_to_source (guint rtprot, gboolean preserve_rtprot)
{
switch (rtprot) {
case RTPROT_UNSPEC:
return NM_IP_CONFIG_SOURCE_UNKNOWN;
- case RTPROT_REDIRECT:
case RTPROT_KERNEL:
+ if (preserve_rtprot)
+ return _NM_IP_CONFIG_SOURCE_RTPROT_KERNEL;
+ /* fall through */
+ case RTPROT_REDIRECT:
return NM_IP_CONFIG_SOURCE_KERNEL;
case RTPROT_RA:
return NM_IP_CONFIG_SOURCE_RDISC;
@@ -1352,7 +1356,7 @@ init_ip4_route (NMPlatformIP4Route *route, struct rtnl_route *rtnlroute)
}
route->metric = rtnl_route_get_priority (rtnlroute);
rtnl_route_get_metric (rtnlroute, RTAX_ADVMSS, &route->mss);
- route->source = rtprot_to_source (rtnl_route_get_protocol (rtnlroute));
+ route->source = rtprot_to_source (rtnl_route_get_protocol (rtnlroute), FALSE);
route->scope_inv = nm_platform_route_scope_inv (rtnl_route_get_scope (rtnlroute));
return TRUE;
@@ -1393,7 +1397,7 @@ init_ip6_route (NMPlatformIP6Route *route, struct rtnl_route *rtnlroute)
}
route->metric = rtnl_route_get_priority (rtnlroute);
rtnl_route_get_metric (rtnlroute, RTAX_ADVMSS, &route->mss);
- route->source = rtprot_to_source (rtnl_route_get_protocol (rtnlroute));
+ route->source = rtprot_to_source (rtnl_route_get_protocol (rtnlroute), FALSE);
return TRUE;
}
diff --git a/src/platform/nm-platform.c b/src/platform/nm-platform.c
index abb0d0335c..c4e70e75bb 100644
--- a/src/platform/nm-platform.c
+++ b/src/platform/nm-platform.c
@@ -2391,6 +2391,8 @@ static const char *
source_to_string (NMIPConfigSource source)
{
switch (source) {
+ case _NM_IP_CONFIG_SOURCE_RTPROT_KERNEL:
+ return "rtprot-kernel";
case NM_IP_CONFIG_SOURCE_KERNEL:
return "kernel";
case NM_IP_CONFIG_SOURCE_SHARED: