mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2025-12-27 16:20:09 +01:00
core: return new route from _nm_ip_config_add_obj()
Later we will need the exact instance that we just added (or the previously existing one, if the new route is already tracked).
This commit is contained in:
parent
ead1ffd9bc
commit
96f1358eef
11 changed files with 95 additions and 54 deletions
|
|
@ -5365,7 +5365,7 @@ ipv4ll_get_ip4_config (NMDevice *self, guint32 lla)
|
|||
route.plen = 4;
|
||||
route.rt_source = NM_IP_CONFIG_SOURCE_IP4LL;
|
||||
route.metric = nm_device_get_ip4_route_metric (self);
|
||||
nm_ip4_config_add_route (config, &route);
|
||||
nm_ip4_config_add_route (config, &route, NULL);
|
||||
|
||||
return config;
|
||||
}
|
||||
|
|
@ -5798,7 +5798,7 @@ ip4_config_merge_and_apply (NMDevice *self,
|
|||
r.network = gateway;
|
||||
r.plen = 32;
|
||||
r.gateway = 0;
|
||||
nm_ip4_config_add_route (composite, &r);
|
||||
nm_ip4_config_add_route (composite, &r, NULL);
|
||||
}
|
||||
|
||||
END_ADD_DEFAULT_ROUTE:
|
||||
|
|
@ -6534,7 +6534,7 @@ ip6_config_merge_and_apply (NMDevice *self,
|
|||
r.network = *gateway;
|
||||
r.plen = 128;
|
||||
r.gateway = in6addr_any;
|
||||
nm_ip6_config_add_route (composite, &r);
|
||||
nm_ip6_config_add_route (composite, &r, NULL);
|
||||
}
|
||||
|
||||
END_ADD_DEFAULT_ROUTE:
|
||||
|
|
|
|||
|
|
@ -997,7 +997,7 @@ context_property_changed (GDBusProxy *proxy,
|
|||
|
||||
mms_route.metric = 1;
|
||||
|
||||
nm_ip4_config_add_route (priv->ip4_config, &mms_route);
|
||||
nm_ip4_config_add_route (priv->ip4_config, &mms_route, NULL);
|
||||
} else {
|
||||
_LOGW ("invalid MessageProxy: %s", s);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -359,7 +359,7 @@ lease_to_ip4_config (NMDedupMultiIndex *multi_idx,
|
|||
if (route.plen) {
|
||||
route.rt_source = NM_IP_CONFIG_SOURCE_DHCP;
|
||||
route.metric = default_priority;
|
||||
nm_ip4_config_add_route (ip4_config, &route);
|
||||
nm_ip4_config_add_route (ip4_config, &route, NULL);
|
||||
|
||||
s = nm_utils_inet4_ntop (route.network, buf);
|
||||
gw_str = nm_utils_inet4_ntop (route.gateway, NULL);
|
||||
|
|
|
|||
|
|
@ -91,7 +91,7 @@ ip4_process_dhcpcd_rfc3442_routes (const char *iface,
|
|||
route.gateway = rt_route;
|
||||
route.rt_source = NM_IP_CONFIG_SOURCE_DHCP;
|
||||
route.metric = priority;
|
||||
nm_ip4_config_add_route (ip4_config, &route);
|
||||
nm_ip4_config_add_route (ip4_config, &route, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -199,7 +199,7 @@ ip4_process_dhclient_rfc3442_routes (const char *iface,
|
|||
/* normal route */
|
||||
route.rt_source = NM_IP_CONFIG_SOURCE_DHCP;
|
||||
route.metric = priority;
|
||||
nm_ip4_config_add_route (ip4_config, &route);
|
||||
nm_ip4_config_add_route (ip4_config, &route, NULL);
|
||||
|
||||
_LOG2I (LOGD_DHCP4, iface, " classless static route %s/%d gw %s",
|
||||
nm_utils_inet4_ntop (route.network, addr), route.plen,
|
||||
|
|
@ -328,7 +328,7 @@ process_classful_routes (const char *iface,
|
|||
|
||||
route.network = nm_utils_ip4_address_clear_host_address (route.network, route.plen);
|
||||
|
||||
nm_ip4_config_add_route (ip4_config, &route);
|
||||
nm_ip4_config_add_route (ip4_config, &route, NULL);
|
||||
_LOG2I (LOGD_DHCP, iface, " static route %s",
|
||||
nm_platform_ip4_route_to_string (&route, NULL, 0));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -166,7 +166,8 @@ _nm_ip_config_add_obj (NMDedupMultiIndex *multi_idx,
|
|||
const NMPlatformObject *pl_new,
|
||||
gboolean merge,
|
||||
gboolean append_force,
|
||||
const NMPObject **out_obj_new)
|
||||
const NMPObject **out_obj_old /* returns a reference! */,
|
||||
const NMPObject **out_obj_new /* does not return a reference */)
|
||||
{
|
||||
NMPObject obj_new_stackinit;
|
||||
const NMDedupMultiEntry *entry_old;
|
||||
|
|
@ -274,7 +275,7 @@ _nm_ip_config_add_obj (NMDedupMultiIndex *multi_idx,
|
|||
entry_old ?: NM_DEDUP_MULTI_ENTRY_MISSING,
|
||||
NULL,
|
||||
&entry_new,
|
||||
NULL)) {
|
||||
out_obj_old)) {
|
||||
nm_assert_not_reached ();
|
||||
NM_SET_OUT (out_obj_new, NULL);
|
||||
return FALSE;
|
||||
|
|
@ -284,6 +285,7 @@ _nm_ip_config_add_obj (NMDedupMultiIndex *multi_idx,
|
|||
return TRUE;
|
||||
|
||||
append_force_and_out:
|
||||
NM_SET_OUT (out_obj_old, nmp_object_ref (entry_old->obj));
|
||||
NM_SET_OUT (out_obj_new, entry_old->obj);
|
||||
if (append_force) {
|
||||
if (nm_dedup_multi_entry_reorder (entry_old, NULL, TRUE))
|
||||
|
|
@ -401,7 +403,7 @@ G_DEFINE_TYPE (NMIP4Config, nm_ip4_config, NM_TYPE_EXPORTED_OBJECT)
|
|||
/*****************************************************************************/
|
||||
|
||||
static void _add_address (NMIP4Config *self, const NMPObject *obj_new, const NMPlatformIP4Address *new);
|
||||
static void _add_route (NMIP4Config *self, const NMPObject *obj_new, const NMPlatformIP4Route *new);
|
||||
static void _add_route (NMIP4Config *self, const NMPObject *obj_new, const NMPlatformIP4Route *new, const NMPObject **out_obj_new);
|
||||
static const NMDedupMultiEntry *_lookup_route (const NMIP4Config *self,
|
||||
const NMPObject *needle,
|
||||
NMPlatformIPRouteCmpType cmp_type);
|
||||
|
|
@ -647,6 +649,7 @@ nm_ip4_config_capture (NMDedupMultiIndex *multi_idx, NMPlatform *platform, int i
|
|||
NULL,
|
||||
FALSE,
|
||||
TRUE,
|
||||
NULL,
|
||||
NULL))
|
||||
nm_assert_not_reached ();
|
||||
}
|
||||
|
|
@ -687,7 +690,7 @@ nm_ip4_config_capture (NMDedupMultiIndex *multi_idx, NMPlatform *platform, int i
|
|||
continue;
|
||||
if (NM_PLATFORM_IP_ROUTE_IS_DEFAULT (route))
|
||||
continue;
|
||||
_add_route (self, plobj, NULL);
|
||||
_add_route (self, plobj, NULL, NULL);
|
||||
}
|
||||
|
||||
/* we detect the route metric based on the default route. All non-default
|
||||
|
|
@ -951,7 +954,7 @@ nm_ip4_config_merge_setting (NMIP4Config *self, NMSettingIPConfig *setting, guin
|
|||
route.network = nm_utils_ip4_address_clear_host_address (route.network, route.plen);
|
||||
|
||||
merge_route_attributes (s_route, &route);
|
||||
_add_route (self, NULL, &route);
|
||||
_add_route (self, NULL, &route, NULL);
|
||||
}
|
||||
|
||||
/* DNS */
|
||||
|
|
@ -1133,7 +1136,7 @@ nm_ip4_config_merge (NMIP4Config *dst, const NMIP4Config *src, NMIPConfigMergeFl
|
|||
const NMPlatformIP4Route *route;
|
||||
|
||||
nm_ip_config_iter_ip4_route_for_each (&ipconf_iter, src, &route)
|
||||
_add_route (dst, NMP_OBJECT_UP_CAST (route), NULL);
|
||||
_add_route (dst, NMP_OBJECT_UP_CAST (route), NULL, NULL);
|
||||
}
|
||||
|
||||
if (dst_priv->route_metric == -1)
|
||||
|
|
@ -1586,6 +1589,7 @@ nm_ip4_config_replace (NMIP4Config *dst, const NMIP4Config *src, gboolean *relev
|
|||
NULL,
|
||||
FALSE,
|
||||
TRUE,
|
||||
NULL,
|
||||
NULL);
|
||||
}
|
||||
nm_dedup_multi_index_dirty_remove_idx (dst_priv->multi_idx, &dst_priv->idx_ip4_addresses, FALSE);
|
||||
|
|
@ -1632,6 +1636,7 @@ nm_ip4_config_replace (NMIP4Config *dst, const NMIP4Config *src, gboolean *relev
|
|||
NULL,
|
||||
FALSE,
|
||||
TRUE,
|
||||
NULL,
|
||||
NULL);
|
||||
}
|
||||
nm_dedup_multi_index_dirty_remove_idx (dst_priv->multi_idx, &dst_priv->idx_ip4_routes, FALSE);
|
||||
|
|
@ -1994,6 +1999,7 @@ _add_address (NMIP4Config *self, const NMPObject *obj_new, const NMPlatformIP4Ad
|
|||
(const NMPlatformObject *) new,
|
||||
TRUE,
|
||||
FALSE,
|
||||
NULL,
|
||||
NULL))
|
||||
_notify_addresses (self);
|
||||
}
|
||||
|
|
@ -2120,9 +2126,13 @@ nm_ip4_config_reset_routes (NMIP4Config *self)
|
|||
}
|
||||
|
||||
static void
|
||||
_add_route (NMIP4Config *self, const NMPObject *obj_new, const NMPlatformIP4Route *new)
|
||||
_add_route (NMIP4Config *self,
|
||||
const NMPObject *obj_new,
|
||||
const NMPlatformIP4Route *new,
|
||||
const NMPObject **out_obj_new)
|
||||
{
|
||||
NMIP4ConfigPrivate *priv = NM_IP4_CONFIG_GET_PRIVATE (self);
|
||||
const NMPObject *obj_new_2;
|
||||
|
||||
nm_assert ((!new) != (!obj_new));
|
||||
nm_assert (!new || _route_valid (new));
|
||||
|
|
@ -2135,14 +2145,20 @@ _add_route (NMIP4Config *self, const NMPObject *obj_new, const NMPlatformIP4Rout
|
|||
(const NMPlatformObject *) new,
|
||||
TRUE,
|
||||
FALSE,
|
||||
NULL))
|
||||
NULL,
|
||||
&obj_new_2)) {
|
||||
NM_SET_OUT (out_obj_new, nmp_object_ref (obj_new_2));
|
||||
_notify_routes (self);
|
||||
} else
|
||||
NM_SET_OUT (out_obj_new, nmp_object_ref (obj_new_2));
|
||||
}
|
||||
|
||||
/**
|
||||
* nm_ip4_config_add_route:
|
||||
* @self: the #NMIP4Config
|
||||
* @new: the new route to add to @self
|
||||
* @out_obj_new: (allow-none): (out): the added route object. Must be unrefed
|
||||
* by caller.
|
||||
*
|
||||
* Adds the new route to @self. If a route with the same basic properties
|
||||
* (network, prefix) already exists in @self, it is overwritten including the
|
||||
|
|
@ -2150,14 +2166,16 @@ _add_route (NMIP4Config *self, const NMPObject *obj_new, const NMPlatformIP4Rout
|
|||
* from @new if that source is higher priority.
|
||||
*/
|
||||
void
|
||||
nm_ip4_config_add_route (NMIP4Config *self, const NMPlatformIP4Route *new)
|
||||
nm_ip4_config_add_route (NMIP4Config *self,
|
||||
const NMPlatformIP4Route *new,
|
||||
const NMPObject **out_obj_new)
|
||||
{
|
||||
g_return_if_fail (self);
|
||||
g_return_if_fail (new);
|
||||
g_return_if_fail (new->plen > 0 && new->plen <= 32);
|
||||
g_return_if_fail (NM_IP4_CONFIG_GET_PRIVATE (self)->ifindex > 0);
|
||||
|
||||
_add_route (self, NULL, new);
|
||||
_add_route (self, NULL, new, out_obj_new);
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
|||
|
|
@ -91,6 +91,7 @@ gboolean _nm_ip_config_add_obj (NMDedupMultiIndex *multi_idx,
|
|||
const NMPlatformObject *pl_new,
|
||||
gboolean merge,
|
||||
gboolean append_force,
|
||||
const NMPObject **out_obj_old,
|
||||
const NMPObject **out_obj_new);
|
||||
|
||||
const NMDedupMultiEntry *_nm_ip_config_lookup_ip_route (const NMDedupMultiIndex *multi_idx,
|
||||
|
|
@ -173,7 +174,9 @@ gboolean nm_ip4_config_address_exists (const NMIP4Config *self, const NMPlatform
|
|||
|
||||
const NMDedupMultiHeadEntry *nm_ip4_config_lookup_routes (const NMIP4Config *self);
|
||||
void nm_ip4_config_reset_routes (NMIP4Config *self);
|
||||
void nm_ip4_config_add_route (NMIP4Config *self, const NMPlatformIP4Route *route);
|
||||
void nm_ip4_config_add_route (NMIP4Config *self,
|
||||
const NMPlatformIP4Route *route,
|
||||
const NMPObject **out_obj_new);
|
||||
void _nmtst_ip4_config_del_route (NMIP4Config *self, guint i);
|
||||
guint nm_ip4_config_get_num_routes (const NMIP4Config *self);
|
||||
const NMPlatformIP4Route *_nmtst_ip4_config_get_route (const NMIP4Config *self, guint i);
|
||||
|
|
|
|||
|
|
@ -113,7 +113,7 @@ NM_GOBJECT_PROPERTIES_DEFINE (NMIP6Config,
|
|||
/*****************************************************************************/
|
||||
|
||||
static void _add_address (NMIP6Config *self, const NMPObject *obj_new, const NMPlatformIP6Address *new);
|
||||
static void _add_route (NMIP6Config *self, const NMPObject *obj_new, const NMPlatformIP6Route *new);
|
||||
static void _add_route (NMIP6Config *self, const NMPObject *obj_new, const NMPlatformIP6Route *new, const NMPObject **out_obj_new);
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
|
|
@ -440,6 +440,7 @@ nm_ip6_config_capture (NMDedupMultiIndex *multi_idx, NMPlatform *platform, int i
|
|||
NULL,
|
||||
FALSE,
|
||||
TRUE,
|
||||
NULL,
|
||||
NULL))
|
||||
nm_assert_not_reached ();
|
||||
has_addresses = TRUE;
|
||||
|
|
@ -479,7 +480,7 @@ nm_ip6_config_capture (NMDedupMultiIndex *multi_idx, NMPlatform *platform, int i
|
|||
continue;
|
||||
if (NM_PLATFORM_IP_ROUTE_IS_DEFAULT (route))
|
||||
continue;
|
||||
_add_route (self, plobj, NULL);
|
||||
_add_route (self, plobj, NULL, NULL);
|
||||
}
|
||||
|
||||
/* we detect the route metric based on the default route. All non-default
|
||||
|
|
@ -670,7 +671,7 @@ nm_ip6_config_merge_setting (NMIP6Config *self, NMSettingIPConfig *setting, guin
|
|||
nm_utils_ip6_address_clear_host_address (&route.network, &route.network, route.plen);
|
||||
|
||||
merge_route_attributes (s_route, &route);
|
||||
_add_route (self, NULL, &route);
|
||||
_add_route (self, NULL, &route, NULL);
|
||||
}
|
||||
|
||||
/* DNS */
|
||||
|
|
@ -859,7 +860,7 @@ nm_ip6_config_merge (NMIP6Config *dst, const NMIP6Config *src, NMIPConfigMergeFl
|
|||
const NMPlatformIP6Route *route;
|
||||
|
||||
nm_ip_config_iter_ip6_route_for_each (&ipconf_iter, src, &route)
|
||||
_add_route (dst, NMP_OBJECT_UP_CAST (route), NULL);
|
||||
_add_route (dst, NMP_OBJECT_UP_CAST (route), NULL, NULL);
|
||||
}
|
||||
|
||||
if (dst_priv->route_metric == -1)
|
||||
|
|
@ -1254,6 +1255,7 @@ nm_ip6_config_replace (NMIP6Config *dst, const NMIP6Config *src, gboolean *relev
|
|||
NULL,
|
||||
FALSE,
|
||||
TRUE,
|
||||
NULL,
|
||||
NULL);
|
||||
}
|
||||
nm_dedup_multi_index_dirty_remove_idx (dst_priv->multi_idx, &dst_priv->idx_ip6_addresses, FALSE);
|
||||
|
|
@ -1300,6 +1302,7 @@ nm_ip6_config_replace (NMIP6Config *dst, const NMIP6Config *src, gboolean *relev
|
|||
NULL,
|
||||
FALSE,
|
||||
TRUE,
|
||||
NULL,
|
||||
NULL);
|
||||
}
|
||||
nm_dedup_multi_index_dirty_remove_idx (dst_priv->multi_idx, &dst_priv->idx_ip6_routes, FALSE);
|
||||
|
|
@ -1563,6 +1566,7 @@ nm_ip6_config_reset_addresses_ndisc (NMIP6Config *self,
|
|||
NULL,
|
||||
FALSE,
|
||||
TRUE,
|
||||
NULL,
|
||||
NULL))
|
||||
changed = TRUE;
|
||||
}
|
||||
|
|
@ -1598,6 +1602,7 @@ _add_address (NMIP6Config *self,
|
|||
(const NMPlatformObject *) new,
|
||||
TRUE,
|
||||
FALSE,
|
||||
NULL,
|
||||
NULL))
|
||||
_notify_addresses (self);
|
||||
}
|
||||
|
|
@ -1792,6 +1797,7 @@ nm_ip6_config_reset_routes_ndisc (NMIP6Config *self,
|
|||
NULL,
|
||||
FALSE,
|
||||
TRUE,
|
||||
NULL,
|
||||
NULL))
|
||||
changed = TRUE;
|
||||
}
|
||||
|
|
@ -1814,9 +1820,13 @@ nm_ip6_config_reset_routes (NMIP6Config *self)
|
|||
}
|
||||
|
||||
static void
|
||||
_add_route (NMIP6Config *self, const NMPObject *obj_new, const NMPlatformIP6Route *new)
|
||||
_add_route (NMIP6Config *self,
|
||||
const NMPObject *obj_new,
|
||||
const NMPlatformIP6Route *new,
|
||||
const NMPObject **out_obj_new)
|
||||
{
|
||||
NMIP6ConfigPrivate *priv = NM_IP6_CONFIG_GET_PRIVATE (self);
|
||||
const NMPObject *obj_new_2;
|
||||
|
||||
nm_assert ((!new) != (!obj_new));
|
||||
nm_assert (!new || _route_valid (new));
|
||||
|
|
@ -1829,14 +1839,20 @@ _add_route (NMIP6Config *self, const NMPObject *obj_new, const NMPlatformIP6Rout
|
|||
(const NMPlatformObject *) new,
|
||||
TRUE,
|
||||
FALSE,
|
||||
NULL))
|
||||
NULL,
|
||||
&obj_new_2)) {
|
||||
NM_SET_OUT (out_obj_new, nmp_object_ref (obj_new_2));
|
||||
_notify_routes (self);
|
||||
} else
|
||||
NM_SET_OUT (out_obj_new, nmp_object_ref (obj_new_2));
|
||||
}
|
||||
|
||||
/**
|
||||
* nm_ip6_config_add_route:
|
||||
* @self: the #NMIP6Config
|
||||
* @new: the new route to add to @self
|
||||
* @out_obj_new: (allow-none): (out): the added route object. Must be unrefed
|
||||
* by caller.
|
||||
*
|
||||
* Adds the new route to @self. If a route with the same basic properties
|
||||
* (network, prefix) already exists in @self, it is overwritten including the
|
||||
|
|
@ -1844,14 +1860,16 @@ _add_route (NMIP6Config *self, const NMPObject *obj_new, const NMPlatformIP6Rout
|
|||
* from @new if that source is higher priority.
|
||||
*/
|
||||
void
|
||||
nm_ip6_config_add_route (NMIP6Config *self, const NMPlatformIP6Route *new)
|
||||
nm_ip6_config_add_route (NMIP6Config *self,
|
||||
const NMPlatformIP6Route *new,
|
||||
const NMPObject **out_obj_new)
|
||||
{
|
||||
g_return_if_fail (self);
|
||||
g_return_if_fail (new);
|
||||
g_return_if_fail (new->plen > 0 && new->plen <= 128);
|
||||
g_return_if_fail (NM_IP6_CONFIG_GET_PRIVATE (self)->ifindex > 0);
|
||||
|
||||
_add_route (self, NULL, new);
|
||||
_add_route (self, NULL, new, out_obj_new);
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
|||
|
|
@ -144,7 +144,9 @@ gboolean nm_ip6_config_has_any_dad_pending (const NMIP6Config *self,
|
|||
|
||||
const NMDedupMultiHeadEntry *nm_ip6_config_lookup_routes (const NMIP6Config *self);
|
||||
void nm_ip6_config_reset_routes (NMIP6Config *self);
|
||||
void nm_ip6_config_add_route (NMIP6Config *self, const NMPlatformIP6Route *route);
|
||||
void nm_ip6_config_add_route (NMIP6Config *self,
|
||||
const NMPlatformIP6Route *route,
|
||||
const NMPObject **out_obj_new);
|
||||
void _nmtst_ip6_config_del_route (NMIP6Config *self, guint i);
|
||||
guint nm_ip6_config_get_num_routes (const NMIP6Config *self);
|
||||
const NMPlatformIP6Route *_nmtst_ip6_config_get_route (const NMIP6Config *self, guint i);
|
||||
|
|
|
|||
|
|
@ -42,10 +42,10 @@ build_test_config (void)
|
|||
nm_ip4_config_add_address (config, &addr);
|
||||
|
||||
route = *nmtst_platform_ip4_route ("10.0.0.0", 8, "192.168.1.1");
|
||||
nm_ip4_config_add_route (config, &route);
|
||||
nm_ip4_config_add_route (config, &route, NULL);
|
||||
|
||||
route = *nmtst_platform_ip4_route ("172.16.0.0", 16, "192.168.1.1");
|
||||
nm_ip4_config_add_route (config, &route);
|
||||
nm_ip4_config_add_route (config, &route, NULL);
|
||||
|
||||
nm_ip4_config_set_gateway (config, nmtst_inet4_from_string ("192.168.1.1"));
|
||||
|
||||
|
|
@ -95,7 +95,7 @@ test_subtract (void)
|
|||
nm_ip4_config_add_address (dst, &addr);
|
||||
|
||||
route = *nmtst_platform_ip4_route (expected_route_dest, expected_route_plen, expected_route_next_hop);
|
||||
nm_ip4_config_add_route (dst, &route);
|
||||
nm_ip4_config_add_route (dst, &route, NULL);
|
||||
|
||||
nm_ip4_config_add_nameserver (dst, expected_ns1);
|
||||
nm_ip4_config_add_nameserver (dst, expected_ns2);
|
||||
|
|
@ -170,10 +170,10 @@ test_compare_with_source (void)
|
|||
/* Route */
|
||||
route = *nmtst_platform_ip4_route ("10.0.0.0", 8, "192.168.1.1");
|
||||
route.rt_source = NM_IP_CONFIG_SOURCE_USER;
|
||||
nm_ip4_config_add_route (a, &route);
|
||||
nm_ip4_config_add_route (a, &route, NULL);
|
||||
|
||||
route.rt_source = NM_IP_CONFIG_SOURCE_VPN;
|
||||
nm_ip4_config_add_route (b, &route);
|
||||
nm_ip4_config_add_route (b, &route, NULL);
|
||||
|
||||
/* Assert that the configs are basically the same, eg that the source is ignored */
|
||||
g_assert (nm_ip4_config_equal (a, b));
|
||||
|
|
@ -234,13 +234,13 @@ test_add_route_with_source (void)
|
|||
/* Test that a higher priority source is not overwritten */
|
||||
route = *nmtst_platform_ip4_route ("1.2.3.0", 24, "1.2.3.1");
|
||||
route.rt_source = NM_IP_CONFIG_SOURCE_USER;
|
||||
nm_ip4_config_add_route (a, &route);
|
||||
nm_ip4_config_add_route (a, &route, NULL);
|
||||
|
||||
test_route = _nmtst_ip4_config_get_route (a, 0);
|
||||
g_assert_cmpint (test_route->rt_source, ==, NM_IP_CONFIG_SOURCE_USER);
|
||||
|
||||
route.rt_source = NM_IP_CONFIG_SOURCE_VPN;
|
||||
nm_ip4_config_add_route (a, &route);
|
||||
nm_ip4_config_add_route (a, &route, NULL);
|
||||
|
||||
test_route = _nmtst_ip4_config_get_route (a, 0);
|
||||
g_assert_cmpint (test_route->rt_source, ==, NM_IP_CONFIG_SOURCE_USER);
|
||||
|
|
@ -248,13 +248,13 @@ test_add_route_with_source (void)
|
|||
/* Test that a lower priority address source is overwritten */
|
||||
_nmtst_ip4_config_del_route (a, 0);
|
||||
route.rt_source = NM_IP_CONFIG_SOURCE_KERNEL;
|
||||
nm_ip4_config_add_route (a, &route);
|
||||
nm_ip4_config_add_route (a, &route, NULL);
|
||||
|
||||
test_route = _nmtst_ip4_config_get_route (a, 0);
|
||||
g_assert_cmpint (test_route->rt_source, ==, NM_IP_CONFIG_SOURCE_KERNEL);
|
||||
|
||||
route.rt_source = NM_IP_CONFIG_SOURCE_USER;
|
||||
nm_ip4_config_add_route (a, &route);
|
||||
nm_ip4_config_add_route (a, &route, NULL);
|
||||
|
||||
test_route = _nmtst_ip4_config_get_route (a, 0);
|
||||
g_assert_cmpint (test_route->rt_source, ==, NM_IP_CONFIG_SOURCE_USER);
|
||||
|
|
|
|||
|
|
@ -37,8 +37,8 @@ build_test_config (void)
|
|||
config = nmtst_ip6_config_new (1);
|
||||
|
||||
nm_ip6_config_add_address (config, nmtst_platform_ip6_address ("abcd:1234:4321::cdde", "1:2:3:4::5", 64));
|
||||
nm_ip6_config_add_route (config, nmtst_platform_ip6_route ("abcd:1200::", 24, "abcd:1234:4321:cdde::2", NULL));
|
||||
nm_ip6_config_add_route (config, nmtst_platform_ip6_route ("2001::", 16, "2001:abba::2234", NULL));
|
||||
nm_ip6_config_add_route (config, nmtst_platform_ip6_route ("abcd:1200::", 24, "abcd:1234:4321:cdde::2", NULL), NULL);
|
||||
nm_ip6_config_add_route (config, nmtst_platform_ip6_route ("2001::", 16, "2001:abba::2234", NULL), NULL);
|
||||
|
||||
nm_ip6_config_set_gateway (config, nmtst_inet6_from_string ("3001:abba::3234"));
|
||||
|
||||
|
|
@ -74,7 +74,7 @@ test_subtract (void)
|
|||
/* add a couple more things to the test config */
|
||||
dst = build_test_config ();
|
||||
nm_ip6_config_add_address (dst, nmtst_platform_ip6_address (expected_addr, NULL, expected_addr_plen));
|
||||
nm_ip6_config_add_route (dst, nmtst_platform_ip6_route (expected_route_dest, expected_route_plen, expected_route_next_hop, NULL));
|
||||
nm_ip6_config_add_route (dst, nmtst_platform_ip6_route (expected_route_dest, expected_route_plen, expected_route_next_hop, NULL), NULL);
|
||||
|
||||
expected_ns1 = *nmtst_inet6_from_string ("2222:3333:4444::5555");
|
||||
nm_ip6_config_add_nameserver (dst, &expected_ns1);
|
||||
|
|
@ -141,10 +141,10 @@ test_compare_with_source (void)
|
|||
/* Route */
|
||||
route = *nmtst_platform_ip6_route ("abcd:1200::", 24, "abcd:1234:4321:cdde::2", NULL);
|
||||
route.rt_source = NM_IP_CONFIG_SOURCE_USER;
|
||||
nm_ip6_config_add_route (a, &route);
|
||||
nm_ip6_config_add_route (a, &route, NULL);
|
||||
|
||||
route.rt_source = NM_IP_CONFIG_SOURCE_VPN;
|
||||
nm_ip6_config_add_route (b, &route);
|
||||
nm_ip6_config_add_route (b, &route, NULL);
|
||||
|
||||
/* Assert that the configs are basically the same, eg that the source is ignored */
|
||||
g_assert (nm_ip6_config_equal (a, b));
|
||||
|
|
@ -205,13 +205,13 @@ test_add_route_with_source (void)
|
|||
/* Test that a higher priority source is not overwritten */
|
||||
route = *nmtst_platform_ip6_route ("abcd:1200::", 24, "abcd:1234:4321:cdde::2", NULL);
|
||||
route.rt_source = NM_IP_CONFIG_SOURCE_USER;
|
||||
nm_ip6_config_add_route (a, &route);
|
||||
nm_ip6_config_add_route (a, &route, NULL);
|
||||
|
||||
test_route = _nmtst_ip6_config_get_route (a, 0);
|
||||
g_assert_cmpint (test_route->rt_source, ==, NM_IP_CONFIG_SOURCE_USER);
|
||||
|
||||
route.rt_source = NM_IP_CONFIG_SOURCE_VPN;
|
||||
nm_ip6_config_add_route (a, &route);
|
||||
nm_ip6_config_add_route (a, &route, NULL);
|
||||
|
||||
test_route = _nmtst_ip6_config_get_route (a, 0);
|
||||
g_assert_cmpint (test_route->rt_source, ==, NM_IP_CONFIG_SOURCE_USER);
|
||||
|
|
@ -219,13 +219,13 @@ test_add_route_with_source (void)
|
|||
/* Test that a lower priority address source is overwritten */
|
||||
_nmtst_ip6_config_del_route (a, 0);
|
||||
route.rt_source = NM_IP_CONFIG_SOURCE_KERNEL;
|
||||
nm_ip6_config_add_route (a, &route);
|
||||
nm_ip6_config_add_route (a, &route, NULL);
|
||||
|
||||
test_route = _nmtst_ip6_config_get_route (a, 0);
|
||||
g_assert_cmpint (test_route->rt_source, ==, NM_IP_CONFIG_SOURCE_KERNEL);
|
||||
|
||||
route.rt_source = NM_IP_CONFIG_SOURCE_USER;
|
||||
nm_ip6_config_add_route (a, &route);
|
||||
nm_ip6_config_add_route (a, &route, NULL);
|
||||
|
||||
test_route = _nmtst_ip6_config_get_route (a, 0);
|
||||
g_assert_cmpint (test_route->rt_source, ==, NM_IP_CONFIG_SOURCE_USER);
|
||||
|
|
|
|||
|
|
@ -760,7 +760,7 @@ add_ip4_vpn_gateway_route (NMIP4Config *config,
|
|||
route.gateway = parent_gw;
|
||||
route.rt_source = NM_IP_CONFIG_SOURCE_VPN;
|
||||
route.metric = route_metric;
|
||||
nm_ip4_config_add_route (config, &route);
|
||||
nm_ip4_config_add_route (config, &route, NULL);
|
||||
|
||||
if (parent_gw) {
|
||||
/* Ensure there's a route to the parent device's gateway through the
|
||||
|
|
@ -773,7 +773,7 @@ add_ip4_vpn_gateway_route (NMIP4Config *config,
|
|||
route.plen = 32;
|
||||
route.rt_source = NM_IP_CONFIG_SOURCE_VPN;
|
||||
route.metric = route_metric;
|
||||
nm_ip4_config_add_route (config, &route);
|
||||
nm_ip4_config_add_route (config, &route, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -834,7 +834,7 @@ add_ip6_vpn_gateway_route (NMIP6Config *config,
|
|||
route.gateway = *parent_gw;
|
||||
route.rt_source = NM_IP_CONFIG_SOURCE_VPN;
|
||||
route.metric = route_metric;
|
||||
nm_ip6_config_add_route (config, &route);
|
||||
nm_ip6_config_add_route (config, &route, NULL);
|
||||
|
||||
/* Ensure there's a route to the parent device's gateway through the
|
||||
* parent device, since if the VPN claims the default route and the VPN
|
||||
|
|
@ -847,7 +847,7 @@ add_ip6_vpn_gateway_route (NMIP6Config *config,
|
|||
route.plen = 128;
|
||||
route.rt_source = NM_IP_CONFIG_SOURCE_VPN;
|
||||
route.metric = route_metric;
|
||||
nm_ip6_config_add_route (config, &route);
|
||||
nm_ip6_config_add_route (config, &route, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1548,7 +1548,7 @@ nm_vpn_connection_ip4_config_get (NMVpnConnection *self, GVariant *dict)
|
|||
const NMPlatformIP4Route *route;
|
||||
|
||||
nm_ip_config_iter_ip4_route_for_each (&ipconf_iter, priv->ip4_config, &route)
|
||||
nm_ip4_config_add_route (config, route);
|
||||
nm_ip4_config_add_route (config, route, NULL);
|
||||
}
|
||||
} else if (g_variant_lookup (dict, NM_VPN_PLUGIN_IP4_CONFIG_ROUTES, "aau", &iter)) {
|
||||
while (g_variant_iter_next (iter, "@au", &v)) {
|
||||
|
|
@ -1578,7 +1578,7 @@ nm_vpn_connection_ip4_config_get (NMVpnConnection *self, GVariant *dict)
|
|||
* whatever the server provides.
|
||||
*/
|
||||
if (!(priv->ip4_external_gw && route.network == priv->ip4_external_gw && route.plen == 32))
|
||||
nm_ip4_config_add_route (config, &route);
|
||||
nm_ip4_config_add_route (config, &route, NULL);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
|
@ -1713,7 +1713,7 @@ nm_vpn_connection_ip6_config_get (NMVpnConnection *self, GVariant *dict)
|
|||
const NMPlatformIP6Route *route;
|
||||
|
||||
nm_ip_config_iter_ip6_route_for_each (&ipconf_iter, priv->ip6_config, &route)
|
||||
nm_ip6_config_add_route (config, route);
|
||||
nm_ip6_config_add_route (config, route, NULL);
|
||||
}
|
||||
} else if (g_variant_lookup (dict, NM_VPN_PLUGIN_IP6_CONFIG_ROUTES, "a(ayuayu)", &iter)) {
|
||||
GVariant *dest, *next_hop;
|
||||
|
|
@ -1741,7 +1741,7 @@ nm_vpn_connection_ip6_config_get (NMVpnConnection *self, GVariant *dict)
|
|||
* the server provides.
|
||||
*/
|
||||
if (!(priv->ip6_external_gw && IN6_ARE_ADDR_EQUAL (&route.network, priv->ip6_external_gw) && route.plen == 128))
|
||||
nm_ip6_config_add_route (config, &route);
|
||||
nm_ip6_config_add_route (config, &route, NULL);
|
||||
|
||||
next:
|
||||
g_variant_unref (dest);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue