diff options
author | Lubomir Rintel <lkundrak@v3.sk> | 2017-05-22 19:31:43 +0200 |
---|---|---|
committer | Lubomir Rintel <lkundrak@v3.sk> | 2017-05-31 20:17:16 +0200 |
commit | 63292b5c4112e247d6e016c481c4cb5c2c444a3b (patch) | |
tree | 37acf280857abe2851f3cd764f64624c09e4b710 | |
parent | 7c5a2be96618787bfa94ad1179c101796b4f986d (diff) | |
download | NetworkManager-63292b5c4112e247d6e016c481c4cb5c2c444a3b.tar.gz |
core/connection: normalize bridge settings into bluetooth NAP connections
For the Bluetooth NAP we need a Bridge link for the BlueZ to assign the BNEP
links for PANU client connections into.
Let's disable STP by default -- it adds extra delay for the Bridge when the
BNEP link is assigned and is likely not useful for a typical client.
-rw-r--r-- | libnm-core/nm-connection.c | 16 | ||||
-rw-r--r-- | libnm-core/nm-setting-bluetooth.c | 37 |
2 files changed, 41 insertions, 12 deletions
diff --git a/libnm-core/nm-connection.c b/libnm-core/nm-connection.c index 858f5aab88..2be9007682 100644 --- a/libnm-core/nm-connection.c +++ b/libnm-core/nm-connection.c @@ -1002,13 +1002,25 @@ _normalize_team_port_config (NMConnection *self, GHashTable *parameters) static gboolean _normalize_required_settings (NMConnection *self, GHashTable *parameters) { + NMSettingBluetooth *s_bt = nm_connection_get_setting_bluetooth (self); + NMSetting *s_bridge; + gboolean changed = FALSE; + if (nm_connection_get_setting_vlan (self)) { if (!nm_connection_get_setting_wired (self)) { nm_connection_add_setting (self, nm_setting_wired_new ()); - return TRUE; + changed = TRUE; } } - return FALSE; + if (s_bt && nm_streq0 (nm_setting_bluetooth_get_connection_type (s_bt), NM_SETTING_BLUETOOTH_TYPE_NAP)) { + if (!nm_connection_get_setting_bridge (self)) { + s_bridge = nm_setting_bridge_new (); + g_object_set (s_bridge, NM_SETTING_BRIDGE_STP, FALSE, NULL); + nm_connection_add_setting (self, s_bridge); + changed = TRUE; + } + } + return changed; } static gboolean diff --git a/libnm-core/nm-setting-bluetooth.c b/libnm-core/nm-setting-bluetooth.c index d25d4db269..26f41d62ce 100644 --- a/libnm-core/nm-setting-bluetooth.c +++ b/libnm-core/nm-setting-bluetooth.c @@ -25,6 +25,7 @@ #include <string.h> #include <net/ethernet.h> +#include "nm-connection-private.h" #include "nm-setting-bluetooth.h" #include "nm-setting-cdma.h" #include "nm-setting-gsm.h" @@ -113,16 +114,7 @@ verify (NMSetting *setting, NMConnection *connection, GError **error) { NMSettingBluetoothPrivate *priv = NM_SETTING_BLUETOOTH_GET_PRIVATE (setting); - if (!priv->bdaddr) { - g_set_error_literal (error, - NM_CONNECTION_ERROR, - NM_CONNECTION_ERROR_MISSING_PROPERTY, - _("property is missing")); - g_prefix_error (error, "%s.%s: ", NM_SETTING_BLUETOOTH_SETTING_NAME, NM_SETTING_BLUETOOTH_BDADDR); - return FALSE; - } - - if (!nm_utils_hwaddr_valid (priv->bdaddr, ETH_ALEN)) { + if (priv->bdaddr && !nm_utils_hwaddr_valid (priv->bdaddr, ETH_ALEN)) { g_set_error_literal (error, NM_CONNECTION_ERROR, NM_CONNECTION_ERROR_INVALID_PROPERTY, @@ -177,6 +169,31 @@ verify (NMSetting *setting, NMConnection *connection, GError **error) * is required at the interface level. */ + /* NAP mode needs a bridge setting, and a bridge needs a name. */ + if (!strcmp (priv->type, NM_SETTING_BLUETOOTH_TYPE_NAP)) { + if (!_nm_connection_verify_required_interface_name (connection, error)) + return FALSE; + if (connection && !nm_connection_get_setting_bridge (connection)) { + g_set_error (error, + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_INVALID_SETTING, + _("'%s' connection requires '%s' setting"), + NM_SETTING_BLUETOOTH_TYPE_NAP, + NM_SETTING_BRIDGE_SETTING_NAME); + g_prefix_error (error, "%s: ", NM_SETTING_BLUETOOTH_SETTING_NAME); + return NM_SETTING_VERIFY_NORMALIZABLE_ERROR; + } + } else { + if (!priv->bdaddr) { + g_set_error_literal (error, + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_MISSING_PROPERTY, + _("property is missing")); + g_prefix_error (error, "%s.%s: ", NM_SETTING_BLUETOOTH_SETTING_NAME, NM_SETTING_BLUETOOTH_BDADDR); + return FALSE; + } + } + return TRUE; } |