Commit 2e146148 authored by Thomas Haller's avatar Thomas Haller
Browse files

core: use ipv6.route-table setting for other IPv6 routes

Including device-routes, default-route, SLAAC.
parent 01930c96
......@@ -6607,6 +6607,7 @@ ip6_config_merge_and_apply (NMDevice *self,
memset (&default_route, 0, sizeof (default_route));
default_route.rt_source = NM_IP_CONFIG_SOURCE_USER;
default_route.gateway = *gateway;
default_route.table_coerced = nm_platform_route_table_coerce (nm_device_get_route_table (self, AF_INET6, TRUE));
default_route.metric = route_metric_with_penalty (self, default_route_metric);
default_route.mss = nm_ip6_config_get_mss (composite);
nm_clear_nmp_object (&priv->default_route6);
......@@ -6632,6 +6633,7 @@ END_ADD_DEFAULT_ROUTE:
if (commit) {
nm_ip6_config_add_device_routes (composite,
nm_device_get_route_table (self, AF_INET6, TRUE),
default_route_metric);
}
......@@ -7514,6 +7516,7 @@ ndisc_config_changed (NMNDisc *ndisc, const NMNDiscData *rdata, guint changed_in
nm_ip6_config_reset_routes_ndisc (priv->ac_ip6_config,
rdata->routes,
rdata->routes_n,
nm_device_get_route_table (self, AF_INET6, TRUE),
nm_device_get_route_metric (self, AF_INET6));
}
......
......@@ -211,6 +211,7 @@ ndisc_config_changed (NMNDisc *ndisc, const NMNDiscData *rdata, guint changed_in
nm_ip6_config_reset_routes_ndisc (ndisc_config,
rdata->routes,
rdata->routes_n,
RT_TABLE_MAIN,
global_opt.priority_v6);
}
......@@ -230,6 +231,7 @@ ndisc_config_changed (NMNDisc *ndisc, const NMNDiscData *rdata, guint changed_in
nm_ip6_config_merge (existing, ndisc_config, NM_IP_CONFIG_MERGE_DEFAULT);
nm_ip6_config_add_device_routes (existing,
RT_TABLE_MAIN,
global_opt.priority_v6);
if (!nm_ip6_config_commit (existing,
NM_PLATFORM_GET,
......
......@@ -470,6 +470,7 @@ nm_ip6_config_capture (NMDedupMultiIndex *multi_idx, NMPlatform *platform, int i
void
nm_ip6_config_add_device_routes (NMIP6Config *self,
guint32 route_table,
guint32 route_metric)
{
const NMIP6ConfigPrivate *priv;
......@@ -513,6 +514,7 @@ nm_ip6_config_add_device_routes (NMIP6Config *self,
route->ifindex = ifindex;
route->rt_source = NM_IP_CONFIG_SOURCE_KERNEL;
route->table_coerced = nm_platform_route_table_coerce (route_table);
route->metric = route_metric;
if (has_peer) {
......@@ -1855,7 +1857,8 @@ void
nm_ip6_config_reset_routes_ndisc (NMIP6Config *self,
const NMNDiscRoute *routes,
guint routes_n,
guint32 metric)
guint32 route_table,
guint32 route_metric)
{
NMIP6ConfigPrivate *priv;
guint i;
......@@ -1884,7 +1887,8 @@ nm_ip6_config_reset_routes_ndisc (NMIP6Config *self,
r->plen = ndisc_route->plen;
r->gateway = ndisc_route->gateway;
r->rt_source = NM_IP_CONFIG_SOURCE_NDISC;
r->metric = metric;
r->table_coerced = nm_platform_route_table_coerce (route_table);
r->metric = route_metric;
if (_nm_ip_config_add_obj (priv->multi_idx,
&priv->idx_ip6_routes_,
......
......@@ -109,6 +109,7 @@ NMIP6Config *nm_ip6_config_capture (struct _NMDedupMultiIndex *multi_idx, NMPlat
gboolean capture_resolv_conf, NMSettingIP6ConfigPrivacy use_temporary);
void nm_ip6_config_add_device_routes (NMIP6Config *self,
guint32 route_table,
guint32 route_metric);
gboolean nm_ip6_config_commit (const NMIP6Config *self,
......@@ -216,6 +217,7 @@ struct _NMNDiscRoute;
void nm_ip6_config_reset_routes_ndisc (NMIP6Config *self,
const struct _NMNDiscRoute *routes,
guint routes_n,
guint32 metric);
guint32 route_table,
guint32 route_metric);
#endif /* __NETWORKMANAGER_IP6_CONFIG_H__ */
......@@ -815,8 +815,9 @@ add_ip6_vpn_gateway_route (NMIP6Config *config,
* In which case, it pretends the destination is directly reachable.
*
* So, only accept direct routes, if @vpn_gw is a private network. */
if ( !IN6_IS_ADDR_UNSPECIFIED (&r->gateway)
|| nm_utils_ip_is_site_local (AF_INET6, &vpn_gw)) {
if ( nm_platform_route_table_is_main (r->table_coerced)
&& ( !IN6_IS_ADDR_UNSPECIFIED (&r->gateway)
|| nm_utils_ip_is_site_local (AF_INET6, &vpn_gw))) {
parent_gw = &r->gateway;
has_parent_gw = TRUE;
}
......@@ -1671,6 +1672,7 @@ nm_vpn_connection_ip6_config_get (NMVpnConnection *self, GVariant *dict)
NMVpnConnectionPrivate *priv = NM_VPN_CONNECTION_GET_PRIVATE (self);
NMPlatformIP6Address address;
guint32 u32, route_metric;
guint32 route_table;
NMIP6Config *config;
GVariantIter *iter;
const char *str;
......@@ -1761,6 +1763,7 @@ nm_vpn_connection_ip6_config_get (NMVpnConnection *self, GVariant *dict)
g_variant_iter_free (iter);
}
route_table = get_route_table (self, AF_INET6, TRUE);
route_metric = nm_vpn_connection_get_ip6_route_metric (self);
if ( g_variant_lookup (dict, NM_VPN_PLUGIN_IP6_CONFIG_PRESERVE_ROUTES, "b", &b)
......@@ -1789,6 +1792,7 @@ nm_vpn_connection_ip6_config_get (NMVpnConnection *self, GVariant *dict)
route.plen = prefix;
ip6_addr_from_variant (next_hop, &route.gateway);
route.table_coerced = nm_platform_route_table_coerce (route_table);
route.metric = route_metric;
route.rt_source = NM_IP_CONFIG_SOURCE_VPN;
......@@ -1813,7 +1817,7 @@ next:
/* Merge in user overrides from the NMConnection's IPv6 setting */
nm_ip6_config_merge_setting (config,
nm_connection_get_setting_ip6_config (_get_applied_connection (self)),
get_route_table (self, AF_INET6, TRUE),
route_table,
route_metric);
if (!nm_ip6_config_get_never_default (config)) {
......@@ -1821,6 +1825,7 @@ next:
.ifindex = ip_ifindex,
.rt_source = NM_IP_CONFIG_SOURCE_VPN,
.gateway = *(nm_ip6_config_get_gateway (config) ?: &in6addr_any),
.table_coerced = nm_platform_route_table_coerce (route_table),
.metric = route_metric,
.mss = nm_ip6_config_get_mss (config),
};
......@@ -1829,7 +1834,8 @@ next:
}
nm_ip6_config_add_device_routes (config,
nm_vpn_connection_get_ip6_route_metric (self));
route_table,
route_metric);
if (priv->ip6_config) {
nm_ip6_config_replace (priv->ip6_config, config, NULL);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment