Blame SOURCES/macsec-0012-mka-Fix-getting-capabilities-from-the-driver.patch

41389a
From 088d53dd15b14a1868b70fd0b8d695ac6b68f642 Mon Sep 17 00:00:00 2001
41389a
Message-Id: <088d53dd15b14a1868b70fd0b8d695ac6b68f642.1488376601.git.dcaratti@redhat.com>
41389a
From: Sabrina Dubroca <sd@queasysnail.net>
41389a
Date: Tue, 15 Nov 2016 18:06:23 +0100
41389a
Subject: [PATCH] mka: Fix getting capabilities from the driver
41389a
41389a
In commit a25e4efc9e428d968e83398bd8c9c94698ba5851 ('mka: Add driver op
41389a
to get macsec capabilities') I added some code to check the driver's
41389a
capabilities. This commit has two problems:
41389a
 - wrong enum type set in kay->macsec_confidentiality
41389a
 - ignores that drivers could report MACSEC_CAP_NOT_IMPLEMENTED, in
41389a
   which case the MKA would claim that MACsec is supported.
41389a
41389a
Fix this by interpreting MACSEC_CAP_NOT_IMPLEMENTED in the same way as a
41389a
DO_NOT_SECURE policy, and set the correct value in
41389a
kay->macsec_confidentiality.
41389a
41389a
Signed-off-by: Sabrina Dubroca <sd@queasysnail.net>
41389a
---
41389a
 src/pae/ieee802_1x_kay.c | 16 +++++++++-------
41389a
 1 file changed, 9 insertions(+), 7 deletions(-)
41389a
41389a
diff --git a/src/pae/ieee802_1x_kay.c b/src/pae/ieee802_1x_kay.c
41389a
index 63bbd13..2841b10 100644
41389a
--- a/src/pae/ieee802_1x_kay.c
41389a
+++ b/src/pae/ieee802_1x_kay.c
41389a
@@ -3111,7 +3111,14 @@ ieee802_1x_kay_init(struct ieee802_1x_kay_ctx *ctx, enum macsec_policy policy,
41389a
 
41389a
 	dl_list_init(&kay->participant_list);
41389a
 
41389a
-	if (policy == DO_NOT_SECURE) {
41389a
+	if (policy != DO_NOT_SECURE &&
41389a
+	    secy_get_capability(kay, &kay->macsec_capable) < 0) {
41389a
+		os_free(kay);
41389a
+		return NULL;
41389a
+	}
41389a
+
41389a
+	if (policy == DO_NOT_SECURE ||
41389a
+	    kay->macsec_capable == MACSEC_CAP_NOT_IMPLEMENTED) {
41389a
 		kay->macsec_capable = MACSEC_CAP_NOT_IMPLEMENTED;
41389a
 		kay->macsec_desired = FALSE;
41389a
 		kay->macsec_protect = FALSE;
41389a
@@ -3120,11 +3127,6 @@ ieee802_1x_kay_init(struct ieee802_1x_kay_ctx *ctx, enum macsec_policy policy,
41389a
 		kay->macsec_replay_window = 0;
41389a
 		kay->macsec_confidentiality = CONFIDENTIALITY_NONE;
41389a
 	} else {
41389a
-		if (secy_get_capability(kay, &kay->macsec_capable) < 0) {
41389a
-			os_free(kay);
41389a
-			return NULL;
41389a
-		}
41389a
-
41389a
 		kay->macsec_desired = TRUE;
41389a
 		kay->macsec_protect = TRUE;
41389a
 		kay->macsec_validate = Strict;
41389a
@@ -3133,7 +3135,7 @@ ieee802_1x_kay_init(struct ieee802_1x_kay_ctx *ctx, enum macsec_policy policy,
41389a
 		if (kay->macsec_capable >= MACSEC_CAP_INTEG_AND_CONF)
41389a
 			kay->macsec_confidentiality = CONFIDENTIALITY_OFFSET_0;
41389a
 		else
41389a
-			kay->macsec_confidentiality = MACSEC_CAP_INTEGRITY;
41389a
+			kay->macsec_confidentiality = CONFIDENTIALITY_NONE;
41389a
 	}
41389a
 
41389a
 	wpa_printf(MSG_DEBUG, "KaY: state machine created");
41389a
-- 
41389a
2.7.4
41389a