diff options
Diffstat (limited to 'libnm-core')
| -rw-r--r-- | libnm-core/Makefile.am | 9 | ||||
| -rw-r--r-- | libnm-core/Makefile.in | 14 | ||||
| -rw-r--r-- | libnm-core/nm-core-enum-types.c | 21 | ||||
| -rw-r--r-- | libnm-core/nm-core-enum-types.h | 2 | ||||
| -rw-r--r-- | libnm-core/nm-core-internal.h | 12 | ||||
| -rw-r--r-- | libnm-core/nm-dbus-interface.h | 47 | ||||
| -rw-r--r-- | libnm-core/nm-setting-bond.c | 197 | ||||
| -rw-r--r-- | libnm-core/nm-setting-bond.h | 42 | ||||
| -rw-r--r-- | libnm-core/nm-setting-bridge.c | 2 | ||||
| -rw-r--r-- | libnm-core/nm-setting-infiniband.c | 2 | ||||
| -rw-r--r-- | libnm-core/nm-setting-ip-config.c | 1 | ||||
| -rw-r--r-- | libnm-core/nm-setting-ip-config.h | 1 | ||||
| -rw-r--r-- | libnm-core/nm-setting-macvlan.c | 3 | ||||
| -rw-r--r-- | libnm-core/nm-setting-wired.c | 4 | ||||
| -rw-r--r-- | libnm-core/nm-setting-wireless.c | 4 | ||||
| -rw-r--r-- | libnm-core/nm-utils.c | 5 | ||||
| -rw-r--r-- | libnm-core/nm-version.h | 14 | ||||
| -rw-r--r-- | libnm-core/nm-vpn-dbus-interface.h | 8 | ||||
| -rw-r--r-- | libnm-core/tests/Makefile.am | 2 | ||||
| -rw-r--r-- | libnm-core/tests/Makefile.in | 25 | ||||
| -rw-r--r-- | libnm-core/tests/test-setting-bond.c | 198 |
21 files changed, 492 insertions, 121 deletions
diff --git a/libnm-core/Makefile.am b/libnm-core/Makefile.am index 527a1c24..23aa042d 100644 --- a/libnm-core/Makefile.am +++ b/libnm-core/Makefile.am @@ -1,5 +1,7 @@ include $(GLIB_MAKEFILE) +@GNOME_CODE_COVERAGE_RULES@ + SUBDIRS = . tests AM_CPPFLAGS = \ @@ -10,8 +12,8 @@ AM_CPPFLAGS = \ -DNMCONFDIR=\"$(nmconfdir)\" \ -DNMLIBDIR=\"$(nmlibdir)\" \ -DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_LIB \ - -DNM_VERSION_MAX_ALLOWED=NM_VERSION_NEXT_STABLE \ - $(GLIB_CFLAGS) + $(GLIB_CFLAGS) \ + $(CODE_COVERAGE_CFLAGS) noinst_LTLIBRARIES = libnm-core.la @@ -35,6 +37,9 @@ libnm_core_la_LIBADD = \ $(GLIB_LIBS) \ $(UUID_LIBS) +libnm_core_la_LDFLAGS = \ + $(CODE_COVERAGE_LDFLAGS) + if WITH_GNUTLS AM_CPPFLAGS += $(GNUTLS_CFLAGS) libnm_core_la_SOURCES += crypto_gnutls.c diff --git a/libnm-core/Makefile.in b/libnm-core/Makefile.in index 0661fc1e..62f1275f 100644 --- a/libnm-core/Makefile.in +++ b/libnm-core/Makefile.in @@ -188,6 +188,9 @@ AM_V_lt = $(am__v_lt_@AM_V@) am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@) am__v_lt_0 = --silent am__v_lt_1 = +libnm_core_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ + $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ + $(libnm_core_la_LDFLAGS) $(LDFLAGS) -o $@ AM_V_P = $(am__v_P_@AM_V@) am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) am__v_P_0 = false @@ -590,8 +593,8 @@ AM_CPPFLAGS = -I${top_srcdir}/shared -I${top_builddir}/shared \ -DG_LOG_DOMAIN=\""libnm"\" -DLOCALEDIR=\"$(datadir)/locale\" \ -DNMCONFDIR=\"$(nmconfdir)\" -DNMLIBDIR=\"$(nmlibdir)\" \ -DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_LIB \ - -DNM_VERSION_MAX_ALLOWED=NM_VERSION_NEXT_STABLE $(GLIB_CFLAGS) \ - $(am__append_1) $(am__append_4) + $(GLIB_CFLAGS) $(CODE_COVERAGE_CFLAGS) $(am__append_1) \ + $(am__append_4) noinst_LTLIBRARIES = libnm-core.la core = $(top_srcdir)/libnm-core core_build = $(top_builddir)/libnm-core @@ -714,6 +717,9 @@ GLIB_MKENUMS_H_FLAGS = --identifier-prefix NM GLIB_MKENUMS_C_FLAGS = --identifier-prefix NM libnm_core_la_LIBADD = $(GLIB_LIBS) $(UUID_LIBS) $(am__append_3) \ $(am__append_6) +libnm_core_la_LDFLAGS = \ + $(CODE_COVERAGE_LDFLAGS) + BUILT_SOURCES = $(GLIB_GENERATED) CLEANFILES = $(BUILT_SOURCES) all: $(BUILT_SOURCES) @@ -764,7 +770,7 @@ clean-noinstLTLIBRARIES: } libnm-core.la: $(libnm_core_la_OBJECTS) $(libnm_core_la_DEPENDENCIES) $(EXTRA_libnm_core_la_DEPENDENCIES) - $(AM_V_CCLD)$(LINK) $(libnm_core_la_OBJECTS) $(libnm_core_la_LIBADD) $(LIBS) + $(AM_V_CCLD)$(libnm_core_la_LINK) $(libnm_core_la_OBJECTS) $(libnm_core_la_LIBADD) $(LIBS) mostlyclean-compile: -rm -f *.$(OBJEXT) @@ -1481,6 +1487,8 @@ uninstall-am: uninstall-libnmincludeHEADERS include $(GLIB_MAKEFILE) +@GNOME_CODE_COVERAGE_RULES@ + # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: diff --git a/libnm-core/nm-core-enum-types.c b/libnm-core/nm-core-enum-types.c index 7d0f68ff..83f5e889 100644 --- a/libnm-core/nm-core-enum-types.c +++ b/libnm-core/nm-core-enum-types.c @@ -317,6 +317,27 @@ nm_device_modem_capabilities_get_type (void) return g_define_type_id__volatile; } GType +nm_wimax_nsp_network_type_get_type (void) +{ + static volatile gsize g_define_type_id__volatile = 0; + + if (g_once_init_enter (&g_define_type_id__volatile)) + { + static const GEnumValue values[] = { + { NM_WIMAX_NSP_NETWORK_TYPE_UNKNOWN, "NM_WIMAX_NSP_NETWORK_TYPE_UNKNOWN", "unknown" }, + { NM_WIMAX_NSP_NETWORK_TYPE_HOME, "NM_WIMAX_NSP_NETWORK_TYPE_HOME", "home" }, + { NM_WIMAX_NSP_NETWORK_TYPE_PARTNER, "NM_WIMAX_NSP_NETWORK_TYPE_PARTNER", "partner" }, + { NM_WIMAX_NSP_NETWORK_TYPE_ROAMING_PARTNER, "NM_WIMAX_NSP_NETWORK_TYPE_ROAMING_PARTNER", "roaming-partner" }, + { 0, NULL, NULL } + }; + GType g_define_type_id = + g_enum_register_static (g_intern_static_string ("NMWimaxNspNetworkType"), values); + g_once_init_leave (&g_define_type_id__volatile, g_define_type_id); + } + + return g_define_type_id__volatile; +} +GType nm_device_state_get_type (void) { static volatile gsize g_define_type_id__volatile = 0; diff --git a/libnm-core/nm-core-enum-types.h b/libnm-core/nm-core-enum-types.h index be038761..d316b5e0 100644 --- a/libnm-core/nm-core-enum-types.h +++ b/libnm-core/nm-core-enum-types.h @@ -31,6 +31,8 @@ GType nm_bluetooth_capabilities_get_type (void) G_GNUC_CONST; #define NM_TYPE_BLUETOOTH_CAPABILITIES (nm_bluetooth_capabilities_get_type ()) GType nm_device_modem_capabilities_get_type (void) G_GNUC_CONST; #define NM_TYPE_DEVICE_MODEM_CAPABILITIES (nm_device_modem_capabilities_get_type ()) +GType nm_wimax_nsp_network_type_get_type (void) G_GNUC_CONST; +#define NM_TYPE_WIMAX_NSP_NETWORK_TYPE (nm_wimax_nsp_network_type_get_type ()) GType nm_device_state_get_type (void) G_GNUC_CONST; #define NM_TYPE_DEVICE_STATE (nm_device_state_get_type ()) GType nm_device_state_reason_get_type (void) G_GNUC_CONST; diff --git a/libnm-core/nm-core-internal.h b/libnm-core/nm-core-internal.h index 9512ee56..082ebc9e 100644 --- a/libnm-core/nm-core-internal.h +++ b/libnm-core/nm-core-internal.h @@ -283,4 +283,16 @@ void _nm_setting_vlan_get_priorities (NMSettingVlan *setting, /***********************************************************/ +typedef enum { + NM_BOND_OPTION_TYPE_INT, + NM_BOND_OPTION_TYPE_STRING, + NM_BOND_OPTION_TYPE_BOTH, + NM_BOND_OPTION_TYPE_IP, + NM_BOND_OPTION_TYPE_MAC, + NM_BOND_OPTION_TYPE_IFNAME, +} NMBondOptionType; + +NMBondOptionType +_nm_setting_bond_get_option_type (NMSettingBond *setting, const char *name); + #endif diff --git a/libnm-core/nm-dbus-interface.h b/libnm-core/nm-dbus-interface.h index d76c5640..84e080af 100644 --- a/libnm-core/nm-dbus-interface.h +++ b/libnm-core/nm-dbus-interface.h @@ -94,8 +94,6 @@ * @NM_STATE_CONNECTED_GLOBAL: there is global IPv4 and/or IPv6 Internet connectivity * * #NMState values indicate the current overall networking state. - * - * (Corresponds to the NM_STATE type in nm-manager.xml.) **/ typedef enum { NM_STATE_UNKNOWN = 0, @@ -118,8 +116,6 @@ typedef enum { * does not appear to be able to reach the full Internet. * @NM_CONNECTIVITY_FULL: The host is connected to a network, and * appears to be able to reach the full Internet. - * - * (Corresponds to the NM_CONNECTIVITY type in nm-manager.xml.) */ typedef enum { NM_CONNECTIVITY_UNKNOWN, @@ -156,8 +152,6 @@ typedef enum { * * #NMDeviceType values indicate the type of hardware represented by * an #NMDevice. - * - * (Corresponds to the NM_DEVICE_TYPE type in nm-device.xml.) **/ typedef enum { NM_DEVICE_TYPE_UNKNOWN = 0, @@ -191,8 +185,6 @@ typedef enum { * @NM_DEVICE_CAP_IS_SOFTWARE: this device is a software device * * General device capability flags. - * - * (Corresponds to the NM_DEVICE_CAP type in nm-device-wifi.xml.) **/ typedef enum { /*< flags >*/ NM_DEVICE_CAP_NONE = 0x00000000, @@ -218,8 +210,6 @@ typedef enum { /*< flags >*/ * @NM_WIFI_DEVICE_CAP_FREQ_5GHZ: device supports 5GHz frequencies * * 802.11 specific device encryption and authentication capabilities. - * - * (Corresponds to the NM_802_11_DEVICE_CAP type in nm-device-wifi.xml.) **/ typedef enum { /*< flags >*/ NM_WIFI_DEVICE_CAP_NONE = 0x00000000, @@ -244,8 +234,6 @@ typedef enum { /*< flags >*/ * encryption (usually means WEP) * * 802.11 access point flags. - * - * (Corresponds to the NM_802_11_AP_FLAGS type in nm-access-point.xml.) **/ typedef enum { /*< underscore_name=nm_802_11_ap_flags, flags >*/ NM_802_11_AP_FLAGS_NONE = 0x00000000, @@ -276,8 +264,6 @@ typedef enum { /*< underscore_name=nm_802_11_ap_flags, flags >*/ * 802.11 access point security and authentication flags. These flags describe * the current security requirements of an access point as determined from the * access point's beacon. - * - * (Corresponds to the NM_802_11_AP_SEC type in nm-access-point.xml.) **/ typedef enum { /*< underscore_name=nm_802_11_ap_security_flags, flags >*/ NM_802_11_AP_SEC_NONE = 0x00000000, @@ -307,8 +293,6 @@ typedef enum { /*< underscore_name=nm_802_11_ap_security_flags, flags >*/ * access point objects; used only for hotspot mode on the local machine. * * Indicates the 802.11 mode an access point or device is currently in. - * - * (Corresponds to the NM_802_11_MODE type in generic-types.xml.) **/ typedef enum { /*< underscore_name=nm_802_11_mode >*/ NM_802_11_MODE_UNKNOWN = 0, @@ -325,8 +309,6 @@ typedef enum { /*< underscore_name=nm_802_11_mode >*/ * * #NMBluetoothCapabilities values indicate the usable capabilities of a * Bluetooth device. - * - * (Corresponds to the NM_BT_CAPABILITY type in nm-device-bt.xml.) **/ typedef enum { /*< flags >*/ NM_BT_CAPABILITY_NONE = 0x00000000, @@ -349,8 +331,6 @@ typedef enum { /*< flags >*/ * technology families a modem device supports. For more information on the * specific access technologies the device supports use the ModemManager D-Bus * API. - * - * (Corresponds to the NM_DEVICE_MODEM_CAPABILITY type in nm-device-modem.xml.) **/ typedef enum { /*< flags >*/ NM_DEVICE_MODEM_CAPABILITY_NONE = 0x00000000, @@ -360,6 +340,21 @@ typedef enum { /*< flags >*/ NM_DEVICE_MODEM_CAPABILITY_LTE = 0x00000008, } NMDeviceModemCapabilities; +/** + * NMWimaxNspNetworkType: + * @NM_WIMAX_NSP_NETWORK_TYPE_UNKNOWN: unknown network type + * @NM_WIMAX_NSP_NETWORK_TYPE_HOME: home network + * @NM_WIMAX_NSP_NETWORK_TYPE_PARTNER: partner network + * @NM_WIMAX_NSP_NETWORK_TYPE_ROAMING_PARTNER: roaming partner network + * + * WiMAX network type. + */ +typedef enum { + NM_WIMAX_NSP_NETWORK_TYPE_UNKNOWN = 0, + NM_WIMAX_NSP_NETWORK_TYPE_HOME = 1, + NM_WIMAX_NSP_NETWORK_TYPE_PARTNER = 2, + NM_WIMAX_NSP_NETWORK_TYPE_ROAMING_PARTNER = 3 +} NMWimaxNspNetworkType; /** * NMDeviceState: @@ -398,8 +393,6 @@ typedef enum { /*< flags >*/ * that connection. The network connection may still be valid. * @NM_DEVICE_STATE_FAILED: the device failed to connect to the requested * network and is cleaning up the connection request - * - * (Corresponds to the NM_DEVICE_STATE type in nm-device.xml.) **/ typedef enum { NM_DEVICE_STATE_UNKNOWN = 0, @@ -484,8 +477,6 @@ typedef enum { * @NM_DEVICE_STATE_REASON_PARENT_MANAGED_CHANGED: the device parent's management changed * * Device state change reason codes - * - * (Corresponds to the NM_DEVICE_STATE_REASON type in nm-device.xml.) */ typedef enum { NM_DEVICE_STATE_REASON_NONE = 0, @@ -561,8 +552,6 @@ typedef enum { * @NM_METERED_GUESS_YES: Metered, the value was guessed * @NM_METERED_GUESS_NO: Not metered, the value was guessed * - * (Corresponds to the NM_METERED type in nm-device.xml.) - * * Since: 1.2 **/ NM_AVAILABLE_IN_1_2 @@ -587,8 +576,6 @@ typedef enum { * #NMActiveConnectionState values indicate the state of a connection to a * specific network while it is starting, connected, or disconnecting from that * network. - * - * (Corresponds to the NM_ACTIVE_CONNECTION_STATE type in nm-active-connection.xml.) **/ typedef enum { NM_ACTIVE_CONNECTION_STATE_UNKNOWN = 0, @@ -620,8 +607,6 @@ typedef enum { * the D-Bus API. * * #NMSecretAgentGetSecretsFlags values modify the behavior of a GetSecrets request. - * - * (Corresponds to the NM_SECRET_AGENT_GET_SECRETS_FLAGS type in nm-secret-agent.xml.) */ typedef enum { /*< flags >*/ NM_SECRET_AGENT_GET_SECRETS_FLAG_NONE = 0x0, @@ -642,8 +627,6 @@ typedef enum { /*< flags >*/ * @NM_SECRET_AGENT_CAPABILITY_LAST: bounds checking value; should not be used. * * #NMSecretAgentCapabilities indicate various capabilities of the agent. - * - * (Corresponds to the NM_SECRET_AGENT_CAPABILITIES type in nm-secret-agent.xml.) */ typedef enum /*< flags >*/ { NM_SECRET_AGENT_CAPABILITY_NONE = 0x0, diff --git a/libnm-core/nm-setting-bond.c b/libnm-core/nm-setting-bond.c index 4d40de00..e008878d 100644 --- a/libnm-core/nm-setting-bond.c +++ b/libnm-core/nm-setting-bond.c @@ -32,6 +32,7 @@ #include "nm-utils-private.h" #include "nm-connection-private.h" #include "nm-setting-infiniband.h" +#include "nm-core-internal.h" /** * SECTION:nm-setting-bond @@ -57,14 +58,6 @@ enum { LAST_PROP }; -enum { - TYPE_INT, - TYPE_STR, - TYPE_BOTH, - TYPE_IP, - TYPE_IFNAME, -}; - typedef struct { const char *opt; const char *val; @@ -75,28 +68,40 @@ typedef struct { } BondDefault; static const BondDefault defaults[] = { - { NM_SETTING_BOND_OPTION_MODE, "balance-rr", TYPE_BOTH, 0, 6, + { NM_SETTING_BOND_OPTION_MODE, "balance-rr", NM_BOND_OPTION_TYPE_BOTH, 0, 6, { "balance-rr", "active-backup", "balance-xor", "broadcast", "802.3ad", "balance-tlb", "balance-alb", NULL } }, - { NM_SETTING_BOND_OPTION_MIIMON, "100", TYPE_INT, 0, G_MAXINT }, - { NM_SETTING_BOND_OPTION_DOWNDELAY, "0", TYPE_INT, 0, G_MAXINT }, - { NM_SETTING_BOND_OPTION_UPDELAY, "0", TYPE_INT, 0, G_MAXINT }, - { NM_SETTING_BOND_OPTION_ARP_INTERVAL, "0", TYPE_INT, 0, G_MAXINT }, - { NM_SETTING_BOND_OPTION_ARP_IP_TARGET, "", TYPE_IP }, - { NM_SETTING_BOND_OPTION_ARP_VALIDATE, "0", TYPE_BOTH, 0, 3, + { NM_SETTING_BOND_OPTION_MIIMON, "100", NM_BOND_OPTION_TYPE_INT, 0, G_MAXINT }, + { NM_SETTING_BOND_OPTION_DOWNDELAY, "0", NM_BOND_OPTION_TYPE_INT, 0, G_MAXINT }, + { NM_SETTING_BOND_OPTION_UPDELAY, "0", NM_BOND_OPTION_TYPE_INT, 0, G_MAXINT }, + { NM_SETTING_BOND_OPTION_ARP_INTERVAL, "0", NM_BOND_OPTION_TYPE_INT, 0, G_MAXINT }, + { NM_SETTING_BOND_OPTION_ARP_IP_TARGET, "", NM_BOND_OPTION_TYPE_IP }, + { NM_SETTING_BOND_OPTION_ARP_VALIDATE, "none", NM_BOND_OPTION_TYPE_BOTH, 0, 3, { "none", "active", "backup", "all", NULL } }, - { NM_SETTING_BOND_OPTION_PRIMARY, "", TYPE_IFNAME }, - { NM_SETTING_BOND_OPTION_PRIMARY_RESELECT, "0", TYPE_BOTH, 0, 2, + { NM_SETTING_BOND_OPTION_PRIMARY, "", NM_BOND_OPTION_TYPE_IFNAME }, + { NM_SETTING_BOND_OPTION_PRIMARY_RESELECT, "always", NM_BOND_OPTION_TYPE_BOTH, 0, 2, { "always", "better", "failure", NULL } }, - { NM_SETTING_BOND_OPTION_FAIL_OVER_MAC, "0", TYPE_BOTH, 0, 2, + { NM_SETTING_BOND_OPTION_FAIL_OVER_MAC, "none", NM_BOND_OPTION_TYPE_BOTH, 0, 2, { "none", "active", "follow", NULL } }, - { NM_SETTING_BOND_OPTION_USE_CARRIER, "1", TYPE_INT, 0, 1 }, - { NM_SETTING_BOND_OPTION_AD_SELECT, "0", TYPE_BOTH, 0, 2, + { NM_SETTING_BOND_OPTION_USE_CARRIER, "1", NM_BOND_OPTION_TYPE_INT, 0, 1 }, + { NM_SETTING_BOND_OPTION_AD_SELECT, "stable", NM_BOND_OPTION_TYPE_BOTH, 0, 2, { "stable", "bandwidth", "count", NULL } }, - { NM_SETTING_BOND_OPTION_XMIT_HASH_POLICY, "0", TYPE_BOTH, 0, 2, + { NM_SETTING_BOND_OPTION_XMIT_HASH_POLICY, "layer2", NM_BOND_OPTION_TYPE_BOTH, 0, 2, { "layer2", "layer3+4", "layer2+3", NULL } }, - { NM_SETTING_BOND_OPTION_RESEND_IGMP, "1", TYPE_INT, 0, 255 }, - { NM_SETTING_BOND_OPTION_LACP_RATE, "0", TYPE_BOTH, 0, 1, + { NM_SETTING_BOND_OPTION_RESEND_IGMP, "1", NM_BOND_OPTION_TYPE_INT, 0, 255 }, + { NM_SETTING_BOND_OPTION_LACP_RATE, "slow", NM_BOND_OPTION_TYPE_BOTH, 0, 1, { "slow", "fast", NULL } }, + { NM_SETTING_BOND_OPTION_ACTIVE_SLAVE, "", NM_BOND_OPTION_TYPE_IFNAME }, + { NM_SETTING_BOND_OPTION_AD_ACTOR_SYS_PRIO,"65535", NM_BOND_OPTION_TYPE_INT, 1, 65535 }, + { NM_SETTING_BOND_OPTION_AD_ACTOR_SYSTEM, "", NM_BOND_OPTION_TYPE_MAC }, + { NM_SETTING_BOND_OPTION_AD_USER_PORT_KEY, "0", NM_BOND_OPTION_TYPE_INT, 0, 1023}, + { NM_SETTING_BOND_OPTION_ALL_SLAVES_ACTIVE,"0", NM_BOND_OPTION_TYPE_INT, 0, 1}, + { NM_SETTING_BOND_OPTION_ARP_ALL_TARGETS, "any", NM_BOND_OPTION_TYPE_BOTH, 0, 1, {"any", "all"}}, + { NM_SETTING_BOND_OPTION_MIN_LINKS, "0", NM_BOND_OPTION_TYPE_INT, 0, G_MAXINT }, + { NM_SETTING_BOND_OPTION_NUM_GRAT_ARP, "1", NM_BOND_OPTION_TYPE_INT, 0, 255 }, + { NM_SETTING_BOND_OPTION_NUM_UNSOL_NA, "1", NM_BOND_OPTION_TYPE_INT, 0, 255 }, + { NM_SETTING_BOND_OPTION_PACKETS_PER_SLAVE,"1", NM_BOND_OPTION_TYPE_INT, 0, 65535 }, + { NM_SETTING_BOND_OPTION_TLB_DYNAMIC_LB, "1", NM_BOND_OPTION_TYPE_INT, 0, 1 }, + { NM_SETTING_BOND_OPTION_LP_INTERVAL, "1", NM_BOND_OPTION_TYPE_INT, 1, G_MAXINT }, }; /** @@ -268,16 +273,18 @@ nm_setting_bond_validate_option (const char *name, if (value == NULL) return TRUE; switch (defaults[i].opt_type) { - case TYPE_INT: + case NM_BOND_OPTION_TYPE_INT: return validate_int (name, value, &defaults[i]); - case TYPE_STR: + case NM_BOND_OPTION_TYPE_STRING: return validate_list (name, value, &defaults[i]); - case TYPE_BOTH: + case NM_BOND_OPTION_TYPE_BOTH: return ( validate_int (name, value, &defaults[i]) || validate_list (name, value, &defaults[i])); - case TYPE_IP: + case NM_BOND_OPTION_TYPE_IP: return validate_ip (name, value); - case TYPE_IFNAME: + case NM_BOND_OPTION_TYPE_MAC: + return nm_utils_hwaddr_valid (value, ETH_ALEN); + case NM_BOND_OPTION_TYPE_IFNAME: return validate_ifname (name, value); } return FALSE; @@ -433,6 +440,29 @@ nm_setting_bond_get_option_default (NMSettingBond *setting, const char *name) g_assert_not_reached (); } +/** + * nm_setting_bond_get_option_type: + * @setting: the #NMSettingBond + * @name: the name of the option + * + * Returns: the type of the bond option. + **/ +NMBondOptionType +_nm_setting_bond_get_option_type (NMSettingBond *setting, const char *name) +{ + guint i; + + g_return_val_if_fail (NM_IS_SETTING_BOND (setting), NM_BOND_OPTION_TYPE_INT); + g_return_val_if_fail (nm_setting_bond_validate_option (name, NULL), NM_BOND_OPTION_TYPE_INT); + + for (i = 0; i < G_N_ELEMENTS (defaults); i++) { + if (nm_streq0 (defaults[i].opt, name)) + return defaults[i].opt_type; + } + /* Any option that passes nm_setting_bond_validate_option() should also be found in defaults */ + g_assert_not_reached (); +} + static gboolean verify (NMSetting *setting, NMConnection *connection, GError **error) { @@ -440,6 +470,7 @@ verify (NMSetting *setting, NMConnection *connection, GError **error) GHashTableIter iter; const char *key, *value; int mode, miimon = 0, arp_interval = 0; + int num_grat_arp = -1, num_unsol_na = -1; const char *mode_orig, *mode_new; const char *arp_ip_target = NULL; const char *lacp_rate; @@ -464,6 +495,12 @@ verify (NMSetting *setting, NMConnection *connection, GError **error) value = g_hash_table_lookup (priv->options, NM_SETTING_BOND_OPTION_ARP_INTERVAL); if (value) arp_interval = atoi (value); + value = g_hash_table_lookup (priv->options, NM_SETTING_BOND_OPTION_NUM_GRAT_ARP); + if (value) + num_grat_arp = atoi (value); + value = g_hash_table_lookup (priv->options, NM_SETTING_BOND_OPTION_NUM_UNSOL_NA); + if (value) + num_unsol_na = atoi (value); /* Can only set one of miimon and arp_interval */ if (miimon > 0 && arp_interval > 0) { @@ -474,11 +511,12 @@ verify (NMSetting *setting, NMConnection *connection, GError **error) NM_SETTING_BOND_OPTION_MIIMON, NM_SETTING_BOND_OPTION_ARP_INTERVAL); g_prefix_error (error, "%s.%s: ", NM_SETTING_BOND_SETTING_NAME, NM_SETTING_BOND_OPTIONS); + return FALSE; } /* Verify bond mode */ - mode_orig = value = g_hash_table_lookup (priv->options, NM_SETTING_BOND_OPTION_MODE); - if (!value) { + mode_orig = g_hash_table_lookup (priv->options, NM_SETTING_BOND_OPTION_MODE); + if (!mode_orig) { g_set_error (error, NM_CONNECTION_ERROR, NM_CONNECTION_ERROR_INVALID_PROPERTY, @@ -487,7 +525,7 @@ verify (NMSetting *setting, NMConnection *connection, GError **error) g_prefix_error (error, "%s.%s: ", NM_SETTING_BOND_SETTING_NAME, NM_SETTING_BOND_OPTIONS); return FALSE; } - mode = nm_utils_bond_mode_string_to_int (value); + mode = nm_utils_bond_mode_string_to_int (mode_orig); if (mode == -1) { g_set_error (error, NM_CONNECTION_ERROR, @@ -497,24 +535,24 @@ verify (NMSetting *setting, NMConnection *connection, GError **error) g_prefix_error (error, "%s.%s: ", NM_SETTING_BOND_SETTING_NAME, NM_SETTING_BOND_OPTIONS); return FALSE; } - mode_new = value = nm_utils_bond_mode_int_to_string (mode); + mode_new = nm_utils_bond_mode_int_to_string (mode); /* Make sure mode is compatible with other settings */ - if ( strcmp (value, "balance-alb") == 0 - || strcmp (value, "balance-tlb") == 0) { + if ( strcmp (mode_new, "balance-alb") == 0 + || strcmp (mode_new, "balance-tlb") == 0) { if (arp_interval > 0) { g_set_error (error, NM_CONNECTION_ERROR, NM_CONNECTION_ERROR_INVALID_PROPERTY, _("'%s=%s' is incompatible with '%s > 0'"), - NM_SETTING_BOND_OPTION_MODE, value, NM_SETTING_BOND_OPTION_ARP_INTERVAL); + NM_SETTING_BOND_OPTION_MODE, mode_new, NM_SETTING_BOND_OPTION_ARP_INTERVAL); g_prefix_error (error, "%s.%s: ", NM_SETTING_BOND_SETTING_NAME, NM_SETTING_BOND_OPTIONS); return FALSE; } } primary = g_hash_table_lookup (priv->options, NM_SETTING_BOND_OPTION_PRIMARY); - if (strcmp (value, "active-backup") == 0) { + if (strcmp (mode_new, "active-backup") == 0) { if (primary && !nm_utils_iface_valid_name (primary)) { g_set_error (error, NM_CONNECTION_ERROR, @@ -538,12 +576,12 @@ verify (NMSetting *setting, NMConnection *connection, GError **error) } if (nm_connection_get_setting_infiniband (connection)) { - if (strcmp (value, "active-backup") != 0) { + if (strcmp (mode_new, "active-backup") != 0) { g_set_error (error, NM_CONNECTION_ERROR, NM_CONNECTION_ERROR_INVALID_PROPERTY, _("'%s=%s' is not a valid configuration for '%s'"), - NM_SETTING_BOND_OPTION_MODE, value, NM_SETTING_INFINIBAND_SETTING_NAME); + NM_SETTING_BOND_OPTION_MODE, mode_new, NM_SETTING_INFINIBAND_SETTING_NAME); g_prefix_error (error, "%s.%s: ", NM_SETTING_BOND_SETTING_NAME, NM_SETTING_BOND_OPTIONS); return FALSE; } @@ -629,8 +667,9 @@ verify (NMSetting *setting, NMConnection *connection, GError **error) lacp_rate = g_hash_table_lookup (priv->options, NM_SETTING_BOND_OPTION_LACP_RATE); if ( lacp_rate - && (g_strcmp0 (value, "802.3ad") != 0 && g_strcmp0 (value, "4") != 0) - && (strcmp (lacp_rate, "slow") != 0 && strcmp (lacp_rate, "0") != 0)) { + && g_strcmp0 (mode_new, "802.3ad") + && strcmp (lacp_rate, "slow") != 0 + && strcmp (lacp_rate, "0") != 0) { g_set_error (error, NM_CONNECTION_ERROR, NM_CONNECTION_ERROR_INVALID_PROPERTY, @@ -640,6 +679,18 @@ verify (NMSetting *setting, NMConnection *connection, GError **error) return FALSE; } + if ( (num_grat_arp != -1 && num_unsol_na != -1) + && (num_grat_arp != num_unsol_na)) { + g_set_error (error, + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_INVALID_PROPERTY, + _("'%s' and '%s' cannot have different values"), + NM_SETTING_BOND_OPTION_NUM_GRAT_ARP, + NM_SETTING_BOND_OPTION_NUM_UNSOL_NA); + g_prefix_error (error, "%s.%s: ", NM_SETTING_BOND_SETTING_NAME, NM_SETTING_BOND_OPTIONS); + return FALSE; + } + if (!_nm_connection_verify_required_interface_name (connection, error)) return FALSE; @@ -658,6 +709,63 @@ verify (NMSetting *setting, NMConnection *connection, GError **error) return TRUE; } +static gboolean +options_hash_match (NMSettingBond *s_bond, GHashTable *options1, GHashTable *options2) +{ + GHashTableIter iter; + const char *key, *value, *value2; + + g_hash_table_iter_init (&iter, options1); + while (g_hash_table_iter_next (&iter, (gpointer *) &key, (gpointer *) &value)) { + value2 = g_hash_table_lookup (options2, key); + + if (!value2) { + if (nm_streq (key, "num_grat_arp")) + value2 = g_hash_table_lookup (options2, "num_unsol_na"); + else if (nm_streq (key, "num_unsol_na")) + value2 = g_hash_table_lookup (options2, "num_grat_arp"); + } + + if (value2) { + if (nm_streq (value, value2)) + continue; + } else { + if (nm_streq (value, nm_setting_bond_get_option_default (s_bond, key))) + continue; + } + + return FALSE; + } + + return TRUE; +} + +static gboolean +options_equal (NMSettingBond *s_bond, GHashTable *options1, GHashTable *options2) +{ + return options_hash_match (s_bond, options1, options2) + && options_hash_match (s_bond, options2, options1); +} + +static gboolean +compare_property (NMSetting *setting, + NMSetting *other, + const GParamSpec *prop_spec, + NMSettingCompareFlags flags) +{ + NMSettingClass *parent_class; + + if (nm_streq0 (prop_spec->name, NM_SETTING_BOND_OPTIONS)) { + return options_equal (NM_SETTING_BOND (setting), + NM_SETTING_BOND_GET_PRIVATE (setting)->options, + NM_SETTING_BOND_GET_PRIVATE (other)->options); + } + + /* Otherwise chain up to parent to handle generic compare */ + parent_class = NM_SETTING_CLASS (nm_setting_bond_parent_class); + return parent_class->compare_property (setting, other, prop_spec, flags); +} + static void nm_setting_bond_init (NMSettingBond *setting) { @@ -721,10 +829,11 @@ nm_setting_bond_class_init (NMSettingBondClass *setting_class) g_type_class_add_private (setting_class, sizeof (NMSettingBondPrivate)); /* virtual methods */ - object_class->set_property = set_property; - object_class->get_property = get_property; - object_class->finalize = finalize; - parent_class->verify = verify; + object_class->set_property = set_property; + object_class->get_property = get_property; + object_class->finalize = finalize; + parent_class->verify = verify; + parent_class->compare_property = compare_property; /* Properties */ /** diff --git a/libnm-core/nm-setting-bond.h b/libnm-core/nm-setting-bond.h index 055801a5..98fcc6d0 100644 --- a/libnm-core/nm-setting-bond.h +++ b/libnm-core/nm-setting-bond.h @@ -42,21 +42,33 @@ G_BEGIN_DECLS #define NM_SETTING_BOND_OPTIONS "options" /* Valid options for the 'options' property */ -#define NM_SETTING_BOND_OPTION_MODE "mode" -#define NM_SETTING_BOND_OPTION_MIIMON "miimon" -#define NM_SETTING_BOND_OPTION_DOWNDELAY "downdelay" -#define NM_SETTING_BOND_OPTION_UPDELAY "updelay" -#define NM_SETTING_BOND_OPTION_ARP_INTERVAL "arp_interval" -#define NM_SETTING_BOND_OPTION_ARP_IP_TARGET "arp_ip_target" -#define NM_SETTING_BOND_OPTION_ARP_VALIDATE "arp_validate" -#define NM_SETTING_BOND_OPTION_PRIMARY "primary" -#define NM_SETTING_BOND_OPTION_PRIMARY_RESELECT "primary_reselect" -#define NM_SETTING_BOND_OPTION_FAIL_OVER_MAC "fail_over_mac" -#define NM_SETTING_BOND_OPTION_USE_CARRIER "use_carrier" -#define NM_SETTING_BOND_OPTION_AD_SELECT "ad_select" -#define NM_SETTING_BOND_OPTION_XMIT_HASH_POLICY "xmit_hash_policy" -#define NM_SETTING_BOND_OPTION_RESEND_IGMP "resend_igmp" -#define NM_SETTING_BOND_OPTION_LACP_RATE "lacp_rate" +#define NM_SETTING_BOND_OPTION_MODE "mode" +#define NM_SETTING_BOND_OPTION_MIIMON "miimon" +#define NM_SETTING_BOND_OPTION_DOWNDELAY "downdelay" +#define NM_SETTING_BOND_OPTION_UPDELAY "updelay" +#define NM_SETTING_BOND_OPTION_ARP_INTERVAL "arp_interval" +#define NM_SETTING_BOND_OPTION_ARP_IP_TARGET "arp_ip_target" +#define NM_SETTING_BOND_OPTION_ARP_VALIDATE "arp_validate" +#define NM_SETTING_BOND_OPTION_PRIMARY "primary" +#define NM_SETTING_BOND_OPTION_PRIMARY_RESELECT "primary_reselect" +#define NM_SETTING_BOND_OPTION_FAIL_OVER_MAC "fail_over_mac" +#define NM_SETTING_BOND_OPTION_USE_CARRIER "use_carrier" +#define NM_SETTING_BOND_OPTION_AD_SELECT "ad_select" +#define NM_SETTING_BOND_OPTION_XMIT_HASH_POLICY "xmit_hash_policy" +#define NM_SETTING_BOND_OPTION_RESEND_IGMP "resend_igmp" +#define NM_SETTING_BOND_OPTION_LACP_RATE "lacp_rate" +#define NM_SETTING_BOND_OPTION_ACTIVE_SLAVE "active_slave" +#define NM_SETTING_BOND_OPTION_AD_ACTOR_SYS_PRIO "ad_actor_sys_prio" +#define NM_SETTING_BOND_OPTION_AD_ACTOR_SYSTEM "ad_actor_system" +#define NM_SETTING_BOND_OPTION_AD_USER_PORT_KEY "ad_user_port_key" +#define NM_SETTING_BOND_OPTION_ALL_SLAVES_ACTIVE "all_slaves_active" +#define NM_SETTING_BOND_OPTION_ARP_ALL_TARGETS "arp_all_targets" +#define NM_SETTING_BOND_OPTION_MIN_LINKS "min_links" +#define NM_SETTING_BOND_OPTION_NUM_GRAT_ARP "num_grat_arp" +#define NM_SETTING_BOND_OPTION_NUM_UNSOL_NA "num_unsol_na" +#define NM_SETTING_BOND_OPTION_PACKETS_PER_SLAVE "packets_per_slave" +#define NM_SETTING_BOND_OPTION_TLB_DYNAMIC_LB "tlb_dynamic_lb" +#define NM_SETTING_BOND_OPTION_LP_INTERVAL "lp_interval" struct _NMSettingBond { NMSetting parent; diff --git a/libnm-core/nm-setting-bridge.c b/libnm-core/nm-setting-bridge.c index fa934c46..7cfa7eb8 100644 --- a/libnm-core/nm-setting-bridge.c +++ b/libnm-core/nm-setting-bridge.c @@ -397,7 +397,7 @@ nm_setting_bridge_class_init (NMSettingBridgeClass *setting_class) **/ /* ---keyfile--- * property: mac-address - * format: ususal hex-digits-and-colons notation + * format: usual hex-digits-and-colons notation * description: MAC address in traditional hex-digits-and-colons notation, * or semicolon separated list of 6 decimal bytes (obsolete) * example: mac-address=00:22:68:12:79:A2 diff --git a/libnm-core/nm-setting-infiniband.c b/libnm-core/nm-setting-infiniband.c index 3a71879d..6086f076 100644 --- a/libnm-core/nm-setting-infiniband.c +++ b/libnm-core/nm-setting-infiniband.c @@ -397,7 +397,7 @@ nm_setting_infiniband_class_init (NMSettingInfinibandClass *setting_class) **/ /* ---keyfile--- * property: mac-address - * format: ususal hex-digits-and-colons notation + * format: usual hex-digits-and-colons notation * description: MAC address in traditional hex-digits-and-colons notation, or * or semicolon separated list of 20 decimal bytes (obsolete) * example: mac-address= 80:00:00:6d:fe:80:00:00:00:00:00:00:00:02:55:00:70:33:cf:01 diff --git a/libnm-core/nm-setting-ip-config.c b/libnm-core/nm-setting-ip-config.c index a69045b3..4e3088a9 100644 --- a/libnm-core/nm-setting-ip-config.c +++ b/libnm-core/nm-setting-ip-config.c @@ -59,6 +59,7 @@ const NMUtilsDNSOptionDesc _nm_utils_dns_option_descs[] = { { NM_SETTING_DNS_OPTION_SINGLE_REQUEST, FALSE, FALSE }, { NM_SETTING_DNS_OPTION_SINGLE_REQUEST_REOPEN, FALSE, FALSE }, { NM_SETTING_DNS_OPTION_NO_TLD_QUERY, FALSE, FALSE }, + { NM_SETTING_DNS_OPTION_USE_VC, FALSE, FALSE }, { NULL, FALSE, FALSE } }; diff --git a/libnm-core/nm-setting-ip-config.h b/libnm-core/nm-setting-ip-config.h index 6d182338..39e4c9f0 100644 --- a/libnm-core/nm-setting-ip-config.h +++ b/libnm-core/nm-setting-ip-config.h @@ -163,6 +163,7 @@ void nm_ip_route_set_attribute (NMIPRoute *route, #define NM_SETTING_DNS_OPTION_SINGLE_REQUEST "single-request" #define NM_SETTING_DNS_OPTION_SINGLE_REQUEST_REOPEN "single-request-reopen" #define NM_SETTING_DNS_OPTION_NO_TLD_QUERY "no-tld-query" +#define NM_SETTING_DNS_OPTION_USE_VC "use-vc" struct _NMSettingIPConfig { NMSetting parent; diff --git a/libnm-core/nm-setting-macvlan.c b/libnm-core/nm-setting-macvlan.c index 00341acc..aec3b4f9 100644 --- a/libnm-core/nm-setting-macvlan.c +++ b/libnm-core/nm-setting-macvlan.c @@ -189,12 +189,11 @@ verify (NMSetting *setting, NMConnection *connection, GError **error) g_set_error_literal (error, NM_CONNECTION_ERROR, NM_CONNECTION_ERROR_INVALID_PROPERTY, - _("non promiscuous operation is allowed only in passthru mode'")); + _("non promiscuous operation is allowed only in passthru mode")); g_prefix_error (error, "%s.%s: ", NM_SETTING_MACVLAN_SETTING_NAME, NM_SETTING_MACVLAN_PROMISCUOUS); return FALSE; - } return TRUE; diff --git a/libnm-core/nm-setting-wired.c b/libnm-core/nm-setting-wired.c index 149ddb91..132f8e05 100644 --- a/libnm-core/nm-setting-wired.c +++ b/libnm-core/nm-setting-wired.c @@ -1004,7 +1004,7 @@ nm_setting_wired_class_init (NMSettingWiredClass *setting_class) **/ /* ---keyfile--- * property: mac-address - * format: ususal hex-digits-and-colons notation + * format: usual hex-digits-and-colons notation * description: MAC address in traditional hex-digits-and-colons notation * (e.g. 00:22:68:12:79:A2), or semicolon separated list of 6 bytes (obsolete) * (e.g. 0;34;104;18;121;162) @@ -1036,7 +1036,7 @@ nm_setting_wired_class_init (NMSettingWiredClass *setting_class) **/ /* ---keyfile--- * property: cloned-mac-address - * format: ususal hex-digits-and-colons notation + * format: usual hex-digits-and-colons notation * description: Cloned MAC address in traditional hex-digits-and-colons notation * (e.g. 00:22:68:12:79:B2), or semicolon separated list of 6 bytes (obsolete) * (e.g. 0;34;104;18;121;178). diff --git a/libnm-core/nm-setting-wireless.c b/libnm-core/nm-setting-wireless.c index 72fd77e4..ee4ac6f2 100644 --- a/libnm-core/nm-setting-wireless.c +++ b/libnm-core/nm-setting-wireless.c @@ -1213,7 +1213,7 @@ nm_setting_wireless_class_init (NMSettingWirelessClass *setting_class) **/ /* ---keyfile--- * property: mac-address - * format: ususal hex-digits-and-colons notation + * format: usual hex-digits-and-colons notation * description: MAC address in traditional hex-digits-and-colons notation * (e.g. 00:22:68:12:79:A2), or semicolon separated list of 6 bytes (obsolete) * (e.g. 0;34;104;18;121;162). @@ -1244,7 +1244,7 @@ nm_setting_wireless_class_init (NMSettingWirelessClass *setting_class) **/ /* ---keyfile--- * property: cloned-mac-address - * format: ususal hex-digits-and-colons notation + * format: usual hex-digits-and-colons notation * description: Cloned MAC address in traditional hex-digits-and-colons notation * (e.g. 00:22:68:12:79:B2), or semicolon separated list of 6 bytes (obsolete) * (e.g. 0;34;104;18;121;178). diff --git a/libnm-core/nm-utils.c b/libnm-core/nm-utils.c index a8467081..70c268fa 100644 --- a/libnm-core/nm-utils.c +++ b/libnm-core/nm-utils.c @@ -45,9 +45,6 @@ #include "nm-setting-wired.h" #include "nm-setting-wireless.h" -/* Embed the commit id in the build binary */ -static const char *const __nm_git_sha = NM_STRLEN (NM_GIT_SHA) > 0 ? "NM_GIT_SHA:"NM_GIT_SHA : ""; - /** * SECTION:nm-utils * @short_description: Utility functions @@ -223,8 +220,6 @@ _nm_utils_init (void) GModule *self; gpointer func; - (void) __nm_git_sha; - if (initialized) return; initialized = TRUE; diff --git a/libnm-core/nm-version.h b/libnm-core/nm-version.h index 859a3a8c..d7f112bf 100644 --- a/libnm-core/nm-version.h +++ b/libnm-core/nm-version.h @@ -90,4 +90,18 @@ # define NM_AVAILABLE_IN_1_2 #endif +#if NM_VERSION_MIN_REQUIRED >= NM_VERSION_1_4 +# define NM_DEPRECATED_IN_1_4 G_DEPRECATED +# define NM_DEPRECATED_IN_1_4_FOR(f) G_DEPRECATED_FOR(f) +#else +# define NM_DEPRECATED_IN_1_4 +# define NM_DEPRECATED_IN_1_4_FOR(f) +#endif + +#if NM_VERSION_MAX_ALLOWED < NM_VERSION_1_4 +# define NM_AVAILABLE_IN_1_4 G_UNAVAILABLE(1,4) +#else +# define NM_AVAILABLE_IN_1_4 +#endif + #endif /* NM_VERSION_H */ diff --git a/libnm-core/nm-vpn-dbus-interface.h b/libnm-core/nm-vpn-dbus-interface.h index c4099be2..9226458d 100644 --- a/libnm-core/nm-vpn-dbus-interface.h +++ b/libnm-core/nm-vpn-dbus-interface.h @@ -78,8 +78,6 @@ * @NM_VPN_SERVICE_STATE_STOPPED: The plugin has disconnected from the VPN server. * * VPN daemon states - * - * (Corresponds to the NM_VPN_SERVICE_STATE type in nm-vpn-connection.xml.) */ typedef enum { NM_VPN_SERVICE_STATE_UNKNOWN = 0, @@ -108,8 +106,6 @@ typedef enum { * @NM_VPN_CONNECTION_STATE_DISCONNECTED: The VPN connection is disconnected. * * VPN connection states - * - * (Corresponds to the NM_VPN_CONNECTION_STATE type in nm-vpn-connection.xml.) */ typedef enum { NM_VPN_CONNECTION_STATE_UNKNOWN = 0, @@ -150,8 +146,6 @@ typedef enum { * deleted from settings. * * VPN connection state reasons - * - * (Corresponds to the NM_VPN_CONNECTION_STATE_REASON type in nm-vpn-connection.xml.) */ typedef enum { NM_VPN_CONNECTION_STATE_REASON_UNKNOWN = 0, @@ -176,8 +170,6 @@ typedef enum { * the VPN plugin. * * VPN plugin failure reasons - * - * (Corresponds to the NM_VPN_PLUGIN_FAILURE type in nm-vpn-plugin.xml.) */ typedef enum { NM_VPN_PLUGIN_FAILURE_LOGIN_FAILED, diff --git a/libnm-core/tests/Makefile.am b/libnm-core/tests/Makefile.am index 92c816fd..1926c86f 100644 --- a/libnm-core/tests/Makefile.am +++ b/libnm-core/tests/Makefile.am @@ -17,7 +17,6 @@ AM_CPPFLAGS = \ -I$(top_srcdir)/libnm-core \ -I$(top_builddir)/libnm-core \ -DNETWORKMANAGER_COMPILATION \ - -DNM_VERSION_MAX_ALLOWED=NM_VERSION_NEXT_STABLE \ $(GLIB_CFLAGS) \ -DTEST_CERT_DIR=\"$(certsdir)\" @@ -28,6 +27,7 @@ noinst_PROGRAMS = \ test-keyfile \ test-secrets \ test-setting-8021x \ + test-setting-bond \ test-setting-dcb \ test-settings-defaults diff --git a/libnm-core/tests/Makefile.in b/libnm-core/tests/Makefile.in index 43892d75..356ce8df 100644 --- a/libnm-core/tests/Makefile.in +++ b/libnm-core/tests/Makefile.in @@ -92,6 +92,7 @@ host_triplet = @host@ @ENABLE_TESTS_TRUE@ test-crypto$(EXEEXT) test-general$(EXEEXT) \ @ENABLE_TESTS_TRUE@ test-keyfile$(EXEEXT) test-secrets$(EXEEXT) \ @ENABLE_TESTS_TRUE@ test-setting-8021x$(EXEEXT) \ +@ENABLE_TESTS_TRUE@ test-setting-bond$(EXEEXT) \ @ENABLE_TESTS_TRUE@ test-setting-dcb$(EXEEXT) \ @ENABLE_TESTS_TRUE@ test-settings-defaults$(EXEEXT) subdir = libnm-core/tests @@ -161,6 +162,12 @@ test_setting_8021x_LDADD = $(LDADD) @ENABLE_TESTS_TRUE@test_setting_8021x_DEPENDENCIES = \ @ENABLE_TESTS_TRUE@ $(top_builddir)/libnm-core/libnm-core.la \ @ENABLE_TESTS_TRUE@ $(am__DEPENDENCIES_1) +test_setting_bond_SOURCES = test-setting-bond.c +test_setting_bond_OBJECTS = test-setting-bond.$(OBJEXT) +test_setting_bond_LDADD = $(LDADD) +@ENABLE_TESTS_TRUE@test_setting_bond_DEPENDENCIES = \ +@ENABLE_TESTS_TRUE@ $(top_builddir)/libnm-core/libnm-core.la \ +@ENABLE_TESTS_TRUE@ $(am__DEPENDENCIES_1) test_setting_dcb_SOURCES = test-setting-dcb.c test_setting_dcb_OBJECTS = test-setting-dcb.$(OBJEXT) test_setting_dcb_LDADD = $(LDADD) @@ -209,10 +216,11 @@ am__v_CCLD_0 = @echo " CCLD " $@; am__v_CCLD_1 = SOURCES = test-compare.c test-crypto.c $(test_general_SOURCES) \ test-keyfile.c test-secrets.c test-setting-8021x.c \ - test-setting-dcb.c test-settings-defaults.c + test-setting-bond.c test-setting-dcb.c \ + test-settings-defaults.c DIST_SOURCES = test-compare.c test-crypto.c \ $(am__test_general_SOURCES_DIST) test-keyfile.c test-secrets.c \ - test-setting-8021x.c test-setting-dcb.c \ + test-setting-8021x.c test-setting-bond.c test-setting-dcb.c \ test-settings-defaults.c am__can_run_installinfo = \ case $$AM_UPDATE_INFO_DIR in \ @@ -720,7 +728,6 @@ BUILT_SOURCES = $(GLIB_GENERATED) @ENABLE_TESTS_TRUE@ -I$(top_srcdir)/libnm-core \ @ENABLE_TESTS_TRUE@ -I$(top_builddir)/libnm-core \ @ENABLE_TESTS_TRUE@ -DNETWORKMANAGER_COMPILATION \ -@ENABLE_TESTS_TRUE@ -DNM_VERSION_MAX_ALLOWED=NM_VERSION_NEXT_STABLE \ @ENABLE_TESTS_TRUE@ $(GLIB_CFLAGS) \ @ENABLE_TESTS_TRUE@ -DTEST_CERT_DIR=\"$(certsdir)\" @@ -831,6 +838,10 @@ test-setting-8021x$(EXEEXT): $(test_setting_8021x_OBJECTS) $(test_setting_8021x_ @rm -f test-setting-8021x$(EXEEXT) $(AM_V_CCLD)$(LINK) $(test_setting_8021x_OBJECTS) $(test_setting_8021x_LDADD) $(LIBS) +test-setting-bond$(EXEEXT): $(test_setting_bond_OBJECTS) $(test_setting_bond_DEPENDENCIES) $(EXTRA_test_setting_bond_DEPENDENCIES) + @rm -f test-setting-bond$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_setting_bond_OBJECTS) $(test_setting_bond_LDADD) $(LIBS) + test-setting-dcb$(EXEEXT): $(test_setting_dcb_OBJECTS) $(test_setting_dcb_DEPENDENCIES) $(EXTRA_test_setting_dcb_DEPENDENCIES) @rm -f test-setting-dcb$(EXEEXT) $(AM_V_CCLD)$(LINK) $(test_setting_dcb_OBJECTS) $(test_setting_dcb_LDADD) $(LIBS) @@ -852,6 +863,7 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-keyfile.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-secrets.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-setting-8021x.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-setting-bond.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-setting-dcb.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-settings-defaults.Po@am__quote@ @@ -1117,6 +1129,13 @@ test-setting-8021x.log: test-setting-8021x$(EXEEXT) --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) +test-setting-bond.log: test-setting-bond$(EXEEXT) + @p='test-setting-bond$(EXEEXT)'; \ + b='test-setting-bond'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) test-setting-dcb.log: test-setting-dcb$(EXEEXT) @p='test-setting-dcb$(EXEEXT)'; \ b='test-setting-dcb'; \ diff --git a/libnm-core/tests/test-setting-bond.c b/libnm-core/tests/test-setting-bond.c new file mode 100644 index 00000000..a6afa1c8 --- /dev/null +++ b/libnm-core/tests/test-setting-bond.c @@ -0,0 +1,198 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ +/* + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Copyright 2016 Red Hat, Inc. + */ + +#include "nm-default.h" + +#include "nm-utils.h" +#include "nm-setting-bond.h" +#include "nm-connection.h" +#include "nm-simple-connection.h" +#include "nm-setting-connection.h" +#include "nm-errors.h" + +#include "nm-test-utils.h" + +static void +create_bond_connection (NMConnection **con, NMSettingBond **s_bond) +{ + NMSettingConnection *s_con; + + g_assert (con); + g_assert (s_bond); + + *con = nmtst_create_minimal_connection ("bond", + NULL, + NM_SETTING_BOND_SETTING_NAME, + &s_con); + g_assert (*con); + g_assert (s_con); + + g_object_set (s_con, NM_SETTING_CONNECTION_INTERFACE_NAME, "bond0", NULL); + + *s_bond = (NMSettingBond *) nm_setting_bond_new (); + g_assert (*s_bond); + + nm_connection_add_setting (*con, NM_SETTING (*s_bond)); +} + +#define test_verify_options(exp, ...) \ + G_STMT_START { \ + const char *__opts[] = { __VA_ARGS__ , NULL }; \ + \ + _test_verify_options (__opts, exp); \ + } G_STMT_END + +static void +_test_verify_options (const char **options, gboolean expected_result) +{ + gs_unref_object NMConnection *con = NULL; + NMSettingBond *s_bond; + GError *error = NULL; + gboolean success; + const char **option; + + create_bond_connection (&con, &s_bond); + + for (option = options; option[0] && option[1]; option += 2) + g_assert (nm_setting_bond_add_option (s_bond, option[0], option[1])); + + if (expected_result) { + nmtst_assert_connection_verifies_and_normalizable (con); + nmtst_connection_normalize (con); + success = nm_setting_verify ((NMSetting *) s_bond, con, &error); + nmtst_assert_success (success, error); + } else { + nmtst_assert_connection_unnormalizable (con, + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_INVALID_PROPERTY); + } +} + +static void +test_verify (void) +{ + test_verify_options (TRUE, + "mode", "3", + "arp_interval", "0"); + test_verify_options (FALSE, + /* arp_interval not supported in balance-alb mode */ + "mode", "balance-alb", + "arp_interval", "1", + "arp_ip_target", "1.2.3.4"); + test_verify_options (FALSE, + /* arp_ip_target requires arp_interval */ + "mode", "balance-rr", + "arp_ip_target", "1.2.3.4"); + test_verify_options (TRUE, + "mode", "balance-rr", + "arp_interval", "1", + "arp_ip_target", "1.2.3.4"); + test_verify_options (FALSE, + /* num_grat_arp, num_unsol_na cannot be different */ + "mode", "balance-rr", + "num_grat_arp", "3", + "num_unsol_na", "4"); + test_verify_options (TRUE, + "mode", "balance-rr", + "num_grat_arp", "5", + "num_unsol_na", "5"); + test_verify_options (TRUE, + "mode", "active-backup", + "primary", "eth0"); + test_verify_options (FALSE, + /* primary requires mode=active-backup */ + "mode", "802.3ad", + "primary", "eth0"); + test_verify_options (TRUE, + "mode", "802.3ad", + "lacp_rate", "fast"); + test_verify_options (FALSE, + /* lacp_rate=fast requires mode=802.3ad */ + "mode", "balance-rr", + "lacp_rate", "fast"); + test_verify_options (TRUE, + "mode", "802.3ad", + "ad_actor_system", "ae:00:11:33:44:55"); +} + +static void +test_compare_options (gboolean exp_res, const char **opts1, const char **opts2) +{ + gs_unref_object NMSettingBond *s_bond1 = NULL, *s_bond2 = NULL; + const char **p; + + s_bond1 = (NMSettingBond *) nm_setting_bond_new (); + g_assert (s_bond1); + s_bond2 = (NMSettingBond *) nm_setting_bond_new (); + g_assert (s_bond2); + + for (p = opts1; p[0] && p[1]; p += 2) + g_assert (nm_setting_bond_add_option (s_bond1, p[0], p[1])); + + for (p = opts2; p[0] && p[1]; p += 2) + g_assert (nm_setting_bond_add_option (s_bond2, p[0], p[1])); + + g_assert_cmpint (nm_setting_compare ((NMSetting *) s_bond1, + (NMSetting *) s_bond2, + NM_SETTING_COMPARE_FLAG_EXACT), + ==, + exp_res); +} + +static void +test_compare (void) +{ + test_compare_options (TRUE, + ((const char *[]){ "mode", "balance-rr", "miimon", "1", NULL }), + ((const char *[]){ "mode", "balance-rr", "miimon", "1", NULL })); + test_compare_options (FALSE, + ((const char *[]){ "mode", "balance-rr", "miimon", "1", NULL }), + ((const char *[]){ "mode", "balance-rr", "miimon", "2", NULL })); + + /* ignore default values */ + test_compare_options (TRUE, + ((const char *[]){ "miimon", "1", NULL }), + ((const char *[]){ "miimon", "1", "updelay", "0", NULL })); + + /* special handling of num_grat_arp, num_unsol_na */ + test_compare_options (FALSE, + ((const char *[]){ "num_grat_arp", "2", NULL }), + ((const char *[]){ "num_grat_arp", "1", NULL })); + test_compare_options (TRUE, + ((const char *[]){ "num_grat_arp", "3", NULL }), + ((const char *[]){ "num_unsol_na", "3", NULL })); + test_compare_options (TRUE, + ((const char *[]){ "num_grat_arp", "4", NULL }), + ((const char *[]){ "num_unsol_na", "4", "num_grat_arp", "4", NULL })); +} + +#define TPATH "/libnm/settings/bond/" + +NMTST_DEFINE (); + +int +main (int argc, char **argv) +{ + nmtst_init (&argc, &argv, TRUE); + + g_test_add_func (TPATH "verify", test_verify); + g_test_add_func (TPATH "compare", test_compare); + + return g_test_run (); +} |