Blame SOURCES/macsec-0006-mka-Pass-full-structures-down-to-macsec-drivers-rece.patch

9c84ec
From 5f5ca28414de7ae0b86d4c2aa09c3e67b697dd56 Mon Sep 17 00:00:00 2001
9c84ec
Message-Id: <5f5ca28414de7ae0b86d4c2aa09c3e67b697dd56.1488376601.git.dcaratti@redhat.com>
9c84ec
From: Sabrina Dubroca <sd@queasysnail.net>
9c84ec
Date: Fri, 7 Oct 2016 12:08:10 +0200
9c84ec
Subject: [PATCH] mka: Pass full structures down to macsec drivers' receive SC
9c84ec
 ops
9c84ec
9c84ec
Clean up the driver interface by passing pointers to struct receive_sc
9c84ec
down the stack to the {create,delete}_recevie_sc() ops, instead of
9c84ec
passing the individual properties of the SC.
9c84ec
9c84ec
Signed-off-by: Sabrina Dubroca <sd@queasysnail.net>
9c84ec
---
9c84ec
 src/drivers/driver.h            | 12 +++++-------
9c84ec
 src/drivers/driver_macsec_qca.c |  9 ++++++---
9c84ec
 src/pae/ieee802_1x_kay.h        |  5 ++---
9c84ec
 src/pae/ieee802_1x_secy_ops.c   |  5 ++---
9c84ec
 wpa_supplicant/driver_i.h       | 12 +++++-------
9c84ec
 wpa_supplicant/wpas_kay.c       | 11 ++++-------
9c84ec
 6 files changed, 24 insertions(+), 30 deletions(-)
9c84ec
9c84ec
diff --git a/src/drivers/driver.h b/src/drivers/driver.h
9c84ec
index 1e2d623..a57aa53 100644
9c84ec
--- a/src/drivers/driver.h
9c84ec
+++ b/src/drivers/driver.h
9c84ec
@@ -3368,25 +3368,23 @@ struct wpa_driver_ops {
9c84ec
 	/**
9c84ec
 	 * create_receive_sc - create secure channel for receiving
9c84ec
 	 * @priv: Private driver interface data
9c84ec
-	 * @channel: secure channel
9c84ec
-	 * @sci_addr: secure channel identifier - address
9c84ec
-	 * @sci_port: secure channel identifier - port
9c84ec
+	 * @sc: secure channel
9c84ec
 	 * @conf_offset: confidentiality offset (0, 30, or 50)
9c84ec
 	 * @validation: frame validation policy (0 = Disabled, 1 = Checked,
9c84ec
 	 *	2 = Strict)
9c84ec
 	 * Returns: 0 on success, -1 on failure (or if not supported)
9c84ec
 	 */
9c84ec
-	int (*create_receive_sc)(void *priv, u32 channel, const u8 *sci_addr,
9c84ec
-				 u16 sci_port, unsigned int conf_offset,
9c84ec
+	int (*create_receive_sc)(void *priv, struct receive_sc *sc,
9c84ec
+				 unsigned int conf_offset,
9c84ec
 				 int validation);
9c84ec
 
9c84ec
 	/**
9c84ec
 	 * delete_receive_sc - delete secure connection for receiving
9c84ec
 	 * @priv: private driver interface data from init()
9c84ec
-	 * @channel: secure channel
9c84ec
+	 * @sc: secure channel
9c84ec
 	 * Returns: 0 on success, -1 on failure
9c84ec
 	 */
9c84ec
-	int (*delete_receive_sc)(void *priv, u32 channel);
9c84ec
+	int (*delete_receive_sc)(void *priv, struct receive_sc *sc);
9c84ec
 
9c84ec
 	/**
9c84ec
 	 * create_receive_sa - create secure association for receive
9c84ec
diff --git a/src/drivers/driver_macsec_qca.c b/src/drivers/driver_macsec_qca.c
9c84ec
index fef93df..385f7c5 100644
9c84ec
--- a/src/drivers/driver_macsec_qca.c
9c84ec
+++ b/src/drivers/driver_macsec_qca.c
9c84ec
@@ -601,8 +601,7 @@ static int macsec_qca_get_available_receive_sc(void *priv, u32 *channel)
9c84ec
 }
9c84ec
 
9c84ec
 
9c84ec
-static int macsec_qca_create_receive_sc(void *priv, u32 channel,
9c84ec
-					const u8 *sci_addr, u16 sci_port,
9c84ec
+static int macsec_qca_create_receive_sc(void *priv, struct receive_sc *sc,
9c84ec
 					unsigned int conf_offset,
9c84ec
 					int validation)
9c84ec
 {
9c84ec
@@ -611,6 +610,9 @@ static int macsec_qca_create_receive_sc(void *priv, u32 channel,
9c84ec
 	fal_rx_prc_lut_t entry;
9c84ec
 	fal_rx_sc_validate_frame_e vf;
9c84ec
 	enum validate_frames validate_frames = validation;
9c84ec
+	u32 channel = sc->channel;
9c84ec
+	const u8 *sci_addr = sc->sci.addr;
9c84ec
+	u16 sci_port = be_to_host16(sc->sci.port);
9c84ec
 
9c84ec
 	wpa_printf(MSG_DEBUG, "%s: channel=%d", __func__, channel);
9c84ec
 
9c84ec
@@ -649,11 +651,12 @@ static int macsec_qca_create_receive_sc(void *priv, u32 channel,
9c84ec
 }
9c84ec
 
9c84ec
 
9c84ec
-static int macsec_qca_delete_receive_sc(void *priv, u32 channel)
9c84ec
+static int macsec_qca_delete_receive_sc(void *priv, struct receive_sc *sc)
9c84ec
 {
9c84ec
 	struct macsec_qca_data *drv = priv;
9c84ec
 	int ret = 0;
9c84ec
 	fal_rx_prc_lut_t entry;
9c84ec
+	u32 channel = sc->channel;
9c84ec
 
9c84ec
 	wpa_printf(MSG_DEBUG, "%s: channel=%d", __func__, channel);
9c84ec
 
9c84ec
diff --git a/src/pae/ieee802_1x_kay.h b/src/pae/ieee802_1x_kay.h
9c84ec
index 8cd5fa6..144ee90 100644
9c84ec
--- a/src/pae/ieee802_1x_kay.h
9c84ec
+++ b/src/pae/ieee802_1x_kay.h
9c84ec
@@ -146,11 +146,10 @@ struct ieee802_1x_kay_ctx {
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
+	int (*create_receive_sc)(void *ctx, struct receive_sc *sc,
9c84ec
 				 enum validate_frames vf,
9c84ec
 				 enum confidentiality_offset co);
9c84ec
-	int (*delete_receive_sc)(void *ctx, u32 channel);
9c84ec
+	int (*delete_receive_sc)(void *ctx, struct receive_sc *sc);
9c84ec
 	int (*create_receive_sa)(void *ctx, struct receive_sa *sa);
9c84ec
 	int (*enable_receive_sa)(void *ctx, struct receive_sa *sa);
9c84ec
 	int (*disable_receive_sa)(void *ctx, struct receive_sa *sa);
9c84ec
diff --git a/src/pae/ieee802_1x_secy_ops.c b/src/pae/ieee802_1x_secy_ops.c
9c84ec
index 669dc98..b8fcf05 100644
9c84ec
--- a/src/pae/ieee802_1x_secy_ops.c
9c84ec
+++ b/src/pae/ieee802_1x_secy_ops.c
9c84ec
@@ -212,8 +212,7 @@ int secy_create_receive_sc(struct ieee802_1x_kay *kay, struct receive_sc *rxsc)
9c84ec
 		return -1;
9c84ec
 	}
9c84ec
 
9c84ec
-	return ops->create_receive_sc(ops->ctx, rxsc->channel, &rxsc->sci,
9c84ec
-				      kay->vf, kay->co);
9c84ec
+	return ops->create_receive_sc(ops->ctx, rxsc, kay->vf, kay->co);
9c84ec
 }
9c84ec
 
9c84ec
 
9c84ec
@@ -233,7 +232,7 @@ int secy_delete_receive_sc(struct ieee802_1x_kay *kay, struct receive_sc *rxsc)
9c84ec
 		return -1;
9c84ec
 	}
9c84ec
 
9c84ec
-	return ops->delete_receive_sc(ops->ctx, rxsc->channel);
9c84ec
+	return ops->delete_receive_sc(ops->ctx, rxsc);
9c84ec
 }
9c84ec
 
9c84ec
 
9c84ec
diff --git a/wpa_supplicant/driver_i.h b/wpa_supplicant/driver_i.h
9c84ec
index 2dc74bf..d47395c 100644
9c84ec
--- a/wpa_supplicant/driver_i.h
9c84ec
+++ b/wpa_supplicant/driver_i.h
9c84ec
@@ -782,23 +782,21 @@ static inline int wpa_drv_get_available_receive_sc(struct wpa_supplicant *wpa_s,
9c84ec
 }
9c84ec
 
9c84ec
 static inline int
9c84ec
-wpa_drv_create_receive_sc(struct wpa_supplicant *wpa_s, u32 channel,
9c84ec
-			  const u8 *sci_addr, u16 sci_port,
9c84ec
+wpa_drv_create_receive_sc(struct wpa_supplicant *wpa_s, struct receive_sc *sc,
9c84ec
 			  unsigned int conf_offset, int validation)
9c84ec
 {
9c84ec
 	if (!wpa_s->driver->create_receive_sc)
9c84ec
 		return -1;
9c84ec
-	return wpa_s->driver->create_receive_sc(wpa_s->drv_priv, channel,
9c84ec
-						sci_addr, sci_port, conf_offset,
9c84ec
-						validation);
9c84ec
+	return wpa_s->driver->create_receive_sc(wpa_s->drv_priv, sc,
9c84ec
+						conf_offset, validation);
9c84ec
 }
9c84ec
 
9c84ec
 static inline int wpa_drv_delete_receive_sc(struct wpa_supplicant *wpa_s,
9c84ec
-					    u32 channel)
9c84ec
+					    struct receive_sc *sc)
9c84ec
 {
9c84ec
 	if (!wpa_s->driver->delete_receive_sc)
9c84ec
 		return -1;
9c84ec
-	return wpa_s->driver->delete_receive_sc(wpa_s->drv_priv, channel);
9c84ec
+	return wpa_s->driver->delete_receive_sc(wpa_s->drv_priv, sc);
9c84ec
 }
9c84ec
 
9c84ec
 static inline int wpa_drv_create_receive_sa(struct wpa_supplicant *wpa_s,
9c84ec
diff --git a/wpa_supplicant/wpas_kay.c b/wpa_supplicant/wpas_kay.c
9c84ec
index e0f8e28..4163b61 100644
9c84ec
--- a/wpa_supplicant/wpas_kay.c
9c84ec
+++ b/wpa_supplicant/wpas_kay.c
9c84ec
@@ -100,20 +100,17 @@ static unsigned int conf_offset_val(enum confidentiality_offset co)
9c84ec
 }
9c84ec
 
9c84ec
 
9c84ec
-static int wpas_create_receive_sc(void *wpa_s, u32 channel,
9c84ec
-				  struct ieee802_1x_mka_sci *sci,
9c84ec
+static int wpas_create_receive_sc(void *wpa_s, struct receive_sc *sc,
9c84ec
 				  enum validate_frames vf,
9c84ec
 				  enum confidentiality_offset co)
9c84ec
 {
9c84ec
-	return wpa_drv_create_receive_sc(wpa_s, channel, sci->addr,
9c84ec
-					 be_to_host16(sci->port),
9c84ec
-					 conf_offset_val(co), vf);
9c84ec
+	return wpa_drv_create_receive_sc(wpa_s, sc, conf_offset_val(co), vf);
9c84ec
 }
9c84ec
 
9c84ec
 
9c84ec
-static int wpas_delete_receive_sc(void *wpa_s, u32 channel)
9c84ec
+static int wpas_delete_receive_sc(void *wpa_s, struct receive_sc *sc)
9c84ec
 {
9c84ec
-	return wpa_drv_delete_receive_sc(wpa_s, channel);
9c84ec
+	return wpa_drv_delete_receive_sc(wpa_s, sc);
9c84ec
 }
9c84ec
 
9c84ec
 
9c84ec
-- 
9c84ec
2.7.4
9c84ec