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