Blame SOURCES/macsec-0017-wpa_supplicant-Allow-configuring-the-MACsec-port-for.patch

9c84ec
From e0d9fd344d20bb35efcd5c37ece0a5d67632439d Mon Sep 17 00:00:00 2001
9c84ec
Message-Id: <e0d9fd344d20bb35efcd5c37ece0a5d67632439d.1488376602.git.dcaratti@redhat.com>
9c84ec
From: Sabrina Dubroca <sd@queasysnail.net>
9c84ec
Date: Wed, 2 Nov 2016 16:38:39 +0100
9c84ec
Subject: [PATCH] wpa_supplicant: Allow configuring the MACsec port for MKA
9c84ec
9c84ec
Previously, wpa_supplicant only supported hardcoded port == 1 in the
9c84ec
SCI, but users may want to choose a different port.
9c84ec
9c84ec
Signed-off-by: Sabrina Dubroca <sd@queasysnail.net>
9c84ec
---
9c84ec
 src/pae/ieee802_1x_kay.c           | 4 ++--
9c84ec
 src/pae/ieee802_1x_kay.h           | 2 +-
9c84ec
 wpa_supplicant/config.c            | 1 +
9c84ec
 wpa_supplicant/config_file.c       | 1 +
9c84ec
 wpa_supplicant/config_ssid.h       | 9 +++++++++
9c84ec
 wpa_supplicant/wpa_cli.c           | 1 +
9c84ec
 wpa_supplicant/wpa_supplicant.conf | 4 ++++
9c84ec
 wpa_supplicant/wpas_kay.c          | 4 ++--
9c84ec
 8 files changed, 21 insertions(+), 5 deletions(-)
9c84ec
9c84ec
diff --git a/src/pae/ieee802_1x_kay.c b/src/pae/ieee802_1x_kay.c
9c84ec
index 7664e2d..3a495ca 100644
9c84ec
--- a/src/pae/ieee802_1x_kay.c
9c84ec
+++ b/src/pae/ieee802_1x_kay.c
9c84ec
@@ -3071,7 +3071,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
-		    const char *ifname, const u8 *addr)
9c84ec
+		    u16 port, const char *ifname, const u8 *addr)
9c84ec
 {
9c84ec
 	struct ieee802_1x_kay *kay;
9c84ec
 
9c84ec
@@ -3093,7 +3093,7 @@ ieee802_1x_kay_init(struct ieee802_1x_kay_ctx *ctx, enum macsec_policy policy,
9c84ec
 
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(0x0001);
9c84ec
+	kay->actor_sci.port = host_to_be16(port ? port : 0x0001);
9c84ec
 	kay->actor_priority = DEFAULT_PRIO_NOT_KEY_SERVER;
9c84ec
 
9c84ec
 	/* While actor acts as a key server, shall distribute sakey */
9c84ec
diff --git a/src/pae/ieee802_1x_kay.h b/src/pae/ieee802_1x_kay.h
9c84ec
index fb49f62..ea5a0dd 100644
9c84ec
--- a/src/pae/ieee802_1x_kay.h
9c84ec
+++ b/src/pae/ieee802_1x_kay.h
9c84ec
@@ -233,7 +233,7 @@ struct ieee802_1x_kay {
9c84ec
 
9c84ec
 struct ieee802_1x_kay *
9c84ec
 ieee802_1x_kay_init(struct ieee802_1x_kay_ctx *ctx, enum macsec_policy policy,
9c84ec
-		    const char *ifname, const u8 *addr);
9c84ec
+		    u16 port, 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 afb631e..2120a6e 100644
9c84ec
--- a/wpa_supplicant/config.c
9c84ec
+++ b/wpa_supplicant/config.c
9c84ec
@@ -2126,6 +2126,7 @@ static const struct parse_data ssid_fields[] = {
9c84ec
 #ifdef CONFIG_MACSEC
9c84ec
 	{ INT_RANGE(macsec_policy, 0, 1) },
9c84ec
 	{ INT_RANGE(macsec_integ_only, 0, 1) },
9c84ec
+	{ INT_RANGE(macsec_port, 1, 65534) },
9c84ec
 	{ FUNC_KEY(mka_cak) },
9c84ec
 	{ FUNC_KEY(mka_ckn) },
9c84ec
 #endif /* CONFIG_MACSEC */
9c84ec
diff --git a/wpa_supplicant/config_file.c b/wpa_supplicant/config_file.c
9c84ec
index f605fa9..2e3d57e 100644
9c84ec
--- a/wpa_supplicant/config_file.c
9c84ec
+++ b/wpa_supplicant/config_file.c
9c84ec
@@ -809,6 +809,7 @@ static void wpa_config_write_network(FILE *f, struct wpa_ssid *ssid)
9c84ec
 	write_mka_cak(f, ssid);
9c84ec
 	write_mka_ckn(f, ssid);
9c84ec
 	INT(macsec_integ_only);
9c84ec
+	INT(macsec_port);
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 b8c3192..fe0f7fa 100644
9c84ec
--- a/wpa_supplicant/config_ssid.h
9c84ec
+++ b/wpa_supplicant/config_ssid.h
9c84ec
@@ -742,6 +742,15 @@ struct wpa_ssid {
9c84ec
 	int macsec_integ_only;
9c84ec
 
9c84ec
 	/**
9c84ec
+	 * macsec_port - MACsec port (in SCI)
9c84ec
+	 *
9c84ec
+	 * Port component of the SCI.
9c84ec
+	 *
9c84ec
+	 * Range: 1-65534 (default: 1)
9c84ec
+	 */
9c84ec
+	int macsec_port;
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 aed95e6..f11028a 100644
9c84ec
--- a/wpa_supplicant/wpa_cli.c
9c84ec
+++ b/wpa_supplicant/wpa_cli.c
9c84ec
@@ -1391,6 +1391,7 @@ static const char *network_fields[] = {
9c84ec
 #ifdef CONFIG_MACSEC
9c84ec
 	"macsec_policy",
9c84ec
 	"macsec_integ_only",
9c84ec
+	"macsec_port",
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 b23c5e6..82aa24e 100644
9c84ec
--- a/wpa_supplicant/wpa_supplicant.conf
9c84ec
+++ b/wpa_supplicant/wpa_supplicant.conf
9c84ec
@@ -899,6 +899,10 @@ fast_reauth=1
9c84ec
 # 0: Encrypt traffic (default)
9c84ec
 # 1: Integrity only
9c84ec
 #
9c84ec
+# macsec_port: IEEE 802.1X/MACsec port
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
 # 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
diff --git a/wpa_supplicant/wpas_kay.c b/wpa_supplicant/wpas_kay.c
9c84ec
index 2ff4895..d3fefda 100644
9c84ec
--- a/wpa_supplicant/wpas_kay.c
9c84ec
+++ b/wpa_supplicant/wpas_kay.c
9c84ec
@@ -232,8 +232,8 @@ int ieee802_1x_alloc_kay_sm(struct wpa_supplicant *wpa_s, struct wpa_ssid *ssid)
9c84ec
 	kay_ctx->enable_transmit_sa = wpas_enable_transmit_sa;
9c84ec
 	kay_ctx->disable_transmit_sa = wpas_disable_transmit_sa;
9c84ec
 
9c84ec
-	res = ieee802_1x_kay_init(kay_ctx, policy, wpa_s->ifname,
9c84ec
-				  wpa_s->own_addr);
9c84ec
+	res = ieee802_1x_kay_init(kay_ctx, policy, ssid->macsec_port,
9c84ec
+				  wpa_s->ifname, wpa_s->own_addr);
9c84ec
 	if (res == NULL) {
9c84ec
 		os_free(kay_ctx);
9c84ec
 		return -1;
9c84ec
-- 
9c84ec
2.7.4
9c84ec