Blame SOURCES/macsec-0031-PAE-Make-KaY-specific-details-available-via-control-.patch

b645d2
From 7508c2ad99cef6d0691190063ec7735b7759f836 Mon Sep 17 00:00:00 2001
b645d2
Message-Id: <7508c2ad99cef6d0691190063ec7735b7759f836.1488376602.git.dcaratti@redhat.com>
b645d2
From: Badrish Adiga H R <badrish.adigahr@gmail.com>
b645d2
Date: Fri, 16 Dec 2016 01:40:53 +0530
b645d2
Subject: [PATCH] PAE: Make KaY specific details available via control
b645d2
 interface
b645d2
b645d2
Add KaY details to the STATUS command output.
b645d2
b645d2
Signed-off-by: Badrish Adiga H R <badrish.adigahr@hpe.com>
b645d2
---
b645d2
 src/pae/ieee802_1x_kay.c    | 49 +++++++++++++++++++++++++++++++++++++++++++++
b645d2
 src/pae/ieee802_1x_kay.h    |  3 +++
b645d2
 wpa_supplicant/ctrl_iface.c |  6 ++++++
b645d2
 3 files changed, 58 insertions(+)
b645d2
b645d2
diff --git a/src/pae/ieee802_1x_kay.c b/src/pae/ieee802_1x_kay.c
b645d2
index 1d6d9a9..cf5782a 100644
b645d2
--- a/src/pae/ieee802_1x_kay.c
b645d2
+++ b/src/pae/ieee802_1x_kay.c
b645d2
@@ -1641,6 +1641,7 @@ ieee802_1x_mka_decode_dist_sak_body(
b645d2
 	ieee802_1x_cp_signal_newsak(kay->cp);
b645d2
 	ieee802_1x_cp_sm_step(kay->cp);
b645d2
 
b645d2
+	kay->rcvd_keys++;
b645d2
 	participant->to_use_sak = TRUE;
b645d2
 
b645d2
 	return 0;
b645d2
@@ -3519,3 +3520,51 @@ ieee802_1x_kay_change_cipher_suite(struct ieee802_1x_kay *kay,
b645d2
 
b645d2
 	return 0;
b645d2
 }
b645d2
+
b645d2
+
b645d2
+#ifdef CONFIG_CTRL_IFACE
b645d2
+/**
b645d2
+ * ieee802_1x_kay_get_status - Get IEEE 802.1X KaY status details
b645d2
+ * @sm: Pointer to KaY allocated with ieee802_1x_kay_init()
b645d2
+ * @buf: Buffer for status information
b645d2
+ * @buflen: Maximum buffer length
b645d2
+ * @verbose: Whether to include verbose status information
b645d2
+ * Returns: Number of bytes written to buf.
b645d2
+ *
b645d2
+ * Query KAY status information. This function fills in a text area with current
b645d2
+ * status information. If the buffer (buf) is not large enough, status
b645d2
+ * information will be truncated to fit the buffer.
b645d2
+ */
b645d2
+int ieee802_1x_kay_get_status(struct ieee802_1x_kay *kay, char *buf,
b645d2
+			      size_t buflen)
b645d2
+{
b645d2
+	int len;
b645d2
+
b645d2
+	if (!kay)
b645d2
+		return 0;
b645d2
+
b645d2
+	len = os_snprintf(buf, buflen,
b645d2
+			  "PAE KaY status=%s\n"
b645d2
+			  "Authenticated=%s\n"
b645d2
+			  "Secured=%s\n"
b645d2
+			  "Failed=%s\n"
b645d2
+			  "Actor Priority=%u\n"
b645d2
+			  "Key Server Priority=%u\n"
b645d2
+			  "Is Key Server=%s\n"
b645d2
+			  "Number of Keys Distributed=%u\n"
b645d2
+			  "Number of Keys Received=%u\n",
b645d2
+			  kay->active ? "Active" : "Not-Active",
b645d2
+			  kay->authenticated ? "Yes" : "No",
b645d2
+			  kay->secured ? "Yes" : "No",
b645d2
+			  kay->failed ? "Yes" : "No",
b645d2
+			  kay->actor_priority,
b645d2
+			  kay->key_server_priority,
b645d2
+			  kay->is_key_server ? "Yes" : "No",
b645d2
+			  kay->dist_kn - 1,
b645d2
+			  kay->rcvd_keys);
b645d2
+	if (os_snprintf_error(buflen, len))
b645d2
+		return 0;
b645d2
+
b645d2
+	return len;
b645d2
+}
b645d2
+#endif /* CONFIG_CTRL_IFACE */
b645d2
diff --git a/src/pae/ieee802_1x_kay.h b/src/pae/ieee802_1x_kay.h
b645d2
index 9a92d1c..b38e814 100644
b645d2
--- a/src/pae/ieee802_1x_kay.h
b645d2
+++ b/src/pae/ieee802_1x_kay.h
b645d2
@@ -208,6 +208,7 @@ struct ieee802_1x_kay {
b645d2
 	int mka_algindex;  /* MKA alg table index */
b645d2
 
b645d2
 	u32 dist_kn;
b645d2
+	u32 rcvd_keys;
b645d2
 	u8 dist_an;
b645d2
 	time_t dist_time;
b645d2
 
b645d2
@@ -267,5 +268,7 @@ int ieee802_1x_kay_enable_tx_sas(struct ieee802_1x_kay *kay,
b645d2
 int ieee802_1x_kay_enable_rx_sas(struct ieee802_1x_kay *kay,
b645d2
 				 struct ieee802_1x_mka_ki *lki);
b645d2
 int ieee802_1x_kay_enable_new_info(struct ieee802_1x_kay *kay);
b645d2
+int ieee802_1x_kay_get_status(struct ieee802_1x_kay *kay, char *buf,
b645d2
+			      size_t buflen);
b645d2
 
b645d2
 #endif /* IEEE802_1X_KAY_H */
b645d2
diff --git a/wpa_supplicant/ctrl_iface.c b/wpa_supplicant/ctrl_iface.c
b645d2
index c943dee..624e894 100644
b645d2
--- a/wpa_supplicant/ctrl_iface.c
b645d2
+++ b/wpa_supplicant/ctrl_iface.c
b645d2
@@ -2050,6 +2050,12 @@ static int wpa_supplicant_ctrl_iface_status(struct wpa_supplicant *wpa_s,
b645d2
 			pos += res;
b645d2
 	}
b645d2
 
b645d2
+#ifdef CONFIG_MACSEC
b645d2
+	res = ieee802_1x_kay_get_status(wpa_s->kay, pos, end - pos);
b645d2
+	if (res > 0)
b645d2
+		pos += res;
b645d2
+#endif /* CONFIG_MACSEC */
b645d2
+
b645d2
 	sess_id = eapol_sm_get_session_id(wpa_s->eapol, &sess_id_len);
b645d2
 	if (sess_id) {
b645d2
 		char *start = pos;
b645d2
-- 
b645d2
2.7.4
b645d2