TDLS: Fix higher/lower MAC address check for concurrent init
authorJouni Malinen <jouni.malinen@atheros.com>
Thu, 27 Jan 2011 19:08:50 +0000 (21:08 +0200)
committerJouni Malinen <j@w1.fi>
Sun, 6 Mar 2011 12:54:36 +0000 (14:54 +0200)
The logic here was reversed: the STA with lower MAC address is the
one that continues as the initiator.

src/rsn_supp/tdls.c

index 8c6a362..db423e3 100644 (file)
@@ -1302,28 +1302,23 @@ skip_rsn:
                }
 
                /*
-                * An entry is already present, so check if a TPK M1 Request
-                * had been sent.
-                * If so compare MAC address and let
-                *  - greater MAC continue to be initiator
-                *  - other MAC be Peer and process the Req.
+                * An entry is already present, so check if we already sent a
+                * TDLS Setup Request. If so, compare MAC addresses and let the
+                * STA with the lower MAC address continue as the initiator.
+                * The other negotiation is terminated.
                 */
                if (peer->initiator) {
-                       if (os_memcmp(sm->own_addr, src_addr, ETH_ALEN) > 0) {
-                               wpa_printf(MSG_DEBUG, "TDLS: Dropping Request "
-                                          "from peer with smaller address "
+                       if (os_memcmp(sm->own_addr, src_addr, ETH_ALEN) < 0) {
+                               wpa_printf(MSG_DEBUG, "TDLS: Discard request "
+                                          "from peer with higher address "
                                           MACSTR, MAC2STR(src_addr));
                                return -1;
                        } else {
-                               /*
-                                * If smaller node then accept the packet,
-                                * clear values and get ready to process this
-                                * Req.
-                                */
-                               wpa_printf(MSG_DEBUG, "TDLS: Accepting "
-                                          "Request from peer " MACSTR,
+                               wpa_printf(MSG_DEBUG, "TDLS: Accept request "
+                                          "from peer with lower address "
+                                          MACSTR " (terminate previously "
+                                          "initiated negotiation",
                                           MAC2STR(src_addr));
-                               /* clear sm info and preserve the list */
                                wpa_tdls_peer_free(sm, peer);
                        }
                }