OSDN Git Service

core: Load link keys and long term keys only when controller supports it
authorMarcel Holtmann <marcel@holtmann.org>
Thu, 10 Jan 2013 00:01:12 +0000 (16:01 -0800)
committerMarcel Holtmann <marcel@holtmann.org>
Thu, 10 Jan 2013 00:01:12 +0000 (16:01 -0800)
Check for BR/EDR support before loading link keys and check for LE support
before loading long term keys.

This has the nice benefit that for BR/EDR only controllers the warning
message from the kernel bug for loading long term keys is gone now. And
only systems with dual mode controllers will expierence it. Makes it a
little bit less confusing.

src/adapter.c

index 236fe2d..7bf5bca 100644 (file)
@@ -1961,6 +1961,16 @@ static void load_link_keys(struct btd_adapter *adapter, GSList *keys,
        unsigned int id;
        GSList *l;
 
+       /*
+        * If the controller does not support BR/EDR operation,
+        * there is no point in trying to load the link keys into
+        * the kernel.
+        *
+        * This is an optimization for Low Energy only controllers.
+        */
+       if (!(adapter->supported_settings & MGMT_SETTING_BREDR))
+               return;
+
        key_count = g_slist_length(keys);
 
        DBG("hci%u keys %zu debug_keys %d", adapter->dev_id, key_count,
@@ -2036,6 +2046,19 @@ static void load_ltks(struct btd_adapter *adapter, GSList *keys)
        size_t key_count, cp_size;
        GSList *l;
 
+       /*
+        * If the controller does not support Low Energy operation,
+        * there is no point in trying to load the long term keys
+        * into the kernel.
+        *
+        * While there is no harm in loading keys into the kernel,
+        * this is an optimization to avoid a confusing warning
+        * message when the loading of the keys timed out due to
+        * a kernel bug (see comment below).
+        */
+       if (!(adapter->supported_settings & MGMT_SETTING_LE))
+               return;
+
        key_count = g_slist_length(keys);
 
        DBG("hci%u keys %zu", adapter->dev_id, key_count);