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

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