mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-05-07 10:48:12 +02:00
merge: allow overriding MTU for team devices (rh #1255927)
https://bugzilla.redhat.com/show_bug.cgi?id=1255927
(cherry picked from commit 4207671ecd)
This commit is contained in:
commit
0dee0d415f
2 changed files with 62 additions and 27 deletions
|
|
@ -40,6 +40,7 @@
|
||||||
#include "nm-enum-types.h"
|
#include "nm-enum-types.h"
|
||||||
#include "nm-team-enum-types.h"
|
#include "nm-team-enum-types.h"
|
||||||
#include "nm-core-internal.h"
|
#include "nm-core-internal.h"
|
||||||
|
#include "nm-ip4-config.h"
|
||||||
#include "gsystem-local-alloc.h"
|
#include "gsystem-local-alloc.h"
|
||||||
|
|
||||||
#include "nm-device-team-glue.h"
|
#include "nm-device-team-glue.h"
|
||||||
|
|
@ -564,6 +565,25 @@ act_stage1_prepare (NMDevice *device, NMDeviceStateReason *reason)
|
||||||
NM_ACT_STAGE_RETURN_POSTPONE : NM_ACT_STAGE_RETURN_FAILURE;
|
NM_ACT_STAGE_RETURN_POSTPONE : NM_ACT_STAGE_RETURN_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
ip4_config_pre_commit (NMDevice *self, NMIP4Config *config)
|
||||||
|
{
|
||||||
|
NMConnection *connection;
|
||||||
|
NMSettingWired *s_wired;
|
||||||
|
guint32 mtu;
|
||||||
|
|
||||||
|
connection = nm_device_get_connection (self);
|
||||||
|
g_assert (connection);
|
||||||
|
s_wired = nm_connection_get_setting_wired (connection);
|
||||||
|
|
||||||
|
if (s_wired) {
|
||||||
|
/* MTU override */
|
||||||
|
mtu = nm_setting_wired_get_mtu (s_wired);
|
||||||
|
if (mtu)
|
||||||
|
nm_ip4_config_set_mtu (config, mtu, NM_IP_CONFIG_SOURCE_USER);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
deactivate (NMDevice *device)
|
deactivate (NMDevice *device)
|
||||||
{
|
{
|
||||||
|
|
@ -813,6 +833,7 @@ nm_device_team_class_init (NMDeviceTeamClass *klass)
|
||||||
parent_class->master_update_slave_connection = master_update_slave_connection;
|
parent_class->master_update_slave_connection = master_update_slave_connection;
|
||||||
|
|
||||||
parent_class->act_stage1_prepare = act_stage1_prepare;
|
parent_class->act_stage1_prepare = act_stage1_prepare;
|
||||||
|
parent_class->ip4_config_pre_commit = ip4_config_pre_commit;
|
||||||
parent_class->deactivate = deactivate;
|
parent_class->deactivate = deactivate;
|
||||||
parent_class->enslave_slave = enslave_slave;
|
parent_class->enslave_slave = enslave_slave;
|
||||||
parent_class->release_slave = release_slave;
|
parent_class->release_slave = release_slave;
|
||||||
|
|
|
||||||
|
|
@ -1193,12 +1193,43 @@ vlan_priority_maplist_to_stringlist (NMSettingVlan *s_vlan, NMVlanPriorityMap ma
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static gboolean
|
||||||
|
write_wired_for_virtual (NMConnection *connection, shvarFile *ifcfg)
|
||||||
|
{
|
||||||
|
NMSettingWired *s_wired;
|
||||||
|
gboolean has_wired = FALSE;
|
||||||
|
|
||||||
|
s_wired = nm_connection_get_setting_wired (connection);
|
||||||
|
if (s_wired) {
|
||||||
|
const char *device_mac, *cloned_mac;
|
||||||
|
char *tmp;
|
||||||
|
guint32 mtu;
|
||||||
|
|
||||||
|
has_wired = TRUE;
|
||||||
|
|
||||||
|
device_mac = nm_setting_wired_get_mac_address (s_wired);
|
||||||
|
if (device_mac)
|
||||||
|
svSetValue (ifcfg, "HWADDR", device_mac, FALSE);
|
||||||
|
|
||||||
|
cloned_mac = nm_setting_wired_get_cloned_mac_address (s_wired);
|
||||||
|
if (cloned_mac)
|
||||||
|
svSetValue (ifcfg, "MACADDR", cloned_mac, FALSE);
|
||||||
|
|
||||||
|
mtu = nm_setting_wired_get_mtu (s_wired);
|
||||||
|
if (mtu) {
|
||||||
|
tmp = g_strdup_printf ("%u", mtu);
|
||||||
|
svSetValue (ifcfg, "MTU", tmp, FALSE);
|
||||||
|
g_free (tmp);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return has_wired;
|
||||||
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
write_vlan_setting (NMConnection *connection, shvarFile *ifcfg, gboolean *wired, GError **error)
|
write_vlan_setting (NMConnection *connection, shvarFile *ifcfg, gboolean *wired, GError **error)
|
||||||
{
|
{
|
||||||
NMSettingVlan *s_vlan;
|
NMSettingVlan *s_vlan;
|
||||||
NMSettingConnection *s_con;
|
NMSettingConnection *s_con;
|
||||||
NMSettingWired *s_wired;
|
|
||||||
char *tmp;
|
char *tmp;
|
||||||
guint32 vlan_flags = 0;
|
guint32 vlan_flags = 0;
|
||||||
|
|
||||||
|
|
@ -1252,34 +1283,13 @@ write_vlan_setting (NMConnection *connection, shvarFile *ifcfg, gboolean *wired,
|
||||||
svSetValue (ifcfg, "MACADDR", NULL, FALSE);
|
svSetValue (ifcfg, "MACADDR", NULL, FALSE);
|
||||||
svSetValue (ifcfg, "MTU", NULL, FALSE);
|
svSetValue (ifcfg, "MTU", NULL, FALSE);
|
||||||
|
|
||||||
s_wired = nm_connection_get_setting_wired (connection);
|
*wired = write_wired_for_virtual (connection, ifcfg);
|
||||||
if (s_wired) {
|
|
||||||
const char *device_mac, *cloned_mac;
|
|
||||||
guint32 mtu;
|
|
||||||
|
|
||||||
*wired = TRUE;
|
|
||||||
|
|
||||||
device_mac = nm_setting_wired_get_mac_address (s_wired);
|
|
||||||
if (device_mac)
|
|
||||||
svSetValue (ifcfg, "HWADDR", device_mac, FALSE);
|
|
||||||
|
|
||||||
cloned_mac = nm_setting_wired_get_cloned_mac_address (s_wired);
|
|
||||||
if (cloned_mac)
|
|
||||||
svSetValue (ifcfg, "MACADDR", cloned_mac, FALSE);
|
|
||||||
|
|
||||||
mtu = nm_setting_wired_get_mtu (s_wired);
|
|
||||||
if (mtu) {
|
|
||||||
tmp = g_strdup_printf ("%u", mtu);
|
|
||||||
svSetValue (ifcfg, "MTU", tmp, FALSE);
|
|
||||||
g_free (tmp);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
write_bonding_setting (NMConnection *connection, shvarFile *ifcfg, GError **error)
|
write_bonding_setting (NMConnection *connection, shvarFile *ifcfg, gboolean *wired, GError **error)
|
||||||
{
|
{
|
||||||
NMSettingBond *s_bond;
|
NMSettingBond *s_bond;
|
||||||
const char *iface;
|
const char *iface;
|
||||||
|
|
@ -1327,11 +1337,13 @@ write_bonding_setting (NMConnection *connection, shvarFile *ifcfg, GError **erro
|
||||||
svSetValue (ifcfg, "TYPE", TYPE_BOND, FALSE);
|
svSetValue (ifcfg, "TYPE", TYPE_BOND, FALSE);
|
||||||
svSetValue (ifcfg, "BONDING_MASTER", "yes", FALSE);
|
svSetValue (ifcfg, "BONDING_MASTER", "yes", FALSE);
|
||||||
|
|
||||||
|
*wired = write_wired_for_virtual (connection, ifcfg);
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
write_team_setting (NMConnection *connection, shvarFile *ifcfg, GError **error)
|
write_team_setting (NMConnection *connection, shvarFile *ifcfg, gboolean *wired, GError **error)
|
||||||
{
|
{
|
||||||
NMSettingTeam *s_team;
|
NMSettingTeam *s_team;
|
||||||
const char *iface;
|
const char *iface;
|
||||||
|
|
@ -1356,6 +1368,8 @@ write_team_setting (NMConnection *connection, shvarFile *ifcfg, GError **error)
|
||||||
svSetValue (ifcfg, "TEAM_CONFIG", config, FALSE);
|
svSetValue (ifcfg, "TEAM_CONFIG", config, FALSE);
|
||||||
svSetValue (ifcfg, "DEVICETYPE", TYPE_TEAM, FALSE);
|
svSetValue (ifcfg, "DEVICETYPE", TYPE_TEAM, FALSE);
|
||||||
|
|
||||||
|
*wired = write_wired_for_virtual (connection, ifcfg);
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -2610,10 +2624,10 @@ write_connection (NMConnection *connection,
|
||||||
if (!write_infiniband_setting (connection, ifcfg, error))
|
if (!write_infiniband_setting (connection, ifcfg, error))
|
||||||
goto out;
|
goto out;
|
||||||
} else if (!strcmp (type, NM_SETTING_BOND_SETTING_NAME)) {
|
} else if (!strcmp (type, NM_SETTING_BOND_SETTING_NAME)) {
|
||||||
if (!write_bonding_setting (connection, ifcfg, error))
|
if (!write_bonding_setting (connection, ifcfg, &wired, error))
|
||||||
goto out;
|
goto out;
|
||||||
} else if (!strcmp (type, NM_SETTING_TEAM_SETTING_NAME)) {
|
} else if (!strcmp (type, NM_SETTING_TEAM_SETTING_NAME)) {
|
||||||
if (!write_team_setting (connection, ifcfg, error))
|
if (!write_team_setting (connection, ifcfg, &wired, error))
|
||||||
goto out;
|
goto out;
|
||||||
} else if (!strcmp (type, NM_SETTING_BRIDGE_SETTING_NAME)) {
|
} else if (!strcmp (type, NM_SETTING_BRIDGE_SETTING_NAME)) {
|
||||||
if (!write_bridge_setting (connection, ifcfg, error))
|
if (!write_bridge_setting (connection, ifcfg, error))
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue