diff options
| author | Michael Biebl <biebl@debian.org> | 2023-02-23 17:11:22 +0100 |
|---|---|---|
| committer | Michael Biebl <biebl@debian.org> | 2023-02-23 17:11:22 +0100 |
| commit | b22a7b55d0bc5a7999dccaeacdde745f5ace9d66 (patch) | |
| tree | 597d2716cfa4b904c98717b874371e0e7b5e0c71 /src/libnm-core-impl | |
| parent | 1372848511cb896b80b51ed1a3e9606bd9816631 (diff) | |
New upstream version 1.42.2 upstream/1.42.2
Diffstat (limited to 'src/libnm-core-impl')
| -rw-r--r-- | src/libnm-core-impl/gen-metadata-nm-settings-libnm-core.xml.in | 8 | ||||
| -rw-r--r-- | src/libnm-core-impl/nm-setting-ip-config.c | 76 | ||||
| -rw-r--r-- | src/libnm-core-impl/nm-setting-ip4-config.c | 9 | ||||
| -rw-r--r-- | src/libnm-core-impl/nm-setting-ip6-config.c | 9 | ||||
| -rw-r--r-- | src/libnm-core-impl/nm-setting-private.h | 1 | ||||
| -rw-r--r-- | src/libnm-core-impl/nm-utils.c | 17 | ||||
| -rw-r--r-- | src/libnm-core-impl/tests/test-general.c | 30 | ||||
| -rw-r--r-- | src/libnm-core-impl/tests/test-setting.c | 10 |
8 files changed, 137 insertions, 23 deletions
diff --git a/src/libnm-core-impl/gen-metadata-nm-settings-libnm-core.xml.in b/src/libnm-core-impl/gen-metadata-nm-settings-libnm-core.xml.in index 3b210b16..a40b8695 100644 --- a/src/libnm-core-impl/gen-metadata-nm-settings-libnm-core.xml.in +++ b/src/libnm-core-impl/gen-metadata-nm-settings-libnm-core.xml.in @@ -1574,6 +1574,10 @@ dbus-type="b" gprop-type="gboolean" /> + <property name="replace-local-rule" + dbus-type="i" + gprop-type="NMTernary" + /> <property name="required-timeout" dbus-type="i" gprop-type="gint" @@ -1705,6 +1709,10 @@ dbus-type="i" gprop-type="gint" /> + <property name="replace-local-rule" + dbus-type="i" + gprop-type="NMTernary" + /> <property name="required-timeout" dbus-type="i" gprop-type="gint" diff --git a/src/libnm-core-impl/nm-setting-ip-config.c b/src/libnm-core-impl/nm-setting-ip-config.c index 3a31848e..5d947e29 100644 --- a/src/libnm-core-impl/nm-setting-ip-config.c +++ b/src/libnm-core-impl/nm-setting-ip-config.c @@ -3999,7 +3999,8 @@ NM_GOBJECT_PROPERTIES_DEFINE(NMSettingIPConfig, PROP_REQUIRED_TIMEOUT, PROP_DHCP_IAID, PROP_DHCP_REJECT_SERVERS, - PROP_AUTO_ROUTE_EXT_GW, ); + PROP_AUTO_ROUTE_EXT_GW, + PROP_REPLACE_LOCAL_RULE, ); G_DEFINE_ABSTRACT_TYPE(NMSettingIPConfig, nm_setting_ip_config, NM_TYPE_SETTING) @@ -5445,6 +5446,22 @@ nm_setting_ip_config_get_auto_route_ext_gw(NMSettingIPConfig *setting) return NM_SETTING_IP_CONFIG_GET_PRIVATE(setting)->auto_route_ext_gw; } +/** + * nm_setting_ip_config_get_replace_local_rule: + * @setting: the #NMSettingIPConfig + * + * Returns: the #NMSettingIPConfig:replace-local-rule property of the setting + * + * Since: 1.44, 1.42.2 + **/ +NMTernary +nm_setting_ip_config_get_replace_local_rule(NMSettingIPConfig *setting) +{ + g_return_val_if_fail(NM_IS_SETTING_IP_CONFIG(setting), NM_TERNARY_DEFAULT); + + return NM_SETTING_IP_CONFIG_GET_PRIVATE(setting)->replace_local_rule; +} + static gboolean verify_label(const char *label) { @@ -6105,6 +6122,13 @@ _nm_sett_info_property_override_create_array_ip_config(int addr_family) .direct_offset = NM_STRUCT_OFFSET_ENSURE_TYPE(int, NMSettingIPConfigPrivate, auto_route_ext_gw)); + _nm_properties_override_gobj( + properties_override, + obj_properties[PROP_REPLACE_LOCAL_RULE], + &nm_sett_info_propert_type_direct_enum, + .direct_offset = + NM_STRUCT_OFFSET_ENSURE_TYPE(int, NMSettingIPConfigPrivate, replace_local_rule)); + return properties_override; } @@ -6702,18 +6726,28 @@ nm_setting_ip_config_class_init(NMSettingIPConfigClass *klass) /** * NMSettingIPConfig:dhcp-iaid: * - * A string containing the "Identity Association Identifier" (IAID) used - * by the DHCP client. The property is a 32-bit decimal value or a - * special value among "mac", "perm-mac", "ifname" and "stable". When - * set to "mac" (or "perm-mac"), the last 4 bytes of the current (or - * permanent) MAC address are used as IAID. When set to "ifname", the - * IAID is computed by hashing the interface name. The special value - * "stable" can be used to generate an IAID based on the stable-id (see - * connection.stable-id), a per-host key and the interface name. When - * the property is unset, the value from global configuration is used; - * if no global default is set then the IAID is assumed to be - * "ifname". Note that at the moment this property is ignored for IPv6 - * by dhclient, which always derives the IAID from the MAC address. + * A string containing the "Identity Association Identifier" (IAID) used by + * the DHCP client. The string can be a 32-bit number (either decimal, + * hexadecimal or or as colon separated hexadecimal numbers). Alternatively + * it can be set to the special values "mac", "perm-mac", "ifname" or + * "stable". When set to "mac" (or "perm-mac"), the last 4 bytes of the + * current (or permanent) MAC address are used as IAID. When set to + * "ifname", the IAID is computed by hashing the interface name. The + * special value "stable" can be used to generate an IAID based on the + * stable-id (see connection.stable-id), a per-host key and the interface + * name. When the property is unset, the value from global configuration is + * used; if no global default is set then the IAID is assumed to be + * "ifname". + * + * For DHCPv4, the IAID is only used with "ipv4.dhcp-client-id" + * values "duid" and "ipv6-duid" to generate the client-id. + * + * For DHCPv6, note that at the moment this property is + * only supported by the "internal" DHCPv6 plugin. The "dhclient" DHCPv6 + * plugin always derives the IAID from the MAC address. + * + * The actually used DHCPv6 IAID for a currently activated interface is + * exposed in the lease information of the device. * * Since: 1.22 **/ @@ -6797,5 +6831,21 @@ nm_setting_ip_config_class_init(NMSettingIPConfigClass *klass) NM_TERNARY_DEFAULT, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); + /** + * NMSettingIPConfig:replace-local-rule: + * + * Connections will default to keep the autogenerated priority 0 local rule + * unless this setting is set to %TRUE. + * + * Since: 1.44, 1.42.2 + */ + obj_properties[PROP_REPLACE_LOCAL_RULE] = + g_param_spec_enum(NM_SETTING_IP_CONFIG_REPLACE_LOCAL_RULE, + "", + "", + NM_TYPE_TERNARY, + NM_TERNARY_DEFAULT, + G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); + g_object_class_install_properties(object_class, _PROPERTY_ENUMS_LAST, obj_properties); } diff --git a/src/libnm-core-impl/nm-setting-ip4-config.c b/src/libnm-core-impl/nm-setting-ip4-config.c index f847918e..83727ea3 100644 --- a/src/libnm-core-impl/nm-setting-ip4-config.c +++ b/src/libnm-core-impl/nm-setting-ip4-config.c @@ -808,6 +808,15 @@ nm_setting_ip4_config_class_init(NMSettingIP4ConfigClass *klass) * ---end--- */ + /* ---ifcfg-rh--- + * property: replace-local-rule + * variable: IPV4_REPLACE_LOCAL_RULE(+) + * default: no + * description: Connections will default to keep the autogenerated priority + * 0 local rule unless this setting is set to %TRUE. + * ---end--- + */ + /** * NMSettingIP4Config:dhcp-client-id: * diff --git a/src/libnm-core-impl/nm-setting-ip6-config.c b/src/libnm-core-impl/nm-setting-ip6-config.c index 43e2e3c7..54f0967c 100644 --- a/src/libnm-core-impl/nm-setting-ip6-config.c +++ b/src/libnm-core-impl/nm-setting-ip6-config.c @@ -752,6 +752,15 @@ nm_setting_ip6_config_class_init(NMSettingIP6ConfigClass *klass) * ---end--- */ + /* ---ifcfg-rh--- + * property: replace-local-rule + * variable: IPV6_REPLACE_LOCAL_RULE(+) + * default: no + * description: Connections will default to keep the autogenerated priority + * 0 local rule unless this setting is set to %TRUE. + * ---end--- + */ + /** * NMSettingIP6Config:ip6-privacy: * diff --git a/src/libnm-core-impl/nm-setting-private.h b/src/libnm-core-impl/nm-setting-private.h index 26a31b1e..fff6c1cc 100644 --- a/src/libnm-core-impl/nm-setting-private.h +++ b/src/libnm-core-impl/nm-setting-private.h @@ -198,6 +198,7 @@ typedef struct { char *dhcp_iaid; gint64 route_metric; int auto_route_ext_gw; + int replace_local_rule; gint32 required_timeout; gint32 dad_timeout; gint32 dhcp_timeout; diff --git a/src/libnm-core-impl/nm-utils.c b/src/libnm-core-impl/nm-utils.c index 8ffc070e..c389213f 100644 --- a/src/libnm-core-impl/nm-utils.c +++ b/src/libnm-core-impl/nm-utils.c @@ -5666,7 +5666,8 @@ _nm_utils_ranges_cmp(_NM_SETT_INFO_PROP_COMPARE_FCN_ARGS _nm_nil) gboolean _nm_utils_iaid_verify(const char *str, gint64 *out_value) { - gint64 iaid; + gint64 i64; + guint32 u32; NM_SET_OUT(out_value, -1); @@ -5676,10 +5677,16 @@ _nm_utils_iaid_verify(const char *str, gint64 *out_value) if (NM_IAID_IS_SPECIAL(str)) return TRUE; - if (NM_STRCHAR_ALL(str, ch, ch >= '0' && ch <= '9') && (str[0] != '0' || str[1] == '\0') - && (iaid = _nm_utils_ascii_str_to_int64(str, 10, 0, G_MAXUINT32, -1)) != -1) { - NM_SET_OUT(out_value, iaid); - return TRUE; + if (NM_STRCHAR_ALL(str, ch, g_ascii_isxdigit(ch) || NM_IN_SET(ch, 'x', ':'))) { + if ((i64 = _nm_utils_ascii_str_to_int64(str, 0, 0, G_MAXUINT32, -1)) != -1) { + NM_SET_OUT(out_value, i64); + return TRUE; + } + + if (nm_dhcp_iaid_from_hexstr(str, &u32)) { + NM_SET_OUT(out_value, u32); + return TRUE; + } } return FALSE; diff --git a/src/libnm-core-impl/tests/test-general.c b/src/libnm-core-impl/tests/test-general.c index f6684bfb..8a98265a 100644 --- a/src/libnm-core-impl/tests/test-general.c +++ b/src/libnm-core-impl/tests/test-general.c @@ -4014,6 +4014,7 @@ test_connection_diff_a_only(void) {NM_SETTING_IP_CONFIG_DHCP_REJECT_SERVERS, NM_SETTING_DIFF_RESULT_IN_A}, {NM_SETTING_IP4_CONFIG_LINK_LOCAL, NM_SETTING_DIFF_RESULT_IN_A}, {NM_SETTING_IP_CONFIG_AUTO_ROUTE_EXT_GW, NM_SETTING_DIFF_RESULT_IN_A}, + {NM_SETTING_IP_CONFIG_REPLACE_LOCAL_RULE, NM_SETTING_DIFF_RESULT_IN_A}, {NULL, NM_SETTING_DIFF_RESULT_UNKNOWN}, }}, }; @@ -11352,6 +11353,34 @@ test_dnsname(void) /*****************************************************************************/ +static void +test_dhcp_iaid_hexstr(void) +{ + char str[NM_DHCP_IAID_TO_HEXSTR_BUF_LEN]; + int i; + + for (i = 0; i < 10; i++) { + guint32 iaid = nmtst_get_rand_uint32(); + guint32 iaid2; + char *s; + gboolean r; + + s = nm_dhcp_iaid_to_hexstr(iaid, str); + g_assert(s == str); + g_assert(strlen(s) < sizeof(str)); + + r = nm_dhcp_iaid_from_hexstr(str, &iaid2); + g_assert(r); + g_assert_cmpint(iaid, ==, iaid2); + } + + g_assert_cmpstr(nm_dhcp_iaid_to_hexstr(0, str), ==, "00:00:00:00"); + g_assert_cmpstr(nm_dhcp_iaid_to_hexstr(1, str), ==, "00:00:00:01"); + g_assert_cmpstr(nm_dhcp_iaid_to_hexstr(0x01002044, str), ==, "01:00:20:44"); +} + +/*****************************************************************************/ + NMTST_DEFINE(); int @@ -11699,6 +11728,7 @@ main(int argc, char **argv) g_test_add_func("/core/general/test_direct_string_is_refstr", test_direct_string_is_refstr); g_test_add_func("/core/general/test_connection_path", test_connection_path); g_test_add_func("/core/general/test_dnsname", test_dnsname); + g_test_add_func("/core/general/test_dhcp_iaid_hexstr", test_dhcp_iaid_hexstr); return g_test_run(); } diff --git a/src/libnm-core-impl/tests/test-setting.c b/src/libnm-core-impl/tests/test-setting.c index de60afd1..09e0fc70 100644 --- a/src/libnm-core-impl/tests/test-setting.c +++ b/src/libnm-core-impl/tests/test-setting.c @@ -975,25 +975,25 @@ test_dcb_flags_invalid(void) s_dcb = (NMSettingDcb *) nm_setting_dcb_new(); g_assert(s_dcb); - NMTST_EXPECT("GLib-GObject", G_LOG_LEVEL_WARNING, "*invalid or out of range*"); + NMTST_EXPECT("GLib-GObject", NMTST_EXPECT_GOBJECT_ASSERT_LEVEL, "*invalid or out of range*"); TEST_FLAG(NM_SETTING_DCB_APP_FCOE_FLAGS, nm_setting_dcb_get_app_fcoe_flags, 0x332523); g_test_assert_expected_messages(); - NMTST_EXPECT("GLib-GObject", G_LOG_LEVEL_WARNING, "*invalid or out of range*"); + NMTST_EXPECT("GLib-GObject", NMTST_EXPECT_GOBJECT_ASSERT_LEVEL, "*invalid or out of range*"); TEST_FLAG(NM_SETTING_DCB_APP_ISCSI_FLAGS, nm_setting_dcb_get_app_iscsi_flags, 0xFF); g_test_assert_expected_messages(); - NMTST_EXPECT("GLib-GObject", G_LOG_LEVEL_WARNING, "*invalid or out of range*"); + NMTST_EXPECT("GLib-GObject", NMTST_EXPECT_GOBJECT_ASSERT_LEVEL, "*invalid or out of range*"); TEST_FLAG(NM_SETTING_DCB_APP_FIP_FLAGS, nm_setting_dcb_get_app_fip_flags, 0x1111); g_test_assert_expected_messages(); - NMTST_EXPECT("GLib-GObject", G_LOG_LEVEL_WARNING, "*invalid or out of range*"); + NMTST_EXPECT("GLib-GObject", NMTST_EXPECT_GOBJECT_ASSERT_LEVEL, "*invalid or out of range*"); TEST_FLAG(NM_SETTING_DCB_PRIORITY_FLOW_CONTROL_FLAGS, nm_setting_dcb_get_priority_flow_control_flags, G_MAXUINT32); g_test_assert_expected_messages(); - NMTST_EXPECT("GLib-GObject", G_LOG_LEVEL_WARNING, "*invalid or out of range*"); + NMTST_EXPECT("GLib-GObject", NMTST_EXPECT_GOBJECT_ASSERT_LEVEL, "*invalid or out of range*"); TEST_FLAG( NM_SETTING_DCB_PRIORITY_GROUP_FLAGS, nm_setting_dcb_get_priority_group_flags, |