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

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