Blame SOURCES/macsec-0002-mka-Pass-full-structures-down-to-macsec-drivers-pack.patch

9c84ec
From 7fa5eff8abbbff4f3385932175b080aad40bf211 Mon Sep 17 00:00:00 2001
9c84ec
Message-Id: <7fa5eff8abbbff4f3385932175b080aad40bf211.1488376601.git.dcaratti@redhat.com>
9c84ec
From: Sabrina Dubroca <sd@queasysnail.net>
9c84ec
Date: Tue, 20 Sep 2016 09:43:05 +0200
9c84ec
Subject: [PATCH] mka: Pass full structures down to macsec drivers' packet
9c84ec
 number ops
9c84ec
9c84ec
Clean up the driver interface by passing pointers to structs transmit_sa
9c84ec
and receive_sa down the stack to get_receive_lowest_pn(),
9c84ec
get_transmit_next_pn(), and set_transmit_next_pn() ops, instead of
9c84ec
passing the individual arguments.
9c84ec
9c84ec
Signed-off-by: Sabrina Dubroca <sd@queasysnail.net>
9c84ec
---
9c84ec
 src/drivers/driver.h            | 21 ++++++---------------
9c84ec
 src/drivers/driver_macsec_qca.c | 33 ++++++++++++++++++---------------
9c84ec
 src/pae/ieee802_1x_kay.h        |  8 +++-----
9c84ec
 src/pae/ieee802_1x_secy_ops.c   | 15 +++------------
9c84ec
 wpa_supplicant/driver_i.h       | 18 ++++++------------
9c84ec
 wpa_supplicant/wpas_kay.c       | 15 ++++++---------
9c84ec
 6 files changed, 42 insertions(+), 68 deletions(-)
9c84ec
9c84ec
diff --git a/src/drivers/driver.h b/src/drivers/driver.h
9c84ec
index 073219e..2c7ce6c 100644
9c84ec
--- a/src/drivers/driver.h
9c84ec
+++ b/src/drivers/driver.h
9c84ec
@@ -3336,35 +3336,26 @@ struct wpa_driver_ops {
9c84ec
 	/**
9c84ec
 	 * get_receive_lowest_pn - Get receive lowest pn
9c84ec
 	 * @priv: Private driver interface data
9c84ec
-	 * @channel: secure channel
9c84ec
-	 * @an: association number
9c84ec
-	 * @lowest_pn: lowest accept pn
9c84ec
+	 * @sa: secure association
9c84ec
 	 * Returns: 0 on success, -1 on failure (or if not supported)
9c84ec
 	 */
9c84ec
-	int (*get_receive_lowest_pn)(void *priv, u32 channel, u8 an,
9c84ec
-				     u32 *lowest_pn);
9c84ec
+	int (*get_receive_lowest_pn)(void *priv, struct receive_sa *sa);
9c84ec
 
9c84ec
 	/**
9c84ec
 	 * get_transmit_next_pn - Get transmit next pn
9c84ec
 	 * @priv: Private driver interface data
9c84ec
-	 * @channel: secure channel
9c84ec
-	 * @an: association number
9c84ec
-	 * @next_pn: next pn
9c84ec
+	 * @sa: secure association
9c84ec
 	 * Returns: 0 on success, -1 on failure (or if not supported)
9c84ec
 	 */
9c84ec
-	int (*get_transmit_next_pn)(void *priv, u32 channel, u8 an,
9c84ec
-				    u32 *next_pn);
9c84ec
+	int (*get_transmit_next_pn)(void *priv, struct transmit_sa *sa);
9c84ec
 
9c84ec
 	/**
9c84ec
 	 * set_transmit_next_pn - Set transmit next pn
9c84ec
 	 * @priv: Private driver interface data
9c84ec
-	 * @channel: secure channel
9c84ec
-	 * @an: association number
9c84ec
-	 * @next_pn: next pn
9c84ec
+	 * @sa: secure association
9c84ec
 	 * Returns: 0 on success, -1 on failure (or if not supported)
9c84ec
 	 */
9c84ec
-	int (*set_transmit_next_pn)(void *priv, u32 channel, u8 an,
9c84ec
-				    u32 next_pn);
9c84ec
+	int (*set_transmit_next_pn)(void *priv, struct transmit_sa *sa);
9c84ec
 
9c84ec
 	/**
9c84ec
 	 * get_available_receive_sc - get available receive channel
9c84ec
diff --git a/src/drivers/driver_macsec_qca.c b/src/drivers/driver_macsec_qca.c
9c84ec
index 826d3cc..95f1e27 100644
9c84ec
--- a/src/drivers/driver_macsec_qca.c
9c84ec
+++ b/src/drivers/driver_macsec_qca.c
9c84ec
@@ -29,6 +29,7 @@
9c84ec
 #include "utils/eloop.h"
9c84ec
 #include "common/defs.h"
9c84ec
 #include "common/ieee802_1x_defs.h"
9c84ec
+#include "pae/ieee802_1x_kay.h"
9c84ec
 #include "driver.h"
9c84ec
 
9c84ec
 #include "nss_macsec_secy.h"
9c84ec
@@ -515,16 +516,16 @@ static int macsec_qca_enable_controlled_port(void *priv, Boolean enabled)
9c84ec
 }
9c84ec
 
9c84ec
 
9c84ec
-static int macsec_qca_get_receive_lowest_pn(void *priv, u32 channel, u8 an,
9c84ec
-					    u32 *lowest_pn)
9c84ec
+static int macsec_qca_get_receive_lowest_pn(void *priv, struct receive_sa *sa)
9c84ec
 {
9c84ec
 	struct macsec_qca_data *drv = priv;
9c84ec
 	int ret = 0;
9c84ec
 	u32 next_pn = 0;
9c84ec
 	bool enabled = FALSE;
9c84ec
 	u32 win;
9c84ec
+	u32 channel = sa->sc->channel;
9c84ec
 
9c84ec
-	ret += nss_macsec_secy_rx_sa_next_pn_get(drv->secy_id, channel, an,
9c84ec
+	ret += nss_macsec_secy_rx_sa_next_pn_get(drv->secy_id, channel, sa->an,
9c84ec
 						 &next_pn);
9c84ec
 	ret += nss_macsec_secy_rx_sc_replay_protect_get(drv->secy_id, channel,
9c84ec
 							&enabled);
9c84ec
@@ -532,40 +533,42 @@ static int macsec_qca_get_receive_lowest_pn(void *priv, u32 channel, u8 an,
9c84ec
 							    channel, &win);
9c84ec
 
9c84ec
 	if (enabled)
9c84ec
-		*lowest_pn = (next_pn > win) ? (next_pn - win) : 1;
9c84ec
+		sa->lowest_pn = (next_pn > win) ? (next_pn - win) : 1;
9c84ec
 	else
9c84ec
-		*lowest_pn = next_pn;
9c84ec
+		sa->lowest_pn = next_pn;
9c84ec
 
9c84ec
-	wpa_printf(MSG_DEBUG, "%s: lpn=0x%x", __func__, *lowest_pn);
9c84ec
+	wpa_printf(MSG_DEBUG, "%s: lpn=0x%x", __func__, sa->lowest_pn);
9c84ec
 
9c84ec
 	return ret;
9c84ec
 }
9c84ec
 
9c84ec
 
9c84ec
-static int macsec_qca_get_transmit_next_pn(void *priv, u32 channel, u8 an,
9c84ec
-					   u32 *next_pn)
9c84ec
+static int macsec_qca_get_transmit_next_pn(void *priv, struct transmit_sa *sa)
9c84ec
 {
9c84ec
 	struct macsec_qca_data *drv = priv;
9c84ec
 	int ret = 0;
9c84ec
+	u32 channel = sa->sc->channel;
9c84ec
 
9c84ec
-	ret += nss_macsec_secy_tx_sa_next_pn_get(drv->secy_id, channel, an,
9c84ec
-						 next_pn);
9c84ec
+	ret += nss_macsec_secy_tx_sa_next_pn_get(drv->secy_id, channel, sa->an,
9c84ec
+						 &sa->next_pn);
9c84ec
 
9c84ec
-	wpa_printf(MSG_DEBUG, "%s: npn=0x%x", __func__, *next_pn);
9c84ec
+	wpa_printf(MSG_DEBUG, "%s: npn=0x%x", __func__, sa->next_pn);
9c84ec
 
9c84ec
 	return ret;
9c84ec
 }
9c84ec
 
9c84ec
 
9c84ec
-int macsec_qca_set_transmit_next_pn(void *priv, u32 channel, u8 an, u32 next_pn)
9c84ec
+int macsec_qca_set_transmit_next_pn(void *priv, struct transmit_sa *sa)
9c84ec
 {
9c84ec
 	struct macsec_qca_data *drv = priv;
9c84ec
 	int ret = 0;
9c84ec
+	u32 channel = sa->sc->channel;
9c84ec
 
9c84ec
-	ret += nss_macsec_secy_tx_sa_next_pn_set(drv->secy_id, channel, an,
9c84ec
-						 next_pn);
9c84ec
 
9c84ec
-	wpa_printf(MSG_INFO, "%s: npn=0x%x", __func__, next_pn);
9c84ec
+	ret += nss_macsec_secy_tx_sa_next_pn_set(drv->secy_id, channel, sa->an,
9c84ec
+						 sa->next_pn);
9c84ec
+
9c84ec
+	wpa_printf(MSG_INFO, "%s: npn=0x%x", __func__, sa->next_pn);
9c84ec
 
9c84ec
 	return ret;
9c84ec
 }
9c84ec
diff --git a/src/pae/ieee802_1x_kay.h b/src/pae/ieee802_1x_kay.h
9c84ec
index 0361e1a..a747b11 100644
9c84ec
--- a/src/pae/ieee802_1x_kay.h
9c84ec
+++ b/src/pae/ieee802_1x_kay.h
9c84ec
@@ -142,11 +142,9 @@ struct ieee802_1x_kay_ctx {
9c84ec
 	int (*set_replay_protect)(void *ctx, Boolean enabled, u32 window);
9c84ec
 	int (*set_current_cipher_suite)(void *ctx, u64 cs);
9c84ec
 	int (*enable_controlled_port)(void *ctx, Boolean enabled);
9c84ec
-	int (*get_receive_lowest_pn)(void *ctx, u32 channel, u8 an,
9c84ec
-				     u32 *lowest_pn);
9c84ec
-	int (*get_transmit_next_pn)(void *ctx, u32 channel, u8 an,
9c84ec
-				    u32 *next_pn);
9c84ec
-	int (*set_transmit_next_pn)(void *ctx, u32 channel, u8 an, u32 next_pn);
9c84ec
+	int (*get_receive_lowest_pn)(void *ctx, struct receive_sa *sa);
9c84ec
+	int (*get_transmit_next_pn)(void *ctx, struct transmit_sa *sa);
9c84ec
+	int (*set_transmit_next_pn)(void *ctx, struct transmit_sa *sa);
9c84ec
 	int (*get_available_receive_sc)(void *ctx, u32 *channel);
9c84ec
 	int (*create_receive_sc)(void *ctx, u32 channel,
9c84ec
 				 struct ieee802_1x_mka_sci *sci,
9c84ec
diff --git a/src/pae/ieee802_1x_secy_ops.c b/src/pae/ieee802_1x_secy_ops.c
9c84ec
index 2d12911..d05e00f 100644
9c84ec
--- a/src/pae/ieee802_1x_secy_ops.c
9c84ec
+++ b/src/pae/ieee802_1x_secy_ops.c
9c84ec
@@ -130,10 +130,7 @@ int secy_get_receive_lowest_pn(struct ieee802_1x_kay *kay,
9c84ec
 		return -1;
9c84ec
 	}
9c84ec
 
9c84ec
-	return ops->get_receive_lowest_pn(ops->ctx,
9c84ec
-					rxsa->sc->channel,
9c84ec
-					rxsa->an,
9c84ec
-					&rxsa->lowest_pn);
9c84ec
+	return ops->get_receive_lowest_pn(ops->ctx, rxsa);
9c84ec
 }
9c84ec
 
9c84ec
 
9c84ec
@@ -154,10 +151,7 @@ int secy_get_transmit_next_pn(struct ieee802_1x_kay *kay,
9c84ec
 		return -1;
9c84ec
 	}
9c84ec
 
9c84ec
-	return ops->get_transmit_next_pn(ops->ctx,
9c84ec
-					txsa->sc->channel,
9c84ec
-					txsa->an,
9c84ec
-					&txsa->next_pn);
9c84ec
+	return ops->get_transmit_next_pn(ops->ctx, txsa);
9c84ec
 }
9c84ec
 
9c84ec
 
9c84ec
@@ -178,10 +172,7 @@ int secy_set_transmit_next_pn(struct ieee802_1x_kay *kay,
9c84ec
 		return -1;
9c84ec
 	}
9c84ec
 
9c84ec
-	return ops->set_transmit_next_pn(ops->ctx,
9c84ec
-					txsa->sc->channel,
9c84ec
-					txsa->an,
9c84ec
-					txsa->next_pn);
9c84ec
+	return ops->set_transmit_next_pn(ops->ctx, txsa);
9c84ec
 }
9c84ec
 
9c84ec
 
9c84ec
diff --git a/wpa_supplicant/driver_i.h b/wpa_supplicant/driver_i.h
9c84ec
index 220b7ba..639bb83 100644
9c84ec
--- a/wpa_supplicant/driver_i.h
9c84ec
+++ b/wpa_supplicant/driver_i.h
9c84ec
@@ -749,33 +749,27 @@ static inline int wpa_drv_enable_controlled_port(struct wpa_supplicant *wpa_s,
9c84ec
 }
9c84ec
 
9c84ec
 static inline int wpa_drv_get_receive_lowest_pn(struct wpa_supplicant *wpa_s,
9c84ec
-						u32 channel, u8 an,
9c84ec
-						u32 *lowest_pn)
9c84ec
+						struct receive_sa *sa)
9c84ec
 {
9c84ec
 	if (!wpa_s->driver->get_receive_lowest_pn)
9c84ec
 		return -1;
9c84ec
-	return wpa_s->driver->get_receive_lowest_pn(wpa_s->drv_priv, channel,
9c84ec
-						    an, lowest_pn);
9c84ec
+	return wpa_s->driver->get_receive_lowest_pn(wpa_s->drv_priv, sa);
9c84ec
 }
9c84ec
 
9c84ec
 static inline int wpa_drv_get_transmit_next_pn(struct wpa_supplicant *wpa_s,
9c84ec
-						u32 channel, u8 an,
9c84ec
-						u32 *next_pn)
9c84ec
+						struct transmit_sa *sa)
9c84ec
 {
9c84ec
 	if (!wpa_s->driver->get_transmit_next_pn)
9c84ec
 		return -1;
9c84ec
-	return wpa_s->driver->get_transmit_next_pn(wpa_s->drv_priv, channel,
9c84ec
-						    an, next_pn);
9c84ec
+	return wpa_s->driver->get_transmit_next_pn(wpa_s->drv_priv, sa);
9c84ec
 }
9c84ec
 
9c84ec
 static inline int wpa_drv_set_transmit_next_pn(struct wpa_supplicant *wpa_s,
9c84ec
-						u32 channel, u8 an,
9c84ec
-						u32 next_pn)
9c84ec
+						struct transmit_sa *sa)
9c84ec
 {
9c84ec
 	if (!wpa_s->driver->set_transmit_next_pn)
9c84ec
 		return -1;
9c84ec
-	return wpa_s->driver->set_transmit_next_pn(wpa_s->drv_priv, channel,
9c84ec
-						    an, next_pn);
9c84ec
+	return wpa_s->driver->set_transmit_next_pn(wpa_s->drv_priv, sa);
9c84ec
 }
9c84ec
 
9c84ec
 static inline int wpa_drv_get_available_receive_sc(struct wpa_supplicant *wpa_s,
9c84ec
diff --git a/wpa_supplicant/wpas_kay.c b/wpa_supplicant/wpas_kay.c
9c84ec
index d6ec8c5..306d9f1 100644
9c84ec
--- a/wpa_supplicant/wpas_kay.c
9c84ec
+++ b/wpa_supplicant/wpas_kay.c
9c84ec
@@ -62,24 +62,21 @@ static int wpas_enable_controlled_port(void *wpa_s, Boolean enabled)
9c84ec
 }
9c84ec
 
9c84ec
 
9c84ec
-static int wpas_get_receive_lowest_pn(void *wpa_s, u32 channel,
9c84ec
-				      u8 an, u32 *lowest_pn)
9c84ec
+static int wpas_get_receive_lowest_pn(void *wpa_s, struct receive_sa *sa)
9c84ec
 {
9c84ec
-	return wpa_drv_get_receive_lowest_pn(wpa_s, channel, an, lowest_pn);
9c84ec
+	return wpa_drv_get_receive_lowest_pn(wpa_s, sa);
9c84ec
 }
9c84ec
 
9c84ec
 
9c84ec
-static int wpas_get_transmit_next_pn(void *wpa_s, u32 channel,
9c84ec
-				      u8 an, u32 *next_pn)
9c84ec
+static int wpas_get_transmit_next_pn(void *wpa_s, struct transmit_sa *sa)
9c84ec
 {
9c84ec
-	return wpa_drv_get_transmit_next_pn(wpa_s, channel, an, next_pn);
9c84ec
+	return wpa_drv_get_transmit_next_pn(wpa_s, sa);
9c84ec
 }
9c84ec
 
9c84ec
 
9c84ec
-static int wpas_set_transmit_next_pn(void *wpa_s, u32 channel,
9c84ec
-				      u8 an, u32 next_pn)
9c84ec
+static int wpas_set_transmit_next_pn(void *wpa_s, struct transmit_sa *sa)
9c84ec
 {
9c84ec
-	return wpa_drv_set_transmit_next_pn(wpa_s, channel, an, next_pn);
9c84ec
+	return wpa_drv_set_transmit_next_pn(wpa_s, sa);
9c84ec
 }
9c84ec
 
9c84ec
 
9c84ec
-- 
9c84ec
2.7.4
9c84ec