summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBeniamino Galvani <bgalvani@redhat.com>2015-10-02 10:28:05 +0200
committerBeniamino Galvani <bgalvani@redhat.com>2015-10-02 15:11:06 +0200
commite0b93c29257b3ba00a79fb78a1b9be183352de46 (patch)
tree6c52c52e18aaa7faa44ca1ebeae2b81ce53d56cb
parent45a7b90f3dd0bb1badc0afb4dd5e15fb44df29e3 (diff)
downloadNetworkManager-e0b93c29257b3ba00a79fb78a1b9be183352de46.tar.gz
core,libnm-core: accept a default value for macvlan.mode
Allow the definition of a macvlan.mode default value from configuration file.
-rw-r--r--libnm-core/nm-setting-macvlan.c2
-rw-r--r--libnm-core/nm-setting-macvlan.h9
-rw-r--r--man/NetworkManager.conf.xml.in4
-rw-r--r--src/devices/nm-device-macvlan.c32
4 files changed, 40 insertions, 7 deletions
diff --git a/libnm-core/nm-setting-macvlan.c b/libnm-core/nm-setting-macvlan.c
index 4b6ba59431..f13013eeba 100644
--- a/libnm-core/nm-setting-macvlan.c
+++ b/libnm-core/nm-setting-macvlan.c
@@ -92,7 +92,7 @@ nm_setting_macvlan_get_parent (NMSettingMacvlan *setting)
NMSettingMacvlanMode
nm_setting_macvlan_get_mode (NMSettingMacvlan *setting)
{
- g_return_val_if_fail (NM_IS_SETTING_MACVLAN (setting), NM_SETTING_MACVLAN_MODE_VEPA);
+ g_return_val_if_fail (NM_IS_SETTING_MACVLAN (setting), NM_SETTING_MACVLAN_MODE_DEFAULT);
return NM_SETTING_MACVLAN_GET_PRIVATE (setting)->mode;
}
diff --git a/libnm-core/nm-setting-macvlan.h b/libnm-core/nm-setting-macvlan.h
index d4a1a10d10..b963f48cd3 100644
--- a/libnm-core/nm-setting-macvlan.h
+++ b/libnm-core/nm-setting-macvlan.h
@@ -57,10 +57,11 @@ typedef struct {
* NMSettingMacvlanMode:
**/
typedef enum {
- NM_SETTING_MACVLAN_MODE_VEPA = 0,
- NM_SETTING_MACVLAN_MODE_BRIDGE = 1,
- NM_SETTING_MACVLAN_MODE_PRIVATE = 2,
- NM_SETTING_MACVLAN_MODE_PASSTHRU = 3,
+ NM_SETTING_MACVLAN_MODE_DEFAULT = 0,
+ NM_SETTING_MACVLAN_MODE_VEPA = 1,
+ NM_SETTING_MACVLAN_MODE_BRIDGE = 2,
+ NM_SETTING_MACVLAN_MODE_PRIVATE = 3,
+ NM_SETTING_MACVLAN_MODE_PASSTHRU = 4,
_NM_SETTING_MACVLAN_MODE_NUM, /*< skip >*/
NM_SETTING_MACVLAN_MODE_LAST = _NM_SETTING_MACVLAN_MODE_NUM - 1, /*< skip >*/
} NMSettingMacvlanMode;
diff --git a/man/NetworkManager.conf.xml.in b/man/NetworkManager.conf.xml.in
index a8b7f3a38d..2444bb0a5d 100644
--- a/man/NetworkManager.conf.xml.in
+++ b/man/NetworkManager.conf.xml.in
@@ -594,6 +594,10 @@ ipv6.ip6-privacy=1
<term><varname>vpn.timeout</varname></term>
<listitem><para>If left unspecified, default value of 60 seconds is used.</para></listitem>
</varlistentry>
+ <varlistentry>
+ <term><varname>macvlan.mode/varname></term>
+ <listitem><para>If left unspecified, VEPA mode is used.</para></listitem>
+ </varlistentry>
</para>
</refsect1>
diff --git a/src/devices/nm-device-macvlan.c b/src/devices/nm-device-macvlan.c
index 5ad81394a7..4a3ef7ca54 100644
--- a/src/devices/nm-device-macvlan.c
+++ b/src/devices/nm-device-macvlan.c
@@ -34,6 +34,8 @@
#include "nm-setting-wired.h"
#include "nm-active-connection.h"
#include "nm-ip4-config.h"
+#include "nm-config.h"
+#include "nm-core-internal.h"
#include "nm-utils.h"
#include "nmdbus-device-macvlan.h"
@@ -228,6 +230,32 @@ realize (NMDevice *device, NMPlatformLink *plink, GError **error)
return TRUE;
}
+static NMSettingMacvlanMode
+get_setting_macvlan_mode (NMDevice *device, NMSettingMacvlan *s_macvlan)
+{
+ NMSettingMacvlanMode mode;
+ gs_free char *value = NULL;
+
+ mode = nm_setting_macvlan_get_mode (s_macvlan);
+ if ( mode > NM_SETTING_MACVLAN_MODE_DEFAULT
+ && mode <= NM_SETTING_MACVLAN_MODE_LAST)
+ return mode;
+
+ value = nm_config_data_get_connection_default (NM_CONFIG_GET_DATA,
+ "macvlan.mode",
+ device);
+ if (value) {
+ mode = _nm_utils_ascii_str_to_int64 (value, 10,
+ NM_SETTING_MACVLAN_MODE_DEFAULT,
+ NM_SETTING_MACVLAN_MODE_LAST,
+ NM_SETTING_MACVLAN_MODE_DEFAULT);
+ if (mode != NM_SETTING_MACVLAN_MODE_DEFAULT)
+ return mode;
+ }
+
+ return NM_SETTING_MACVLAN_MODE_VEPA;
+}
+
static gboolean
create_and_realize (NMDevice *device,
NMConnection *connection,
@@ -248,7 +276,7 @@ create_and_realize (NMDevice *device,
parent_ifindex = nm_device_get_ifindex (parent);
g_warn_if_fail (parent_ifindex > 0);
- mode = setting_mode_to_platform (nm_setting_macvlan_get_mode (s_macvlan));
+ mode = setting_mode_to_platform (get_setting_macvlan_mode (device, s_macvlan));
plerr = nm_platform_macvlan_add (NM_PLATFORM_GET, iface, parent_ifindex, mode, out_plink);
if (plerr != NM_PLATFORM_ERROR_SUCCESS && plerr != NM_PLATFORM_ERROR_EXISTS) {
@@ -399,7 +427,7 @@ check_connection_compatible (NMDevice *device, NMConnection *connection)
if (!s_macvlan)
return FALSE;
- if (setting_mode_to_platform (nm_setting_macvlan_get_mode (s_macvlan)) != priv->props.mode)
+ if (setting_mode_to_platform (get_setting_macvlan_mode (device, s_macvlan)) != priv->props.mode)
return FALSE;
/* Check parent interface; could be an interface name or a UUID */