mka: Pass full structures down to macsec drivers' receive SA ops

Clean up the driver interface by passing pointers to struct receive_sa
down the stack to the {create,enable,disable}_receive_sa() ops, instead
of passing the individual properties of the SA.

Signed-off-by: Sabrina Dubroca <sd@queasysnail.net>
This commit is contained in:
Sabrina Dubroca 2016-09-20 09:43:09 +02:00 committed by Jouni Malinen
parent 909c1b9835
commit cecdecdbe8
6 changed files with 44 additions and 47 deletions

View file

@ -3391,32 +3391,26 @@ struct wpa_driver_ops {
/**
* create_receive_sa - create secure association for receive
* @priv: private driver interface data from init()
* @channel: secure channel
* @an: association number
* @lowest_pn: the lowest packet number can be received
* @sak: the secure association key
* @sa: secure association
* Returns: 0 on success, -1 on failure
*/
int (*create_receive_sa)(void *priv, u32 channel, u8 an,
u32 lowest_pn, const u8 *sak);
int (*create_receive_sa)(void *priv, struct receive_sa *sa);
/**
* enable_receive_sa - enable the SA for receive
* @priv: private driver interface data from init()
* @channel: secure channel
* @an: association number
* @sa: secure association
* Returns: 0 on success, -1 on failure
*/
int (*enable_receive_sa)(void *priv, u32 channel, u8 an);
int (*enable_receive_sa)(void *priv, struct receive_sa *sa);
/**
* disable_receive_sa - disable SA for receive
* @priv: private driver interface data from init()
* @channel: secure channel index
* @an: association number
* @sa: secure association
* Returns: 0 on success, -1 on failure
*/
int (*disable_receive_sa)(void *priv, u32 channel, u8 an);
int (*disable_receive_sa)(void *priv, struct receive_sa *sa);
/**
* get_available_transmit_sc - get available transmit channel

View file

@ -667,49 +667,57 @@ static int macsec_qca_delete_receive_sc(void *priv, u32 channel)
}
static int macsec_qca_create_receive_sa(void *priv, u32 channel, u8 an,
u32 lowest_pn, const u8 *sak)
static int macsec_qca_create_receive_sa(void *priv, struct receive_sa *sa)
{
struct macsec_qca_data *drv = priv;
int ret = 0;
fal_rx_sak_t rx_sak;
int i = 0;
u32 channel = sa->sc->channel;
wpa_printf(MSG_DEBUG, "%s, channel=%d, an=%d, lpn=0x%x",
__func__, channel, an, lowest_pn);
__func__, channel, sa->an, sa->lowest_pn);
os_memset(&rx_sak, 0, sizeof(rx_sak));
for (i = 0; i < 16; i++)
rx_sak.sak[i] = sak[15 - i];
rx_sak.sak[i] = sa->pkey->key[15 - i];
ret += nss_macsec_secy_rx_sa_create(drv->secy_id, channel, an);
ret += nss_macsec_secy_rx_sak_set(drv->secy_id, channel, an, &rx_sak);
ret += nss_macsec_secy_rx_sa_create(drv->secy_id, channel, sa->an);
ret += nss_macsec_secy_rx_sak_set(drv->secy_id, channel, sa->an,
&rx_sak);
return ret;
}
static int macsec_qca_enable_receive_sa(void *priv, u32 channel, u8 an)
static int macsec_qca_enable_receive_sa(void *priv, struct receive_sa *sa)
{
struct macsec_qca_data *drv = priv;
int ret = 0;
u32 channel = sa->sc->channel;
wpa_printf(MSG_DEBUG, "%s: channel=%d, an=%d", __func__, channel, an);
ret += nss_macsec_secy_rx_sa_en_set(drv->secy_id, channel, an, TRUE);
wpa_printf(MSG_DEBUG, "%s: channel=%d, an=%d", __func__, channel,
sa->an);
ret += nss_macsec_secy_rx_sa_en_set(drv->secy_id, channel, sa->an,
TRUE);
return ret;
}
static int macsec_qca_disable_receive_sa(void *priv, u32 channel, u8 an)
static int macsec_qca_disable_receive_sa(void *priv, struct receive_sa *sa)
{
struct macsec_qca_data *drv = priv;
int ret = 0;
u32 channel = sa->sc->channel;
wpa_printf(MSG_DEBUG, "%s: channel=%d, an=%d", __func__, channel, an);
wpa_printf(MSG_DEBUG, "%s: channel=%d, an=%d", __func__, channel,
sa->an);
ret += nss_macsec_secy_rx_sa_en_set(drv->secy_id, channel, an, FALSE);
ret += nss_macsec_secy_rx_sa_en_set(drv->secy_id, channel, sa->an,
FALSE);
return ret;
}

View file

@ -151,10 +151,9 @@ struct ieee802_1x_kay_ctx {
enum validate_frames vf,
enum confidentiality_offset co);
int (*delete_receive_sc)(void *ctx, u32 channel);
int (*create_receive_sa)(void *ctx, u32 channel, u8 an, u32 lowest_pn,
const u8 *sak);
int (*enable_receive_sa)(void *ctx, u32 channel, u8 an);
int (*disable_receive_sa)(void *ctx, u32 channel, u8 an);
int (*create_receive_sa)(void *ctx, struct receive_sa *sa);
int (*enable_receive_sa)(void *ctx, struct receive_sa *sa);
int (*disable_receive_sa)(void *ctx, struct receive_sa *sa);
int (*get_available_transmit_sc)(void *ctx, u32 *channel);
int (*create_transmit_sc)(void *ctx, u32 channel,
const struct ieee802_1x_mka_sci *sci,

View file

@ -253,8 +253,7 @@ int secy_create_receive_sa(struct ieee802_1x_kay *kay, struct receive_sa *rxsa)
return -1;
}
return ops->create_receive_sa(ops->ctx, rxsa->sc->channel, rxsa->an,
rxsa->lowest_pn, rxsa->pkey->key);
return ops->create_receive_sa(ops->ctx, rxsa);
}
@ -276,7 +275,7 @@ int secy_enable_receive_sa(struct ieee802_1x_kay *kay, struct receive_sa *rxsa)
rxsa->enable_receive = TRUE;
return ops->enable_receive_sa(ops->ctx, rxsa->sc->channel, rxsa->an);
return ops->enable_receive_sa(ops->ctx, rxsa);
}
@ -298,7 +297,7 @@ int secy_disable_receive_sa(struct ieee802_1x_kay *kay, struct receive_sa *rxsa)
rxsa->enable_receive = FALSE;
return ops->disable_receive_sa(ops->ctx, rxsa->sc->channel, rxsa->an);
return ops->disable_receive_sa(ops->ctx, rxsa);
}

View file

@ -802,29 +802,27 @@ static inline int wpa_drv_delete_receive_sc(struct wpa_supplicant *wpa_s,
}
static inline int wpa_drv_create_receive_sa(struct wpa_supplicant *wpa_s,
u32 channel, u8 an,
u32 lowest_pn, const u8 *sak)
struct receive_sa *sa)
{
if (!wpa_s->driver->create_receive_sa)
return -1;
return wpa_s->driver->create_receive_sa(wpa_s->drv_priv, channel, an,
lowest_pn, sak);
return wpa_s->driver->create_receive_sa(wpa_s->drv_priv, sa);
}
static inline int wpa_drv_enable_receive_sa(struct wpa_supplicant *wpa_s,
u32 channel, u8 an)
struct receive_sa *sa)
{
if (!wpa_s->driver->enable_receive_sa)
return -1;
return wpa_s->driver->enable_receive_sa(wpa_s->drv_priv, channel, an);
return wpa_s->driver->enable_receive_sa(wpa_s->drv_priv, sa);
}
static inline int wpa_drv_disable_receive_sa(struct wpa_supplicant *wpa_s,
u32 channel, u8 an)
struct receive_sa *sa)
{
if (!wpa_s->driver->disable_receive_sa)
return -1;
return wpa_s->driver->disable_receive_sa(wpa_s->drv_priv, channel, an);
return wpa_s->driver->disable_receive_sa(wpa_s->drv_priv, sa);
}
static inline int

View file

@ -117,22 +117,21 @@ static int wpas_delete_receive_sc(void *wpa_s, u32 channel)
}
static int wpas_create_receive_sa(void *wpa_s, u32 channel, u8 an,
u32 lowest_pn, const u8 *sak)
static int wpas_create_receive_sa(void *wpa_s, struct receive_sa *sa)
{
return wpa_drv_create_receive_sa(wpa_s, channel, an, lowest_pn, sak);
return wpa_drv_create_receive_sa(wpa_s, sa);
}
static int wpas_enable_receive_sa(void *wpa_s, u32 channel, u8 an)
static int wpas_enable_receive_sa(void *wpa_s, struct receive_sa *sa)
{
return wpa_drv_enable_receive_sa(wpa_s, channel, an);
return wpa_drv_enable_receive_sa(wpa_s, sa);
}
static int wpas_disable_receive_sa(void *wpa_s, u32 channel, u8 an)
static int wpas_disable_receive_sa(void *wpa_s, struct receive_sa *sa)
{
return wpa_drv_disable_receive_sa(wpa_s, channel, an);
return wpa_drv_disable_receive_sa(wpa_s, sa);
}