mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-05-04 08:17:58 +02:00
platform: merge branch 'th/platform-route-cleanup-bgo765432'
https://bugzilla.gnome.org/show_bug.cgi?id=765432
This commit is contained in:
commit
bfc858ccab
30 changed files with 405 additions and 276 deletions
|
|
@ -1209,7 +1209,7 @@ nmtst_platform_ip4_address_full (const char *address, const char *peer_address,
|
|||
g_assert (!label || strlen (label) < IFNAMSIZ);
|
||||
|
||||
addr->ifindex = ifindex;
|
||||
addr->source = source;
|
||||
addr->addr_source = source;
|
||||
addr->timestamp = timestamp;
|
||||
addr->lifetime = lifetime;
|
||||
addr->preferred = preferred;
|
||||
|
|
@ -1243,7 +1243,7 @@ nmtst_platform_ip6_address_full (const char *address, const char *peer_address,
|
|||
NMPlatformIP6Address *addr = nmtst_platform_ip6_address (address, peer_address, plen);
|
||||
|
||||
addr->ifindex = ifindex;
|
||||
addr->source = source;
|
||||
addr->addr_source = source;
|
||||
addr->timestamp = timestamp;
|
||||
addr->lifetime = lifetime;
|
||||
addr->preferred = preferred;
|
||||
|
|
@ -1277,7 +1277,7 @@ nmtst_platform_ip4_route_full (const char *network, guint plen, const char *gate
|
|||
NMPlatformIP4Route *route = nmtst_platform_ip4_route (network, plen, gateway);
|
||||
|
||||
route->ifindex = ifindex;
|
||||
route->source = source;
|
||||
route->rt_source = source;
|
||||
route->metric = metric;
|
||||
route->mss = mss;
|
||||
route->scope_inv = nm_platform_route_scope_inv (scope);
|
||||
|
|
@ -1309,7 +1309,7 @@ nmtst_platform_ip6_route_full (const char *network, guint plen, const char *gate
|
|||
NMPlatformIP6Route *route = nmtst_platform_ip6_route (network, plen, gateway);
|
||||
|
||||
route->ifindex = ifindex;
|
||||
route->source = source;
|
||||
route->rt_source = source;
|
||||
route->metric = metric;
|
||||
route->mss = mss;
|
||||
|
||||
|
|
|
|||
|
|
@ -3997,14 +3997,14 @@ ipv4ll_get_ip4_config (NMDevice *self, guint32 lla)
|
|||
|
||||
memset (&address, 0, sizeof (address));
|
||||
nm_platform_ip4_address_set_addr (&address, lla, 16);
|
||||
address.source = NM_IP_CONFIG_SOURCE_IP4LL;
|
||||
address.addr_source = NM_IP_CONFIG_SOURCE_IP4LL;
|
||||
nm_ip4_config_add_address (config, &address);
|
||||
|
||||
/* Add a multicast route for link-local connections: destination= 224.0.0.0, netmask=240.0.0.0 */
|
||||
memset (&route, 0, sizeof (route));
|
||||
route.network = htonl (0xE0000000L);
|
||||
route.plen = 4;
|
||||
route.source = NM_IP_CONFIG_SOURCE_IP4LL;
|
||||
route.rt_source = NM_IP_CONFIG_SOURCE_IP4LL;
|
||||
route.metric = nm_device_get_ip4_route_metric (self);
|
||||
nm_ip4_config_add_route (config, &route);
|
||||
|
||||
|
|
@ -4441,7 +4441,7 @@ ip4_config_merge_and_apply (NMDevice *self,
|
|||
|
||||
priv->default_route.v4_has = TRUE;
|
||||
memset (&priv->default_route.v4, 0, sizeof (priv->default_route.v4));
|
||||
priv->default_route.v4.source = NM_IP_CONFIG_SOURCE_USER;
|
||||
priv->default_route.v4.rt_source = NM_IP_CONFIG_SOURCE_USER;
|
||||
priv->default_route.v4.gateway = gateway;
|
||||
priv->default_route.v4.metric = default_route_metric;
|
||||
priv->default_route.v4.mss = nm_ip4_config_get_mss (composite);
|
||||
|
|
@ -4806,7 +4806,7 @@ shared4_new_config (NMDevice *self, NMConnection *connection, NMDeviceStateReaso
|
|||
}
|
||||
|
||||
config = nm_ip4_config_new (nm_device_get_ip_ifindex (self));
|
||||
address.source = NM_IP_CONFIG_SOURCE_SHARED;
|
||||
address.addr_source = NM_IP_CONFIG_SOURCE_SHARED;
|
||||
nm_ip4_config_add_address (config, &address);
|
||||
|
||||
/* Remove the address lock when the object gets disposed */
|
||||
|
|
@ -5172,7 +5172,7 @@ ip6_config_merge_and_apply (NMDevice *self,
|
|||
|
||||
priv->default_route.v6_has = TRUE;
|
||||
memset (&priv->default_route.v6, 0, sizeof (priv->default_route.v6));
|
||||
priv->default_route.v6.source = NM_IP_CONFIG_SOURCE_USER;
|
||||
priv->default_route.v6.rt_source = NM_IP_CONFIG_SOURCE_USER;
|
||||
priv->default_route.v6.gateway = *gateway;
|
||||
priv->default_route.v6.metric = nm_device_get_ip6_route_metric (self);
|
||||
priv->default_route.v6.mss = nm_ip6_config_get_mss (composite);
|
||||
|
|
@ -5799,7 +5799,7 @@ rdisc_config_changed (NMRDisc *rdisc, NMRDiscConfigMap changed, NMDevice *self)
|
|||
address.preferred = discovered_address->preferred;
|
||||
if (address.preferred > address.lifetime)
|
||||
address.preferred = address.lifetime;
|
||||
address.source = NM_IP_CONFIG_SOURCE_RDISC;
|
||||
address.addr_source = NM_IP_CONFIG_SOURCE_RDISC;
|
||||
address.n_ifa_flags = ifa_flags;
|
||||
|
||||
nm_ip6_config_add_address (priv->ac_ip6_config, &address);
|
||||
|
|
@ -5824,7 +5824,7 @@ rdisc_config_changed (NMRDisc *rdisc, NMRDiscConfigMap changed, NMDevice *self)
|
|||
nm_assert (discovered_route->plen <= 128);
|
||||
route.plen = discovered_route->plen;
|
||||
route.gateway = discovered_route->gateway;
|
||||
route.source = NM_IP_CONFIG_SOURCE_RDISC;
|
||||
route.rt_source = NM_IP_CONFIG_SOURCE_RDISC;
|
||||
route.metric = nm_device_get_ip6_route_metric (self);
|
||||
|
||||
nm_ip6_config_add_route (priv->ac_ip6_config, &route);
|
||||
|
|
@ -9004,7 +9004,7 @@ queued_ip6_config_change (gpointer user_data)
|
|||
for (iter = priv->dad6_failed_addrs; iter; iter = g_slist_next (iter)) {
|
||||
NMPlatformIP6Address *addr = iter->data;
|
||||
|
||||
if (addr->source >= NM_IP_CONFIG_SOURCE_USER)
|
||||
if (addr->addr_source >= NM_IP_CONFIG_SOURCE_USER)
|
||||
continue;
|
||||
|
||||
_LOGI (LOGD_IP6, "ipv6: duplicate address check failed for the %s address",
|
||||
|
|
@ -10218,7 +10218,7 @@ find_dhcp4_address (NMDevice *self)
|
|||
for (i = 0; i < n; i++) {
|
||||
const NMPlatformIP4Address *a = nm_ip4_config_get_address (priv->ip4_config, i);
|
||||
|
||||
if (a->source == NM_IP_CONFIG_SOURCE_DHCP)
|
||||
if (a->addr_source == NM_IP_CONFIG_SOURCE_DHCP)
|
||||
return g_strdup (nm_utils_inet4_ntop (a->address, NULL));
|
||||
}
|
||||
return NULL;
|
||||
|
|
|
|||
|
|
@ -869,7 +869,7 @@ static_stage3_ip4_done (NMModemBroadband *self)
|
|||
address.address = address_network;
|
||||
address.peer_address = address_network;
|
||||
address.plen = mm_bearer_ip_config_get_prefix (self->priv->ipv4_config);
|
||||
address.source = NM_IP_CONFIG_SOURCE_WWAN;
|
||||
address.addr_source = NM_IP_CONFIG_SOURCE_WWAN;
|
||||
if (address.plen <= 32)
|
||||
nm_ip4_config_add_address (config, &address);
|
||||
|
||||
|
|
|
|||
|
|
@ -700,7 +700,7 @@ nm_dhcp_dhclient_read_lease_ip_configs (const char *iface,
|
|||
|
||||
address.timestamp = now_monotonic_ts;
|
||||
address.lifetime = address.preferred = expiry;
|
||||
address.source = NM_IP_CONFIG_SOURCE_DHCP;
|
||||
address.addr_source = NM_IP_CONFIG_SOURCE_DHCP;
|
||||
|
||||
ip4 = nm_ip4_config_new (ifindex);
|
||||
nm_ip4_config_add_address (ip4, &address);
|
||||
|
|
|
|||
|
|
@ -256,7 +256,7 @@ lease_to_ip4_config (const char *iface,
|
|||
SD_DHCP_OPTION_IP_ADDRESS_LEASE_TIME,
|
||||
end_time);
|
||||
|
||||
address.source = NM_IP_CONFIG_SOURCE_DHCP;
|
||||
address.addr_source = NM_IP_CONFIG_SOURCE_DHCP;
|
||||
nm_ip4_config_add_address (ip4_config, &address);
|
||||
|
||||
/* DNS Servers */
|
||||
|
|
@ -322,7 +322,7 @@ lease_to_ip4_config (const char *iface,
|
|||
route.gateway = a.s_addr;
|
||||
|
||||
if (route.plen) {
|
||||
route.source = NM_IP_CONFIG_SOURCE_DHCP;
|
||||
route.rt_source = NM_IP_CONFIG_SOURCE_DHCP;
|
||||
route.metric = default_priority;
|
||||
nm_ip4_config_add_route (ip4_config, &route);
|
||||
|
||||
|
|
@ -740,7 +740,7 @@ lease_to_ip6_config (const char *iface,
|
|||
.timestamp = ts,
|
||||
.lifetime = lft_valid,
|
||||
.preferred = lft_pref,
|
||||
.source = NM_IP_CONFIG_SOURCE_DHCP,
|
||||
.addr_source = NM_IP_CONFIG_SOURCE_DHCP,
|
||||
};
|
||||
|
||||
nm_ip6_config_add_address (ip6_config, &address);
|
||||
|
|
|
|||
|
|
@ -84,7 +84,7 @@ ip4_process_dhcpcd_rfc3442_routes (const char *str,
|
|||
route.network = rt_addr;
|
||||
route.plen = rt_cidr;
|
||||
route.gateway = rt_route;
|
||||
route.source = NM_IP_CONFIG_SOURCE_DHCP;
|
||||
route.rt_source = NM_IP_CONFIG_SOURCE_DHCP;
|
||||
route.metric = priority;
|
||||
nm_ip4_config_add_route (ip4_config, &route);
|
||||
}
|
||||
|
|
@ -192,7 +192,7 @@ ip4_process_dhclient_rfc3442_routes (const char *str,
|
|||
char addr[INET_ADDRSTRLEN];
|
||||
|
||||
/* normal route */
|
||||
route.source = NM_IP_CONFIG_SOURCE_DHCP;
|
||||
route.rt_source = NM_IP_CONFIG_SOURCE_DHCP;
|
||||
route.metric = priority;
|
||||
nm_ip4_config_add_route (ip4_config, &route);
|
||||
|
||||
|
|
@ -314,7 +314,7 @@ process_classful_routes (GHashTable *options, guint32 priority, NMIP4Config *ip4
|
|||
route.plen = 32;
|
||||
}
|
||||
route.gateway = rt_route;
|
||||
route.source = NM_IP_CONFIG_SOURCE_DHCP;
|
||||
route.rt_source = NM_IP_CONFIG_SOURCE_DHCP;
|
||||
route.metric = priority;
|
||||
|
||||
nm_ip4_config_add_route (ip4_config, &route);
|
||||
|
|
@ -465,7 +465,7 @@ nm_dhcp_utils_ip4_config_from_options (int ifindex,
|
|||
route.plen = 32;
|
||||
/* this will be a device route if gwaddr is 0 */
|
||||
route.gateway = gwaddr;
|
||||
route.source = NM_IP_CONFIG_SOURCE_DHCP;
|
||||
route.rt_source = NM_IP_CONFIG_SOURCE_DHCP;
|
||||
route.metric = priority;
|
||||
nm_ip4_config_add_route (ip4_config, &route);
|
||||
nm_log_dbg (LOGD_IP, "adding route for server identifier: %s",
|
||||
|
|
@ -482,7 +482,7 @@ nm_dhcp_utils_ip4_config_from_options (int ifindex,
|
|||
nm_log_info (LOGD_DHCP4, " lease time %u", address.lifetime);
|
||||
}
|
||||
|
||||
address.source = NM_IP_CONFIG_SOURCE_DHCP;
|
||||
address.addr_source = NM_IP_CONFIG_SOURCE_DHCP;
|
||||
nm_ip4_config_add_address (ip4_config, &address);
|
||||
|
||||
str = g_hash_table_lookup (options, "host_name");
|
||||
|
|
@ -642,7 +642,7 @@ nm_dhcp_utils_ip6_config_from_options (int ifindex,
|
|||
}
|
||||
|
||||
address.address = tmp_addr;
|
||||
address.source = NM_IP_CONFIG_SOURCE_DHCP;
|
||||
address.addr_source = NM_IP_CONFIG_SOURCE_DHCP;
|
||||
nm_ip6_config_add_address (ip6_config, &address);
|
||||
nm_log_info (LOGD_DHCP6, " address %s", str);
|
||||
} else if (info_only == FALSE) {
|
||||
|
|
|
|||
|
|
@ -199,6 +199,27 @@ nm_ethernet_address_is_valid (gconstpointer addr, gssize len)
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
gconstpointer
|
||||
nm_utils_ipx_address_clear_host_address (int family, gpointer dst, gconstpointer src, guint8 plen)
|
||||
{
|
||||
g_return_val_if_fail (src, NULL);
|
||||
g_return_val_if_fail (dst, NULL);
|
||||
|
||||
switch (family) {
|
||||
case AF_INET:
|
||||
g_return_val_if_fail (plen <= 32, NULL);
|
||||
*((guint32 *) dst) = nm_utils_ip4_address_clear_host_address (*((guint32 *) src), plen);
|
||||
break;
|
||||
case AF_INET6:
|
||||
g_return_val_if_fail (plen <= 128, NULL);
|
||||
nm_utils_ip6_address_clear_host_address (dst, src, plen);
|
||||
break;
|
||||
default:
|
||||
g_return_val_if_reached (NULL);
|
||||
}
|
||||
return dst;
|
||||
}
|
||||
|
||||
/* nm_utils_ip4_address_clear_host_address:
|
||||
* @addr: source ip6 address
|
||||
* @plen: prefix length of network
|
||||
|
|
|
|||
|
|
@ -93,6 +93,7 @@ GETTER (void) \
|
|||
|
||||
gboolean nm_ethernet_address_is_valid (gconstpointer addr, gssize len);
|
||||
|
||||
gconstpointer nm_utils_ipx_address_clear_host_address (int family, gpointer dst, gconstpointer src, guint8 plen);
|
||||
in_addr_t nm_utils_ip4_address_clear_host_address (in_addr_t addr, guint8 plen);
|
||||
const struct in6_addr *nm_utils_ip6_address_clear_host_address (struct in6_addr *dst, const struct in6_addr *src, guint8 plen);
|
||||
gboolean nm_utils_ip6_address_same_prefix (const struct in6_addr *addr_a, const struct in6_addr *addr_b, guint8 plen);
|
||||
|
|
|
|||
|
|
@ -200,7 +200,7 @@ _vt_routes_has_entry (const VTableIP *vtable, GArray *routes, const Entry *entry
|
|||
for (i = 0; i < routes->len; i++) {
|
||||
NMPlatformIP4Route *r = &g_array_index (routes, NMPlatformIP4Route, i);
|
||||
|
||||
route.rx.source = r->source;
|
||||
route.rx.rt_source = r->rt_source;
|
||||
if (nm_platform_ip4_route_cmp (r, &route.r4) == 0)
|
||||
return TRUE;
|
||||
}
|
||||
|
|
@ -208,7 +208,7 @@ _vt_routes_has_entry (const VTableIP *vtable, GArray *routes, const Entry *entry
|
|||
for (i = 0; i < routes->len; i++) {
|
||||
NMPlatformIP6Route *r = &g_array_index (routes, NMPlatformIP6Route, i);
|
||||
|
||||
route.rx.source = r->source;
|
||||
route.rx.rt_source = r->rt_source;
|
||||
if (nm_platform_ip6_route_cmp (r, &route.r6) == 0)
|
||||
return TRUE;
|
||||
}
|
||||
|
|
@ -289,7 +289,7 @@ _platform_route_sync_add (const VTableIP *vtable, NMDefaultRouteManager *self, g
|
|||
if (vtable->vt->is_ip4) {
|
||||
success = nm_platform_ip4_route_add (priv->platform,
|
||||
entry->route.rx.ifindex,
|
||||
entry->route.rx.source,
|
||||
entry->route.rx.rt_source,
|
||||
0,
|
||||
0,
|
||||
entry->route.r4.gateway,
|
||||
|
|
@ -299,7 +299,7 @@ _platform_route_sync_add (const VTableIP *vtable, NMDefaultRouteManager *self, g
|
|||
} else {
|
||||
success = nm_platform_ip6_route_add (priv->platform,
|
||||
entry->route.rx.ifindex,
|
||||
entry->route.rx.source,
|
||||
entry->route.rx.rt_source,
|
||||
in6addr_any,
|
||||
0,
|
||||
entry->route.r6.gateway,
|
||||
|
|
@ -773,7 +773,7 @@ _ipx_update_default_route (const VTableIP *vtable, NMDefaultRouteManager *self,
|
|||
* the device. */
|
||||
memset (&rt, 0, sizeof (rt));
|
||||
rt.rx.ifindex = ip_ifindex;
|
||||
rt.rx.source = NM_IP_CONFIG_SOURCE_UNKNOWN;
|
||||
rt.rx.rt_source = NM_IP_CONFIG_SOURCE_UNKNOWN;
|
||||
rt.rx.metric = G_MAXUINT32;
|
||||
default_route = &rt.rx;
|
||||
|
||||
|
|
@ -795,7 +795,7 @@ _ipx_update_default_route (const VTableIP *vtable, NMDefaultRouteManager *self,
|
|||
if (vpn_config) {
|
||||
never_default = nm_ip4_config_get_never_default (vpn_config);
|
||||
rt.r4.ifindex = ip_ifindex;
|
||||
rt.r4.source = NM_IP_CONFIG_SOURCE_VPN;
|
||||
rt.r4.rt_source = NM_IP_CONFIG_SOURCE_VPN;
|
||||
rt.r4.gateway = nm_ip4_config_get_gateway (vpn_config);
|
||||
rt.r4.metric = nm_vpn_connection_get_ip4_route_metric (vpn);
|
||||
rt.r4.mss = nm_ip4_config_get_mss (vpn_config);
|
||||
|
|
@ -810,7 +810,7 @@ _ipx_update_default_route (const VTableIP *vtable, NMDefaultRouteManager *self,
|
|||
|
||||
never_default = nm_ip6_config_get_never_default (vpn_config);
|
||||
rt.r6.ifindex = ip_ifindex;
|
||||
rt.r6.source = NM_IP_CONFIG_SOURCE_VPN;
|
||||
rt.r6.rt_source = NM_IP_CONFIG_SOURCE_VPN;
|
||||
rt.r6.gateway = int_gw ? *int_gw : in6addr_any;
|
||||
rt.r6.metric = nm_vpn_connection_get_ip6_route_metric (vpn);
|
||||
rt.r6.mss = nm_ip6_config_get_mss (vpn_config);
|
||||
|
|
|
|||
|
|
@ -194,7 +194,7 @@ rdisc_config_changed (NMRDisc *rdisc, NMRDiscConfigMap changed, gpointer user_da
|
|||
address.preferred = discovered_address->preferred;
|
||||
if (address.preferred > address.lifetime)
|
||||
address.preferred = address.lifetime;
|
||||
address.source = NM_IP_CONFIG_SOURCE_RDISC;
|
||||
address.addr_source = NM_IP_CONFIG_SOURCE_RDISC;
|
||||
address.n_ifa_flags = ifa_flags;
|
||||
|
||||
nm_ip6_config_add_address (rdisc_config, &address);
|
||||
|
|
@ -219,7 +219,7 @@ rdisc_config_changed (NMRDisc *rdisc, NMRDiscConfigMap changed, gpointer user_da
|
|||
route.network = discovered_route->network;
|
||||
route.plen = discovered_route->plen;
|
||||
route.gateway = discovered_route->gateway;
|
||||
route.source = NM_IP_CONFIG_SOURCE_RDISC;
|
||||
route.rt_source = NM_IP_CONFIG_SOURCE_RDISC;
|
||||
route.metric = global_opt.priority_v6;
|
||||
|
||||
nm_ip6_config_add_route (rdisc_config, &route);
|
||||
|
|
|
|||
|
|
@ -207,8 +207,8 @@ _addresses_sort_cmp (gconstpointer a, gconstpointer b)
|
|||
return p1 > p2 ? -1 : 1;
|
||||
|
||||
/* Sort the addresses based on their source. */
|
||||
if (a1->source != a2->source)
|
||||
return a1->source > a2->source ? -1 : 1;
|
||||
if (a1->addr_source != a2->addr_source)
|
||||
return a1->addr_source > a2->addr_source ? -1 : 1;
|
||||
|
||||
if ((a1->label[0] == '\0') != (a2->label[0] == '\0'))
|
||||
return (a1->label[0] == '\0') ? -1 : 1;
|
||||
|
|
@ -368,7 +368,7 @@ nm_ip4_config_commit (const NMIP4Config *config, int ifindex, gboolean routes_fu
|
|||
nm_assert (addr->plen <= 32);
|
||||
|
||||
route.ifindex = ifindex;
|
||||
route.source = NM_IP_CONFIG_SOURCE_KERNEL;
|
||||
route.rt_source = NM_IP_CONFIG_SOURCE_KERNEL;
|
||||
|
||||
/* The destination network depends on the peer-address. */
|
||||
route.network = nm_utils_ip4_address_clear_host_address (addr->peer_address, addr->plen);
|
||||
|
|
@ -471,7 +471,7 @@ nm_ip4_config_merge_setting (NMIP4Config *config, NMSettingIPConfig *setting, gu
|
|||
nm_assert (address.plen <= 32);
|
||||
address.lifetime = NM_PLATFORM_LIFETIME_PERMANENT;
|
||||
address.preferred = NM_PLATFORM_LIFETIME_PERMANENT;
|
||||
address.source = NM_IP_CONFIG_SOURCE_USER;
|
||||
address.addr_source = NM_IP_CONFIG_SOURCE_USER;
|
||||
|
||||
label = nm_ip_address_get_attribute (s_addr, "label");
|
||||
if (label)
|
||||
|
|
@ -500,7 +500,7 @@ nm_ip4_config_merge_setting (NMIP4Config *config, NMSettingIPConfig *setting, gu
|
|||
route.metric = default_route_metric;
|
||||
else
|
||||
route.metric = nm_ip_route_get_metric (s_route);
|
||||
route.source = NM_IP_CONFIG_SOURCE_USER;
|
||||
route.rt_source = NM_IP_CONFIG_SOURCE_USER;
|
||||
|
||||
nm_ip4_config_add_route (config, &route);
|
||||
}
|
||||
|
|
@ -606,7 +606,7 @@ nm_ip4_config_create_setting (const NMIP4Config *config)
|
|||
continue;
|
||||
|
||||
/* Ignore routes provided by external sources */
|
||||
if (route->source != NM_IP_CONFIG_SOURCE_USER)
|
||||
if (route->rt_source != NM_IP_CONFIG_SOURCE_USER)
|
||||
continue;
|
||||
|
||||
s_route = nm_ip_route_new_binary (AF_INET,
|
||||
|
|
@ -1481,14 +1481,14 @@ nm_ip4_config_add_address (NMIP4Config *config, const NMPlatformIP4Address *new)
|
|||
*item = *new;
|
||||
|
||||
/* But restore highest priority source */
|
||||
item->source = MAX (item_old.source, new->source);
|
||||
item->addr_source = MAX (item_old.addr_source, new->addr_source);
|
||||
|
||||
/* for addresses that we read from the kernel, we keep the timestamps as defined
|
||||
* by the previous source (item_old). The reason is, that the other source configured the lifetimes
|
||||
* with "what should be" and the kernel values are "what turned out after configuring it".
|
||||
*
|
||||
* For other sources, the longer lifetime wins. */
|
||||
if ( (new->source == NM_IP_CONFIG_SOURCE_KERNEL && new->source != item_old.source)
|
||||
if ( (new->addr_source == NM_IP_CONFIG_SOURCE_KERNEL && new->addr_source != item_old.addr_source)
|
||||
|| nm_platform_ip_address_cmp_expiry ((const NMPlatformIPAddress *) &item_old, (const NMPlatformIPAddress *) new) > 0) {
|
||||
item->timestamp = item_old.timestamp;
|
||||
item->lifetime = item_old.lifetime;
|
||||
|
|
@ -1582,10 +1582,10 @@ nm_ip4_config_add_route (NMIP4Config *config, const NMPlatformIP4Route *new)
|
|||
if (routes_are_duplicate (item, new, FALSE)) {
|
||||
if (nm_platform_ip4_route_cmp (item, new) == 0)
|
||||
return;
|
||||
old_source = item->source;
|
||||
old_source = item->rt_source;
|
||||
memcpy (item, new, sizeof (*item));
|
||||
/* Restore highest priority source */
|
||||
item->source = MAX (old_source, new->source);
|
||||
item->rt_source = MAX (old_source, new->rt_source);
|
||||
item->ifindex = priv->ifindex;
|
||||
goto NOTIFY;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -240,8 +240,8 @@ _addresses_sort_cmp (gconstpointer a, gconstpointer b, gpointer user_data)
|
|||
}
|
||||
|
||||
/* Sort the addresses based on their source. */
|
||||
if (a1->source != a2->source)
|
||||
return a1->source > a2->source ? -1 : 1;
|
||||
if (a1->addr_source != a2->addr_source)
|
||||
return a1->addr_source > a2->addr_source ? -1 : 1;
|
||||
|
||||
/* sort permanent addresses before non-permanent. */
|
||||
perm1 = (a1->n_ifa_flags & IFA_F_PERMANENT);
|
||||
|
|
@ -457,7 +457,7 @@ nm_ip6_config_merge_setting (NMIP6Config *config, NMSettingIPConfig *setting, gu
|
|||
nm_assert (address.plen <= 128);
|
||||
address.lifetime = NM_PLATFORM_LIFETIME_PERMANENT;
|
||||
address.preferred = NM_PLATFORM_LIFETIME_PERMANENT;
|
||||
address.source = NM_IP_CONFIG_SOURCE_USER;
|
||||
address.addr_source = NM_IP_CONFIG_SOURCE_USER;
|
||||
|
||||
nm_ip6_config_add_address (config, &address);
|
||||
}
|
||||
|
|
@ -482,7 +482,7 @@ nm_ip6_config_merge_setting (NMIP6Config *config, NMSettingIPConfig *setting, gu
|
|||
route.metric = default_route_metric;
|
||||
else
|
||||
route.metric = nm_ip_route_get_metric (s_route);
|
||||
route.source = NM_IP_CONFIG_SOURCE_USER;
|
||||
route.rt_source = NM_IP_CONFIG_SOURCE_USER;
|
||||
|
||||
nm_ip6_config_add_route (config, &route);
|
||||
}
|
||||
|
|
@ -596,7 +596,7 @@ nm_ip6_config_create_setting (const NMIP6Config *config)
|
|||
continue;
|
||||
|
||||
/* Ignore routes provided by external sources */
|
||||
if (route->source != NM_IP_CONFIG_SOURCE_USER)
|
||||
if (route->rt_source != NM_IP_CONFIG_SOURCE_USER)
|
||||
continue;
|
||||
|
||||
s_route = nm_ip_route_new_binary (AF_INET6,
|
||||
|
|
@ -1290,14 +1290,14 @@ nm_ip6_config_add_address (NMIP6Config *config, const NMPlatformIP6Address *new)
|
|||
*item = *new;
|
||||
|
||||
/* But restore highest priority source */
|
||||
item->source = MAX (item_old.source, new->source);
|
||||
item->addr_source = MAX (item_old.addr_source, new->addr_source);
|
||||
|
||||
/* for addresses that we read from the kernel, we keep the timestamps as defined
|
||||
* by the previous source (item_old). The reason is, that the other source configured the lifetimes
|
||||
* with "what should be" and the kernel values are "what turned out after configuring it".
|
||||
*
|
||||
* For other sources, the longer lifetime wins. */
|
||||
if ( (new->source == NM_IP_CONFIG_SOURCE_KERNEL && new->source != item_old.source)
|
||||
if ( (new->addr_source == NM_IP_CONFIG_SOURCE_KERNEL && new->addr_source != item_old.addr_source)
|
||||
|| nm_platform_ip_address_cmp_expiry ((const NMPlatformIPAddress *) &item_old, (const NMPlatformIPAddress *) new) > 0) {
|
||||
item->timestamp = item_old.timestamp;
|
||||
item->lifetime = item_old.lifetime;
|
||||
|
|
@ -1414,10 +1414,10 @@ nm_ip6_config_add_route (NMIP6Config *config, const NMPlatformIP6Route *new)
|
|||
if (routes_are_duplicate (item, new, FALSE)) {
|
||||
if (nm_platform_ip6_route_cmp (item, new) == 0)
|
||||
return;
|
||||
old_source = item->source;
|
||||
old_source = item->rt_source;
|
||||
*item = *new;
|
||||
/* Restore highest priority source */
|
||||
item->source = MAX (old_source, new->source);
|
||||
item->rt_source = MAX (old_source, new->rt_source);
|
||||
item->ifindex = priv->ifindex;
|
||||
goto NOTIFY;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -873,7 +873,7 @@ next:
|
|||
|| !_route_equals_ignoring_ifindex (vtable, cur_plat_route, cur_ipx_route, *p_effective_metric)) {
|
||||
|
||||
if (!vtable->vt->route_add (priv->platform, ifindex, cur_ipx_route, *p_effective_metric)) {
|
||||
if (cur_ipx_route->rx.source < NM_IP_CONFIG_SOURCE_USER) {
|
||||
if (cur_ipx_route->rx.rt_source < NM_IP_CONFIG_SOURCE_USER) {
|
||||
_LOGD (vtable->vt->addr_family,
|
||||
"ignore error adding IPv%c route to kernel: %s",
|
||||
vtable->vt->is_ip4 ? '4' : '6',
|
||||
|
|
@ -1024,7 +1024,7 @@ _ip4_device_routes_ip4_route_changed (NMPlatform *platform,
|
|||
if (change_type == NM_PLATFORM_SIGNAL_REMOVED)
|
||||
return;
|
||||
|
||||
if ( route->source != NM_IP_CONFIG_SOURCE_RTPROT_KERNEL
|
||||
if ( route->rt_source != NM_IP_CONFIG_SOURCE_RTPROT_KERNEL
|
||||
|| route->metric != 0) {
|
||||
/* we don't have an automatically created device route at hand. Bail out early. */
|
||||
return;
|
||||
|
|
|
|||
|
|
@ -54,13 +54,20 @@ typedef struct _NMLldpListener NMLldpListener;
|
|||
|
||||
typedef enum {
|
||||
/* In priority order; higher number == higher priority */
|
||||
NM_IP_CONFIG_SOURCE_UNKNOWN,
|
||||
|
||||
/* platform internal flag used to mark routes with RTM_F_CLONED. */
|
||||
_NM_IP_CONFIG_SOURCE_RTM_F_CLONED,
|
||||
NM_IP_CONFIG_SOURCE_UNKNOWN = 0,
|
||||
|
||||
/* routes from platform with protocol RTPROT_KERNEL. */
|
||||
NM_IP_CONFIG_SOURCE_RTPROT_KERNEL,
|
||||
/* for routes, the source is mapped to the uint8 field rtm_protocol.
|
||||
* Reserve the range [1,0x100] for native RTPROT values. */
|
||||
|
||||
NM_IP_CONFIG_SOURCE_RTPROT_UNSPEC = 1 + 0,
|
||||
NM_IP_CONFIG_SOURCE_RTPROT_REDIRECT = 1 + 1,
|
||||
NM_IP_CONFIG_SOURCE_RTPROT_KERNEL = 1 + 2,
|
||||
NM_IP_CONFIG_SOURCE_RTPROT_BOOT = 1 + 3,
|
||||
NM_IP_CONFIG_SOURCE_RTPROT_STATIC = 1 + 4,
|
||||
NM_IP_CONFIG_SOURCE_RTPROT_RA = 1 + 9,
|
||||
NM_IP_CONFIG_SOURCE_RTPROT_DHCP = 1 + 16,
|
||||
_NM_IP_CONFIG_SOURCE_RTPROT_LAST = 1 + 0xFF,
|
||||
|
||||
NM_IP_CONFIG_SOURCE_KERNEL,
|
||||
NM_IP_CONFIG_SOURCE_SHARED,
|
||||
|
|
@ -73,6 +80,12 @@ typedef enum {
|
|||
NM_IP_CONFIG_SOURCE_USER,
|
||||
} NMIPConfigSource;
|
||||
|
||||
inline static gboolean
|
||||
NM_IS_IP_CONFIG_SOURCE_RTPROT (NMIPConfigSource source)
|
||||
{
|
||||
return source > NM_IP_CONFIG_SOURCE_UNKNOWN && source <= _NM_IP_CONFIG_SOURCE_RTPROT_LAST;
|
||||
}
|
||||
|
||||
/* platform */
|
||||
typedef struct _NMPlatform NMPlatform;
|
||||
typedef struct _NMPlatformIP4Address NMPlatformIP4Address;
|
||||
|
|
|
|||
|
|
@ -31,6 +31,7 @@
|
|||
#include "nm-utils.h"
|
||||
|
||||
#include "nm-core-utils.h"
|
||||
#include "nm-platform-utils.h"
|
||||
#include "nmp-object.h"
|
||||
|
||||
#include "nm-test-utils.h"
|
||||
|
|
@ -911,7 +912,7 @@ ip4_address_add (NMPlatform *platform,
|
|||
int i;
|
||||
|
||||
memset (&address, 0, sizeof (address));
|
||||
address.source = NM_IP_CONFIG_SOURCE_KERNEL;
|
||||
address.addr_source = NM_IP_CONFIG_SOURCE_KERNEL;
|
||||
address.ifindex = ifindex;
|
||||
address.address = addr;
|
||||
address.peer_address = peer_addr;
|
||||
|
|
@ -962,7 +963,7 @@ ip6_address_add (NMPlatform *platform,
|
|||
int i;
|
||||
|
||||
memset (&address, 0, sizeof (address));
|
||||
address.source = NM_IP_CONFIG_SOURCE_KERNEL;
|
||||
address.addr_source = NM_IP_CONFIG_SOURCE_KERNEL;
|
||||
address.ifindex = ifindex;
|
||||
address.address = addr;
|
||||
address.peer_address = (IN6_IS_ADDR_UNSPECIFIED (&peer_addr) || IN6_ARE_ADDR_EQUAL (&addr, &peer_addr)) ? in6addr_any : peer_addr;
|
||||
|
|
@ -1207,9 +1208,8 @@ ip4_route_add (NMPlatform *platform, int ifindex, NMIPConfigSource source,
|
|||
scope = gateway == 0 ? RT_SCOPE_LINK : RT_SCOPE_UNIVERSE;
|
||||
|
||||
memset (&route, 0, sizeof (route));
|
||||
route.source = NM_IP_CONFIG_SOURCE_KERNEL;
|
||||
route.ifindex = ifindex;
|
||||
route.source = source;
|
||||
route.rt_source = nmp_utils_ip_config_source_round_trip_rtprot (source);
|
||||
route.network = nm_utils_ip4_address_clear_host_address (network, plen);
|
||||
route.plen = plen;
|
||||
route.gateway = gateway;
|
||||
|
|
@ -1273,9 +1273,8 @@ ip6_route_add (NMPlatform *platform, int ifindex, NMIPConfigSource source,
|
|||
metric = nm_utils_ip6_route_metric_normalize (metric);
|
||||
|
||||
memset (&route, 0, sizeof (route));
|
||||
route.source = NM_IP_CONFIG_SOURCE_KERNEL;
|
||||
route.ifindex = ifindex;
|
||||
route.source = source;
|
||||
route.rt_source = nmp_utils_ip_config_source_round_trip_rtprot (source);
|
||||
nm_utils_ip6_address_clear_host_address (&route.network, &network, plen);
|
||||
route.plen = plen;
|
||||
route.gateway = gateway;
|
||||
|
|
|
|||
|
|
@ -308,23 +308,6 @@ _support_user_ipv6ll_detect (struct nlattr **tb)
|
|||
* Various utilities
|
||||
******************************************************************/
|
||||
|
||||
static void
|
||||
clear_host_address (int family, const void *network, guint8 plen, void *dst)
|
||||
{
|
||||
g_return_if_fail (network);
|
||||
|
||||
switch (family) {
|
||||
case AF_INET:
|
||||
*((in_addr_t *) dst) = nm_utils_ip4_address_clear_host_address (*((in_addr_t *) network), plen);
|
||||
break;
|
||||
case AF_INET6:
|
||||
nm_utils_ip6_address_clear_host_address ((struct in6_addr *) dst, (const struct in6_addr *) network, plen);
|
||||
break;
|
||||
default:
|
||||
g_assert_not_reached ();
|
||||
}
|
||||
}
|
||||
|
||||
static int
|
||||
_vlan_qos_mapping_cmp_from (gconstpointer a, gconstpointer b, gpointer user_data)
|
||||
{
|
||||
|
|
@ -1669,7 +1652,7 @@ _new_from_nl_addr (struct nlmsghdr *nlh, gboolean id_only)
|
|||
}
|
||||
}
|
||||
|
||||
obj->ip_address.source = NM_IP_CONFIG_SOURCE_KERNEL;
|
||||
obj->ip_address.addr_source = NM_IP_CONFIG_SOURCE_KERNEL;
|
||||
|
||||
obj->ip_address.n_ifa_flags = tb[IFA_FLAGS]
|
||||
? nla_get_u32 (tb[IFA_FLAGS])
|
||||
|
|
@ -1899,9 +1882,10 @@ _new_from_nl_route (struct nlmsghdr *nlh, gboolean id_only)
|
|||
*
|
||||
* This happens, because this route is not nmp_object_is_alive().
|
||||
* */
|
||||
obj->ip_route.source = _NM_IP_CONFIG_SOURCE_RTM_F_CLONED;
|
||||
} else
|
||||
obj->ip_route.source = nmp_utils_ip_config_source_from_rtprot (rtm->rtm_protocol);
|
||||
obj->ip_route.rt_cloned = TRUE;
|
||||
}
|
||||
|
||||
obj->ip_route.rt_source = nmp_utils_ip_config_source_from_rtprot (rtm->rtm_protocol);
|
||||
|
||||
obj_result = obj;
|
||||
obj = NULL;
|
||||
|
|
@ -2261,7 +2245,7 @@ _nl_msg_new_route (int nlmsg_type,
|
|||
.rtm_family = family,
|
||||
.rtm_tos = 0,
|
||||
.rtm_table = RT_TABLE_MAIN, /* omit setting RTA_TABLE attribute */
|
||||
.rtm_protocol = nmp_utils_ip_config_source_to_rtprot (source),
|
||||
.rtm_protocol = nmp_utils_ip_config_source_coerce_to_rtprot (source),
|
||||
.rtm_scope = scope,
|
||||
.rtm_type = RTN_UNICAST,
|
||||
.rtm_flags = 0,
|
||||
|
|
@ -2285,7 +2269,7 @@ _nl_msg_new_route (int nlmsg_type,
|
|||
|
||||
addr_len = family == AF_INET ? sizeof (in_addr_t) : sizeof (struct in6_addr);
|
||||
|
||||
clear_host_address (family, network, plen, &network_clean);
|
||||
nm_utils_ipx_address_clear_host_address (family, &network_clean, network, plen);
|
||||
NLA_PUT (msg, RTA_DST, addr_len, &network_clean);
|
||||
|
||||
NLA_PUT_U32 (msg, RTA_PRIORITY, metric);
|
||||
|
|
@ -3744,6 +3728,16 @@ cache_lookup_link (NMPlatform *platform, int ifindex)
|
|||
return obj_cache;
|
||||
}
|
||||
|
||||
const NMPlatformObject *const*
|
||||
nm_linux_platform_lookup (NMPlatform *platform, const NMPCacheId *cache_id, guint *out_len)
|
||||
{
|
||||
g_return_val_if_fail (NM_IS_LINUX_PLATFORM (platform), NULL);
|
||||
g_return_val_if_fail (cache_id, NULL);
|
||||
|
||||
return nmp_cache_lookup_multi (NM_LINUX_PLATFORM_GET_PRIVATE (platform)->cache,
|
||||
cache_id, out_len);
|
||||
}
|
||||
|
||||
static GArray *
|
||||
link_get_all (NMPlatform *platform)
|
||||
{
|
||||
|
|
@ -5600,7 +5594,7 @@ ipx_route_get_all (NMPlatform *platform, int ifindex, NMPObjectType obj_type, NM
|
|||
nm_assert (NMP_OBJECT_GET_CLASS (NMP_OBJECT_UP_CAST (routes[i])) == klass);
|
||||
|
||||
if ( with_rtprot_kernel
|
||||
|| routes[i]->source != NM_IP_CONFIG_SOURCE_RTPROT_KERNEL)
|
||||
|| routes[i]->rt_source != NM_IP_CONFIG_SOURCE_RTPROT_KERNEL)
|
||||
g_array_append_vals (array, routes[i], 1);
|
||||
}
|
||||
return array;
|
||||
|
|
|
|||
|
|
@ -52,4 +52,10 @@ NMPlatform *nm_linux_platform_new (gboolean netns_support);
|
|||
|
||||
void nm_linux_platform_setup (void);
|
||||
|
||||
struct _NMPCacheId;
|
||||
|
||||
const NMPlatformObject *const *nm_linux_platform_lookup (NMPlatform *platform,
|
||||
const struct _NMPCacheId *cache_id,
|
||||
guint *out_len);
|
||||
|
||||
#endif /* __NETWORKMANAGER_LINUX_PLATFORM_H__ */
|
||||
|
|
|
|||
|
|
@ -433,14 +433,38 @@ nmp_utils_device_exists (const char *name)
|
|||
return g_file_test (sysdir, G_FILE_TEST_EXISTS);
|
||||
}
|
||||
|
||||
guint
|
||||
nmp_utils_ip_config_source_to_rtprot (NMIPConfigSource source)
|
||||
NMIPConfigSource
|
||||
nmp_utils_ip_config_source_from_rtprot (guint8 rtprot)
|
||||
{
|
||||
switch (source) {
|
||||
case NM_IP_CONFIG_SOURCE_UNKNOWN:
|
||||
return ((int) rtprot) + 1;
|
||||
}
|
||||
|
||||
NMIPConfigSource
|
||||
nmp_utils_ip_config_source_round_trip_rtprot (NMIPConfigSource source)
|
||||
{
|
||||
/* when adding a route to kernel for a give @source, the resulting route
|
||||
* will be put into the cache with a source of NM_IP_CONFIG_SOURCE_RTPROT_*.
|
||||
* This function returns that. */
|
||||
return nmp_utils_ip_config_source_from_rtprot (nmp_utils_ip_config_source_coerce_to_rtprot (source));
|
||||
}
|
||||
|
||||
guint8
|
||||
nmp_utils_ip_config_source_coerce_to_rtprot (NMIPConfigSource source)
|
||||
{
|
||||
/* when adding a route to kernel, we coerce the @source field
|
||||
* to rtm_protocol. This is not lossless as we map different
|
||||
* source values to the same RTPROT uint8 value. */
|
||||
if (source <= NM_IP_CONFIG_SOURCE_UNKNOWN)
|
||||
return RTPROT_UNSPEC;
|
||||
|
||||
if (source <= _NM_IP_CONFIG_SOURCE_RTPROT_LAST) {
|
||||
nm_assert (NM_IS_IP_CONFIG_SOURCE_RTPROT (source));
|
||||
return source - 1;
|
||||
} else
|
||||
nm_assert (!NM_IS_IP_CONFIG_SOURCE_RTPROT (source));
|
||||
|
||||
switch (source) {
|
||||
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;
|
||||
|
|
@ -453,18 +477,32 @@ nmp_utils_ip_config_source_to_rtprot (NMIPConfigSource source)
|
|||
}
|
||||
|
||||
NMIPConfigSource
|
||||
nmp_utils_ip_config_source_from_rtprot (guint rtprot)
|
||||
nmp_utils_ip_config_source_coerce_from_rtprot (NMIPConfigSource source)
|
||||
{
|
||||
switch (rtprot) {
|
||||
case RTPROT_UNSPEC:
|
||||
/* When we receive a route from kernel and put it into the platform cache,
|
||||
* we preserve the protocol field by converting it to a NMIPConfigSource
|
||||
* via nmp_utils_ip_config_source_from_rtprot().
|
||||
*
|
||||
* However, that is not the inverse of nmp_utils_ip_config_source_coerce_to_rtprot().
|
||||
* Instead, to go back to the original value, you need another step:
|
||||
* nmp_utils_ip_config_source_coerce_from_rtprot (nmp_utils_ip_config_source_from_rtprot (rtprot)).
|
||||
*
|
||||
* This might partly restore the original source value, but of course that
|
||||
* is not really possible because nmp_utils_ip_config_source_coerce_to_rtprot()
|
||||
* is not injective.
|
||||
* */
|
||||
switch (source) {
|
||||
case NM_IP_CONFIG_SOURCE_RTPROT_UNSPEC:
|
||||
return NM_IP_CONFIG_SOURCE_UNKNOWN;
|
||||
case RTPROT_KERNEL:
|
||||
return NM_IP_CONFIG_SOURCE_RTPROT_KERNEL;
|
||||
case RTPROT_REDIRECT:
|
||||
|
||||
case NM_IP_CONFIG_SOURCE_RTPROT_KERNEL:
|
||||
case NM_IP_CONFIG_SOURCE_RTPROT_REDIRECT:
|
||||
return NM_IP_CONFIG_SOURCE_KERNEL;
|
||||
case RTPROT_RA:
|
||||
|
||||
case NM_IP_CONFIG_SOURCE_RTPROT_RA:
|
||||
return NM_IP_CONFIG_SOURCE_RDISC;
|
||||
case RTPROT_DHCP:
|
||||
|
||||
case NM_IP_CONFIG_SOURCE_RTPROT_DHCP:
|
||||
return NM_IP_CONFIG_SOURCE_DHCP;
|
||||
|
||||
default:
|
||||
|
|
@ -472,3 +510,50 @@ nmp_utils_ip_config_source_from_rtprot (guint rtprot)
|
|||
}
|
||||
}
|
||||
|
||||
const char *
|
||||
nmp_utils_ip_config_source_to_string (NMIPConfigSource source, char *buf, gsize len)
|
||||
{
|
||||
const char *s = NULL;
|
||||
nm_utils_to_string_buffer_init (&buf, &len); \
|
||||
|
||||
if (!len)
|
||||
return buf;
|
||||
|
||||
switch (source) {
|
||||
case NM_IP_CONFIG_SOURCE_UNKNOWN: s = "unknown"; break;
|
||||
|
||||
case NM_IP_CONFIG_SOURCE_RTPROT_UNSPEC: s = "rt-unspec"; break;
|
||||
case NM_IP_CONFIG_SOURCE_RTPROT_REDIRECT: s = "rt-redirect"; break;
|
||||
case NM_IP_CONFIG_SOURCE_RTPROT_KERNEL: s = "rt-kernel"; break;
|
||||
case NM_IP_CONFIG_SOURCE_RTPROT_BOOT: s = "rt-boot"; break;
|
||||
case NM_IP_CONFIG_SOURCE_RTPROT_STATIC: s = "rt-static"; break;
|
||||
case NM_IP_CONFIG_SOURCE_RTPROT_DHCP: s = "rt-dhcp"; break;
|
||||
case NM_IP_CONFIG_SOURCE_RTPROT_RA: s = "rt-ra"; break;
|
||||
|
||||
case NM_IP_CONFIG_SOURCE_KERNEL: s = "kernel"; break;
|
||||
case NM_IP_CONFIG_SOURCE_SHARED: s = "shared"; break;
|
||||
case NM_IP_CONFIG_SOURCE_IP4LL: s = "ipv4ll"; break;
|
||||
case NM_IP_CONFIG_SOURCE_PPP: s = "ppp"; break;
|
||||
case NM_IP_CONFIG_SOURCE_WWAN: s = "wwan"; break;
|
||||
case NM_IP_CONFIG_SOURCE_VPN: s = "vpn"; break;
|
||||
case NM_IP_CONFIG_SOURCE_DHCP: s = "dhcp"; break;
|
||||
case NM_IP_CONFIG_SOURCE_RDISC: s = "rdisc"; break;
|
||||
case NM_IP_CONFIG_SOURCE_USER: s = "user"; break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if (source >= 1 && source <= 0x100) {
|
||||
if (s)
|
||||
g_snprintf (buf, len, "%s", s);
|
||||
else
|
||||
g_snprintf (buf, len, "rt-%d", ((int) source) - 1);
|
||||
} else {
|
||||
if (s)
|
||||
g_strlcpy (buf, s, len);
|
||||
else
|
||||
g_snprintf (buf, len, "(%d)", source);
|
||||
}
|
||||
return buf;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -54,7 +54,10 @@ const char *nmp_utils_udev_get_driver (GUdevDevice *device);
|
|||
|
||||
gboolean nmp_utils_device_exists (const char *name);
|
||||
|
||||
guint nmp_utils_ip_config_source_to_rtprot (NMIPConfigSource source);
|
||||
NMIPConfigSource nmp_utils_ip_config_source_from_rtprot (guint rtprot);
|
||||
NMIPConfigSource nmp_utils_ip_config_source_from_rtprot (guint8 rtprot);
|
||||
guint8 nmp_utils_ip_config_source_coerce_to_rtprot (NMIPConfigSource source);
|
||||
NMIPConfigSource nmp_utils_ip_config_source_coerce_from_rtprot (NMIPConfigSource source);
|
||||
NMIPConfigSource nmp_utils_ip_config_source_round_trip_rtprot (NMIPConfigSource source);
|
||||
const char * nmp_utils_ip_config_source_to_string (NMIPConfigSource source, char *buf, gsize len);
|
||||
|
||||
#endif /* __NM_PLATFORM_UTILS_H__ */
|
||||
|
|
|
|||
|
|
@ -387,6 +387,20 @@ nm_platform_sysctl_get_int_checked (NMPlatform *self, const char *path, guint ba
|
|||
|
||||
/******************************************************************/
|
||||
|
||||
static int
|
||||
_link_get_all_presort (gconstpointer p_a,
|
||||
gconstpointer p_b)
|
||||
{
|
||||
const NMPlatformLink *a = p_a;
|
||||
const NMPlatformLink *b = p_b;
|
||||
|
||||
if (a->ifindex < b->ifindex)
|
||||
return -1;
|
||||
if (a->ifindex > b->ifindex)
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* nm_platform_link_get_all:
|
||||
* self: platform instance
|
||||
|
|
@ -409,15 +423,17 @@ nm_platform_link_get_all (NMPlatform *self)
|
|||
if (!links || links->len == 0)
|
||||
return links;
|
||||
|
||||
/* first sort the links by their ifindex. Below we will sort further by moving
|
||||
* children/slaves to the end. */
|
||||
g_array_sort (links, _link_get_all_presort);
|
||||
|
||||
unseen = g_hash_table_new (g_direct_hash, g_direct_equal);
|
||||
for (i = 0; i < links->len; i++) {
|
||||
item = &g_array_index (links, NMPlatformLink, i);
|
||||
|
||||
_LOGt ("link-get: %3d: %s", i, nm_platform_link_to_string (item, NULL, 0));
|
||||
|
||||
nm_assert (item->ifindex > 0 && !g_hash_table_contains (unseen, GINT_TO_POINTER (item->ifindex)));
|
||||
|
||||
g_hash_table_insert (unseen, GINT_TO_POINTER (item->ifindex), NULL);
|
||||
nm_assert (item->ifindex > 0);
|
||||
if (!nm_g_hash_table_insert (unseen, GINT_TO_POINTER (item->ifindex), NULL))
|
||||
nm_assert_not_reached ();
|
||||
}
|
||||
|
||||
#ifndef G_DISABLE_ASSERT
|
||||
|
|
@ -468,8 +484,6 @@ nm_platform_link_get_all (NMPlatform *self)
|
|||
if (item->parent > 0 && g_hash_table_contains (unseen, GINT_TO_POINTER (item->parent)))
|
||||
continue;
|
||||
|
||||
_LOGt ("link-get: add %3d -> %3d: %s", i, j, nm_platform_link_to_string (item, NULL, 0));
|
||||
|
||||
g_hash_table_remove (unseen, GINT_TO_POINTER (item->ifindex));
|
||||
g_array_index (result, NMPlatformLink, j++) = *item;
|
||||
item->ifindex = 0;
|
||||
|
|
@ -481,8 +495,6 @@ nm_platform_link_get_all (NMPlatform *self)
|
|||
* This can happen for veth pairs where each peer is parent of the other end. */
|
||||
item = &g_array_index (links, NMPlatformLink, first_idx);
|
||||
|
||||
_LOGt ("link-get: add (loop) %3d -> %3d: %s", first_idx, j, nm_platform_link_to_string (item, NULL, 0));
|
||||
|
||||
g_hash_table_remove (unseen, GINT_TO_POINTER (item->ifindex));
|
||||
g_array_index (result, NMPlatformLink, j++) = *item;
|
||||
item->ifindex = 0;
|
||||
|
|
@ -2900,7 +2912,7 @@ nm_platform_ip4_route_add (NMPlatform *self,
|
|||
NMPlatformIP4Route route = { 0 };
|
||||
|
||||
route.ifindex = ifindex;
|
||||
route.source = source;
|
||||
route.rt_source = source;
|
||||
route.network = network;
|
||||
route.plen = plen;
|
||||
route.gateway = gateway;
|
||||
|
|
@ -2927,7 +2939,7 @@ nm_platform_ip6_route_add (NMPlatform *self,
|
|||
NMPlatformIP6Route route = { 0 };
|
||||
|
||||
route.ifindex = ifindex;
|
||||
route.source = source;
|
||||
route.rt_source = source;
|
||||
route.network = network;
|
||||
route.plen = plen;
|
||||
route.gateway = gateway;
|
||||
|
|
@ -3017,38 +3029,6 @@ nm_platform_vlan_qos_mapping_to_string (const char *name,
|
|||
return buf;
|
||||
}
|
||||
|
||||
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_RTM_F_CLONED:
|
||||
return "rtm-f-cloned";
|
||||
case NM_IP_CONFIG_SOURCE_KERNEL:
|
||||
return "kernel";
|
||||
case NM_IP_CONFIG_SOURCE_SHARED:
|
||||
return "shared";
|
||||
case NM_IP_CONFIG_SOURCE_IP4LL:
|
||||
return "ipv4ll";
|
||||
case NM_IP_CONFIG_SOURCE_PPP:
|
||||
return "ppp";
|
||||
case NM_IP_CONFIG_SOURCE_WWAN:
|
||||
return "wwan";
|
||||
case NM_IP_CONFIG_SOURCE_VPN:
|
||||
return "vpn";
|
||||
case NM_IP_CONFIG_SOURCE_DHCP:
|
||||
return "dhcp";
|
||||
case NM_IP_CONFIG_SOURCE_RDISC:
|
||||
return "rdisc";
|
||||
case NM_IP_CONFIG_SOURCE_USER:
|
||||
return "user";
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return "unknown";
|
||||
}
|
||||
|
||||
static const char *
|
||||
_lifetime_to_string (guint32 timestamp, guint32 lifetime, gint32 now, char *buf, size_t buf_size)
|
||||
{
|
||||
|
|
@ -3477,7 +3457,7 @@ nm_platform_ip4_address_to_string (const NMPlatformIP4Address *address, char *bu
|
|||
char s_peer[INET_ADDRSTRLEN];
|
||||
char str_dev[TO_STRING_DEV_BUF_SIZE];
|
||||
char str_label[32];
|
||||
char str_lft[30], str_pref[30], str_time[50];
|
||||
char str_lft[30], str_pref[30], str_time[50], s_source[50];
|
||||
char *str_peer = NULL;
|
||||
const char *str_lft_p, *str_pref_p, *str_time_p;
|
||||
gint32 now = nm_utils_get_monotonic_timestamp_s ();
|
||||
|
|
@ -3516,7 +3496,7 @@ nm_platform_ip4_address_to_string (const NMPlatformIP4Address *address, char *bu
|
|||
str_dev,
|
||||
_to_string_ifa_flags (address->n_ifa_flags, s_flags, sizeof (s_flags)),
|
||||
str_label,
|
||||
source_to_string (address->source));
|
||||
nmp_utils_ip_config_source_to_string (address->addr_source, s_source, sizeof (s_source)));
|
||||
g_free (str_peer);
|
||||
return buf;
|
||||
}
|
||||
|
|
@ -3588,7 +3568,7 @@ nm_platform_ip6_address_to_string (const NMPlatformIP6Address *address, char *bu
|
|||
char s_flags[TO_STRING_IFA_FLAGS_BUF_SIZE];
|
||||
char s_address[INET6_ADDRSTRLEN];
|
||||
char s_peer[INET6_ADDRSTRLEN];
|
||||
char str_lft[30], str_pref[30], str_time[50];
|
||||
char str_lft[30], str_pref[30], str_time[50], s_source[50];
|
||||
char str_dev[TO_STRING_DEV_BUF_SIZE];
|
||||
char *str_peer = NULL;
|
||||
const char *str_lft_p, *str_pref_p, *str_time_p;
|
||||
|
|
@ -3622,7 +3602,7 @@ nm_platform_ip6_address_to_string (const NMPlatformIP6Address *address, char *bu
|
|||
str_peer ? str_peer : "",
|
||||
str_dev,
|
||||
_to_string_ifa_flags (address->n_ifa_flags, s_flags, sizeof (s_flags)),
|
||||
source_to_string (address->source));
|
||||
nmp_utils_ip_config_source_to_string (address->addr_source, s_source, sizeof (s_source)));
|
||||
g_free (str_peer);
|
||||
return buf;
|
||||
}
|
||||
|
|
@ -3645,7 +3625,7 @@ nm_platform_ip4_route_to_string (const NMPlatformIP4Route *route, char *buf, gsi
|
|||
char s_network[INET_ADDRSTRLEN], s_gateway[INET_ADDRSTRLEN];
|
||||
char s_pref_src[INET_ADDRSTRLEN];
|
||||
char str_dev[TO_STRING_DEV_BUF_SIZE];
|
||||
char str_scope[30];
|
||||
char str_scope[30], s_source[50];
|
||||
|
||||
if (!nm_utils_to_string_buffer_init_null (route, &buf, &len))
|
||||
return buf;
|
||||
|
|
@ -3662,6 +3642,7 @@ nm_platform_ip4_route_to_string (const NMPlatformIP4Route *route, char *buf, gsi
|
|||
" metric %"G_GUINT32_FORMAT
|
||||
" mss %"G_GUINT32_FORMAT
|
||||
" src %s" /* source */
|
||||
"%s" /* cloned */
|
||||
"%s%s" /* scope */
|
||||
"%s%s" /* pref-src */
|
||||
"",
|
||||
|
|
@ -3671,7 +3652,8 @@ nm_platform_ip4_route_to_string (const NMPlatformIP4Route *route, char *buf, gsi
|
|||
str_dev,
|
||||
route->metric,
|
||||
route->mss,
|
||||
source_to_string (route->source),
|
||||
nmp_utils_ip_config_source_to_string (route->rt_source, s_source, sizeof (s_source)),
|
||||
route->rt_cloned ? " cloned" : "",
|
||||
route->scope_inv ? " scope " : "",
|
||||
route->scope_inv ? (nm_platform_route_scope2str (nm_platform_route_scope_inv (route->scope_inv), str_scope, sizeof (str_scope))) : "",
|
||||
route->pref_src ? " pref-src " : "",
|
||||
|
|
@ -3695,7 +3677,7 @@ const char *
|
|||
nm_platform_ip6_route_to_string (const NMPlatformIP6Route *route, char *buf, gsize len)
|
||||
{
|
||||
char s_network[INET6_ADDRSTRLEN], s_gateway[INET6_ADDRSTRLEN];
|
||||
char str_dev[TO_STRING_DEV_BUF_SIZE];
|
||||
char str_dev[TO_STRING_DEV_BUF_SIZE], s_source[50];
|
||||
|
||||
if (!nm_utils_to_string_buffer_init_null (route, &buf, &len))
|
||||
return buf;
|
||||
|
|
@ -3712,6 +3694,7 @@ nm_platform_ip6_route_to_string (const NMPlatformIP6Route *route, char *buf, gsi
|
|||
" metric %"G_GUINT32_FORMAT
|
||||
" mss %"G_GUINT32_FORMAT
|
||||
" src %s" /* source */
|
||||
"%s" /* cloned */
|
||||
"",
|
||||
s_network,
|
||||
route->plen,
|
||||
|
|
@ -3719,7 +3702,8 @@ nm_platform_ip6_route_to_string (const NMPlatformIP6Route *route, char *buf, gsi
|
|||
str_dev,
|
||||
route->metric,
|
||||
route->mss,
|
||||
source_to_string (route->source));
|
||||
nmp_utils_ip_config_source_to_string (route->rt_source, s_source, sizeof (s_source)),
|
||||
route->rt_cloned ? " cloned" : "");
|
||||
return buf;
|
||||
}
|
||||
|
||||
|
|
@ -3941,10 +3925,10 @@ nm_platform_ip4_address_cmp (const NMPlatformIP4Address *a, const NMPlatformIP4A
|
|||
{
|
||||
_CMP_SELF (a, b);
|
||||
_CMP_FIELD (a, b, ifindex);
|
||||
_CMP_FIELD (a, b, source);
|
||||
_CMP_FIELD (a, b, address);
|
||||
_CMP_FIELD (a, b, plen);
|
||||
_CMP_FIELD (a, b, peer_address);
|
||||
_CMP_FIELD (a, b, addr_source);
|
||||
_CMP_FIELD (a, b, timestamp);
|
||||
_CMP_FIELD (a, b, lifetime);
|
||||
_CMP_FIELD (a, b, preferred);
|
||||
|
|
@ -3960,14 +3944,12 @@ nm_platform_ip6_address_cmp (const NMPlatformIP6Address *a, const NMPlatformIP6A
|
|||
|
||||
_CMP_SELF (a, b);
|
||||
_CMP_FIELD (a, b, ifindex);
|
||||
_CMP_FIELD (a, b, source);
|
||||
_CMP_FIELD_MEMCMP (a, b, address);
|
||||
|
||||
_CMP_FIELD (a, b, plen);
|
||||
p_a = nm_platform_ip6_address_get_peer (a);
|
||||
p_b = nm_platform_ip6_address_get_peer (b);
|
||||
_CMP_DIRECT_MEMCMP (p_a, p_b, sizeof (*p_a));
|
||||
|
||||
_CMP_FIELD (a, b, plen);
|
||||
_CMP_FIELD (a, b, addr_source);
|
||||
_CMP_FIELD (a, b, timestamp);
|
||||
_CMP_FIELD (a, b, lifetime);
|
||||
_CMP_FIELD (a, b, preferred);
|
||||
|
|
@ -3980,14 +3962,15 @@ nm_platform_ip4_route_cmp (const NMPlatformIP4Route *a, const NMPlatformIP4Route
|
|||
{
|
||||
_CMP_SELF (a, b);
|
||||
_CMP_FIELD (a, b, ifindex);
|
||||
_CMP_FIELD (a, b, source);
|
||||
_CMP_FIELD (a, b, network);
|
||||
_CMP_FIELD (a, b, plen);
|
||||
_CMP_FIELD (a, b, gateway);
|
||||
_CMP_FIELD (a, b, metric);
|
||||
_CMP_FIELD (a, b, gateway);
|
||||
_CMP_FIELD (a, b, rt_source);
|
||||
_CMP_FIELD (a, b, mss);
|
||||
_CMP_FIELD (a, b, scope_inv);
|
||||
_CMP_FIELD (a, b, pref_src);
|
||||
_CMP_FIELD (a, b, rt_cloned);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -3996,12 +3979,13 @@ nm_platform_ip6_route_cmp (const NMPlatformIP6Route *a, const NMPlatformIP6Route
|
|||
{
|
||||
_CMP_SELF (a, b);
|
||||
_CMP_FIELD (a, b, ifindex);
|
||||
_CMP_FIELD (a, b, source);
|
||||
_CMP_FIELD_MEMCMP (a, b, network);
|
||||
_CMP_FIELD (a, b, plen);
|
||||
_CMP_FIELD_MEMCMP (a, b, gateway);
|
||||
_CMP_FIELD (a, b, metric);
|
||||
_CMP_FIELD_MEMCMP (a, b, gateway);
|
||||
_CMP_FIELD (a, b, rt_source);
|
||||
_CMP_FIELD (a, b, mss);
|
||||
_CMP_FIELD (a, b, rt_cloned);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -4134,7 +4118,7 @@ _vtr_v4_route_add (NMPlatform *self, int ifindex, const NMPlatformIPXRoute *rout
|
|||
{
|
||||
return nm_platform_ip4_route_add (self,
|
||||
ifindex > 0 ? ifindex : route->rx.ifindex,
|
||||
route->rx.source,
|
||||
route->rx.rt_source,
|
||||
route->r4.network,
|
||||
route->rx.plen,
|
||||
route->r4.gateway,
|
||||
|
|
@ -4148,7 +4132,7 @@ _vtr_v6_route_add (NMPlatform *self, int ifindex, const NMPlatformIPXRoute *rout
|
|||
{
|
||||
return nm_platform_ip6_route_add (self,
|
||||
ifindex > 0 ? ifindex : route->rx.ifindex,
|
||||
route->rx.source,
|
||||
route->rx.rt_source,
|
||||
route->r6.network,
|
||||
route->rx.plen,
|
||||
route->r6.gateway,
|
||||
|
|
|
|||
|
|
@ -200,7 +200,7 @@ typedef struct {
|
|||
|
||||
#define __NMPlatformIPAddress_COMMON \
|
||||
__NMPlatformObject_COMMON; \
|
||||
NMIPConfigSource source; \
|
||||
NMIPConfigSource addr_source; \
|
||||
\
|
||||
/* Timestamp in seconds in the reference system of nm_utils_get_monotonic_timestamp_*().
|
||||
*
|
||||
|
|
@ -303,8 +303,21 @@ typedef union {
|
|||
|
||||
#define __NMPlatformIPRoute_COMMON \
|
||||
__NMPlatformObject_COMMON; \
|
||||
NMIPConfigSource source; \
|
||||
\
|
||||
/* The NMIPConfigSource. For routes that we receive from cache this corresponds
|
||||
* to the rtm_protocol field (and is one of the NM_IP_CONFIG_SOURCE_RTPROT_* values).
|
||||
* When adding a route, the source will be coerced to the protocol using
|
||||
* nmp_utils_ip_config_source_coerce_to_rtprot(). */ \
|
||||
NMIPConfigSource rt_source; \
|
||||
\
|
||||
guint8 plen; \
|
||||
\
|
||||
/* the route has rtm_flags set to RTM_F_CLONED. Such a route
|
||||
* is hidden by platform and does not exist from the point-of-view
|
||||
* of platform users. This flag is internal to track those hidden
|
||||
* routes. Such a route is not alive, according to nmp_object_is_alive(). */ \
|
||||
bool rt_cloned:1; \
|
||||
\
|
||||
guint32 metric; \
|
||||
guint32 mss; \
|
||||
;
|
||||
|
|
|
|||
|
|
@ -915,12 +915,12 @@ _vt_cmd_obj_is_alive_ipx_route (const NMPObject *obj)
|
|||
*
|
||||
* If nmp_object_from_nl() would just return NULL, we couldn't look
|
||||
* into the cache to see if it contains a route that now disappears
|
||||
* (because it is cloned).
|
||||
* (because it changed to be cloned).
|
||||
*
|
||||
* Instead we create a dead object, and nmp_cache_update_netlink()
|
||||
* will remove the old version of the update.
|
||||
**/
|
||||
return obj->object.ifindex > 0 && (obj->ip_route.source != _NM_IP_CONFIG_SOURCE_RTM_F_CLONED);
|
||||
return obj->object.ifindex > 0 && !obj->ip_route.rt_cloned;
|
||||
}
|
||||
|
||||
gboolean
|
||||
|
|
|
|||
|
|
@ -95,8 +95,9 @@ typedef enum { /*< skip >*/
|
|||
} NMPCacheIdType;
|
||||
|
||||
typedef struct _NMPObject NMPObject;
|
||||
typedef struct _NMPCacheId NMPCacheId;
|
||||
|
||||
typedef struct {
|
||||
struct _NMPCacheId {
|
||||
union {
|
||||
NMMultiIndexId base;
|
||||
guint8 _id_type; /* NMPCacheIdType as guint8 */
|
||||
|
|
@ -136,7 +137,7 @@ typedef struct {
|
|||
struct in6_addr _misaligned_network;
|
||||
} routes_by_destination_ip6;
|
||||
};
|
||||
} NMPCacheId;
|
||||
};
|
||||
|
||||
extern NMPCacheId _nmp_cache_id_static;
|
||||
#define NMP_CACHE_ID_STATIC (&_nmp_cache_id_static)
|
||||
|
|
|
|||
|
|
@ -23,9 +23,9 @@
|
|||
#include <linux/rtnetlink.h>
|
||||
|
||||
#include "nm-core-utils.h"
|
||||
#include "test-common.h"
|
||||
#include "nm-platform-utils.h"
|
||||
|
||||
#include "nm-test-utils.h"
|
||||
#include "test-common.h"
|
||||
|
||||
#define DEVICE_NAME "nm-test-device"
|
||||
|
||||
|
|
@ -178,7 +178,7 @@ test_ip4_route (void)
|
|||
/* Test route listing */
|
||||
routes = nm_platform_ip4_route_get_all (NM_PLATFORM_GET, ifindex, NM_PLATFORM_GET_ROUTE_FLAGS_WITH_DEFAULT | NM_PLATFORM_GET_ROUTE_FLAGS_WITH_NON_DEFAULT);
|
||||
memset (rts, 0, sizeof (rts));
|
||||
rts[0].source = NM_IP_CONFIG_SOURCE_USER;
|
||||
rts[0].rt_source = nmp_utils_ip_config_source_round_trip_rtprot (NM_IP_CONFIG_SOURCE_USER);
|
||||
rts[0].network = gateway;
|
||||
rts[0].plen = 32;
|
||||
rts[0].ifindex = ifindex;
|
||||
|
|
@ -186,7 +186,7 @@ test_ip4_route (void)
|
|||
rts[0].metric = metric;
|
||||
rts[0].mss = mss;
|
||||
rts[0].scope_inv = nm_platform_route_scope_inv (RT_SCOPE_LINK);
|
||||
rts[1].source = NM_IP_CONFIG_SOURCE_USER;
|
||||
rts[1].rt_source = nmp_utils_ip_config_source_round_trip_rtprot (NM_IP_CONFIG_SOURCE_USER);
|
||||
rts[1].network = network;
|
||||
rts[1].plen = plen;
|
||||
rts[1].ifindex = ifindex;
|
||||
|
|
@ -194,7 +194,7 @@ test_ip4_route (void)
|
|||
rts[1].metric = metric;
|
||||
rts[1].mss = mss;
|
||||
rts[1].scope_inv = nm_platform_route_scope_inv (RT_SCOPE_UNIVERSE);
|
||||
rts[2].source = NM_IP_CONFIG_SOURCE_USER;
|
||||
rts[2].rt_source = nmp_utils_ip_config_source_round_trip_rtprot (NM_IP_CONFIG_SOURCE_USER);
|
||||
rts[2].network = 0;
|
||||
rts[2].plen = 0;
|
||||
rts[2].ifindex = ifindex;
|
||||
|
|
@ -265,21 +265,21 @@ test_ip6_route (void)
|
|||
/* Test route listing */
|
||||
routes = nm_platform_ip6_route_get_all (NM_PLATFORM_GET, ifindex, NM_PLATFORM_GET_ROUTE_FLAGS_WITH_DEFAULT | NM_PLATFORM_GET_ROUTE_FLAGS_WITH_NON_DEFAULT);
|
||||
memset (rts, 0, sizeof (rts));
|
||||
rts[0].source = NM_IP_CONFIG_SOURCE_USER;
|
||||
rts[0].rt_source = nmp_utils_ip_config_source_round_trip_rtprot (NM_IP_CONFIG_SOURCE_USER);
|
||||
rts[0].network = gateway;
|
||||
rts[0].plen = 128;
|
||||
rts[0].ifindex = ifindex;
|
||||
rts[0].gateway = in6addr_any;
|
||||
rts[0].metric = nm_utils_ip6_route_metric_normalize (metric);
|
||||
rts[0].mss = mss;
|
||||
rts[1].source = NM_IP_CONFIG_SOURCE_USER;
|
||||
rts[1].rt_source = nmp_utils_ip_config_source_round_trip_rtprot (NM_IP_CONFIG_SOURCE_USER);
|
||||
rts[1].network = network;
|
||||
rts[1].plen = plen;
|
||||
rts[1].ifindex = ifindex;
|
||||
rts[1].gateway = gateway;
|
||||
rts[1].metric = nm_utils_ip6_route_metric_normalize (metric);
|
||||
rts[1].mss = mss;
|
||||
rts[2].source = NM_IP_CONFIG_SOURCE_USER;
|
||||
rts[2].rt_source = nmp_utils_ip_config_source_round_trip_rtprot (NM_IP_CONFIG_SOURCE_USER);
|
||||
rts[2].network = in6addr_any;
|
||||
rts[2].plen = 0;
|
||||
rts[2].ifindex = ifindex;
|
||||
|
|
|
|||
|
|
@ -482,7 +482,7 @@ impl_ppp_manager_set_ip4_config (NMPPPManager *manager,
|
|||
address.plen = u32;
|
||||
|
||||
if (address.address && address.plen && address.plen <= 32) {
|
||||
address.source = NM_IP_CONFIG_SOURCE_PPP;
|
||||
address.addr_source = NM_IP_CONFIG_SOURCE_PPP;
|
||||
nm_ip4_config_add_address (config, &address);
|
||||
} else {
|
||||
_LOGE ("invalid IPv4 address received!");
|
||||
|
|
|
|||
|
|
@ -52,6 +52,7 @@ test_ip6_config_LDADD = \
|
|||
|
||||
test_route_manager_fake_CPPFLAGS = \
|
||||
$(AM_CPPFLAGS) \
|
||||
$(GUDEV_CFLAGS) \
|
||||
-I$(top_srcdir)/src/platform/tests \
|
||||
-DSETUP=nm_fake_platform_setup \
|
||||
-DKERNEL_HACKS=0
|
||||
|
|
@ -69,6 +70,7 @@ test_route_manager_linux_SOURCES = \
|
|||
|
||||
test_route_manager_linux_CPPFLAGS = \
|
||||
$(AM_CPPFLAGS) \
|
||||
$(GUDEV_CFLAGS) \
|
||||
-I$(top_srcdir)/src/platform/tests \
|
||||
-DSETUP=nm_linux_platform_setup \
|
||||
-DKERNEL_HACKS=1
|
||||
|
|
|
|||
|
|
@ -161,18 +161,18 @@ test_compare_with_source (void)
|
|||
|
||||
/* Address */
|
||||
addr = *nmtst_platform_ip4_address ("1.2.3.4", NULL, 24);
|
||||
addr.source = NM_IP_CONFIG_SOURCE_USER;
|
||||
addr.addr_source = NM_IP_CONFIG_SOURCE_USER;
|
||||
nm_ip4_config_add_address (a, &addr);
|
||||
|
||||
addr.source = NM_IP_CONFIG_SOURCE_VPN;
|
||||
addr.addr_source = NM_IP_CONFIG_SOURCE_VPN;
|
||||
nm_ip4_config_add_address (b, &addr);
|
||||
|
||||
/* Route */
|
||||
route = *nmtst_platform_ip4_route ("10.0.0.0", 8, "192.168.1.1");
|
||||
route.source = NM_IP_CONFIG_SOURCE_USER;
|
||||
route.rt_source = NM_IP_CONFIG_SOURCE_USER;
|
||||
nm_ip4_config_add_route (a, &route);
|
||||
|
||||
route.source = NM_IP_CONFIG_SOURCE_VPN;
|
||||
route.rt_source = NM_IP_CONFIG_SOURCE_VPN;
|
||||
nm_ip4_config_add_route (b, &route);
|
||||
|
||||
/* Assert that the configs are basically the same, eg that the source is ignored */
|
||||
|
|
@ -193,31 +193,31 @@ test_add_address_with_source (void)
|
|||
|
||||
/* Test that a higher priority source is not overwritten */
|
||||
addr = *nmtst_platform_ip4_address ("1.2.3.4", NULL, 24);
|
||||
addr.source = NM_IP_CONFIG_SOURCE_USER;
|
||||
addr.addr_source = NM_IP_CONFIG_SOURCE_USER;
|
||||
nm_ip4_config_add_address (a, &addr);
|
||||
|
||||
test_addr = nm_ip4_config_get_address (a, 0);
|
||||
g_assert_cmpint (test_addr->source, ==, NM_IP_CONFIG_SOURCE_USER);
|
||||
g_assert_cmpint (test_addr->addr_source, ==, NM_IP_CONFIG_SOURCE_USER);
|
||||
|
||||
addr.source = NM_IP_CONFIG_SOURCE_VPN;
|
||||
addr.addr_source = NM_IP_CONFIG_SOURCE_VPN;
|
||||
nm_ip4_config_add_address (a, &addr);
|
||||
|
||||
test_addr = nm_ip4_config_get_address (a, 0);
|
||||
g_assert_cmpint (test_addr->source, ==, NM_IP_CONFIG_SOURCE_USER);
|
||||
g_assert_cmpint (test_addr->addr_source, ==, NM_IP_CONFIG_SOURCE_USER);
|
||||
|
||||
/* Test that a lower priority address source is overwritten */
|
||||
nm_ip4_config_del_address (a, 0);
|
||||
addr.source = NM_IP_CONFIG_SOURCE_KERNEL;
|
||||
addr.addr_source = NM_IP_CONFIG_SOURCE_KERNEL;
|
||||
nm_ip4_config_add_address (a, &addr);
|
||||
|
||||
test_addr = nm_ip4_config_get_address (a, 0);
|
||||
g_assert_cmpint (test_addr->source, ==, NM_IP_CONFIG_SOURCE_KERNEL);
|
||||
g_assert_cmpint (test_addr->addr_source, ==, NM_IP_CONFIG_SOURCE_KERNEL);
|
||||
|
||||
addr.source = NM_IP_CONFIG_SOURCE_USER;
|
||||
addr.addr_source = NM_IP_CONFIG_SOURCE_USER;
|
||||
nm_ip4_config_add_address (a, &addr);
|
||||
|
||||
test_addr = nm_ip4_config_get_address (a, 0);
|
||||
g_assert_cmpint (test_addr->source, ==, NM_IP_CONFIG_SOURCE_USER);
|
||||
g_assert_cmpint (test_addr->addr_source, ==, NM_IP_CONFIG_SOURCE_USER);
|
||||
|
||||
g_object_unref (a);
|
||||
}
|
||||
|
|
@ -233,31 +233,31 @@ test_add_route_with_source (void)
|
|||
|
||||
/* Test that a higher priority source is not overwritten */
|
||||
route = *nmtst_platform_ip4_route ("1.2.3.4", 24, "1.2.3.1");
|
||||
route.source = NM_IP_CONFIG_SOURCE_USER;
|
||||
route.rt_source = NM_IP_CONFIG_SOURCE_USER;
|
||||
nm_ip4_config_add_route (a, &route);
|
||||
|
||||
test_route = nm_ip4_config_get_route (a, 0);
|
||||
g_assert_cmpint (test_route->source, ==, NM_IP_CONFIG_SOURCE_USER);
|
||||
g_assert_cmpint (test_route->rt_source, ==, NM_IP_CONFIG_SOURCE_USER);
|
||||
|
||||
route.source = NM_IP_CONFIG_SOURCE_VPN;
|
||||
route.rt_source = NM_IP_CONFIG_SOURCE_VPN;
|
||||
nm_ip4_config_add_route (a, &route);
|
||||
|
||||
test_route = nm_ip4_config_get_route (a, 0);
|
||||
g_assert_cmpint (test_route->source, ==, NM_IP_CONFIG_SOURCE_USER);
|
||||
g_assert_cmpint (test_route->rt_source, ==, NM_IP_CONFIG_SOURCE_USER);
|
||||
|
||||
/* Test that a lower priority address source is overwritten */
|
||||
nm_ip4_config_del_route (a, 0);
|
||||
route.source = NM_IP_CONFIG_SOURCE_KERNEL;
|
||||
route.rt_source = NM_IP_CONFIG_SOURCE_KERNEL;
|
||||
nm_ip4_config_add_route (a, &route);
|
||||
|
||||
test_route = nm_ip4_config_get_route (a, 0);
|
||||
g_assert_cmpint (test_route->source, ==, NM_IP_CONFIG_SOURCE_KERNEL);
|
||||
g_assert_cmpint (test_route->rt_source, ==, NM_IP_CONFIG_SOURCE_KERNEL);
|
||||
|
||||
route.source = NM_IP_CONFIG_SOURCE_USER;
|
||||
route.rt_source = NM_IP_CONFIG_SOURCE_USER;
|
||||
nm_ip4_config_add_route (a, &route);
|
||||
|
||||
test_route = nm_ip4_config_get_route (a, 0);
|
||||
g_assert_cmpint (test_route->source, ==, NM_IP_CONFIG_SOURCE_USER);
|
||||
g_assert_cmpint (test_route->rt_source, ==, NM_IP_CONFIG_SOURCE_USER);
|
||||
|
||||
g_object_unref (a);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -132,18 +132,18 @@ test_compare_with_source (void)
|
|||
|
||||
/* Address */
|
||||
addr = *nmtst_platform_ip6_address ("1122:3344:5566::7788", NULL, 64);
|
||||
addr.source = NM_IP_CONFIG_SOURCE_USER;
|
||||
addr.addr_source = NM_IP_CONFIG_SOURCE_USER;
|
||||
nm_ip6_config_add_address (a, &addr);
|
||||
|
||||
addr.source = NM_IP_CONFIG_SOURCE_VPN;
|
||||
addr.addr_source = NM_IP_CONFIG_SOURCE_VPN;
|
||||
nm_ip6_config_add_address (b, &addr);
|
||||
|
||||
/* Route */
|
||||
route = *nmtst_platform_ip6_route ("abcd:1234:4321::", 24, "abcd:1234:4321:cdde::2");
|
||||
route.source = NM_IP_CONFIG_SOURCE_USER;
|
||||
route.rt_source = NM_IP_CONFIG_SOURCE_USER;
|
||||
nm_ip6_config_add_route (a, &route);
|
||||
|
||||
route.source = NM_IP_CONFIG_SOURCE_VPN;
|
||||
route.rt_source = NM_IP_CONFIG_SOURCE_VPN;
|
||||
nm_ip6_config_add_route (b, &route);
|
||||
|
||||
/* Assert that the configs are basically the same, eg that the source is ignored */
|
||||
|
|
@ -164,31 +164,31 @@ test_add_address_with_source (void)
|
|||
|
||||
/* Test that a higher priority source is not overwritten */
|
||||
addr = *nmtst_platform_ip6_address ("1122:3344:5566::7788", NULL, 64);
|
||||
addr.source = NM_IP_CONFIG_SOURCE_USER;
|
||||
addr.addr_source = NM_IP_CONFIG_SOURCE_USER;
|
||||
nm_ip6_config_add_address (a, &addr);
|
||||
|
||||
test_addr = nm_ip6_config_get_address (a, 0);
|
||||
g_assert_cmpint (test_addr->source, ==, NM_IP_CONFIG_SOURCE_USER);
|
||||
g_assert_cmpint (test_addr->addr_source, ==, NM_IP_CONFIG_SOURCE_USER);
|
||||
|
||||
addr.source = NM_IP_CONFIG_SOURCE_VPN;
|
||||
addr.addr_source = NM_IP_CONFIG_SOURCE_VPN;
|
||||
nm_ip6_config_add_address (a, &addr);
|
||||
|
||||
test_addr = nm_ip6_config_get_address (a, 0);
|
||||
g_assert_cmpint (test_addr->source, ==, NM_IP_CONFIG_SOURCE_USER);
|
||||
g_assert_cmpint (test_addr->addr_source, ==, NM_IP_CONFIG_SOURCE_USER);
|
||||
|
||||
/* Test that a lower priority address source is overwritten */
|
||||
nm_ip6_config_del_address (a, 0);
|
||||
addr.source = NM_IP_CONFIG_SOURCE_KERNEL;
|
||||
addr.addr_source = NM_IP_CONFIG_SOURCE_KERNEL;
|
||||
nm_ip6_config_add_address (a, &addr);
|
||||
|
||||
test_addr = nm_ip6_config_get_address (a, 0);
|
||||
g_assert_cmpint (test_addr->source, ==, NM_IP_CONFIG_SOURCE_KERNEL);
|
||||
g_assert_cmpint (test_addr->addr_source, ==, NM_IP_CONFIG_SOURCE_KERNEL);
|
||||
|
||||
addr.source = NM_IP_CONFIG_SOURCE_USER;
|
||||
addr.addr_source = NM_IP_CONFIG_SOURCE_USER;
|
||||
nm_ip6_config_add_address (a, &addr);
|
||||
|
||||
test_addr = nm_ip6_config_get_address (a, 0);
|
||||
g_assert_cmpint (test_addr->source, ==, NM_IP_CONFIG_SOURCE_USER);
|
||||
g_assert_cmpint (test_addr->addr_source, ==, NM_IP_CONFIG_SOURCE_USER);
|
||||
|
||||
g_object_unref (a);
|
||||
}
|
||||
|
|
@ -204,31 +204,31 @@ test_add_route_with_source (void)
|
|||
|
||||
/* Test that a higher priority source is not overwritten */
|
||||
route = *nmtst_platform_ip6_route ("abcd:1234:4321::", 24, "abcd:1234:4321:cdde::2");
|
||||
route.source = NM_IP_CONFIG_SOURCE_USER;
|
||||
route.rt_source = NM_IP_CONFIG_SOURCE_USER;
|
||||
nm_ip6_config_add_route (a, &route);
|
||||
|
||||
test_route = nm_ip6_config_get_route (a, 0);
|
||||
g_assert_cmpint (test_route->source, ==, NM_IP_CONFIG_SOURCE_USER);
|
||||
g_assert_cmpint (test_route->rt_source, ==, NM_IP_CONFIG_SOURCE_USER);
|
||||
|
||||
route.source = NM_IP_CONFIG_SOURCE_VPN;
|
||||
route.rt_source = NM_IP_CONFIG_SOURCE_VPN;
|
||||
nm_ip6_config_add_route (a, &route);
|
||||
|
||||
test_route = nm_ip6_config_get_route (a, 0);
|
||||
g_assert_cmpint (test_route->source, ==, NM_IP_CONFIG_SOURCE_USER);
|
||||
g_assert_cmpint (test_route->rt_source, ==, NM_IP_CONFIG_SOURCE_USER);
|
||||
|
||||
/* Test that a lower priority address source is overwritten */
|
||||
nm_ip6_config_del_route (a, 0);
|
||||
route.source = NM_IP_CONFIG_SOURCE_KERNEL;
|
||||
route.rt_source = NM_IP_CONFIG_SOURCE_KERNEL;
|
||||
nm_ip6_config_add_route (a, &route);
|
||||
|
||||
test_route = nm_ip6_config_get_route (a, 0);
|
||||
g_assert_cmpint (test_route->source, ==, NM_IP_CONFIG_SOURCE_KERNEL);
|
||||
g_assert_cmpint (test_route->rt_source, ==, NM_IP_CONFIG_SOURCE_KERNEL);
|
||||
|
||||
route.source = NM_IP_CONFIG_SOURCE_USER;
|
||||
route.rt_source = NM_IP_CONFIG_SOURCE_USER;
|
||||
nm_ip6_config_add_route (a, &route);
|
||||
|
||||
test_route = nm_ip6_config_get_route (a, 0);
|
||||
g_assert_cmpint (test_route->source, ==, NM_IP_CONFIG_SOURCE_USER);
|
||||
g_assert_cmpint (test_route->rt_source, ==, NM_IP_CONFIG_SOURCE_USER);
|
||||
|
||||
g_object_unref (a);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,12 +23,11 @@
|
|||
#include <arpa/inet.h>
|
||||
#include <linux/rtnetlink.h>
|
||||
|
||||
#include "test-common.h"
|
||||
|
||||
#include "nm-platform.h"
|
||||
#include "nm-platform-utils.h"
|
||||
#include "nm-route-manager.h"
|
||||
|
||||
#include "nm-test-utils.h"
|
||||
#include "test-common.h"
|
||||
|
||||
typedef struct {
|
||||
int ifindex0, ifindex1;
|
||||
|
|
@ -45,7 +44,7 @@ setup_dev0_ip4 (int ifindex, guint mss_of_first_route, guint32 metric_of_second_
|
|||
route.ifindex = ifindex;
|
||||
route.mss = 0;
|
||||
|
||||
route.source = NM_IP_CONFIG_SOURCE_USER;
|
||||
route.rt_source = nmp_utils_ip_config_source_round_trip_rtprot (NM_IP_CONFIG_SOURCE_USER);
|
||||
inet_pton (AF_INET, "6.6.6.0", &route.network);
|
||||
route.plen = 24;
|
||||
route.gateway = INADDR_ANY;
|
||||
|
|
@ -53,7 +52,7 @@ setup_dev0_ip4 (int ifindex, guint mss_of_first_route, guint32 metric_of_second_
|
|||
route.mss = mss_of_first_route;
|
||||
g_array_append_val (routes, route);
|
||||
|
||||
route.source = NM_IP_CONFIG_SOURCE_USER;
|
||||
route.rt_source = nmp_utils_ip_config_source_round_trip_rtprot (NM_IP_CONFIG_SOURCE_USER);
|
||||
inet_pton (AF_INET, "7.0.0.0", &route.network);
|
||||
route.plen = 8;
|
||||
inet_pton (AF_INET, "6.6.6.1", &route.gateway);
|
||||
|
|
@ -87,21 +86,21 @@ setup_dev1_ip4 (int ifindex)
|
|||
route.mss))
|
||||
g_assert_not_reached ();
|
||||
|
||||
route.source = NM_IP_CONFIG_SOURCE_USER;
|
||||
route.rt_source = nmp_utils_ip_config_source_round_trip_rtprot (NM_IP_CONFIG_SOURCE_USER);
|
||||
inet_pton (AF_INET, "6.6.6.0", &route.network);
|
||||
route.plen = 24;
|
||||
route.gateway = INADDR_ANY;
|
||||
route.metric = 20;
|
||||
g_array_append_val (routes, route);
|
||||
|
||||
route.source = NM_IP_CONFIG_SOURCE_USER;
|
||||
route.rt_source = nmp_utils_ip_config_source_round_trip_rtprot (NM_IP_CONFIG_SOURCE_USER);
|
||||
inet_pton (AF_INET, "7.0.0.0", &route.network);
|
||||
route.plen = 8;
|
||||
route.gateway = INADDR_ANY;
|
||||
route.metric = 22;
|
||||
g_array_append_val (routes, route);
|
||||
|
||||
route.source = NM_IP_CONFIG_SOURCE_USER;
|
||||
route.rt_source = nmp_utils_ip_config_source_round_trip_rtprot (NM_IP_CONFIG_SOURCE_USER);
|
||||
inet_pton (AF_INET, "8.0.0.0", &route.network);
|
||||
route.plen = 8;
|
||||
inet_pton (AF_INET, "6.6.6.2", &route.gateway);
|
||||
|
|
@ -121,14 +120,14 @@ update_dev0_ip4 (int ifindex)
|
|||
route.ifindex = ifindex;
|
||||
route.mss = 0;
|
||||
|
||||
route.source = NM_IP_CONFIG_SOURCE_USER;
|
||||
route.rt_source = nmp_utils_ip_config_source_round_trip_rtprot (NM_IP_CONFIG_SOURCE_USER);
|
||||
inet_pton (AF_INET, "6.6.6.0", &route.network);
|
||||
route.plen = 24;
|
||||
route.gateway = INADDR_ANY;
|
||||
route.metric = 20;
|
||||
g_array_append_val (routes, route);
|
||||
|
||||
route.source = NM_IP_CONFIG_SOURCE_USER;
|
||||
route.rt_source = nmp_utils_ip_config_source_round_trip_rtprot (NM_IP_CONFIG_SOURCE_USER);
|
||||
inet_pton (AF_INET, "7.0.0.0", &route.network);
|
||||
route.plen = 8;
|
||||
route.gateway = INADDR_ANY;
|
||||
|
|
@ -163,7 +162,7 @@ test_ip4 (test_fixture *fixture, gconstpointer user_data)
|
|||
|
||||
NMPlatformIP4Route state1[] = {
|
||||
{
|
||||
.source = NM_IP_CONFIG_SOURCE_USER,
|
||||
.rt_source = nmp_utils_ip_config_source_round_trip_rtprot (NM_IP_CONFIG_SOURCE_USER),
|
||||
.network = nmtst_inet4_from_string ("6.6.6.0"),
|
||||
.plen = 24,
|
||||
.ifindex = fixture->ifindex0,
|
||||
|
|
@ -173,7 +172,7 @@ test_ip4 (test_fixture *fixture, gconstpointer user_data)
|
|||
.scope_inv = nm_platform_route_scope_inv (RT_SCOPE_LINK),
|
||||
},
|
||||
{
|
||||
.source = NM_IP_CONFIG_SOURCE_USER,
|
||||
.rt_source = nmp_utils_ip_config_source_round_trip_rtprot (NM_IP_CONFIG_SOURCE_USER),
|
||||
.network = nmtst_inet4_from_string ("7.0.0.0"),
|
||||
.plen = 8,
|
||||
.ifindex = fixture->ifindex0,
|
||||
|
|
@ -183,7 +182,7 @@ test_ip4 (test_fixture *fixture, gconstpointer user_data)
|
|||
.scope_inv = nm_platform_route_scope_inv (RT_SCOPE_UNIVERSE),
|
||||
},
|
||||
{
|
||||
.source = NM_IP_CONFIG_SOURCE_USER,
|
||||
.rt_source = nmp_utils_ip_config_source_round_trip_rtprot (NM_IP_CONFIG_SOURCE_USER),
|
||||
.network = nmtst_inet4_from_string ("7.0.0.0"),
|
||||
.plen = 8,
|
||||
.ifindex = fixture->ifindex1,
|
||||
|
|
@ -193,7 +192,7 @@ test_ip4 (test_fixture *fixture, gconstpointer user_data)
|
|||
.scope_inv = nm_platform_route_scope_inv (RT_SCOPE_LINK),
|
||||
},
|
||||
{
|
||||
.source = NM_IP_CONFIG_SOURCE_USER,
|
||||
.rt_source = nmp_utils_ip_config_source_round_trip_rtprot (NM_IP_CONFIG_SOURCE_USER),
|
||||
.network = nmtst_inet4_from_string ("6.6.6.0"),
|
||||
.plen = 24,
|
||||
.ifindex = fixture->ifindex1,
|
||||
|
|
@ -203,7 +202,7 @@ test_ip4 (test_fixture *fixture, gconstpointer user_data)
|
|||
.scope_inv = nm_platform_route_scope_inv (RT_SCOPE_LINK),
|
||||
},
|
||||
{
|
||||
.source = NM_IP_CONFIG_SOURCE_USER,
|
||||
.rt_source = nmp_utils_ip_config_source_round_trip_rtprot (NM_IP_CONFIG_SOURCE_USER),
|
||||
.network = nmtst_inet4_from_string ("8.0.0.0"),
|
||||
.plen = 8,
|
||||
.ifindex = fixture->ifindex1,
|
||||
|
|
@ -216,7 +215,7 @@ test_ip4 (test_fixture *fixture, gconstpointer user_data)
|
|||
|
||||
NMPlatformIP4Route state2[] = {
|
||||
{
|
||||
.source = NM_IP_CONFIG_SOURCE_USER,
|
||||
.rt_source = nmp_utils_ip_config_source_round_trip_rtprot (NM_IP_CONFIG_SOURCE_USER),
|
||||
.network = nmtst_inet4_from_string ("6.6.6.0"),
|
||||
.plen = 24,
|
||||
.ifindex = fixture->ifindex0,
|
||||
|
|
@ -226,7 +225,7 @@ test_ip4 (test_fixture *fixture, gconstpointer user_data)
|
|||
.scope_inv = nm_platform_route_scope_inv (RT_SCOPE_LINK),
|
||||
},
|
||||
{
|
||||
.source = NM_IP_CONFIG_SOURCE_USER,
|
||||
.rt_source = nmp_utils_ip_config_source_round_trip_rtprot (NM_IP_CONFIG_SOURCE_USER),
|
||||
.network = nmtst_inet4_from_string ("7.0.0.0"),
|
||||
.plen = 8,
|
||||
.ifindex = fixture->ifindex0,
|
||||
|
|
@ -236,7 +235,7 @@ test_ip4 (test_fixture *fixture, gconstpointer user_data)
|
|||
.scope_inv = nm_platform_route_scope_inv (RT_SCOPE_LINK),
|
||||
},
|
||||
{
|
||||
.source = NM_IP_CONFIG_SOURCE_USER,
|
||||
.rt_source = nmp_utils_ip_config_source_round_trip_rtprot (NM_IP_CONFIG_SOURCE_USER),
|
||||
.network = nmtst_inet4_from_string ("7.0.0.0"),
|
||||
.plen = 8,
|
||||
.ifindex = fixture->ifindex1,
|
||||
|
|
@ -246,7 +245,7 @@ test_ip4 (test_fixture *fixture, gconstpointer user_data)
|
|||
.scope_inv = nm_platform_route_scope_inv (RT_SCOPE_LINK),
|
||||
},
|
||||
{
|
||||
.source = NM_IP_CONFIG_SOURCE_USER,
|
||||
.rt_source = nmp_utils_ip_config_source_round_trip_rtprot (NM_IP_CONFIG_SOURCE_USER),
|
||||
.network = nmtst_inet4_from_string ("6.6.6.0"),
|
||||
.plen = 24,
|
||||
.ifindex = fixture->ifindex1,
|
||||
|
|
@ -256,7 +255,7 @@ test_ip4 (test_fixture *fixture, gconstpointer user_data)
|
|||
.scope_inv = nm_platform_route_scope_inv (RT_SCOPE_LINK),
|
||||
},
|
||||
{
|
||||
.source = NM_IP_CONFIG_SOURCE_USER,
|
||||
.rt_source = nmp_utils_ip_config_source_round_trip_rtprot (NM_IP_CONFIG_SOURCE_USER),
|
||||
.network = nmtst_inet4_from_string ("8.0.0.0"),
|
||||
.plen = 8,
|
||||
.ifindex = fixture->ifindex1,
|
||||
|
|
@ -269,7 +268,7 @@ test_ip4 (test_fixture *fixture, gconstpointer user_data)
|
|||
|
||||
NMPlatformIP4Route state3[] = {
|
||||
{
|
||||
.source = NM_IP_CONFIG_SOURCE_USER,
|
||||
.rt_source = nmp_utils_ip_config_source_round_trip_rtprot (NM_IP_CONFIG_SOURCE_USER),
|
||||
.network = nmtst_inet4_from_string ("7.0.0.0"),
|
||||
.plen = 8,
|
||||
.ifindex = fixture->ifindex1,
|
||||
|
|
@ -279,7 +278,7 @@ test_ip4 (test_fixture *fixture, gconstpointer user_data)
|
|||
.scope_inv = nm_platform_route_scope_inv (RT_SCOPE_LINK),
|
||||
},
|
||||
{
|
||||
.source = NM_IP_CONFIG_SOURCE_USER,
|
||||
.rt_source = nmp_utils_ip_config_source_round_trip_rtprot (NM_IP_CONFIG_SOURCE_USER),
|
||||
.network = nmtst_inet4_from_string ("6.6.6.0"),
|
||||
.plen = 24,
|
||||
.ifindex = fixture->ifindex1,
|
||||
|
|
@ -289,7 +288,7 @@ test_ip4 (test_fixture *fixture, gconstpointer user_data)
|
|||
.scope_inv = nm_platform_route_scope_inv (RT_SCOPE_LINK),
|
||||
},
|
||||
{
|
||||
.source = NM_IP_CONFIG_SOURCE_USER,
|
||||
.rt_source = nmp_utils_ip_config_source_round_trip_rtprot (NM_IP_CONFIG_SOURCE_USER),
|
||||
.network = nmtst_inet4_from_string ("8.0.0.0"),
|
||||
.plen = 8,
|
||||
.ifindex = fixture->ifindex1,
|
||||
|
|
@ -299,7 +298,7 @@ test_ip4 (test_fixture *fixture, gconstpointer user_data)
|
|||
.scope_inv = nm_platform_route_scope_inv (RT_SCOPE_UNIVERSE),
|
||||
},
|
||||
{
|
||||
.source = NM_IP_CONFIG_SOURCE_USER,
|
||||
.rt_source = nmp_utils_ip_config_source_round_trip_rtprot (NM_IP_CONFIG_SOURCE_USER),
|
||||
.network = nmtst_inet4_from_string ("6.6.6.0"),
|
||||
.plen = 24,
|
||||
.ifindex = fixture->ifindex1,
|
||||
|
|
@ -542,7 +541,7 @@ test_ip6 (test_fixture *fixture, gconstpointer user_data)
|
|||
|
||||
NMPlatformIP6Route state1[] = {
|
||||
{
|
||||
.source = NM_IP_CONFIG_SOURCE_USER,
|
||||
.rt_source = nmp_utils_ip_config_source_round_trip_rtprot (NM_IP_CONFIG_SOURCE_USER),
|
||||
.network = *nmtst_inet6_from_string ("2001:db8:8086::"),
|
||||
.plen = 48,
|
||||
.ifindex = fixture->ifindex0,
|
||||
|
|
@ -551,7 +550,7 @@ test_ip6 (test_fixture *fixture, gconstpointer user_data)
|
|||
.mss = 0,
|
||||
},
|
||||
{
|
||||
.source = NM_IP_CONFIG_SOURCE_USER,
|
||||
.rt_source = nmp_utils_ip_config_source_round_trip_rtprot (NM_IP_CONFIG_SOURCE_USER),
|
||||
.network = *nmtst_inet6_from_string ("2001:db8:1337::"),
|
||||
.plen = 48,
|
||||
.ifindex = fixture->ifindex0,
|
||||
|
|
@ -560,7 +559,7 @@ test_ip6 (test_fixture *fixture, gconstpointer user_data)
|
|||
.mss = 0,
|
||||
},
|
||||
{
|
||||
.source = NM_IP_CONFIG_SOURCE_USER,
|
||||
.rt_source = nmp_utils_ip_config_source_round_trip_rtprot (NM_IP_CONFIG_SOURCE_USER),
|
||||
.network = *nmtst_inet6_from_string ("2001:db8:abad:c0de::"),
|
||||
.plen = 64,
|
||||
.ifindex = fixture->ifindex0,
|
||||
|
|
@ -569,7 +568,7 @@ test_ip6 (test_fixture *fixture, gconstpointer user_data)
|
|||
.mss = 0,
|
||||
},
|
||||
{
|
||||
.source = NM_IP_CONFIG_SOURCE_USER,
|
||||
.rt_source = nmp_utils_ip_config_source_round_trip_rtprot (NM_IP_CONFIG_SOURCE_USER),
|
||||
.network = *nmtst_inet6_from_string ("2001:db8:abad:c0de::"),
|
||||
.plen = 64,
|
||||
.ifindex = fixture->ifindex1,
|
||||
|
|
@ -578,7 +577,7 @@ test_ip6 (test_fixture *fixture, gconstpointer user_data)
|
|||
.mss = 0,
|
||||
},
|
||||
{
|
||||
.source = NM_IP_CONFIG_SOURCE_USER,
|
||||
.rt_source = nmp_utils_ip_config_source_round_trip_rtprot (NM_IP_CONFIG_SOURCE_USER),
|
||||
.network = *nmtst_inet6_from_string ("2001:db8:1337::"),
|
||||
.plen = 48,
|
||||
.ifindex = fixture->ifindex1,
|
||||
|
|
@ -587,7 +586,7 @@ test_ip6 (test_fixture *fixture, gconstpointer user_data)
|
|||
.mss = 0,
|
||||
},
|
||||
{
|
||||
.source = NM_IP_CONFIG_SOURCE_USER,
|
||||
.rt_source = nmp_utils_ip_config_source_round_trip_rtprot (NM_IP_CONFIG_SOURCE_USER),
|
||||
.network = *nmtst_inet6_from_string ("2001:db8:8086::"),
|
||||
.plen = 48,
|
||||
.ifindex = fixture->ifindex1,
|
||||
|
|
@ -596,7 +595,7 @@ test_ip6 (test_fixture *fixture, gconstpointer user_data)
|
|||
.mss = 0,
|
||||
},
|
||||
{
|
||||
.source = NM_IP_CONFIG_SOURCE_USER,
|
||||
.rt_source = nmp_utils_ip_config_source_round_trip_rtprot (NM_IP_CONFIG_SOURCE_USER),
|
||||
.network = *nmtst_inet6_from_string ("2001:db8:d34d::"),
|
||||
.plen = 64,
|
||||
.ifindex = fixture->ifindex1,
|
||||
|
|
@ -608,7 +607,7 @@ test_ip6 (test_fixture *fixture, gconstpointer user_data)
|
|||
|
||||
NMPlatformIP6Route state2[] = {
|
||||
{
|
||||
.source = NM_IP_CONFIG_SOURCE_USER,
|
||||
.rt_source = nmp_utils_ip_config_source_round_trip_rtprot (NM_IP_CONFIG_SOURCE_USER),
|
||||
.network = *nmtst_inet6_from_string ("2001:db8:8086::"),
|
||||
.plen = 48,
|
||||
.ifindex = fixture->ifindex0,
|
||||
|
|
@ -617,7 +616,7 @@ test_ip6 (test_fixture *fixture, gconstpointer user_data)
|
|||
.mss = 0,
|
||||
},
|
||||
{
|
||||
.source = NM_IP_CONFIG_SOURCE_USER,
|
||||
.rt_source = nmp_utils_ip_config_source_round_trip_rtprot (NM_IP_CONFIG_SOURCE_USER),
|
||||
.network = *nmtst_inet6_from_string ("2001:db8:1337::"),
|
||||
.plen = 48,
|
||||
.ifindex = fixture->ifindex0,
|
||||
|
|
@ -626,7 +625,7 @@ test_ip6 (test_fixture *fixture, gconstpointer user_data)
|
|||
.mss = 0,
|
||||
},
|
||||
{
|
||||
.source = NM_IP_CONFIG_SOURCE_USER,
|
||||
.rt_source = nmp_utils_ip_config_source_round_trip_rtprot (NM_IP_CONFIG_SOURCE_USER),
|
||||
.network = *nmtst_inet6_from_string ("2001:db8:abad:c0de::"),
|
||||
.plen = 64,
|
||||
.ifindex = fixture->ifindex0,
|
||||
|
|
@ -635,7 +634,7 @@ test_ip6 (test_fixture *fixture, gconstpointer user_data)
|
|||
.mss = 0,
|
||||
},
|
||||
{
|
||||
.source = NM_IP_CONFIG_SOURCE_USER,
|
||||
.rt_source = nmp_utils_ip_config_source_round_trip_rtprot (NM_IP_CONFIG_SOURCE_USER),
|
||||
.network = *nmtst_inet6_from_string ("2001:db8:abad:c0de::"),
|
||||
.plen = 64,
|
||||
.ifindex = fixture->ifindex1,
|
||||
|
|
@ -644,7 +643,7 @@ test_ip6 (test_fixture *fixture, gconstpointer user_data)
|
|||
.mss = 0,
|
||||
},
|
||||
{
|
||||
.source = NM_IP_CONFIG_SOURCE_USER,
|
||||
.rt_source = nmp_utils_ip_config_source_round_trip_rtprot (NM_IP_CONFIG_SOURCE_USER),
|
||||
.network = *nmtst_inet6_from_string ("2001:db8:1337::"),
|
||||
.plen = 48,
|
||||
.ifindex = fixture->ifindex1,
|
||||
|
|
@ -653,7 +652,7 @@ test_ip6 (test_fixture *fixture, gconstpointer user_data)
|
|||
.mss = 0,
|
||||
},
|
||||
{
|
||||
.source = NM_IP_CONFIG_SOURCE_USER,
|
||||
.rt_source = nmp_utils_ip_config_source_round_trip_rtprot (NM_IP_CONFIG_SOURCE_USER),
|
||||
.network = *nmtst_inet6_from_string ("2001:db8:8086::"),
|
||||
.plen = 48,
|
||||
.ifindex = fixture->ifindex1,
|
||||
|
|
@ -662,7 +661,7 @@ test_ip6 (test_fixture *fixture, gconstpointer user_data)
|
|||
.mss = 0,
|
||||
},
|
||||
{
|
||||
.source = NM_IP_CONFIG_SOURCE_USER,
|
||||
.rt_source = nmp_utils_ip_config_source_round_trip_rtprot (NM_IP_CONFIG_SOURCE_USER),
|
||||
.network = *nmtst_inet6_from_string ("2001:db8:d34d::"),
|
||||
.plen = 64,
|
||||
.ifindex = fixture->ifindex1,
|
||||
|
|
@ -674,7 +673,7 @@ test_ip6 (test_fixture *fixture, gconstpointer user_data)
|
|||
|
||||
NMPlatformIP6Route state3[] = {
|
||||
{
|
||||
.source = NM_IP_CONFIG_SOURCE_USER,
|
||||
.rt_source = nmp_utils_ip_config_source_round_trip_rtprot (NM_IP_CONFIG_SOURCE_USER),
|
||||
.network = *nmtst_inet6_from_string ("2001:db8:abad:c0de::"),
|
||||
.plen = 64,
|
||||
.ifindex = fixture->ifindex1,
|
||||
|
|
@ -683,7 +682,7 @@ test_ip6 (test_fixture *fixture, gconstpointer user_data)
|
|||
.mss = 0,
|
||||
},
|
||||
{
|
||||
.source = NM_IP_CONFIG_SOURCE_USER,
|
||||
.rt_source = nmp_utils_ip_config_source_round_trip_rtprot (NM_IP_CONFIG_SOURCE_USER),
|
||||
.network = *nmtst_inet6_from_string ("2001:db8:8086::"),
|
||||
.plen = 48,
|
||||
.ifindex = fixture->ifindex1,
|
||||
|
|
@ -692,7 +691,7 @@ test_ip6 (test_fixture *fixture, gconstpointer user_data)
|
|||
.mss = 0,
|
||||
},
|
||||
{
|
||||
.source = NM_IP_CONFIG_SOURCE_USER,
|
||||
.rt_source = nmp_utils_ip_config_source_round_trip_rtprot (NM_IP_CONFIG_SOURCE_USER),
|
||||
.network = *nmtst_inet6_from_string ("2001:db8:1337::"),
|
||||
.plen = 48,
|
||||
.ifindex = fixture->ifindex1,
|
||||
|
|
@ -701,7 +700,7 @@ test_ip6 (test_fixture *fixture, gconstpointer user_data)
|
|||
.mss = 0,
|
||||
},
|
||||
{
|
||||
.source = NM_IP_CONFIG_SOURCE_USER,
|
||||
.rt_source = nmp_utils_ip_config_source_round_trip_rtprot (NM_IP_CONFIG_SOURCE_USER),
|
||||
.network = *nmtst_inet6_from_string ("2001:db8:1337::"),
|
||||
.plen = 48,
|
||||
.ifindex = fixture->ifindex1,
|
||||
|
|
@ -710,7 +709,7 @@ test_ip6 (test_fixture *fixture, gconstpointer user_data)
|
|||
.mss = 0,
|
||||
},
|
||||
{
|
||||
.source = NM_IP_CONFIG_SOURCE_USER,
|
||||
.rt_source = nmp_utils_ip_config_source_round_trip_rtprot (NM_IP_CONFIG_SOURCE_USER),
|
||||
.network = *nmtst_inet6_from_string ("2001:db8:8086::"),
|
||||
.plen = 48,
|
||||
.ifindex = fixture->ifindex1,
|
||||
|
|
@ -719,7 +718,7 @@ test_ip6 (test_fixture *fixture, gconstpointer user_data)
|
|||
.mss = 0,
|
||||
},
|
||||
{
|
||||
.source = NM_IP_CONFIG_SOURCE_USER,
|
||||
.rt_source = nmp_utils_ip_config_source_round_trip_rtprot (NM_IP_CONFIG_SOURCE_USER),
|
||||
.network = *nmtst_inet6_from_string ("2001:db8:d34d::"),
|
||||
.plen = 64,
|
||||
.ifindex = fixture->ifindex1,
|
||||
|
|
@ -787,6 +786,7 @@ static void
|
|||
_assert_route_check (const NMPlatformVTableRoute *vtable, gboolean has, const NMPlatformIPXRoute *route)
|
||||
{
|
||||
const NMPlatformIPXRoute *r;
|
||||
NMPlatformIPXRoute c;
|
||||
|
||||
g_assert (route);
|
||||
|
||||
|
|
@ -800,11 +800,18 @@ _assert_route_check (const NMPlatformVTableRoute *vtable, gboolean has, const NM
|
|||
} else {
|
||||
char buf[sizeof (_nm_utils_to_string_buffer)];
|
||||
|
||||
if (!r || vtable->route_cmp (route, r) != 0)
|
||||
if (r) {
|
||||
if (vtable->is_ip4)
|
||||
c.r4 = route->r4;
|
||||
else
|
||||
c.r6 = route->r6;
|
||||
c.rx.rt_source = nmp_utils_ip_config_source_round_trip_rtprot (c.rx.rt_source);
|
||||
}
|
||||
if (!r || vtable->route_cmp (r, &c) != 0) {
|
||||
g_error ("Invalid route. Expect %s, has %s",
|
||||
vtable->route_to_string (route, NULL, 0),
|
||||
vtable->route_to_string (&c, NULL, 0),
|
||||
vtable->route_to_string (r, buf, sizeof (buf)));
|
||||
g_assert (r);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -680,7 +680,7 @@ add_ip4_vpn_gateway_route (NMIP4Config *config, NMDevice *parent_device, guint32
|
|||
if (nm_ip4_config_destination_is_direct (parent_config, vpn_gw, 32))
|
||||
route.gateway = 0;
|
||||
|
||||
route.source = NM_IP_CONFIG_SOURCE_VPN;
|
||||
route.rt_source = NM_IP_CONFIG_SOURCE_VPN;
|
||||
route.metric = route_metric;
|
||||
nm_ip4_config_add_route (config, &route);
|
||||
|
||||
|
|
@ -692,7 +692,7 @@ add_ip4_vpn_gateway_route (NMIP4Config *config, NMDevice *parent_device, guint32
|
|||
memset (&route, 0, sizeof (route));
|
||||
route.network = parent_gw;
|
||||
route.plen = 32;
|
||||
route.source = NM_IP_CONFIG_SOURCE_VPN;
|
||||
route.rt_source = NM_IP_CONFIG_SOURCE_VPN;
|
||||
route.metric = route_metric;
|
||||
|
||||
nm_ip4_config_add_route (config, &route);
|
||||
|
|
@ -732,7 +732,7 @@ add_ip6_vpn_gateway_route (NMIP6Config *config,
|
|||
if (nm_ip6_config_destination_is_direct (parent_config, vpn_gw, 128))
|
||||
route.gateway = in6addr_any;
|
||||
|
||||
route.source = NM_IP_CONFIG_SOURCE_VPN;
|
||||
route.rt_source = NM_IP_CONFIG_SOURCE_VPN;
|
||||
route.metric = route_metric;
|
||||
nm_ip6_config_add_route (config, &route);
|
||||
|
||||
|
|
@ -744,7 +744,7 @@ add_ip6_vpn_gateway_route (NMIP6Config *config,
|
|||
memset (&route, 0, sizeof (route));
|
||||
route.network = *parent_gw;
|
||||
route.plen = 128;
|
||||
route.source = NM_IP_CONFIG_SOURCE_VPN;
|
||||
route.rt_source = NM_IP_CONFIG_SOURCE_VPN;
|
||||
route.metric = route_metric;
|
||||
|
||||
nm_ip6_config_add_route (config, &route);
|
||||
|
|
@ -1386,7 +1386,7 @@ nm_vpn_connection_ip4_config_get (NMVpnConnection *self, GVariant *dict)
|
|||
address.plen = u32;
|
||||
|
||||
if (address.address && address.plen && address.plen <= 32) {
|
||||
address.source = NM_IP_CONFIG_SOURCE_VPN;
|
||||
address.addr_source = NM_IP_CONFIG_SOURCE_VPN;
|
||||
nm_ip4_config_add_address (config, &address);
|
||||
} else {
|
||||
_LOGW ("invalid IP4 config received!");
|
||||
|
|
@ -1435,7 +1435,7 @@ nm_vpn_connection_ip4_config_get (NMVpnConnection *self, GVariant *dict)
|
|||
g_variant_get_child (v, 2, "u", &route.gateway);
|
||||
/* 4th item is unused route metric */
|
||||
route.metric = route_metric;
|
||||
route.source = NM_IP_CONFIG_SOURCE_VPN;
|
||||
route.rt_source = NM_IP_CONFIG_SOURCE_VPN;
|
||||
|
||||
if (route.plen > 32)
|
||||
break;
|
||||
|
|
@ -1523,7 +1523,7 @@ nm_vpn_connection_ip6_config_get (NMVpnConnection *self, GVariant *dict)
|
|||
address.plen = u32;
|
||||
|
||||
if (!IN6_IS_ADDR_UNSPECIFIED (&address.address) && address.plen && address.plen <= 128) {
|
||||
address.source = NM_IP_CONFIG_SOURCE_VPN;
|
||||
address.addr_source = NM_IP_CONFIG_SOURCE_VPN;
|
||||
nm_ip6_config_add_address (config, &address);
|
||||
} else {
|
||||
_LOGW ("invalid IP6 config received!");
|
||||
|
|
@ -1575,7 +1575,7 @@ nm_vpn_connection_ip6_config_get (NMVpnConnection *self, GVariant *dict)
|
|||
route.plen = prefix;
|
||||
ip6_addr_from_variant (next_hop, &route.gateway);
|
||||
route.metric = route_metric;
|
||||
route.source = NM_IP_CONFIG_SOURCE_VPN;
|
||||
route.rt_source = NM_IP_CONFIG_SOURCE_VPN;
|
||||
|
||||
/* Ignore host routes to the VPN gateway since NM adds one itself.
|
||||
* Since NM knows more about the routing situation than the VPN
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue