Blame SOURCES/macsec-0032-mka-Make-MKA-actor-priority-configurable.patch

9c84ec
From 65dfa872862641c17e4f6276c56fad0a6c18d219 Mon Sep 17 00:00:00 2001
9c84ec
Message-Id: <65dfa872862641c17e4f6276c56fad0a6c18d219.1488376602.git.dcaratti@redhat.com>
9c84ec
From: Badrish Adiga H R <badrish.adigahr@gmail.com>
9c84ec
Date: Mon, 5 Dec 2016 06:53:55 -0800
9c84ec
Subject: [PATCH] mka: Make MKA actor priority configurable
9c84ec
9c84ec
This adds a new wpa_supplicant network profile parameter
9c84ec
mka_priority=0..255 to set the priority of the MKA Actor.
9c84ec
9c84ec
Signed-off-by: Badrish Adiga H R <badrish.adigahr@gmail.com>
9c84ec
---
9c84ec
 src/pae/ieee802_1x_kay.c           | 4 ++--
9c84ec
 src/pae/ieee802_1x_kay.h           | 2 +-
9c84ec
 wpa_supplicant/config.c            | 5 +++++
9c84ec
 wpa_supplicant/config_file.c       | 2 ++
9c84ec
 wpa_supplicant/config_ssid.h       | 7 +++++++
9c84ec
 wpa_supplicant/wpa_cli.c           | 1 +
9c84ec
 wpa_supplicant/wpa_supplicant.conf | 8 +++++---
9c84ec
 wpa_supplicant/wpas_kay.c          | 3 ++-
9c84ec
 8 files changed, 25 insertions(+), 7 deletions(-)
9c84ec
9c84ec
diff --git a/src/pae/ieee802_1x_kay.c b/src/pae/ieee802_1x_kay.c
9c84ec
index cf5782a..1004b32 100644
9c84ec
--- a/src/pae/ieee802_1x_kay.c
9c84ec
+++ b/src/pae/ieee802_1x_kay.c
9c84ec
@@ -3083,7 +3083,7 @@ static void kay_l2_receive(void *ctx, const u8 *src_addr, const u8 *buf,
9c84ec
  */
9c84ec
 struct ieee802_1x_kay *
9c84ec
 ieee802_1x_kay_init(struct ieee802_1x_kay_ctx *ctx, enum macsec_policy policy,
9c84ec
-		    u16 port, const char *ifname, const u8 *addr)
9c84ec
+		    u16 port, u8 priority, const char *ifname, const u8 *addr)
9c84ec
 {
9c84ec
 	struct ieee802_1x_kay *kay;
9c84ec
 
9c84ec
@@ -3106,7 +3106,7 @@ ieee802_1x_kay_init(struct ieee802_1x_kay_ctx *ctx, enum macsec_policy policy,
9c84ec
 	os_strlcpy(kay->if_name, ifname, IFNAMSIZ);
9c84ec
 	os_memcpy(kay->actor_sci.addr, addr, ETH_ALEN);
9c84ec
 	kay->actor_sci.port = host_to_be16(port ? port : 0x0001);
9c84ec
-	kay->actor_priority = DEFAULT_PRIO_NOT_KEY_SERVER;
9c84ec
+	kay->actor_priority = priority;
9c84ec
 
9c84ec
 	/* While actor acts as a key server, shall distribute sakey */
9c84ec
 	kay->dist_kn = 1;
9c84ec
diff --git a/src/pae/ieee802_1x_kay.h b/src/pae/ieee802_1x_kay.h
9c84ec
index b38e814..8f394fd 100644
9c84ec
--- a/src/pae/ieee802_1x_kay.h
9c84ec
+++ b/src/pae/ieee802_1x_kay.h
9c84ec
@@ -236,7 +236,7 @@ u64 mka_sci_u64(struct ieee802_1x_mka_sci *sci);
9c84ec
 
9c84ec
 struct ieee802_1x_kay *
9c84ec
 ieee802_1x_kay_init(struct ieee802_1x_kay_ctx *ctx, enum macsec_policy policy,
9c84ec
-		    u16 port, const char *ifname, const u8 *addr);
9c84ec
+		    u16 port, u8 priority, const char *ifname, const u8 *addr);
9c84ec
 void ieee802_1x_kay_deinit(struct ieee802_1x_kay *kay);
9c84ec
 
9c84ec
 struct ieee802_1x_mka_participant *
9c84ec
diff --git a/wpa_supplicant/config.c b/wpa_supplicant/config.c
9c84ec
index 2120a6e..2a26d2d 100644
9c84ec
--- a/wpa_supplicant/config.c
9c84ec
+++ b/wpa_supplicant/config.c
9c84ec
@@ -11,6 +11,7 @@
9c84ec
 #include "common.h"
9c84ec
 #include "utils/uuid.h"
9c84ec
 #include "utils/ip_addr.h"
9c84ec
+#include "common/ieee802_1x_defs.h"
9c84ec
 #include "crypto/sha1.h"
9c84ec
 #include "rsn_supp/wpa.h"
9c84ec
 #include "eap_peer/eap.h"
9c84ec
@@ -2127,6 +2128,7 @@ static const struct parse_data ssid_fields[] = {
9c84ec
 	{ INT_RANGE(macsec_policy, 0, 1) },
9c84ec
 	{ INT_RANGE(macsec_integ_only, 0, 1) },
9c84ec
 	{ INT_RANGE(macsec_port, 1, 65534) },
9c84ec
+	{ INT_RANGE(mka_priority, 0, 255) },
9c84ec
 	{ FUNC_KEY(mka_cak) },
9c84ec
 	{ FUNC_KEY(mka_ckn) },
9c84ec
 #endif /* CONFIG_MACSEC */
9c84ec
@@ -2617,6 +2619,9 @@ void wpa_config_set_network_defaults(struct wpa_ssid *ssid)
9c84ec
 #ifdef CONFIG_IEEE80211W
9c84ec
 	ssid->ieee80211w = MGMT_FRAME_PROTECTION_DEFAULT;
9c84ec
 #endif /* CONFIG_IEEE80211W */
9c84ec
+#ifdef CONFIG_MACSEC
9c84ec
+	ssid->mka_priority = DEFAULT_PRIO_NOT_KEY_SERVER;
9c84ec
+#endif /* CONFIG_MACSEC */
9c84ec
 	ssid->mac_addr = -1;
9c84ec
 }
9c84ec
 
9c84ec
diff --git a/wpa_supplicant/config_file.c b/wpa_supplicant/config_file.c
9c84ec
index b9b1d4d..98e3591 100644
9c84ec
--- a/wpa_supplicant/config_file.c
9c84ec
+++ b/wpa_supplicant/config_file.c
9c84ec
@@ -19,6 +19,7 @@
9c84ec
 #include "config.h"
9c84ec
 #include "base64.h"
9c84ec
 #include "uuid.h"
9c84ec
+#include "common/ieee802_1x_defs.h"
9c84ec
 #include "p2p/p2p.h"
9c84ec
 #include "eap_peer/eap_methods.h"
9c84ec
 #include "eap_peer/eap.h"
9c84ec
@@ -813,6 +814,7 @@ static void wpa_config_write_network(FILE *f, struct wpa_ssid *ssid)
9c84ec
 	write_mka_ckn(f, ssid);
9c84ec
 	INT(macsec_integ_only);
9c84ec
 	INT(macsec_port);
9c84ec
+	INT_DEF(mka_priority, DEFAULT_PRIO_NOT_KEY_SERVER);
9c84ec
 #endif /* CONFIG_MACSEC */
9c84ec
 #ifdef CONFIG_HS20
9c84ec
 	INT(update_identifier);
9c84ec
diff --git a/wpa_supplicant/config_ssid.h b/wpa_supplicant/config_ssid.h
9c84ec
index fe0f7fa..69ace37 100644
9c84ec
--- a/wpa_supplicant/config_ssid.h
9c84ec
+++ b/wpa_supplicant/config_ssid.h
9c84ec
@@ -751,6 +751,13 @@ struct wpa_ssid {
9c84ec
 	int macsec_port;
9c84ec
 
9c84ec
 	/**
9c84ec
+	 * mka_priority - Priority of MKA Actor
9c84ec
+	 *
9c84ec
+	 * Range: 0-255 (default: 255)
9c84ec
+	 */
9c84ec
+	int mka_priority;
9c84ec
+
9c84ec
+	/**
9c84ec
 	 * mka_ckn - MKA pre-shared CKN
9c84ec
 	 */
9c84ec
 #define MACSEC_CKN_LEN 32
9c84ec
diff --git a/wpa_supplicant/wpa_cli.c b/wpa_supplicant/wpa_cli.c
9c84ec
index f11028a..21adc17 100644
9c84ec
--- a/wpa_supplicant/wpa_cli.c
9c84ec
+++ b/wpa_supplicant/wpa_cli.c
9c84ec
@@ -1392,6 +1392,7 @@ static const char *network_fields[] = {
9c84ec
 	"macsec_policy",
9c84ec
 	"macsec_integ_only",
9c84ec
 	"macsec_port",
9c84ec
+	"mka_priority",
9c84ec
 #endif /* CONFIG_MACSEC */
9c84ec
 #ifdef CONFIG_HS20
9c84ec
 	"update_identifier",
9c84ec
diff --git a/wpa_supplicant/wpa_supplicant.conf b/wpa_supplicant/wpa_supplicant.conf
9c84ec
index edb230d..94cef4a 100644
9c84ec
--- a/wpa_supplicant/wpa_supplicant.conf
9c84ec
+++ b/wpa_supplicant/wpa_supplicant.conf
9c84ec
@@ -901,13 +901,15 @@ fast_reauth=1
9c84ec
 # Port component of the SCI
9c84ec
 # Range: 1-65534 (default: 1)
9c84ec
 #
9c84ec
-# mka_cak and mka_ckn: IEEE 802.1X/MACsec pre-shared authentication mode
9c84ec
+# mka_cak, mka_ckn, and mka_priority: IEEE 802.1X/MACsec pre-shared key mode
9c84ec
 # This allows to configure MACsec with a pre-shared key using a (CAK,CKN) pair.
9c84ec
-# In this mode, instances of wpa_supplicant can act as peers, one of
9c84ec
-# which will become the key server and start distributing SAKs.
9c84ec
+# In this mode, instances of wpa_supplicant can act as MACsec peers. The peer
9c84ec
+# with lower priority will become the key server and start distributing SAKs.
9c84ec
 # mka_cak (CAK = Secure Connectivity Association Key) takes a 16-bytes (128 bit)
9c84ec
 # hex-string (32 hex-digits)
9c84ec
 # mka_ckn (CKN = CAK Name) takes a 32-bytes (256 bit) hex-string (64 hex-digits)
9c84ec
+# mka_priority (Priority of MKA Actor) is in 0..255 range with 255 being
9c84ec
+# default priority
9c84ec
 #
9c84ec
 # mixed_cell: This option can be used to configure whether so called mixed
9c84ec
 # cells, i.e., networks that use both plaintext and encryption in the same
9c84ec
diff --git a/wpa_supplicant/wpas_kay.c b/wpa_supplicant/wpas_kay.c
9c84ec
index d3fefda..d087e00 100644
9c84ec
--- a/wpa_supplicant/wpas_kay.c
9c84ec
+++ b/wpa_supplicant/wpas_kay.c
9c84ec
@@ -233,7 +233,8 @@ int ieee802_1x_alloc_kay_sm(struct wpa_supplicant *wpa_s, struct wpa_ssid *ssid)
9c84ec
 	kay_ctx->disable_transmit_sa = wpas_disable_transmit_sa;
9c84ec
 
9c84ec
 	res = ieee802_1x_kay_init(kay_ctx, policy, ssid->macsec_port,
9c84ec
-				  wpa_s->ifname, wpa_s->own_addr);
9c84ec
+				  ssid->mka_priority, wpa_s->ifname,
9c84ec
+				  wpa_s->own_addr);
9c84ec
 	if (res == NULL) {
9c84ec
 		os_free(kay_ctx);
9c84ec
 		return -1;
9c84ec
-- 
9c84ec
2.7.4
9c84ec