Просмотр исходного кода

Some fixes then the session died

Johannes Zellner 1 неделя назад
Родитель
Сommit
6c1c2e0583
2 измененных файлов с 43 добавлено и 17 удалено
  1. 16 13
      iwl_mvm.c
  2. 27 4
      wifi.c

+ 16 - 13
iwl_mvm.c

@@ -375,11 +375,16 @@ static void rx_handler(const struct iwl_pkt *pkt)
 		rx_mpdu(pkt);
 		break;
 	case TX_CMD:
-		/* struct iwl_mvm_tx_resp_v3: status at byte 32. */
+		/* struct iwl_mvm_tx_resp_v3: frame_count at 0, failure_frame
+		 * at 3, ra_tid at 33, status[0] (agg_tx_status) at 36. */
 		iwl_tx_reclaim((pkt->seq >> 8) & 0x1f, pkt->seq & 0xff);
-		if (n > 33 && (d[32] & 0xff) != 1 && (d[32] & 0xff) != 2) {
-			serial_puts(SERIAL_COM1, "iwl: tx status ");
-			serial_puthex(SERIAL_COM1, get16(d + 32));
+		if (n >= 38 && d[36] != 1 && d[36] != 2) {
+			serial_puts(SERIAL_COM1, "iwl: tx failed q");
+			serial_putdec(SERIAL_COM1, (pkt->seq >> 8) & 0x1f);
+			serial_puts(SERIAL_COM1, " status ");
+			serial_puthex(SERIAL_COM1, get16(d + 36));
+			serial_puts(SERIAL_COM1, " retries ");
+			serial_putdec(SERIAL_COM1, d[3]);
 			serial_puts(SERIAL_COM1, "\n");
 		}
 		break;
@@ -1099,15 +1104,13 @@ int iwl_mvm_set_key(int pairwise, int keyidx, const unsigned char key[16],
 	if (!pairwise)
 		c.key_flags |= 1u << 14;         /* STA_KEY_MULTICAST */
 	iwl_memcpy(c.key, key, 16);
-	if (rsc) {
-		/* API v1: PN bytes 0,1 then a 2-byte hole, then 2..5. */
-		c.rx_secur_seq_cnt[0] = rsc[0];
-		c.rx_secur_seq_cnt[1] = rsc[1];
-		c.rx_secur_seq_cnt[4] = rsc[2];
-		c.rx_secur_seq_cnt[5] = rsc[3];
-		c.rx_secur_seq_cnt[6] = rsc[4];
-		c.rx_secur_seq_cnt[7] = rsc[5];
-	}
+	/* rx_secur_seq_cnt stays zero.  iwlmvm fills it from mac80211's
+	 * big-endian PN (with a 2-byte hole on API v1), while the EAPOL RSC is
+	 * little-endian; copying the RSC as-is made a small group PN look
+	 * huge, and the firmware dropped every broadcast/multicast frame as a
+	 * replay.  Starting from 0 only gives up replay protection for the
+	 * group frames sent before we joined. */
+	(void)rsc;
 	if (cmd_status(ADD_STA_KEY, &c, sizeof(c), &status) < 0 ||
 	    (status & 0xff) != 1) {
 		iwl_loghex("ADD_STA_KEY failed, status", status);

+ 27 - 4
wifi.c

@@ -258,6 +258,25 @@ static void queue_eapol(const unsigned char *p, unsigned int len)
 	W.eapq_head = (W.eapq_head + 1) % EAPOLQ_SLOTS;
 }
 
+/* First few data-path drops go to serial/netmon with the reason and the
+ * firmware RX status (decrypt result in bits 8..10, MIC_OK bit 6). */
+static void rx_drop(const char *why, const unsigned char *f,
+		    unsigned int status)
+{
+	W.rx_dropped++;
+	if (W.rx_dropped > 12)
+		return;
+	serial_puts(SERIAL_COM1, "wifi: rx drop ");
+	serial_puts(SERIAL_COM1, why);
+	serial_puts(SERIAL_COM1, " fc ");
+	serial_puthex(SERIAL_COM1, f[0] | (f[1] << 8));
+	serial_puts(SERIAL_COM1, " da ");
+	serial_puthex(SERIAL_COM1, (f[4] << 8) | f[5]);
+	serial_puts(SERIAL_COM1, " status ");
+	serial_puthex(SERIAL_COM1, status);
+	serial_puts(SERIAL_COM1, "\n");
+}
+
 static void rx_data(const unsigned char *f, unsigned int len,
 		    unsigned int status)
 {
@@ -278,7 +297,7 @@ static void rx_data(const unsigned char *f, unsigned int len,
 	if (prot) {
 		if ((status & IWL_RX_SEC_MSK) != IWL_RX_SEC_CCM ||
 		    !(status & IWL_RX_MIC_OK)) {
-			W.rx_dropped++;
+			rx_drop("not decrypted", f, status);
 			return;
 		}
 		hdr += 8;                            /* CCMP header */
@@ -286,8 +305,10 @@ static void rx_data(const unsigned char *f, unsigned int len,
 			return;
 		len -= 8;                            /* MIC */
 	}
-	if (len < hdr + 8 || !meq(f + hdr, snap, 6))
+	if (len < hdr + 8 || !meq(f + hdr, snap, 6)) {
+		rx_drop("no LLC/SNAP", f, status);
 		return;
+	}
 	type = (f[hdr + 6] << 8) | f[hdr + 7];
 	p = f + hdr + 8;
 	plen = len - hdr - 8;
@@ -297,12 +318,13 @@ static void rx_data(const unsigned char *f, unsigned int len,
 	}
 	/* Before the keys are in, or unprotected after: drop. */
 	if (W.state != SYS_WIFI_ST_LINK || (W.protect && !prot)) {
-		W.rx_dropped++;
+		rx_drop(W.state != SYS_WIFI_ST_LINK ? "port closed"
+						      : "unprotected", f, status);
 		return;
 	}
 	if (plen + 14 > RXQ_FRAME ||
 	    ((W.rxq_head + 1) % RXQ_SLOTS) == W.rxq_tail) {
-		W.rx_dropped++;
+		rx_drop("queue full", f, status);
 		return;
 	}
 	s = &W.rxq[W.rxq_head];
@@ -437,6 +459,7 @@ static int do_connect(const struct sys_wifi_connect *c)
 	W.pn = 0;
 	W.eapq_head = W.eapq_tail = 0;
 	W.rxq_head = W.rxq_tail = 0;
+	W.rx_dropped = 0;
 
 	if (iwl_mvm_prepare_connect(c->bssid, c->channel, W.cur.beacon_int) < 0) {
 		W.detail = "firmware connect setup failed";