Blame SOURCES/macsec-0035-mka-Send-MKPDUs-forever-if-mode-is-PSK.patch

9c84ec
From 37e9f511eb0072dbce190cb21e2d48f022173b03 Mon Sep 17 00:00:00 2001
9c84ec
Message-Id: <37e9f511eb0072dbce190cb21e2d48f022173b03.1488376602.git.dcaratti@redhat.com>
9c84ec
From: Badrish Adiga H R <badrish.adigahr@gmail.com>
9c84ec
Date: Tue, 7 Feb 2017 14:28:31 +0530
9c84ec
Subject: [PATCH] mka: Send MKPDUs forever if mode is PSK
9c84ec
9c84ec
Issue: When 2 peers are running MACsec in PSK mode with CA
9c84ec
established, if the interface goes down and comes up after
9c84ec
time > 10 seconds, CA does not get re-established.
9c84ec
9c84ec
Root cause: This is because retry_count of both the peers
9c84ec
would have reached MAX_RETRY_CNT and stays idle for other to
9c84ec
respond. This is clear deadlock situation where peer A waits
9c84ec
for MKA packets from peer B to wake up and vice-versa.
9c84ec
9c84ec
Fix: If MACsec is running in PSK mode, we should send MKPDUs
9c84ec
forever for every 2 seconds.
9c84ec
9c84ec
Signed-off-by: Badrish Adiga H R <badrish.adigahr@gmail.com>
9c84ec
---
9c84ec
 src/pae/ieee802_1x_kay.c   | 6 ++++--
9c84ec
 src/pae/ieee802_1x_kay_i.h | 1 +
9c84ec
 2 files changed, 5 insertions(+), 2 deletions(-)
9c84ec
9c84ec
diff --git a/src/pae/ieee802_1x_kay.c b/src/pae/ieee802_1x_kay.c
9c84ec
index 92fd7ba..e420fc1 100644
9c84ec
--- a/src/pae/ieee802_1x_kay.c
9c84ec
+++ b/src/pae/ieee802_1x_kay.c
9c84ec
@@ -2428,7 +2428,8 @@ static void ieee802_1x_participant_timer(void *eloop_ctx, void *timeout_ctx)
9c84ec
 		participant->new_sak = FALSE;
9c84ec
 	}
9c84ec
 
9c84ec
-	if (participant->retry_count < MAX_RETRY_CNT) {
9c84ec
+	if (participant->retry_count < MAX_RETRY_CNT ||
9c84ec
+	    participant->mode == PSK) {
9c84ec
 		ieee802_1x_participant_send_mkpdu(participant);
9c84ec
 		participant->retry_count++;
9c84ec
 	}
9c84ec
@@ -2828,7 +2829,7 @@ int ieee802_1x_kay_enable_new_info(struct ieee802_1x_kay *kay)
9c84ec
 	if (!principal)
9c84ec
 		return -1;
9c84ec
 
9c84ec
-	if (principal->retry_count < MAX_RETRY_CNT) {
9c84ec
+	if (principal->retry_count < MAX_RETRY_CNT || principal->mode == PSK) {
9c84ec
 		ieee802_1x_participant_send_mkpdu(principal);
9c84ec
 		principal->retry_count++;
9c84ec
 	}
9c84ec
@@ -3368,6 +3369,7 @@ ieee802_1x_kay_create_mka(struct ieee802_1x_kay *kay, struct mka_key_name *ckn,
9c84ec
 		participant->mka_life = MKA_LIFE_TIME / 1000 + time(NULL) +
9c84ec
 			usecs / 1000000;
9c84ec
 	}
9c84ec
+	participant->mode = mode;
9c84ec
 
9c84ec
 	return participant;
9c84ec
 
9c84ec
diff --git a/src/pae/ieee802_1x_kay_i.h b/src/pae/ieee802_1x_kay_i.h
9c84ec
index 0c4bb8e..bc522d8 100644
9c84ec
--- a/src/pae/ieee802_1x_kay_i.h
9c84ec
+++ b/src/pae/ieee802_1x_kay_i.h
9c84ec
@@ -93,6 +93,7 @@ struct ieee802_1x_mka_participant {
9c84ec
 	Boolean active;
9c84ec
 	Boolean participant;
9c84ec
 	Boolean retain;
9c84ec
+	enum mka_created_mode mode;
9c84ec
 
9c84ec
 	enum { DEFAULT, DISABLED, ON_OPER_UP, ALWAYS } activate;
9c84ec
 
9c84ec
-- 
9c84ec
2.7.4
9c84ec