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

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