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.
This commit is contained in:
Lubomir Rintel 2017-05-22 19:31:43 +02:00
parent 7c5a2be966
commit 63292b5c41
2 changed files with 41 additions and 12 deletions

View file

@ -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

View file

@ -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;
}