From fa7acaef8324c6015b9f5bcd751704c8aac4d876 Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Mon, 6 Apr 2015 20:01:05 +0200 Subject: [PATCH] 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. (cherry picked from commit 64d918293bdf3e16c8a53d4146a5343ec6c9ffee) --- src/nm-types.h | 4 ++++ src/platform/nm-linux-platform.c | 12 ++++++++---- src/platform/nm-platform.c | 2 ++ 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/src/nm-types.h b/src/nm-types.h index 52ae04c848..c4cae7618c 100644 --- a/src/nm-types.h +++ b/src/nm-types.h @@ -46,6 +46,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 12591faf47..d6cf033fd4 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 580a706ee0..d09dbd1a7e 100644 --- a/src/platform/nm-platform.c +++ b/src/platform/nm-platform.c @@ -2588,6 +2588,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: