core: use nm_ip_config_iter_ip_route_for_each() in _get_route_table_sync_mode_stateful()

This commit is contained in:
Thomas Haller
2020-11-22 11:26:16 +01:00
parent a25935177e
commit 41d16603f1

View File

@@ -3670,6 +3670,7 @@ nm_device_get_route_table(NMDevice *self, int addr_family)
static NMIPRouteTableSyncMode static NMIPRouteTableSyncMode
_get_route_table_sync_mode_stateful(NMDevice *self, int addr_family) _get_route_table_sync_mode_stateful(NMDevice *self, int addr_family)
{ {
const int IS_IPv4 = NM_IS_IPv4(addr_family);
NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE(self); NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE(self);
NMDedupMultiIter ipconf_iter; NMDedupMultiIter ipconf_iter;
gboolean all_sync_now; gboolean all_sync_now;
@@ -3678,27 +3679,16 @@ _get_route_table_sync_mode_stateful(NMDevice *self, int addr_family)
all_sync_now = _prop_get_ipvx_route_table(self, addr_family) != 0u; all_sync_now = _prop_get_ipvx_route_table(self, addr_family) != 0u;
if (!all_sync_now) { if (!all_sync_now) {
const NMPlatformIPRoute *route;
/* If there's a local route switch to all-sync in order /* If there's a local route switch to all-sync in order
* to properly manage the local table */ * to properly manage the local table */
if (NM_IS_IPv4(addr_family)) { nm_ip_config_iter_ip_route_for_each (&ipconf_iter, priv->con_ip_config_x[IS_IPv4], &route) {
const NMPlatformIP4Route *route;
nm_ip_config_iter_ip4_route_for_each (&ipconf_iter, priv->con_ip_config_4, &route) {
if (nm_platform_route_type_uncoerce(route->type_coerced) == RTN_LOCAL) { if (nm_platform_route_type_uncoerce(route->type_coerced) == RTN_LOCAL) {
all_sync_now = TRUE; all_sync_now = TRUE;
break; break;
} }
} }
} else {
const NMPlatformIP6Route *route;
nm_ip_config_iter_ip6_route_for_each (&ipconf_iter, priv->con_ip_config_6, &route) {
if (nm_platform_route_type_uncoerce(route->type_coerced) == RTN_LOCAL) {
all_sync_now = TRUE;
break;
}
}
}
} }
if (all_sync_now) if (all_sync_now)