Browse Source

TDLS: Fix higher/lower MAC address check for concurrent init

The logic here was reversed: the STA with lower MAC address is the
one that continues as the initiator.
Jouni Malinen 14 years ago
parent
commit
43291b683c
1 changed files with 11 additions and 16 deletions
  1. 11 16
      src/rsn_supp/tdls.c

+ 11 - 16
src/rsn_supp/tdls.c

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