diff options
author | Thomas Haller <thaller@redhat.com> | 2020-11-01 16:47:14 +0100 |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2020-11-01 16:47:14 +0100 |
commit | 0829dbcd3d2ac1a194a30f933db8865ca622bfa5 (patch) | |
tree | 1941886522cfa678e4b96c04f4ddff97b2036bdb | |
parent | 2ebe34a5daf43b36aa8d9f8d5278befe1b5d1875 (diff) | |
parent | 6c9a289451392763dad9c4589da1d2ff75563adf (diff) | |
download | NetworkManager-0829dbcd3d2ac1a194a30f933db8865ca622bfa5.tar.gz |
device: merge branch 'th/device-cleanup-addr-family'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/665
-rw-r--r-- | shared/nm-glib-aux/nm-logging-fwd.h | 10 | ||||
-rw-r--r-- | src/NetworkManagerUtils.c | 32 | ||||
-rw-r--r-- | src/devices/nm-device-private.h | 12 | ||||
-rw-r--r-- | src/devices/nm-device.c | 634 | ||||
-rw-r--r-- | src/nm-core-utils.h | 2 | ||||
-rw-r--r-- | src/nm-l3-config-data.c | 9 | ||||
-rw-r--r-- | src/nm-l3-config-data.h | 12 | ||||
-rw-r--r-- | src/nm-l3cfg.c | 4 | ||||
-rw-r--r-- | src/nm-logging.h | 12 | ||||
-rw-r--r-- | src/platform/nm-platform.c | 22 | ||||
-rw-r--r-- | src/platform/tests/test-common.c | 2 | ||||
-rwxr-xr-x | tools/check-config-options.sh | 4 |
12 files changed, 325 insertions, 430 deletions
diff --git a/shared/nm-glib-aux/nm-logging-fwd.h b/shared/nm-glib-aux/nm-logging-fwd.h index ee75b71325..2f550e5f9f 100644 --- a/shared/nm-glib-aux/nm-logging-fwd.h +++ b/shared/nm-glib-aux/nm-logging-fwd.h @@ -57,15 +57,11 @@ typedef enum { /*< skip >*/ /* aliases: */ LOGD_DHCP = LOGD_DHCP4 | LOGD_DHCP6, LOGD_IP = LOGD_IP4 | LOGD_IP6, -} NMLogDomain; -static inline NMLogDomain -LOGD_DHCP_from_addr_family(int addr_family) -{ - nm_assert_addr_family(addr_family); +#define LOGD_DHCPX(is_ipv4) ((is_ipv4) ? LOGD_DHCP4 : LOGD_DHCP6) +#define LOGD_IPX(is_ipv4) ((is_ipv4) ? LOGD_IP4 : LOGD_IP6) - return addr_family == AF_INET6 ? LOGD_DHCP6 : LOGD_DHCP4; -} +} NMLogDomain; /* Log levels */ typedef enum { /*< skip >*/ diff --git a/src/NetworkManagerUtils.c b/src/NetworkManagerUtils.c index 0e2e97b65b..35b892abed 100644 --- a/src/NetworkManagerUtils.c +++ b/src/NetworkManagerUtils.c @@ -152,7 +152,7 @@ nm_utils_get_ip_config_method(NMConnection *connection, int addr_family) s_con = nm_connection_get_setting_connection(connection); - if (addr_family == AF_INET) { + if (NM_IS_IPv4(addr_family)) { g_return_val_if_fail(s_con != NULL, NM_SETTING_IP4_CONFIG_METHOD_AUTO); s_ip = nm_connection_get_setting_ip4_config(connection); @@ -164,19 +164,15 @@ nm_utils_get_ip_config_method(NMConnection *connection, int addr_family) return method; } - if (addr_family == AF_INET6) { - g_return_val_if_fail(s_con != NULL, NM_SETTING_IP6_CONFIG_METHOD_AUTO); + g_return_val_if_fail(s_con != NULL, NM_SETTING_IP6_CONFIG_METHOD_AUTO); - s_ip = nm_connection_get_setting_ip6_config(connection); - if (!s_ip) - return NM_SETTING_IP6_CONFIG_METHOD_IGNORE; - - method = nm_setting_ip_config_get_method(s_ip); - g_return_val_if_fail(method != NULL, NM_SETTING_IP6_CONFIG_METHOD_AUTO); - return method; - } + s_ip = nm_connection_get_setting_ip6_config(connection); + if (!s_ip) + return NM_SETTING_IP6_CONFIG_METHOD_IGNORE; - g_return_val_if_reached("" /* bogus */); + method = nm_setting_ip_config_get_method(s_ip); + g_return_val_if_fail(method != NULL, NM_SETTING_IP6_CONFIG_METHOD_AUTO); + return method; } gboolean @@ -204,7 +200,7 @@ nm_utils_connection_has_default_route(NMConnection *connection, } method = nm_utils_get_ip_config_method(connection, addr_family); - if (addr_family == AF_INET) { + if (NM_IS_IPv4(addr_family)) { if (NM_IN_STRSET(method, NM_SETTING_IP4_CONFIG_METHOD_DISABLED, NM_SETTING_IP4_CONFIG_METHOD_LINK_LOCAL)) @@ -1312,7 +1308,7 @@ nm_utils_ip_route_attribute_to_platform(int addr_family, else r->table_coerced = nm_platform_route_table_coerce(table ?: (route_table ?: RT_TABLE_MAIN)); - if (addr_family == AF_INET) { + if (NM_IS_IPv4(addr_family)) { guint8 scope; GET_ATTR(NM_IP_ROUTE_ATTRIBUTE_TOS, r4->tos, BYTE, byte, 0); @@ -1338,14 +1334,14 @@ nm_utils_ip_route_attribute_to_platform(int addr_family, if ((variant = nm_ip_route_get_attribute(s_route, NM_IP_ROUTE_ATTRIBUTE_SRC)) && g_variant_is_of_type(variant, G_VARIANT_TYPE_STRING)) { if (inet_pton(addr_family, g_variant_get_string(variant, NULL), &addr) == 1) { - if (addr_family == AF_INET) + if (NM_IS_IPv4(addr_family)) r4->pref_src = addr.addr4; else r6->pref_src = addr.addr6; } } - if (addr_family == AF_INET6 + if (!NM_IS_IPv4(addr_family) && (variant = nm_ip_route_get_attribute(s_route, NM_IP_ROUTE_ATTRIBUTE_FROM)) && g_variant_is_of_type(variant, G_VARIANT_TYPE_STRING)) { int prefix; @@ -1392,7 +1388,7 @@ nm_utils_ip_addresses_to_dbus(int addr_family, GVariant ** out_address_data, GVariant ** out_addresses) { - const gboolean IS_IPv4 = NM_IS_IPv4(addr_family); + const int IS_IPv4 = NM_IS_IPv4(addr_family); GVariantBuilder builder_data; GVariantBuilder builder_legacy; char addr_str[NM_UTILS_INET_ADDRSTRLEN]; @@ -1516,7 +1512,7 @@ nm_utils_ip_routes_to_dbus(int addr_family, GVariant ** out_route_data, GVariant ** out_routes) { - const gboolean IS_IPv4 = NM_IS_IPv4(addr_family); + const int IS_IPv4 = NM_IS_IPv4(addr_family); NMDedupMultiIter iter; const NMPObject *obj; GVariantBuilder builder_data; diff --git a/src/devices/nm-device-private.h b/src/devices/nm-device-private.h index 054197e0c3..dbf5105a08 100644 --- a/src/devices/nm-device-private.h +++ b/src/devices/nm-device-private.h @@ -54,17 +54,7 @@ gboolean nm_device_set_ip_iface(NMDevice *self, const char *iface); void nm_device_activate_schedule_stage3_ip_config_start(NMDevice *device); -gboolean nm_device_activate_stage3_ip4_start(NMDevice *self); - -gboolean nm_device_activate_stage3_ip6_start(NMDevice *self); - -static inline gboolean -nm_device_activate_stage3_ip_start(NMDevice *self, int addr_family) -{ - if (NM_IS_IPv4(addr_family)) - return nm_device_activate_stage3_ip4_start(self); - return nm_device_activate_stage3_ip6_start(self); -} +gboolean nm_device_activate_stage3_ip_start(NMDevice *self, int addr_family); gboolean nm_device_bring_up(NMDevice *self, gboolean wait, gboolean *no_firmware); diff --git a/src/devices/nm-device.c b/src/devices/nm-device.c index bd08de9e19..f979251f89 100644 --- a/src/devices/nm-device.c +++ b/src/devices/nm-device.c @@ -695,6 +695,8 @@ static guint32 default_route_metric_penalty_get(NMDevice *self, int addr_family) static guint _prop_get_ipv4_dad_timeout(NMDevice *self); +static NMIP6Config *dad6_get_pending_addresses(NMDevice *self); + static void _carrier_wait_check_queued_act_request(NMDevice *self); static gint64 _get_carrier_wait_ms(NMDevice *self); @@ -726,24 +728,8 @@ static void concheck_update_state(NMDevice * self, NMConnectivityState state, gboolean is_periodic); -static void activate_stage4_ip_config_timeout_4(NMDevice *self); -static void activate_stage4_ip_config_timeout_6(NMDevice *self); - -static void (*const activate_stage4_ip_config_timeout_x[2])(NMDevice *self) = { - activate_stage4_ip_config_timeout_6, - activate_stage4_ip_config_timeout_4, -}; - static void sriov_op_cb(GError *error, gpointer user_data); -static void activate_stage5_ip_config_result_4(NMDevice *self); -static void activate_stage5_ip_config_result_6(NMDevice *self); - -static void (*const activate_stage5_ip_config_result_x[2])(NMDevice *self) = { - activate_stage5_ip_config_result_6, - activate_stage5_ip_config_result_4, -}; - /*****************************************************************************/ static NM_UTILS_LOOKUP_STR_DEFINE( @@ -1294,7 +1280,7 @@ _prop_get_ipvx_route_table(NMDevice *self, int addr_family) /* the route table setting affects how we sync routes. We shall * not change it while the device is active, hence, cache it. */ - if (addr_family == AF_INET) { + if (NM_IS_IPv4(addr_family)) { if (priv->v4_route_table_initialized) return priv->v4_route_table; } else { @@ -1312,7 +1298,7 @@ _prop_get_ipvx_route_table(NMDevice *self, int addr_family) gint64 v; v = nm_config_data_get_connection_default_int64(NM_CONFIG_GET_DATA, - addr_family == AF_INET + NM_IS_IPv4(addr_family) ? NM_CON_DEFAULT("ipv4.route-table") : NM_CON_DEFAULT("ipv6.route-table"), self, @@ -1348,7 +1334,7 @@ _prop_get_ipvx_route_table(NMDevice *self, int addr_family) if (klass->coerce_route_table) route_table = klass->coerce_route_table(self, addr_family, route_table, is_user_config); - if (addr_family == AF_INET) { + if (NM_IS_IPv4(addr_family)) { priv->v4_route_table_initialized = TRUE; priv->v4_route_table = route_table; } else { @@ -1358,7 +1344,7 @@ _prop_get_ipvx_route_table(NMDevice *self, int addr_family) _LOGT(LOGD_DEVICE, "ipv%c.route-table = %u%s", - addr_family == AF_INET ? '4' : '6', + nm_utils_addr_family_to_char(addr_family), (guint)(route_table ?: RT_TABLE_MAIN), route_table != 0u ? "" : " (policy routing not enabled)"); @@ -1437,7 +1423,7 @@ _prop_get_ipvx_dhcp_timeout(NMDevice *self, int addr_family) goto out; timeout = nm_config_data_get_connection_default_int64(NM_CONFIG_GET_DATA, - addr_family == AF_INET + NM_IS_IPv4(addr_family) ? NM_CON_DEFAULT("ipv4.dhcp-timeout") : NM_CON_DEFAULT("ipv6.dhcp-timeout"), self, @@ -1480,6 +1466,7 @@ _prop_get_ipvx_dhcp_iaid(NMDevice * self, NMConnection *connection, gboolean * out_is_explicit) { + const int IS_IPv4 = NM_IS_IPv4(addr_family); NMSettingIPConfig *s_ip; const char * iaid_str; gs_free char * iaid_str_free = NULL; @@ -1493,8 +1480,7 @@ _prop_get_ipvx_dhcp_iaid(NMDevice * self, if (!iaid_str) { iaid_str_free = nm_config_data_get_connection_default( NM_CONFIG_GET_DATA, - addr_family == AF_INET ? NM_CON_DEFAULT("ipv4.dhcp-iaid") - : NM_CON_DEFAULT("ipv6.dhcp-iaid"), + IS_IPv4 ? NM_CON_DEFAULT("ipv4.dhcp-iaid") : NM_CON_DEFAULT("ipv6.dhcp-iaid"), self); iaid_str = iaid_str_free; if (!iaid_str) { @@ -1578,8 +1564,7 @@ _prop_get_ipvx_dhcp_iaid(NMDevice * self, out_fail: nm_assert(fail_reason); - _LOGW(addr_family == AF_INET ? (LOGD_DEVICE | LOGD_DHCP4 | LOGD_IP4) - : (LOGD_DEVICE | LOGD_DHCP6 | LOGD_IP6), + _LOGW(LOGD_DEVICE | LOGD_DHCPX(IS_IPv4) | LOGD_IPX(IS_IPv4), "ipv%c.dhcp-iaid: failure to generate IAID: %s. Using interface-name based IAID", nm_utils_addr_family_to_char(addr_family), fail_reason); @@ -1587,8 +1572,7 @@ out_fail: iface = nm_device_get_ip_iface(self); iaid = nm_utils_create_dhcp_iaid(TRUE, (const guint8 *) iface, strlen(iface)); out_good: - _LOGD(addr_family == AF_INET ? (LOGD_DEVICE | LOGD_DHCP4 | LOGD_IP4) - : (LOGD_DEVICE | LOGD_DHCP6 | LOGD_IP6), + _LOGD(LOGD_DEVICE | LOGD_DHCPX(IS_IPv4) | LOGD_IPX(IS_IPv4), "ipv%c.dhcp-iaid: using %u (0x%08x) IAID (str: '%s', explicit %d)", nm_utils_addr_family_to_char(addr_family), iaid, @@ -1622,8 +1606,8 @@ _prop_get_ipvx_dhcp_hostname_flags(NMDevice *self, int addr_family) flags = nm_config_data_get_connection_default_int64( NM_CONFIG_GET_DATA, - addr_family == AF_INET ? NM_CON_DEFAULT("ipv4.dhcp-hostname-flags") - : NM_CON_DEFAULT("ipv6.dhcp-hostname-flags"), + NM_IS_IPv4(addr_family) ? NM_CON_DEFAULT("ipv4.dhcp-hostname-flags") + : NM_CON_DEFAULT("ipv6.dhcp-hostname-flags"), self, 0, NM_DHCP_HOSTNAME_FLAG_FQDN_CLEAR_FLAGS, @@ -1631,9 +1615,9 @@ _prop_get_ipvx_dhcp_hostname_flags(NMDevice *self, int addr_family) if (!_nm_utils_validate_dhcp_hostname_flags(flags, addr_family, &error)) { _LOGW(LOGD_DEVICE, - "invalid global default value 0x%x for ipv%d.%s: %s", + "invalid global default value 0x%x for ipv%c.%s: %s", (guint) flags, - addr_family == AF_INET ? 4 : 6, + nm_utils_addr_family_to_char(addr_family), NM_SETTING_IP_CONFIG_DHCP_HOSTNAME_FLAGS, error->message); flags = NM_DHCP_HOSTNAME_FLAG_NONE; @@ -1642,7 +1626,7 @@ _prop_get_ipvx_dhcp_hostname_flags(NMDevice *self, int addr_family) if (flags != NM_DHCP_HOSTNAME_FLAG_NONE) return flags; - if (addr_family == AF_INET) + if (NM_IS_IPv4(addr_family)) return NM_DHCP_HOSTNAME_FLAGS_FQDN_DEFAULT_IP4; else return NM_DHCP_HOSTNAME_FLAGS_FQDN_DEFAULT_IP6; @@ -2338,8 +2322,8 @@ nm_device_ip_config_new(NMDevice *self, int addr_family) { nm_assert_addr_family(addr_family); - return addr_family == AF_INET ? (gpointer) nm_device_ip4_config_new(self) - : (gpointer) nm_device_ip6_config_new(self); + return NM_IS_IPv4(addr_family) ? (gpointer) nm_device_ip4_config_new(self) + : (gpointer) nm_device_ip6_config_new(self); } NML3ConfigData * @@ -2754,7 +2738,7 @@ static void _set_ip_state(NMDevice *self, int addr_family, NMDeviceIPState new_state) { NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE(self); - const gboolean IS_IPv4 = (addr_family == AF_INET); + const int IS_IPv4 = NM_IS_IPv4(addr_family); nm_assert_addr_family(addr_family); @@ -2775,7 +2759,7 @@ _set_ip_state(NMDevice *self, int addr_family, NMDeviceIPState new_state) * * This is not documented/guaranteed behavior, but seems to make sense for now. */ _active_connection_set_state_flags(self, - addr_family == AF_INET + NM_IS_IPv4(addr_family) ? NM_ACTIVATION_STATE_FLAG_IP4_READY : NM_ACTIVATION_STATE_FLAG_IP6_READY); } @@ -3559,7 +3543,7 @@ static gboolean default_route_metric_penalty_detect(NMDevice *self, int addr_family) { NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE(self); - const gboolean IS_IPv4 = (addr_family == AF_INET); + const int IS_IPv4 = NM_IS_IPv4(addr_family); /* currently we don't differentiate between IPv4 and IPv6 when detecting * connectivity. */ @@ -3575,10 +3559,8 @@ default_route_metric_penalty_get(NMDevice *self, int addr_family) { NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE(self); - nm_assert_addr_family(addr_family); - - if (addr_family == AF_INET ? priv->default_route_metric_penalty_ip4_has - : priv->default_route_metric_penalty_ip6_has) + if (NM_IS_IPv4(addr_family) ? priv->default_route_metric_penalty_ip4_has + : priv->default_route_metric_penalty_ip6_has) return 20000; return 0; } @@ -3612,8 +3594,8 @@ nm_device_get_route_metric(NMDevice *self, int addr_family) /* use the current NMConfigData, which makes this configuration reloadable. * Note that that means that the route-metric might change between SIGHUP. * You must cache the returned value if that is a problem. */ - property = addr_family == AF_INET ? NM_CON_DEFAULT("ipv4.route-metric") - : NM_CON_DEFAULT("ipv6.route-metric"); + property = NM_IS_IPv4(addr_family) ? NM_CON_DEFAULT("ipv4.route-metric") + : NM_CON_DEFAULT("ipv6.route-metric"); route_metric = nm_config_data_get_connection_default_int64(NM_CONFIG_GET_DATA, property, self, @@ -3654,7 +3636,7 @@ _get_route_table_sync_mode_stateful(NMDevice *self, int addr_family) if (!all_sync_now) { /* If there's a local route switch to all-sync in order * to properly manage the local table */ - if (addr_family == AF_INET) { + if (NM_IS_IPv4(addr_family)) { const NMPlatformIP4Route *route; nm_ip_config_iter_ip4_route_for_each (&ipconf_iter, priv->con_ip_config_4, &route) { @@ -3685,13 +3667,13 @@ _get_route_table_sync_mode_stateful(NMDevice *self, int addr_family) * The purpose of this is to support reapply of route-table (and thus the * all-sync mode). If reapply toggles from all-sync to no-all-sync, we must * sync one last time. */ - if (addr_family == AF_INET) + if (NM_IS_IPv4(addr_family)) all_sync_eff = priv->v4_route_table_all_sync_before; else all_sync_eff = priv->v6_route_table_all_sync_before; } - if (addr_family == AF_INET) + if (NM_IS_IPv4(addr_family)) priv->v4_route_table_all_sync_before = all_sync_now; else priv->v6_route_table_all_sync_before = all_sync_now; @@ -3943,7 +3925,7 @@ concheck_periodic_schedule_do(NMDevice *self, int addr_family, gint64 now_ns) NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE(self); gboolean periodic_check_disabled = FALSE; gint64 expiry, tdiff; - const gboolean IS_IPv4 = (addr_family == AF_INET); + const int IS_IPv4 = NM_IS_IPv4(addr_family); /* we always cancel whatever was pending. */ if (nm_clear_g_source(&priv->concheck_x[IS_IPv4].p_cur_id)) @@ -3998,7 +3980,7 @@ concheck_periodic_schedule_set(NMDevice *self, int addr_family, ConcheckSchedule NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE(self); gint64 new_expiry, exp_expiry, cur_expiry, tdiff; gint64 now_ns = 0; - const gboolean IS_IPv4 = (addr_family == AF_INET); + const int IS_IPv4 = NM_IS_IPv4(addr_family); if (priv->concheck_x[IS_IPv4].p_max_interval == 0) { /* periodic check is disabled. Nothing to do. */ @@ -4158,7 +4140,7 @@ concheck_update_interval(NMDevice *self, int addr_family, gboolean check_now) { NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE(self); guint new_interval; - const gboolean IS_IPv4 = (addr_family == AF_INET); + const int IS_IPv4 = NM_IS_IPv4(addr_family); new_interval = nm_connectivity_get_interval(concheck_get_mgr(self)); @@ -4202,7 +4184,7 @@ concheck_update_state(NMDevice * self, gboolean allow_periodic_bump) { NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE(self); - const gboolean IS_IPv4 = (addr_family == AF_INET); + const int IS_IPv4 = NM_IS_IPv4(addr_family); /* @state is a result of the connectivity check. We only expect a precise * number of possible values. */ @@ -4283,14 +4265,14 @@ nm_device_get_effective_ip_config_method(NMDevice *self, int addr_family) NMDeviceClass *klass; NMConnection * connection = nm_device_get_applied_connection(self); const char * method; + const int IS_IPv4 = NM_IS_IPv4(addr_family); g_return_val_if_fail(NM_IS_CONNECTION(connection), "" /* bogus */); - nm_assert_addr_family(addr_family); method = nm_utils_get_ip_config_method(connection, addr_family); - if ((addr_family == AF_INET && nm_streq(method, NM_SETTING_IP4_CONFIG_METHOD_AUTO)) - || (addr_family == AF_INET6 && nm_streq(method, NM_SETTING_IP6_CONFIG_METHOD_AUTO))) { + if ((IS_IPv4 && nm_streq(method, NM_SETTING_IP4_CONFIG_METHOD_AUTO)) + || (!IS_IPv4 && nm_streq(method, NM_SETTING_IP6_CONFIG_METHOD_AUTO))) { klass = NM_DEVICE_GET_CLASS(self); if (klass->get_auto_ip_config_method) { const char *auto_method; @@ -4307,7 +4289,7 @@ nm_device_get_effective_ip_config_method(NMDevice *self, int addr_family) static void concheck_handle_complete(NMDeviceConnectivityHandle *handle, GError *error) { - const gboolean IS_IPv4 = (handle->addr_family == AF_INET); + const int IS_IPv4 = NM_IS_IPv4(handle->addr_family); /* The moment we invoke the callback, we unlink it. It signals * that @handle is handled -- as far as the callee of callback @@ -4495,7 +4477,7 @@ concheck_start(NMDevice * self, (long long unsigned) handle->seq, is_periodic ? ", periodic-check" : ""); - if (addr_family == AF_INET && !priv->concheck_rp_filter_checked) { + if (NM_IS_IPv4(addr_family) && !priv->concheck_rp_filter_checked) { if ((ifname = nm_device_get_ip_iface_from_platform(self))) { gboolean due_to_all; int val; @@ -4560,17 +4542,15 @@ NMConnectivityState nm_device_get_connectivity_state(NMDevice *self, int addr_family) { NMDevicePrivate *priv; - const gboolean IS_IPv4 = (addr_family == AF_INET); g_return_val_if_fail(NM_IS_DEVICE(self), NM_CONNECTIVITY_UNKNOWN); - nm_assert_addr_family(addr_family); priv = NM_DEVICE_GET_PRIVATE(self); switch (addr_family) { case AF_INET: case AF_INET6: - return priv->concheck_x[IS_IPv4].state; + return priv->concheck_x[NM_IS_IPv4(addr_family)].state; default: nm_assert(addr_family == AF_UNSPEC); return NM_MAX_WITH_CMP(nm_connectivity_state_cmp, @@ -4653,10 +4633,10 @@ nm_device_master_enslave_slave(NMDevice *self, NMDevice *slave, NMConnection *co */ if (success) { if (priv->ip_state_4 == NM_DEVICE_IP_STATE_WAIT) - nm_device_activate_stage3_ip4_start(self); + nm_device_activate_stage3_ip_start(self, AF_INET); if (priv->ip_state_6 == NM_DEVICE_IP_STATE_WAIT) - nm_device_activate_stage3_ip6_start(self); + nm_device_activate_stage3_ip_start(self, AF_INET6); } /* Since slave devices don't have their own IP configuration, @@ -4887,9 +4867,9 @@ carrier_changed(NMDevice *self, gboolean carrier) /* If needed, also resume IP configuration that is * waiting for carrier. */ if (nm_device_activate_ip4_state_in_wait(self)) - nm_device_activate_stage3_ip4_start(self); + nm_device_activate_stage3_ip_start(self, AF_INET); if (nm_device_activate_ip6_state_in_wait(self)) - nm_device_activate_stage3_ip6_start(self); + nm_device_activate_stage3_ip_start(self, AF_INET6); return; } /* fall-through and change state of device */ @@ -7663,7 +7643,7 @@ static void activation_source_clear(NMDevice *self, int addr_family) { NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE(self); - const gboolean IS_IPv4 = (addr_family == AF_INET); + const int IS_IPv4 = NM_IS_IPv4(addr_family); if (priv->activation_source_id_x[IS_IPv4] != 0) { _LOGD(LOGD_DEVICE, @@ -7680,7 +7660,7 @@ static gboolean activation_source_handle_cb(NMDevice *self, int addr_family) { NMDevicePrivate * priv; - const gboolean IS_IPv4 = (addr_family == AF_INET); + const int IS_IPv4 = NM_IS_IPv4(addr_family); ActivationHandleFunc activation_source_func; guint activation_source_id; @@ -7730,7 +7710,7 @@ static void activation_source_schedule(NMDevice *self, ActivationHandleFunc func, int addr_family) { NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE(self); - const gboolean IS_IPv4 = (addr_family == AF_INET); + const int IS_IPv4 = NM_IS_IPv4(addr_family); guint new_id = 0; if (priv->activation_source_id_x[IS_IPv4] != 0 @@ -7773,7 +7753,7 @@ static void activation_source_invoke_sync(NMDevice *self, ActivationHandleFunc func, int addr_family) { NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE(self); - const gboolean IS_IPv4 = (addr_family == AF_INET); + const int IS_IPv4 = NM_IS_IPv4(addr_family); if (priv->activation_source_id_x[IS_IPv4] == 0) { _LOGD(LOGD_DEVICE, @@ -8762,7 +8742,7 @@ ensure_con_ip_config(NMDevice *self, int addr_family) { NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE(self); NMConnection * connection; - const gboolean IS_IPv4 = (addr_family == AF_INET); + const int IS_IPv4 = NM_IS_IPv4(addr_family); NMIPConfig * con_ip_config; if (priv->con_ip_config_x[IS_IPv4]) @@ -8839,7 +8819,7 @@ ip_config_merge_and_apply(NMDevice *self, int addr_family, gboolean commit) gboolean ignore_default_routes = FALSE; GSList * iter; const char * ip6_addr_gen_token = NULL; - const gboolean IS_IPv4 = (addr_family == AF_INET); + const int IS_IPv4 = NM_IS_IPv4(addr_family); if (nm_device_sys_iface_state_is_external(self)) commit = FALSE; @@ -9083,12 +9063,12 @@ static gboolean dhcp_grace_period_expired(NMDevice *self, int addr_family) { NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE(self); - const gboolean IS_IPv4 = (addr_family == AF_INET); + const int IS_IPv4 = NM_IS_IPv4(addr_family); priv->dhcp_data_x[IS_IPv4].grace_id = 0; priv->dhcp_data_x[IS_IPv4].grace_pending = FALSE; - _LOGI(LOGD_DHCP_from_addr_family(addr_family), + _LOGI(LOGD_DHCPX(IS_IPv4), "DHCPv%c: grace period expired", nm_utils_addr_family_to_char(addr_family)); @@ -9114,7 +9094,7 @@ static gboolean dhcp_grace_period_start(NMDevice *self, int addr_family) { NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE(self); - const gboolean IS_IPv4 = (addr_family == AF_INET); + const int IS_IPv4 = NM_IS_IPv4(addr_family); guint32 timeout; /* In any other case (expired lease, assumed connection, etc.), @@ -9129,12 +9109,12 @@ dhcp_grace_period_start(NMDevice *self, int addr_family) * by a constant factor. */ timeout = _prop_get_ipvx_dhcp_timeout(self, addr_family); if (timeout == NM_DHCP_TIMEOUT_INFINITY) - _LOGI(LOGD_DHCP_from_addr_family(addr_family), + _LOGI(LOGD_DHCPX(IS_IPv4), "DHCPv%c: trying to acquire a new lease", nm_utils_addr_family_to_char(addr_family)); else { timeout = dhcp_grace_period_from_timeout(timeout); - _LOGI(LOGD_DHCP_from_addr_family(addr_family), + _LOGI(LOGD_DHCPX(IS_IPv4), "DHCPv%c: trying to acquire a new lease within %u seconds", nm_utils_addr_family_to_char(addr_family), timeout); @@ -9438,7 +9418,7 @@ connection_ip_method_requires_carrier(NMConnection *connection, method = nm_utils_get_ip_config_method(connection, addr_family); - if (addr_family == AF_INET) { + if (NM_IS_IPv4(addr_family)) { NM_SET_OUT(out_ip_enabled, !nm_streq(method, NM_SETTING_IP4_CONFIG_METHOD_DISABLED)); return NM_IN_STRSET(method, NM_SETTING_IP4_CONFIG_METHOD_AUTO, @@ -10961,7 +10941,7 @@ ip_requires_slaves(NMDevice *self, int addr_family) method = nm_device_get_effective_ip_config_method(self, addr_family); - if (addr_family == AF_INET) + if (NM_IS_IPv4(addr_family)) return nm_streq(method, NM_SETTING_IP4_CONFIG_METHOD_AUTO); /* SLAAC, DHCP, and Link-Local depend on connectivity (and thus slaves) @@ -10978,7 +10958,7 @@ act_stage3_ip_config_start(NMDevice * self, gpointer * out_config, NMDeviceStateReason *out_failure_reason) { - const gboolean IS_IPv4 = (addr_family == AF_INET); + const int IS_IPv4 = NM_IS_IPv4(addr_family); NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE(self); NMConnection * connection; NMActStageReturn ret = NM_ACT_STAGE_RETURN_FAILURE; @@ -11200,103 +11180,62 @@ act_stage3_ip_config_start(NMDevice * self, } } -/** - * nm_device_activate_stage3_ip4_start: - * @self: the device - * - * Try starting IPv4 configuration. - */ gboolean -nm_device_activate_stage3_ip4_start(NMDevice *self) +nm_device_activate_stage3_ip_start(NMDevice *self, int addr_family) { - NMDevicePrivate * priv = NM_DEVICE_GET_PRIVATE(self); + const int IS_IPv4 = NM_IS_IPv4(addr_family); + NMDevicePrivate * priv = NM_DEVICE_GET_PRIVATE(self); NMActStageReturn ret; - NMDeviceStateReason failure_reason = NM_DEVICE_STATE_REASON_NONE; - gs_unref_object NMIP4Config *ip4_config = NULL; + NMDeviceStateReason failure_reason = NM_DEVICE_STATE_REASON_NONE; + gs_unref_object NMIPConfig *ip_config = NULL; - g_assert(priv->ip_state_4 == NM_DEVICE_IP_STATE_WAIT); + g_assert(priv->ip_state_x[IS_IPv4] == NM_DEVICE_IP_STATE_WAIT); if (nm_device_sys_iface_state_is_external(self)) { - _set_ip_state(self, AF_INET, NM_DEVICE_IP_STATE_DONE); + _set_ip_state(self, addr_family, NM_DEVICE_IP_STATE_DONE); check_ip_state(self, FALSE, TRUE); return TRUE; } - _set_ip_state(self, AF_INET, NM_DEVICE_IP_STATE_CONF); - ret = NM_DEVICE_GET_CLASS(self)->act_stage3_ip_config_start(self, - AF_INET, - (gpointer *) &ip4_config, - &failure_reason); - if (ret == NM_ACT_STAGE_RETURN_SUCCESS) - nm_device_activate_schedule_ip_config_result(self, AF_INET, NM_IP_CONFIG_CAST(ip4_config)); - else if (ret == NM_ACT_STAGE_RETURN_IP_DONE) { - _set_ip_state(self, AF_INET, NM_DEVICE_IP_STATE_DONE); - check_ip_state(self, FALSE, TRUE); - } else if (ret == NM_ACT_STAGE_RETURN_FAILURE) { - nm_device_state_changed(self, NM_DEVICE_STATE_FAILED, failure_reason); - return FALSE; - } else if (ret == NM_ACT_STAGE_RETURN_IP_FAIL) { - /* Activation not wanted */ - _set_ip_state(self, AF_INET, NM_DEVICE_IP_STATE_FAIL); - } else if (ret == NM_ACT_STAGE_RETURN_IP_WAIT) { - /* Wait for something to try IP config again */ - _set_ip_state(self, AF_INET, NM_DEVICE_IP_STATE_WAIT); - } else - g_assert(ret == NM_ACT_STAGE_RETURN_POSTPONE); - - return TRUE; -} - -/** - * nm_device_activate_stage3_ip6_start: - * @self: the device - * - * Try starting IPv6 configuration. - */ -gboolean -nm_device_activate_stage3_ip6_start(NMDevice *self) -{ - NMDevicePrivate * priv = NM_DEVICE_GET_PRIVATE(self); - NMActStageReturn ret; - NMDeviceStateReason failure_reason = NM_DEVICE_STATE_REASON_NONE; - gs_unref_object NMIP6Config *ip6_config = NULL; - - g_assert(priv->ip_state_6 == NM_DEVICE_IP_STATE_WAIT); + _set_ip_state(self, addr_family, NM_DEVICE_IP_STATE_CONF); - if (nm_device_sys_iface_state_is_external(self)) { - _set_ip_state(self, AF_INET6, NM_DEVICE_IP_STATE_DONE); - check_ip_state(self, FALSE, TRUE); - return TRUE; - } - - _set_ip_state(self, AF_INET6, NM_DEVICE_IP_STATE_CONF); ret = NM_DEVICE_GET_CLASS(self)->act_stage3_ip_config_start(self, - AF_INET6, - (gpointer *) &ip6_config, + addr_family, + (gpointer *) &ip_config, &failure_reason); - if (ret == NM_ACT_STAGE_RETURN_SUCCESS) { - if (!ip6_config) - ip6_config = nm_device_ip6_config_new(self); - /* Here we get a static IPv6 config, like for Shared where it's - * autogenerated or from modems where it comes from ModemManager. - */ - nm_assert(!applied_config_get_current(&priv->ac_ip6_config)); - applied_config_init(&priv->ac_ip6_config, ip6_config); - nm_device_activate_schedule_ip_config_result(self, AF_INET6, NULL); - } else if (ret == NM_ACT_STAGE_RETURN_IP_DONE) { - _set_ip_state(self, AF_INET6, NM_DEVICE_IP_STATE_DONE); + + switch (ret) { + case NM_ACT_STAGE_RETURN_SUCCESS: + if (!IS_IPv4) { + /* Here we get a static IPv6 config, like for Shared where it's + * autogenerated or from modems where it comes from ModemManager. + */ + if (!ip_config) + ip_config = nm_device_ip_config_new(self, addr_family); + nm_assert(!applied_config_get_current(&priv->ac_ip6_config)); + applied_config_init(&priv->ac_ip6_config, ip_config); + ip_config = NULL; + } + nm_device_activate_schedule_ip_config_result(self, addr_family, ip_config); + break; + case NM_ACT_STAGE_RETURN_IP_DONE: + _set_ip_state(self, addr_family, NM_DEVICE_IP_STATE_DONE); check_ip_state(self, FALSE, TRUE); - } else if (ret == NM_ACT_STAGE_RETURN_FAILURE) { + break; + case NM_ACT_STAGE_RETURN_FAILURE: nm_device_state_changed(self, NM_DEVICE_STATE_FAILED, failure_reason); return FALSE; - } else if (ret == NM_ACT_STAGE_RETURN_IP_FAIL) { + case NM_ACT_STAGE_RETURN_IP_FAIL: /* Activation not wanted */ - _set_ip_state(self, AF_INET6, NM_DEVICE_IP_STATE_FAIL); - } else if (ret == NM_ACT_STAGE_RETURN_IP_WAIT) { + _set_ip_state(self, addr_family, NM_DEVICE_IP_STATE_FAIL); + break; + case NM_ACT_STAGE_RETURN_IP_WAIT: /* Wait for something to try IP config again */ - _set_ip_state(self, AF_INET6, NM_DEVICE_IP_STATE_WAIT); - } else + _set_ip_state(self, addr_family, NM_DEVICE_IP_STATE_WAIT); + break; + default: g_assert(ret == NM_ACT_STAGE_RETURN_POSTPONE); + } return TRUE; } @@ -11326,12 +11265,12 @@ activate_stage3_ip_config_start(NMDevice *self) "interface %s not up for IP configuration", nm_device_get_ip_iface(self)); - /* IPv4 */ - if (nm_device_activate_ip4_state_in_wait(self) && !nm_device_activate_stage3_ip4_start(self)) + if (nm_device_activate_ip4_state_in_wait(self) + && !nm_device_activate_stage3_ip_start(self, AF_INET)) return; - /* IPv6 */ - if (nm_device_activate_ip6_state_in_wait(self) && !nm_device_activate_stage3_ip6_start(self)) + if (nm_device_activate_ip6_state_in_wait(self) + && !nm_device_activate_stage3_ip_start(self, AF_INET6)) return; /* Proxy */ @@ -11471,37 +11410,45 @@ act_stage4_ip_config_timeout(NMDevice * self, return NM_ACT_STAGE_RETURN_SUCCESS; } -/* - * nm_device_activate_stage4_ip4_config_timeout - * - * Time out on retrieving the IPv4 config. - * - */ static void -activate_stage4_ip_config_timeout_4(NMDevice *self) +activate_stage4_ip_config_timeout_x(NMDevice *self, int addr_family) { - NMActStageReturn ret = NM_ACT_STAGE_RETURN_FAILURE; NMDeviceStateReason failure_reason = NM_DEVICE_STATE_REASON_NONE; + NMActStageReturn ret; + + ret = + NM_DEVICE_GET_CLASS(self)->act_stage4_ip_config_timeout(self, addr_family, &failure_reason); - ret = NM_DEVICE_GET_CLASS(self)->act_stage4_ip_config_timeout(self, AF_INET, &failure_reason); if (ret == NM_ACT_STAGE_RETURN_POSTPONE) return; - else if (ret == NM_ACT_STAGE_RETURN_FAILURE) { + + if (ret == NM_ACT_STAGE_RETURN_FAILURE) { nm_device_state_changed(self, NM_DEVICE_STATE_FAILED, failure_reason); return; } g_assert(ret == NM_ACT_STAGE_RETURN_SUCCESS); - _set_ip_state(self, AF_INET, NM_DEVICE_IP_STATE_FAIL); - + _set_ip_state(self, addr_family, NM_DEVICE_IP_STATE_FAIL); check_ip_state(self, FALSE, TRUE); } +static void +activate_stage4_ip_config_timeout_4(NMDevice *self) +{ + activate_stage4_ip_config_timeout_x(self, AF_INET); +} + +static void +activate_stage4_ip_config_timeout_6(NMDevice *self) +{ + activate_stage4_ip_config_timeout_x(self, AF_INET6); +} + void nm_device_activate_schedule_ip_config_timeout(NMDevice *self, int addr_family) { NMDevicePrivate *priv; - const gboolean IS_IPv4 = (addr_family == AF_INET); + const int IS_IPv4 = NM_IS_IPv4(addr_family); g_return_if_fail(NM_IS_DEVICE(self)); g_return_if_fail(NM_IN_SET(addr_family, AF_INET, AF_INET6)); @@ -11510,27 +11457,10 @@ nm_device_activate_schedule_ip_config_timeout(NMDevice *self, int addr_family) g_return_if_fail(priv->act_request.obj); - activation_source_schedule(self, activate_stage4_ip_config_timeout_x[IS_IPv4], addr_family); -} - -static void -activate_stage4_ip_config_timeout_6(NMDevice *self) -{ - NMActStageReturn ret = NM_ACT_STAGE_RETURN_FAILURE; - NMDeviceStateReason failure_reason = NM_DEVICE_STATE_REASON_NONE; - - ret = NM_DEVICE_GET_CLASS(self)->act_stage4_ip_config_timeout(self, AF_INET6, &failure_reason); - if (ret == NM_ACT_STAGE_RETURN_POSTPONE) - return; - if (ret == NM_ACT_STAGE_RETURN_FAILURE) { - nm_device_state_changed(self, NM_DEVICE_STATE_FAILED, failure_reason); - return; - } - g_assert(ret == NM_ACT_STAGE_RETURN_SUCCESS); - - _set_ip_state(self, AF_INET6, NM_DEVICE_IP_STATE_FAIL); - - check_ip_state(self, FALSE, TRUE); + activation_source_schedule(self, + IS_IPv4 ? activate_stage4_ip_config_timeout_4 + : activate_stage4_ip_config_timeout_6, + addr_family); } static gboolean @@ -11734,12 +11664,14 @@ nm_device_arp_announce(NMDevice *self) } static void -activate_stage5_ip_config_result_4(NMDevice *self) +activate_stage5_ip_config_result_x(NMDevice *self, int addr_family) { - NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE(self); + const int IS_IPv4 = NM_IS_IPv4(addr_family); + NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE(self); NMActRequest * req; const char * method; int ip_ifindex; + int errsv; gboolean do_announce = FALSE; req = nm_device_get_act_request(self); @@ -11747,6 +11679,8 @@ activate_stage5_ip_config_result_4(NMDevice *self) /* Interface must be IFF_UP before IP config can be applied */ ip_ifindex = nm_device_get_ip_ifindex(self); + g_return_if_fail(ip_ifindex); + if (!nm_platform_link_is_up(nm_device_get_platform(self), ip_ifindex) && !nm_device_sys_iface_state_is_external_or_assume(self)) { nm_platform_link_set_up(nm_device_get_platform(self), ip_ifindex, NULL); @@ -11756,86 +11690,172 @@ activate_stage5_ip_config_result_4(NMDevice *self) nm_device_get_ip_iface(self)); } - if (!ip_config_merge_and_apply(self, AF_INET, TRUE)) { - _LOGD(LOGD_DEVICE | LOGD_IP4, "Activation: Stage 5 of 5 (IPv4 Commit) failed"); - nm_device_ip_method_failed(self, AF_INET, NM_DEVICE_STATE_REASON_CONFIG_FAILED); + if (!ip_config_merge_and_apply(self, addr_family, TRUE)) { + _LOGD(LOGD_DEVICE | LOGD_IPX(IS_IPv4), + "Activation: Stage 5 of 5 (IPv%c Commit) failed", + nm_utils_addr_family_to_char(addr_family)); + nm_device_ip_method_failed(self, addr_family, NM_DEVICE_STATE_REASON_CONFIG_FAILED); return; } - /* Start IPv4 sharing if we need it */ - method = nm_device_get_effective_ip_config_method(self, AF_INET); - if (nm_streq(method, NM_SETTING_IP4_CONFIG_METHOD_SHARED)) { - gs_free_error GError *error = NULL; + if (!IS_IPv4) { + if (priv->dhcp6.mode != NM_NDISC_DHCP_LEVEL_NONE + && priv->ip_state_6 == NM_DEVICE_IP_STATE_CONF) { + if (applied_config_get_current(&priv->dhcp6.ip6_config)) { + /* If IPv6 wasn't the first IP to complete, and DHCP was used, + * then ensure dispatcher scripts get the DHCP lease information. + */ + nm_dispatcher_call_device(NM_DISPATCHER_ACTION_DHCP6_CHANGE, + self, + NULL, + NULL, + NULL, + NULL); + } else { + /* still waiting for first dhcp6 lease. */ + return; + } + } + } - if (!start_sharing(self, priv->ip_config_4, &error)) { - _LOGW(LOGD_SHARING, - "Activation: Stage 5 of 5 (IPv4 Commit) start sharing failed: %s", - error->message); - nm_device_ip_method_failed(self, AF_INET, NM_DEVICE_STATE_REASON_SHARED_START_FAILED); - return; + /* Start IPv4 sharing/IPv6 forwarding if we need it */ + method = nm_device_get_effective_ip_config_method(self, addr_family); + if (IS_IPv4) { + if (nm_streq(method, NM_SETTING_IP4_CONFIG_METHOD_SHARED)) { + gs_free_error GError *error = NULL; + + if (!start_sharing(self, priv->ip_config_4, &error)) { + _LOGW(LOGD_SHARING, + "Activation: Stage 5 of 5 (IPv4 Commit) start sharing failed: %s", + error->message); + nm_device_ip_method_failed(self, + AF_INET, + NM_DEVICE_STATE_REASON_SHARED_START_FAILED); + return; + } + } + } else { + if (nm_streq(method, NM_SETTING_IP6_CONFIG_METHOD_SHARED)) { + if (!nm_platform_sysctl_set( + nm_device_get_platform(self), + NMP_SYSCTL_PATHID_ABSOLUTE("/proc/sys/net/ipv6/conf/all/forwarding"), + "1")) { + errsv = errno; + _LOGE(LOGD_SHARING, + "share: error enabling IPv6 forwarding: (%d) %s", + errsv, + nm_strerror_native(errsv)); + nm_device_ip_method_failed(self, + AF_INET6, + NM_DEVICE_STATE_REASON_SHARED_START_FAILED); + return; + } } } - if (priv->dhcp_data_4.client) { - gs_free_error GError *error = NULL; + if (IS_IPv4) { + if (priv->dhcp_data_4.client) { + gs_free_error GError *error = NULL; - if (!nm_dhcp_client_accept(priv->dhcp_data_4.client, &error)) { - _LOGW(LOGD_DHCP4, - "Activation: Stage 5 of 5 (IPv4 Commit) error accepting lease: %s", - error->message); - nm_device_ip_method_failed(self, AF_INET, NM_DEVICE_STATE_REASON_DHCP_ERROR); - return; + if (!nm_dhcp_client_accept(priv->dhcp_data_4.client, &error)) { + _LOGW(LOGD_DHCP4, + "Activation: Stage 5 of 5 (IPv4 Commit) error accepting lease: %s", + error->message); + nm_device_ip_method_failed(self, AF_INET, NM_DEVICE_STATE_REASON_DHCP_ERROR); + return; + } + } + + /* If IPv4 wasn't the first to complete, and DHCP was used, then ensure + * dispatcher scripts get the DHCP lease information. + */ + if (priv->dhcp_data_4.client && nm_device_activate_ip4_state_in_conf(self) + && (nm_device_get_state(self) > NM_DEVICE_STATE_IP_CONFIG)) { + nm_dispatcher_call_device(NM_DISPATCHER_ACTION_DHCP4_CHANGE, + self, + NULL, + NULL, + NULL, + NULL); } } - /* If IPv4 wasn't the first to complete, and DHCP was used, then ensure - * dispatcher scripts get the DHCP lease information. - */ - if (priv->dhcp_data_4.client && nm_device_activate_ip4_state_in_conf(self) - && (nm_device_get_state(self) > NM_DEVICE_STATE_IP_CONFIG)) { - nm_dispatcher_call_device(NM_DISPATCHER_ACTION_DHCP4_CHANGE, self, NULL, NULL, NULL, NULL); + if (!IS_IPv4) { + /* Check if we have to wait for DAD */ + if (priv->ip_state_6 == NM_DEVICE_IP_STATE_CONF && !priv->dad6_ip6_config) { + if (!priv->carrier && priv->ignore_carrier && get_ip_config_may_fail(self, AF_INET6)) + _LOGI(LOGD_DEVICE | LOGD_IP6, + "IPv6 DAD: carrier missing and ignored, not delaying activation"); + else + priv->dad6_ip6_config = dad6_get_pending_addresses(self); + + if (priv->dad6_ip6_config) { + _LOGD(LOGD_DEVICE | LOGD_IP6, "IPv6 DAD: awaiting termination"); + } else { + _set_ip_state(self, AF_INET6, NM_DEVICE_IP_STATE_DONE); + check_ip_state(self, FALSE, TRUE); + } + } } - /* Send ARP announcements */ + if (IS_IPv4) { + /* Send ARP announcements */ - if (nm_device_is_master(self)) { - CList * iter; - SlaveInfo *info; + if (nm_device_is_master(self)) { + CList * iter; + SlaveInfo *info; - /* Skip announcement if there are no device enslaved, for two reasons: - * 1) the master has a temporary MAC address until the first slave comes - * 2) announcements are going to be dropped anyway without slaves - */ - do_announce = FALSE; + /* Skip announcement if there are no device enslaved, for two reasons: + * 1) the master has a temporary MAC address until the first slave comes + * 2) announcements are going to be dropped anyway without slaves + */ + do_announce = FALSE; - c_list_for_each (iter, &priv->slaves) { - info = c_list_entry(iter, SlaveInfo, lst_slave); - if (info->slave_is_enslaved) { - do_announce = TRUE; - break; + c_list_for_each (iter, &priv->slaves) { + info = c_list_entry(iter, SlaveInfo, lst_slave); + if (info->slave_is_enslaved) { + do_announce = TRUE; + break; + } } - } - } else - do_announce = TRUE; + } else + do_announce = TRUE; - if (do_announce) - nm_device_arp_announce(self); + if (do_announce) + nm_device_arp_announce(self); + } - /* Enter the IP_CHECK state if this is the first method to complete */ - _set_ip_state(self, AF_INET, NM_DEVICE_IP_STATE_DONE); - check_ip_state(self, FALSE, TRUE); + if (IS_IPv4) { + /* Enter the IP_CHECK state if this is the first method to complete */ + _set_ip_state(self, AF_INET, NM_DEVICE_IP_STATE_DONE); + check_ip_state(self, FALSE, TRUE); + } +} + +static void +activate_stage5_ip_config_result_4(NMDevice *self) +{ + activate_stage5_ip_config_result_x(self, AF_INET); } +static void +activate_stage5_ip_config_result_6(NMDevice *self) +{ + activate_stage5_ip_config_result_x(self, AF_INET6); +} + +#define activate_stage5_ip_config_result_x_fcn(addr_family) \ + (NM_IS_IPv4(addr_family) ? activate_stage5_ip_config_result_4 \ + : activate_stage5_ip_config_result_6) + void nm_device_activate_schedule_ip_config_result(NMDevice *self, int addr_family, NMIPConfig *config) { NMDevicePrivate *priv; - const gboolean IS_IPv4 = (addr_family == AF_INET); + const int IS_IPv4 = NM_IS_IPv4(addr_family); g_return_if_fail(NM_IS_DEVICE(self)); - g_return_if_fail(NM_IN_SET(addr_family, AF_INET, AF_INET6)); - g_return_if_fail( - !config || (addr_family == AF_INET && nm_ip_config_get_addr_family(config) == AF_INET)); + g_return_if_fail(!config || (IS_IPv4 && nm_ip_config_get_addr_family(config) == AF_INET)); priv = NM_DEVICE_GET_PRIVATE(self); @@ -11849,13 +11869,15 @@ nm_device_activate_schedule_ip_config_result(NMDevice *self, int addr_family, NM _set_ip_state(self, AF_INET6, NM_DEVICE_IP_STATE_CONF); } - activation_source_schedule(self, activate_stage5_ip_config_result_x[IS_IPv4], addr_family); + activation_source_schedule(self, + activate_stage5_ip_config_result_x_fcn(addr_family), + addr_family); } NMDeviceIPState nm_device_activate_get_ip_state(NMDevice *self, int addr_family) { - const gboolean IS_IPv4 = (addr_family == AF_INET); + const int IS_IPv4 = NM_IS_IPv4(addr_family); g_return_val_if_fail(NM_IS_DEVICE(self), NM_DEVICE_IP_STATE_NONE); g_return_val_if_fail(NM_IN_SET(addr_family, AF_INET, AF_INET6), NM_DEVICE_IP_STATE_NONE); @@ -11930,89 +11952,6 @@ dad6_get_pending_addresses(NMDevice *self) return dad6_config; } -static void -activate_stage5_ip_config_result_6(NMDevice *self) -{ - NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE(self); - NMActRequest * req; - const char * method; - int ip_ifindex; - int errsv; - - req = nm_device_get_act_request(self); - g_assert(req); - - /* Interface must be IFF_UP before IP config can be applied */ - ip_ifindex = nm_device_get_ip_ifindex(self); - g_return_if_fail(ip_ifindex); - - if (!nm_platform_link_is_up(nm_device_get_platform(self), ip_ifindex) - && !nm_device_sys_iface_state_is_external_or_assume(self)) { - nm_platform_link_set_up(nm_device_get_platform(self), ip_ifindex, NULL); - if (!nm_platform_link_is_up(nm_device_get_platform(self), ip_ifindex)) - _LOGW(LOGD_DEVICE, - "interface %s not up for IP configuration", - nm_device_get_ip_iface(self)); - } - - if (ip_config_merge_and_apply(self, AF_INET6, TRUE)) { - if (priv->dhcp6.mode != NM_NDISC_DHCP_LEVEL_NONE - && priv->ip_state_6 == NM_DEVICE_IP_STATE_CONF) { - if (applied_config_get_current(&priv->dhcp6.ip6_config)) { - /* If IPv6 wasn't the first IP to complete, and DHCP was used, - * then ensure dispatcher scripts get the DHCP lease information. - */ - nm_dispatcher_call_device(NM_DISPATCHER_ACTION_DHCP6_CHANGE, - self, - NULL, - NULL, - NULL, - NULL); - } else { - /* still waiting for first dhcp6 lease. */ - return; - } - } - - /* Start IPv6 forwarding if we need it */ - method = nm_device_get_effective_ip_config_method(self, AF_INET6); - if (nm_streq(method, NM_SETTING_IP6_CONFIG_METHOD_SHARED)) { - if (!nm_platform_sysctl_set( - nm_device_get_platform(self), - NMP_SYSCTL_PATHID_ABSOLUTE("/proc/sys/net/ipv6/conf/all/forwarding"), - "1")) { - errsv = errno; - _LOGE(LOGD_SHARING, - "share: error enabling IPv6 forwarding: (%d) %s", - errsv, - nm_strerror_native(errsv)); - nm_device_ip_method_failed(self, - AF_INET6, - NM_DEVICE_STATE_REASON_SHARED_START_FAILED); - } - } - - /* Check if we have to wait for DAD */ - if (priv->ip_state_6 == NM_DEVICE_IP_STATE_CONF && !priv->dad6_ip6_config) { - if (!priv->carrier && priv->ignore_carrier && get_ip_config_may_fail(self, AF_INET6)) - _LOGI(LOGD_DEVICE | LOGD_IP6, - "IPv6 DAD: carrier missing and ignored, not delaying activation"); - else - priv->dad6_ip6_config = dad6_get_pending_addresses(self); - - if (priv->dad6_ip6_config) { - _LOGD(LOGD_DEVICE | LOGD_IP6, "IPv6 DAD: awaiting termination"); - } else { - _set_ip_state(self, AF_INET6, NM_DEVICE_IP_STATE_DONE); - check_ip_state(self, FALSE, TRUE); - } - } - } else { - _LOGW(LOGD_DEVICE | LOGD_IP6, "Activation: Stage 5 of 5 (IPv6 Commit) failed"); - nm_device_ip_method_failed(self, AF_INET6, NM_DEVICE_STATE_REASON_CONFIG_FAILED); - } -} - /*****************************************************************************/ static void @@ -12166,7 +12105,7 @@ static void _cleanup_ip_pre(NMDevice *self, int addr_family, CleanupType cleanup_type) { NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE(self); - const gboolean IS_IPv4 = (addr_family == AF_INET); + const int IS_IPv4 = NM_IS_IPv4(addr_family); _set_ip_state(self, addr_family, NM_DEVICE_IP_STATE_NONE); @@ -12376,7 +12315,7 @@ nm_device_reactivate_ip_config(NMDevice * self, } if (nm_device_get_ip_ifindex(self) > 0 && !ip_config_merge_and_apply(self, addr_family, TRUE)) { - _LOGW(LOGD_IP_from_af(addr_family), + _LOGW(LOGD_IPX(IS_IPv4), "Failed to reapply IPv%c configuration", nm_utils_addr_family_to_char(addr_family)); } @@ -13374,7 +13313,7 @@ nm_device_set_proxy_config(NMDevice *self, const char *pac_url) NMDhcpConfig * nm_device_get_dhcp_config(NMDevice *self, int addr_family) { - const gboolean IS_IPv4 = (addr_family == AF_INET); + const int IS_IPv4 = NM_IS_IPv4(addr_family); g_return_val_if_fail(NM_IS_DEVICE(self), NULL); @@ -13399,7 +13338,7 @@ nm_device_set_ip_config(NMDevice * self, GPtrArray * ip4_dev_route_blacklist) { NMDevicePrivate * priv = NM_DEVICE_GET_PRIVATE(self); - const gboolean IS_IPv4 = (addr_family == AF_INET); + const int IS_IPv4 = NM_IS_IPv4(addr_family); NMIPConfig * old_config; gboolean has_changes = FALSE; gboolean success = TRUE; @@ -13415,7 +13354,7 @@ nm_device_set_ip_config(NMDevice * self, }))); nm_assert(IS_IPv4 || !ip4_dev_route_blacklist); - _LOGD(LOGD_IP_from_af(addr_family), + _LOGD(LOGD_IPX(IS_IPv4), "ip%c-config: update (commit=%d, new-config=%p)", nm_utils_addr_family_to_char(addr_family), commit, @@ -13452,7 +13391,7 @@ nm_device_set_ip_config(NMDevice * self, * this causes a re-read and reset. This should only happen for relevant changes */ nm_ip_config_replace(old_config, new_config, &has_changes); if (has_changes) { - _LOGD(LOGD_IP_from_af(addr_family), + _LOGD(LOGD_IPX(IS_IPv4), "ip%c-config: update IP Config instance (%s)", nm_utils_addr_family_to_char(addr_family), nm_dbus_object_get_path(NM_DBUS_OBJECT(old_config))); @@ -13463,14 +13402,14 @@ nm_device_set_ip_config(NMDevice * self, if (!nm_dbus_object_is_exported(NM_DBUS_OBJECT(new_config))) nm_dbus_object_export(NM_DBUS_OBJECT(new_config)); - _LOGD(LOGD_IP_from_af(addr_family), + _LOGD(LOGD_IPX(IS_IPv4), "ip%c-config: set IP Config instance (%s)", nm_utils_addr_family_to_char(addr_family), nm_dbus_object_get_path(NM_DBUS_OBJECT(new_config))); } else if (old_config /*&& !new_config*/) { has_changes = TRUE; priv->ip_config_x[IS_IPv4] = NULL; - _LOGD(LOGD_IP_from_af(addr_family), + _LOGD(LOGD_IPX(IS_IPv4), "ip%c-config: clear IP Config instance (%s)", nm_utils_addr_family_to_char(addr_family), nm_dbus_object_get_path(NM_DBUS_OBJECT(old_config))); @@ -13588,7 +13527,7 @@ void nm_device_set_dev2_ip_config(NMDevice *self, int addr_family, NMIPConfig *config) { NMDevicePrivate *priv; - const gboolean IS_IPv4 = (addr_family == AF_INET); + const int IS_IPv4 = NM_IS_IPv4(addr_family); g_return_if_fail(NM_IS_DEVICE(self)); g_return_if_fail(NM_IN_SET(addr_family, AF_INET, AF_INET6)); @@ -14138,7 +14077,7 @@ update_ext_ip_config(NMDevice *self, int addr_family, gboolean intersect_configs is_up = nm_platform_link_is_up(nm_device_get_platform(self), ifindex); - if (addr_family == AF_INET) { + if (NM_IS_IPv4(addr_family)) { g_clear_object(&priv->ext_ip_config_4); priv->ext_ip_config_4 = nm_ip4_config_capture(nm_device_get_multi_index(self), nm_device_get_platform(self), @@ -14187,7 +14126,7 @@ update_ext_ip_config(NMDevice *self, int addr_family, gboolean intersect_configs } } else { - nm_assert(addr_family == AF_INET6); + nm_assert(!NM_IS_IPv4(addr_family)); g_clear_object(&priv->ext_ip_config_6); g_clear_object(&priv->ext_ip6_config_captured); @@ -14262,13 +14201,13 @@ update_ip_config(NMDevice *self, int addr_family) nm_assert_addr_family(addr_family); - if (addr_family == AF_INET) + if (NM_IS_IPv4(addr_family)) priv->update_ip_config_completed_v4 = TRUE; else priv->update_ip_config_completed_v6 = TRUE; if (update_ext_ip_config(self, addr_family, TRUE)) { - if (addr_family == AF_INET) { + if (NM_IS_IPv4(addr_family)) { if (priv->ext_ip_config_4) ip_config_merge_and_apply(self, AF_INET, FALSE); } else { @@ -14293,7 +14232,7 @@ static gboolean queued_ip_config_change(NMDevice *self, int addr_family) { NMDevicePrivate *priv; - const gboolean IS_IPv4 = (addr_family == AF_INET); + const int IS_IPv4 = NM_IS_IPv4(addr_family); g_return_val_if_fail(NM_IS_DEVICE(self), G_SOURCE_REMOVE); @@ -14308,7 +14247,8 @@ queued_ip_config_change(NMDevice *self, int addr_family) * update in such case. */ if (priv->activation_source_id_x[IS_IPv4] != 0 - && priv->activation_source_func_x[IS_IPv4] == activate_stage5_ip_config_result_x[IS_IPv4]) + && priv->activation_source_func_x[IS_IPv4] + == activate_stage5_ip_config_result_x_fcn(addr_family)) return G_SOURCE_CONTINUE; priv->queued_ip_config_id_x[IS_IPv4] = 0; diff --git a/src/nm-core-utils.h b/src/nm-core-utils.h index 237574c550..ecbf1ebbff 100644 --- a/src/nm-core-utils.h +++ b/src/nm-core-utils.h @@ -209,7 +209,7 @@ nm_utils_ip6_route_metric_normalize(guint32 metric) static inline guint32 nm_utils_ip_route_metric_normalize(int addr_family, guint32 metric) { - return addr_family == AF_INET6 ? nm_utils_ip6_route_metric_normalize(metric) : metric; + return NM_IS_IPv4(addr_family) ? metric : nm_utils_ip6_route_metric_normalize(metric); } static inline guint32 diff --git a/src/nm-l3-config-data.c b/src/nm-l3-config-data.c index c02cb78cb3..a5c8d52337 100644 --- a/src/nm-l3-config-data.c +++ b/src/nm-l3-config-data.c @@ -587,9 +587,7 @@ _route_valid_6(const NMPlatformIP6Route *r) static gboolean _route_valid(int addr_family, gconstpointer r) { - nm_assert_addr_family(addr_family); - - return addr_family == AF_INET ? _route_valid_4(r) : _route_valid_6(r); + return NM_IS_IPv4(addr_family) ? _route_valid_4(r) : _route_valid_6(r); } static gboolean @@ -1204,8 +1202,7 @@ nm_l3_config_data_add_address_full(NML3ConfigData * self, nm_assert(!obj_new || NMP_OBJECT_GET_ADDR_FAMILY(obj_new) == addr_family); changed = _l3_config_data_add_obj(self->multi_idx, - addr_family == AF_INET ? &self->idx_addresses_4 - : &self->idx_addresses_6, + &self->idx_addresses_x[NM_IS_IPv4(addr_family)], self->ifindex, obj_new, (const NMPlatformObject *) pl_new, @@ -1252,7 +1249,7 @@ nm_l3_config_data_add_route_full(NML3ConfigData * self, else self->has_routes_with_type_local_6_set = FALSE; if (_l3_config_data_add_obj(self->multi_idx, - addr_family == AF_INET ? &self->idx_routes_4 : &self->idx_routes_6, + &self->idx_routes_x[NM_IS_IPv4(addr_family)], self->ifindex, obj_new, (const NMPlatformObject *) pl_new, diff --git a/src/nm-l3-config-data.h b/src/nm-l3-config-data.h index 0da98079de..da9fd93a96 100644 --- a/src/nm-l3-config-data.h +++ b/src/nm-l3-config-data.h @@ -223,21 +223,13 @@ const NMDedupMultiHeadEntry *nm_l3_config_data_lookup_objs(const NML3ConfigData static inline const NMDedupMultiHeadEntry * nm_l3_config_data_lookup_addresses(const NML3ConfigData *self, int addr_family) { - nm_assert_addr_family(addr_family); - - return nm_l3_config_data_lookup_objs(self, - addr_family == AF_INET ? NMP_OBJECT_TYPE_IP4_ADDRESS - : NMP_OBJECT_TYPE_IP6_ADDRESS); + return nm_l3_config_data_lookup_objs(self, NMP_OBJECT_TYPE_IP_ADDRESS(NM_IS_IPv4(addr_family))); } static inline const NMDedupMultiHeadEntry * nm_l3_config_data_lookup_routes(const NML3ConfigData *self, int addr_family) { - nm_assert_addr_family(addr_family); - - return nm_l3_config_data_lookup_objs(self, - addr_family == AF_INET ? NMP_OBJECT_TYPE_IP4_ROUTE - : NMP_OBJECT_TYPE_IP6_ROUTE); + return nm_l3_config_data_lookup_objs(self, NMP_OBJECT_TYPE_IP_ROUTE(NM_IS_IPv4(addr_family))); } #define nm_l3_config_data_iter_obj_for_each(iter, self, obj, type) \ diff --git a/src/nm-l3cfg.c b/src/nm-l3cfg.c index b45084bb7b..359fe8735f 100644 --- a/src/nm-l3cfg.c +++ b/src/nm-l3cfg.c @@ -637,7 +637,7 @@ _l3cfg_externally_removed_objs_track(NML3Cfg *self, const NMPObject *obj, gboole static void _l3cfg_externally_removed_objs_pickup(NML3Cfg *self, int addr_family) { - const gboolean IS_IPv4 = NM_IS_IPv4(addr_family); + const int IS_IPv4 = NM_IS_IPv4(addr_family); NMDedupMultiIter iter; const NMPObject *obj; @@ -3233,7 +3233,7 @@ _l3_commit_one(NML3Cfg * self, gboolean changed_combined_l3cd, const NML3ConfigData *l3cd_old) { - const gboolean IS_IPv4 = NM_IS_IPv4(addr_family); + const int IS_IPv4 = NM_IS_IPv4(addr_family); gs_unref_ptrarray GPtrArray *addresses = NULL; gs_unref_ptrarray GPtrArray *routes = NULL; gs_unref_ptrarray GPtrArray *addresses_prune = NULL; diff --git a/src/nm-logging.h b/src/nm-logging.h index b2251c929d..cfaffa9885 100644 --- a/src/nm-logging.h +++ b/src/nm-logging.h @@ -17,18 +17,6 @@ #define NM_LOG_CONFIG_BACKEND_SYSLOG "syslog" #define NM_LOG_CONFIG_BACKEND_JOURNAL "journal" -static inline NMLogDomain -LOGD_IP_from_af(int addr_family) -{ - switch (addr_family) { - case AF_INET: - return LOGD_IP4; - case AF_INET6: - return LOGD_IP6; - } - g_return_val_if_reached(LOGD_NONE); -} - #define nm_log_err(domain, ...) nm_log(LOGL_ERR, (domain), NULL, NULL, __VA_ARGS__) #define nm_log_warn(domain, ...) nm_log(LOGL_WARN, (domain), NULL, NULL, __VA_ARGS__) #define nm_log_info(domain, ...) nm_log(LOGL_INFO, (domain), NULL, NULL, __VA_ARGS__) diff --git a/src/platform/nm-platform.c b/src/platform/nm-platform.c index ca5080b009..785ebc9d0b 100644 --- a/src/platform/nm-platform.c +++ b/src/platform/nm-platform.c @@ -3740,7 +3740,7 @@ _addr_array_clean_expired(int addr_family, } #endif - if (addr_family == AF_INET6 && NM_FLAGS_HAS(a->n_ifa_flags, IFA_F_TEMPORARY)) { + if (!NM_IS_IPv4(addr_family) && NM_FLAGS_HAS(a->n_ifa_flags, IFA_F_TEMPORARY)) { /* temporary addresses are never added explicitly by NetworkManager but * kernel adds them via mngtempaddr flag. * @@ -3981,7 +3981,7 @@ nm_platform_ip_address_sync(NMPlatform *self, GPtrArray * addresses_prune) { const gint32 now = nm_utils_get_monotonic_timestamp_sec(); - const gboolean IS_IPv4 = NM_IS_IPv4(addr_family); + const int IS_IPv4 = NM_IS_IPv4(addr_family); gs_unref_hashtable GHashTable *known_addresses_idx = NULL; GPtrArray * plat_addresses; GHashTable * known_subnets = NULL; @@ -4330,7 +4330,7 @@ nm_platform_ip_address_get_prune_list(NMPlatform *self, int ifindex, gboolean exclude_ipv6_temporary_addrs) { - const gboolean IS_IPv4 = NM_IS_IPv4(addr_family); + const int IS_IPv4 = NM_IS_IPv4(addr_family); const NMDedupMultiHeadEntry *head_entry; NMPLookup lookup; GPtrArray * result; @@ -4382,10 +4382,7 @@ nm_platform_ip_route_get_prune_list(NMPlatform * self, NM_IP_ROUTE_TABLE_SYNC_MODE_FULL, NM_IP_ROUTE_TABLE_SYNC_MODE_ALL)); - nmp_lookup_init_object(&lookup, - addr_family == AF_INET ? NMP_OBJECT_TYPE_IP4_ROUTE - : NMP_OBJECT_TYPE_IP6_ROUTE, - ifindex); + nmp_lookup_init_object(&lookup, NMP_OBJECT_TYPE_IP_ROUTE(NM_IS_IPv4(addr_family)), ifindex); head_entry = nm_platform_lookup(self, &lookup); if (!head_entry) return NULL; @@ -4441,6 +4438,7 @@ nm_platform_ip_route_sync(NMPlatform *self, GPtrArray * routes_prune, GPtrArray **out_temporary_not_available) { + const int IS_IPv4 = NM_IS_IPv4(addr_family); const NMPlatformVTableRoute *vt; gs_unref_hashtable GHashTable *routes_idx = NULL; const NMPObject * conf_o; @@ -4450,10 +4448,8 @@ nm_platform_ip_route_sync(NMPlatform *self, gboolean success = TRUE; char sbuf1[sizeof(_nm_utils_to_string_buffer)]; char sbuf2[sizeof(_nm_utils_to_string_buffer)]; - const gboolean IS_IPv4 = (addr_family == AF_INET); nm_assert(NM_IS_PLATFORM(self)); - nm_assert(NM_IN_SET(addr_family, AF_INET, AF_INET6)); nm_assert(ifindex > 0); vt = &nm_platform_vtable_route.vx[IS_IPv4]; @@ -4665,9 +4661,9 @@ sync_route_add: prune_o = routes_prune->pdata[i]; - nm_assert((addr_family == AF_INET + nm_assert((NM_IS_IPv4(addr_family) && NMP_OBJECT_GET_TYPE(prune_o) == NMP_OBJECT_TYPE_IP4_ROUTE) - || (addr_family == AF_INET6 + || (!NM_IS_IPv4(addr_family) && NMP_OBJECT_GET_TYPE(prune_o) == NMP_OBJECT_TYPE_IP6_ROUTE)); if (routes_idx && g_hash_table_lookup(routes_idx, prune_o)) @@ -4810,8 +4806,8 @@ _ip_route_add(NMPlatform *self, NMPNlmFlags flags, int addr_family, gconstpointe _LOG3D("route: %-10s IPv%c route: %s", _nmp_nlm_flag_to_string(flags & NMP_NLM_FLAG_FMASK), nm_utils_addr_family_to_char(addr_family), - addr_family == AF_INET ? nm_platform_ip4_route_to_string(route, sbuf, sizeof(sbuf)) - : nm_platform_ip6_route_to_string(route, sbuf, sizeof(sbuf))); + NM_IS_IPv4(addr_family) ? nm_platform_ip4_route_to_string(route, sbuf, sizeof(sbuf)) + : nm_platform_ip6_route_to_string(route, sbuf, sizeof(sbuf))); return klass->ip_route_add(self, flags, addr_family, route); } diff --git a/src/platform/tests/test-common.c b/src/platform/tests/test-common.c index e225f33923..f51c9e06ba 100644 --- a/src/platform/tests/test-common.c +++ b/src/platform/tests/test-common.c @@ -89,7 +89,7 @@ nmtstp_platform_ip6_address_get_all(NMPlatform *self, int ifindex) const NMPlatformIPAddress * nmtstp_platform_ip_address_find(NMPlatform *self, int ifindex, int addr_family, gconstpointer addr) { - const gboolean IS_IPv4 = NM_IS_IPv4(addr_family); + const int IS_IPv4 = NM_IS_IPv4(addr_family); const NMPlatformIPAddress *found = NULL; NMDedupMultiIter iter; const NMPObject * obj; diff --git a/tools/check-config-options.sh b/tools/check-config-options.sh index 7a775955bb..d9d4431ee8 100755 --- a/tools/check-config-options.sh +++ b/tools/check-config-options.sh @@ -18,8 +18,8 @@ get_missing_options() get_src_con_defaults() { - sed -ne 's/.*\<NM_CON_DEFAULT\s*("\([^"]*\)").*/\1/p' $(find "$srcdir/src/" -name \*.c ! -name test\*.c) - sed -ne 's/.*\<NM_CON_DEFAULT_NOP\s*("\([^"]*\)").*/\1/p' $(find "$srcdir/src/" -name \*.c ! -name test\*.c) + sed -n 's/\<NM_CON_DEFAULT/\n\0/gp' $(find "$srcdir/src/" -name \*.c ! -name test\*.c) | + sed -n 's/.*\<NM_CON_DEFAULT\(_NOP\)\?\s*("\([^"]*\)").*/\2/p' } get_man_con_defaults() |