diff options
author | Thomas Haller <thaller@redhat.com> | 2017-11-07 19:49:39 +0100 |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2017-11-13 11:35:44 +0100 |
commit | 433d2f8659e31719fe13f16cc48b404d926f6ae3 (patch) | |
tree | 47e8246bf7ee7f1c058cd216f803e913f19b206b /src/nm-ip6-config.c | |
parent | a9d1f5e543bba46a5a97a2e440d607550a54a283 (diff) | |
download | NetworkManager-433d2f8659e31719fe13f16cc48b404d926f6ae3.tar.gz |
core: merge IPv4 and IPv6 version of _nm_ip_config_merge_route_attributes()
Diffstat (limited to 'src/nm-ip6-config.c')
-rw-r--r-- | src/nm-ip6-config.c | 64 |
1 files changed, 4 insertions, 60 deletions
diff --git a/src/nm-ip6-config.c b/src/nm-ip6-config.c index 3f0bbfe75c..28841e3434 100644 --- a/src/nm-ip6-config.c +++ b/src/nm-ip6-config.c @@ -571,65 +571,6 @@ nm_ip6_config_commit (const NMIP6Config *self, return success; } -static void -merge_route_attributes (NMIPRoute *s_route, - NMPlatformIP6Route *r, - guint32 route_table) -{ - GVariant *variant; - guint32 u32; - struct in6_addr addr; - -#define GET_ATTR(name, field, variant_type, type) \ - variant = nm_ip_route_get_attribute (s_route, name); \ - if (variant && g_variant_is_of_type (variant, G_VARIANT_TYPE_ ## variant_type)) \ - r->field = g_variant_get_ ## type (variant); - - variant = nm_ip_route_get_attribute (s_route, NM_IP_ROUTE_ATTRIBUTE_TABLE); - u32 = variant && g_variant_is_of_type (variant, G_VARIANT_TYPE_UINT32) - ? g_variant_get_uint32 (variant) - : 0; - r->table_coerced = nm_platform_route_table_coerce (u32 ?: (route_table ?: RT_TABLE_MAIN)); - - GET_ATTR (NM_IP_ROUTE_ATTRIBUTE_WINDOW, window, UINT32, uint32); - GET_ATTR (NM_IP_ROUTE_ATTRIBUTE_CWND, cwnd, UINT32, uint32); - GET_ATTR (NM_IP_ROUTE_ATTRIBUTE_INITCWND, initcwnd, UINT32, uint32); - GET_ATTR (NM_IP_ROUTE_ATTRIBUTE_INITRWND, initrwnd, UINT32, uint32); - GET_ATTR (NM_IP_ROUTE_ATTRIBUTE_MTU, mtu, UINT32, uint32); - GET_ATTR (NM_IP_ROUTE_ATTRIBUTE_LOCK_WINDOW, lock_window, BOOLEAN, boolean); - GET_ATTR (NM_IP_ROUTE_ATTRIBUTE_LOCK_CWND, lock_cwnd, BOOLEAN, boolean); - GET_ATTR (NM_IP_ROUTE_ATTRIBUTE_LOCK_INITCWND, lock_initcwnd, BOOLEAN, boolean); - GET_ATTR (NM_IP_ROUTE_ATTRIBUTE_LOCK_INITRWND, lock_initrwnd, BOOLEAN, boolean); - GET_ATTR (NM_IP_ROUTE_ATTRIBUTE_LOCK_MTU, lock_mtu, BOOLEAN, boolean); - - - if ( (variant = nm_ip_route_get_attribute (s_route, NM_IP_ROUTE_ATTRIBUTE_SRC)) - && g_variant_is_of_type (variant, G_VARIANT_TYPE_STRING)) { - if (inet_pton (AF_INET6, g_variant_get_string (variant, NULL), &addr) == 1) - r->pref_src = addr; - } - - if ( (variant = nm_ip_route_get_attribute (s_route, NM_IP_ROUTE_ATTRIBUTE_FROM)) - && g_variant_is_of_type (variant, G_VARIANT_TYPE_STRING)) { - gs_free char *string = NULL; - guint8 plen = 128; - char *sep; - - string = g_variant_dup_string (variant, NULL); - sep = strchr (string, '/'); - if (sep) { - *sep = 0; - plen = _nm_utils_ascii_str_to_int64 (sep + 1, 10, 1, 128, 255); - } - if ( plen <= 128 - && inet_pton (AF_INET6, string, &addr) == 1) { - r->src = addr; - r->src_plen = plen; - } - } -#undef GET_ATTR -} - void nm_ip6_config_merge_setting (NMIP6Config *self, NMSettingIPConfig *setting, @@ -716,7 +657,10 @@ nm_ip6_config_merge_setting (NMIP6Config *self, nm_utils_ip6_address_clear_host_address (&route.network, &route.network, route.plen); - merge_route_attributes (s_route, &route, route_table); + _nm_ip_config_merge_route_attributes (AF_INET, + s_route, + NM_PLATFORM_IP_ROUTE_CAST (&route), + route_table); _add_route (self, NULL, &route, NULL); } |