summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhilip Withnall <withnall@endlessm.com>2018-03-06 14:34:02 +0000
committerThomas Haller <thaller@redhat.com>2018-03-08 13:35:21 +0100
commit599da6fd02039e8b5b78953d2c517a62e5a08a4a (patch)
tree0d94f613d2ce78804b6218511a37f09f2eaf8693
parentd2f019409d0906814ccd2050ce39609903f879f7 (diff)
downloadNetworkManager-599da6fd02039e8b5b78953d2c517a62e5a08a4a.tar.gz
devices: Set NM_METERED_GUESS_YES for Bluetooth PANU/DUN connections
Bluetooth tethering using DUN or PANU is a common way to expose a metered 3G or 4G connection from a phone to a laptop. We deliberately ignore NAP connections, which is where we’re sharing internet from the laptop to another device. We could also set GUESS_YES for WiMAX connections, but NetworkManager doesn’t support them any more. Add a comment about that. Signed-off-by: Philip Withnall <withnall@endlessm.com> https://bugzilla.gnome.org/show_bug.cgi?id=794120
-rw-r--r--src/devices/nm-device.c21
1 files changed, 19 insertions, 2 deletions
diff --git a/src/devices/nm-device.c b/src/devices/nm-device.c
index 2044f5511f..ce02292079 100644
--- a/src/devices/nm-device.c
+++ b/src/devices/nm-device.c
@@ -12363,10 +12363,27 @@ nm_device_update_metered (NMDevice *self)
value = NM_METERED_GUESS_YES;
}
- /* Otherwise look at connection type */
+ /* Otherwise look at connection type. For Bluetooth, we look at the type of
+ * Bluetooth sharing: for PANU/DUN (where we are receiving internet from
+ * another device) we set GUESS_YES; for NAP (where we are sharing internet
+ * to another device) we set GUESS_NO. We ignore WiMAX here as it’s no
+ * longer supported by NetworkManager. */
+ if (value == NM_METERED_INVALID &&
+ nm_connection_is_type (connection, NM_SETTING_BLUETOOTH_SETTING_NAME)) {
+ NMSettingBluetooth *bt = nm_connection_get_setting_bluetooth (connection);
+ const gchar *bt_type = (bt != NULL) ? nm_setting_bluetooth_get_connection_type (bt) : NULL;
+
+ if ( nm_streq0 (bt_type, NM_SETTING_BLUETOOTH_TYPE_PANU)
+ || nm_streq0 (bt_type, NM_SETTING_BLUETOOTH_TYPE_DUN))
+ value = NM_METERED_GUESS_YES;
+ else
+ value = NM_METERED_GUESS_NO;
+ }
+
if (value == NM_METERED_INVALID) {
if ( nm_connection_is_type (connection, NM_SETTING_GSM_SETTING_NAME)
- || nm_connection_is_type (connection, NM_SETTING_CDMA_SETTING_NAME))
+ || nm_connection_is_type (connection, NM_SETTING_CDMA_SETTING_NAME)
+ || nm_connection_is_type (connection, NM_SETTING_BLUETOOTH_SETTING_NAME))
value = NM_METERED_GUESS_YES;
else
value = NM_METERED_GUESS_NO;