core/connection: ensure wired settings are around for bridges
Bridges are wired ethernet bridges, it makes sense for them to have wired ethernet settings. Ensuring they always exist makes reapplying the MTU changes more convenient. The MTU for bridges is taken from wired settings, making it impossible to change and reapply it for connections that lack them (as reapply doesn't really cope well with addition and removal of settings). https://bugzilla.redhat.com/show_bug.cgi?id=2076131 https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1208
This commit is contained in:
@@ -1924,6 +1924,7 @@ test_write_bridge_main(void)
|
|||||||
gs_unref_object NMConnection *connection = NULL;
|
gs_unref_object NMConnection *connection = NULL;
|
||||||
NMSettingConnection *s_con;
|
NMSettingConnection *s_con;
|
||||||
NMSettingBridge *s_bridge;
|
NMSettingBridge *s_bridge;
|
||||||
|
NMSettingWired *s_wired;
|
||||||
NMSettingIPConfig *s_ip4;
|
NMSettingIPConfig *s_ip4;
|
||||||
NMSettingIPConfig *s_ip6;
|
NMSettingIPConfig *s_ip6;
|
||||||
|
|
||||||
@@ -1953,6 +1954,11 @@ test_write_bridge_main(void)
|
|||||||
g_assert(s_bridge);
|
g_assert(s_bridge);
|
||||||
nm_connection_add_setting(connection, NM_SETTING(s_bridge));
|
nm_connection_add_setting(connection, NM_SETTING(s_bridge));
|
||||||
|
|
||||||
|
/* Ethernet setting */
|
||||||
|
s_wired = (NMSettingWired *) nm_setting_wired_new();
|
||||||
|
g_assert(s_wired);
|
||||||
|
nm_connection_add_setting(connection, NM_SETTING(s_wired));
|
||||||
|
|
||||||
/* IP4 setting */
|
/* IP4 setting */
|
||||||
s_ip4 = (NMSettingIPConfig *) nm_setting_ip4_config_new();
|
s_ip4 = (NMSettingIPConfig *) nm_setting_ip4_config_new();
|
||||||
g_assert(s_ip4);
|
g_assert(s_ip4);
|
||||||
|
@@ -1708,7 +1708,7 @@ _normalize_required_settings(NMConnection *self)
|
|||||||
NMSetting *s_bridge;
|
NMSetting *s_bridge;
|
||||||
gboolean changed = FALSE;
|
gboolean changed = FALSE;
|
||||||
|
|
||||||
if (nm_connection_get_setting_vlan(self)) {
|
if (nm_connection_get_setting_vlan(self) || nm_connection_get_setting_bridge(self)) {
|
||||||
if (!nm_connection_get_setting_wired(self)) {
|
if (!nm_connection_get_setting_wired(self)) {
|
||||||
nm_connection_add_setting(self, nm_setting_wired_new());
|
nm_connection_add_setting(self, nm_setting_wired_new());
|
||||||
changed = TRUE;
|
changed = TRUE;
|
||||||
|
@@ -1311,6 +1311,15 @@ verify(NMSetting *setting, NMConnection *connection, GError **error)
|
|||||||
NM_SETTING_BRIDGE_VLANS))
|
NM_SETTING_BRIDGE_VLANS))
|
||||||
return NM_SETTING_VERIFY_NORMALIZABLE;
|
return NM_SETTING_VERIFY_NORMALIZABLE;
|
||||||
|
|
||||||
|
if (connection && !nm_connection_get_setting_wired(connection)) {
|
||||||
|
g_set_error_literal(error,
|
||||||
|
NM_CONNECTION_ERROR,
|
||||||
|
NM_CONNECTION_ERROR_SETTING_NOT_FOUND,
|
||||||
|
_("bridge connection should have a ethernet setting as well"));
|
||||||
|
g_prefix_error(error, "%s: ", NM_SETTING_BRIDGE_SETTING_NAME);
|
||||||
|
return NM_SETTING_VERIFY_NORMALIZABLE;
|
||||||
|
}
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user