mka: Pass full structures down to macsec drivers' packet number ops

Clean up the driver interface by passing pointers to structs transmit_sa
and receive_sa down the stack to get_receive_lowest_pn(),
get_transmit_next_pn(), and set_transmit_next_pn() ops, instead of
passing the individual arguments.

Signed-off-by: Sabrina Dubroca <sd@queasysnail.net>
This commit is contained in:
Sabrina Dubroca 2016-09-20 09:43:05 +02:00 committed by Jouni Malinen
parent f75f6e2b03
commit 7fa5eff8ab
6 changed files with 42 additions and 68 deletions

View file

@ -3336,35 +3336,26 @@ struct wpa_driver_ops {
/** /**
* get_receive_lowest_pn - Get receive lowest pn * get_receive_lowest_pn - Get receive lowest pn
* @priv: Private driver interface data * @priv: Private driver interface data
* @channel: secure channel * @sa: secure association
* @an: association number
* @lowest_pn: lowest accept pn
* Returns: 0 on success, -1 on failure (or if not supported) * Returns: 0 on success, -1 on failure (or if not supported)
*/ */
int (*get_receive_lowest_pn)(void *priv, u32 channel, u8 an, int (*get_receive_lowest_pn)(void *priv, struct receive_sa *sa);
u32 *lowest_pn);
/** /**
* get_transmit_next_pn - Get transmit next pn * get_transmit_next_pn - Get transmit next pn
* @priv: Private driver interface data * @priv: Private driver interface data
* @channel: secure channel * @sa: secure association
* @an: association number
* @next_pn: next pn
* Returns: 0 on success, -1 on failure (or if not supported) * Returns: 0 on success, -1 on failure (or if not supported)
*/ */
int (*get_transmit_next_pn)(void *priv, u32 channel, u8 an, int (*get_transmit_next_pn)(void *priv, struct transmit_sa *sa);
u32 *next_pn);
/** /**
* set_transmit_next_pn - Set transmit next pn * set_transmit_next_pn - Set transmit next pn
* @priv: Private driver interface data * @priv: Private driver interface data
* @channel: secure channel * @sa: secure association
* @an: association number
* @next_pn: next pn
* Returns: 0 on success, -1 on failure (or if not supported) * Returns: 0 on success, -1 on failure (or if not supported)
*/ */
int (*set_transmit_next_pn)(void *priv, u32 channel, u8 an, int (*set_transmit_next_pn)(void *priv, struct transmit_sa *sa);
u32 next_pn);
/** /**
* get_available_receive_sc - get available receive channel * get_available_receive_sc - get available receive channel

View file

@ -29,6 +29,7 @@
#include "utils/eloop.h" #include "utils/eloop.h"
#include "common/defs.h" #include "common/defs.h"
#include "common/ieee802_1x_defs.h" #include "common/ieee802_1x_defs.h"
#include "pae/ieee802_1x_kay.h"
#include "driver.h" #include "driver.h"
#include "nss_macsec_secy.h" #include "nss_macsec_secy.h"
@ -515,16 +516,16 @@ static int macsec_qca_enable_controlled_port(void *priv, Boolean enabled)
} }
static int macsec_qca_get_receive_lowest_pn(void *priv, u32 channel, u8 an, static int macsec_qca_get_receive_lowest_pn(void *priv, struct receive_sa *sa)
u32 *lowest_pn)
{ {
struct macsec_qca_data *drv = priv; struct macsec_qca_data *drv = priv;
int ret = 0; int ret = 0;
u32 next_pn = 0; u32 next_pn = 0;
bool enabled = FALSE; bool enabled = FALSE;
u32 win; u32 win;
u32 channel = sa->sc->channel;
ret += nss_macsec_secy_rx_sa_next_pn_get(drv->secy_id, channel, an, ret += nss_macsec_secy_rx_sa_next_pn_get(drv->secy_id, channel, sa->an,
&next_pn); &next_pn);
ret += nss_macsec_secy_rx_sc_replay_protect_get(drv->secy_id, channel, ret += nss_macsec_secy_rx_sc_replay_protect_get(drv->secy_id, channel,
&enabled); &enabled);
@ -532,40 +533,42 @@ static int macsec_qca_get_receive_lowest_pn(void *priv, u32 channel, u8 an,
channel, &win); channel, &win);
if (enabled) if (enabled)
*lowest_pn = (next_pn > win) ? (next_pn - win) : 1; sa->lowest_pn = (next_pn > win) ? (next_pn - win) : 1;
else else
*lowest_pn = next_pn; sa->lowest_pn = next_pn;
wpa_printf(MSG_DEBUG, "%s: lpn=0x%x", __func__, *lowest_pn); wpa_printf(MSG_DEBUG, "%s: lpn=0x%x", __func__, sa->lowest_pn);
return ret; return ret;
} }
static int macsec_qca_get_transmit_next_pn(void *priv, u32 channel, u8 an, static int macsec_qca_get_transmit_next_pn(void *priv, struct transmit_sa *sa)
u32 *next_pn)
{ {
struct macsec_qca_data *drv = priv; struct macsec_qca_data *drv = priv;
int ret = 0; int ret = 0;
u32 channel = sa->sc->channel;
ret += nss_macsec_secy_tx_sa_next_pn_get(drv->secy_id, channel, an, ret += nss_macsec_secy_tx_sa_next_pn_get(drv->secy_id, channel, sa->an,
next_pn); &sa->next_pn);
wpa_printf(MSG_DEBUG, "%s: npn=0x%x", __func__, *next_pn); wpa_printf(MSG_DEBUG, "%s: npn=0x%x", __func__, sa->next_pn);
return ret; return ret;
} }
int macsec_qca_set_transmit_next_pn(void *priv, u32 channel, u8 an, u32 next_pn) int macsec_qca_set_transmit_next_pn(void *priv, struct transmit_sa *sa)
{ {
struct macsec_qca_data *drv = priv; struct macsec_qca_data *drv = priv;
int ret = 0; int ret = 0;
u32 channel = sa->sc->channel;
ret += nss_macsec_secy_tx_sa_next_pn_set(drv->secy_id, channel, an,
next_pn);
wpa_printf(MSG_INFO, "%s: npn=0x%x", __func__, next_pn); ret += nss_macsec_secy_tx_sa_next_pn_set(drv->secy_id, channel, sa->an,
sa->next_pn);
wpa_printf(MSG_INFO, "%s: npn=0x%x", __func__, sa->next_pn);
return ret; return ret;
} }

View file

@ -142,11 +142,9 @@ struct ieee802_1x_kay_ctx {
int (*set_replay_protect)(void *ctx, Boolean enabled, u32 window); int (*set_replay_protect)(void *ctx, Boolean enabled, u32 window);
int (*set_current_cipher_suite)(void *ctx, u64 cs); int (*set_current_cipher_suite)(void *ctx, u64 cs);
int (*enable_controlled_port)(void *ctx, Boolean enabled); int (*enable_controlled_port)(void *ctx, Boolean enabled);
int (*get_receive_lowest_pn)(void *ctx, u32 channel, u8 an, int (*get_receive_lowest_pn)(void *ctx, struct receive_sa *sa);
u32 *lowest_pn); int (*get_transmit_next_pn)(void *ctx, struct transmit_sa *sa);
int (*get_transmit_next_pn)(void *ctx, u32 channel, u8 an, int (*set_transmit_next_pn)(void *ctx, struct transmit_sa *sa);
u32 *next_pn);
int (*set_transmit_next_pn)(void *ctx, u32 channel, u8 an, u32 next_pn);
int (*get_available_receive_sc)(void *ctx, u32 *channel); int (*get_available_receive_sc)(void *ctx, u32 *channel);
int (*create_receive_sc)(void *ctx, u32 channel, int (*create_receive_sc)(void *ctx, u32 channel,
struct ieee802_1x_mka_sci *sci, struct ieee802_1x_mka_sci *sci,

View file

@ -130,10 +130,7 @@ int secy_get_receive_lowest_pn(struct ieee802_1x_kay *kay,
return -1; return -1;
} }
return ops->get_receive_lowest_pn(ops->ctx, return ops->get_receive_lowest_pn(ops->ctx, rxsa);
rxsa->sc->channel,
rxsa->an,
&rxsa->lowest_pn);
} }
@ -154,10 +151,7 @@ int secy_get_transmit_next_pn(struct ieee802_1x_kay *kay,
return -1; return -1;
} }
return ops->get_transmit_next_pn(ops->ctx, return ops->get_transmit_next_pn(ops->ctx, txsa);
txsa->sc->channel,
txsa->an,
&txsa->next_pn);
} }
@ -178,10 +172,7 @@ int secy_set_transmit_next_pn(struct ieee802_1x_kay *kay,
return -1; return -1;
} }
return ops->set_transmit_next_pn(ops->ctx, return ops->set_transmit_next_pn(ops->ctx, txsa);
txsa->sc->channel,
txsa->an,
txsa->next_pn);
} }

View file

@ -749,33 +749,27 @@ static inline int wpa_drv_enable_controlled_port(struct wpa_supplicant *wpa_s,
} }
static inline int wpa_drv_get_receive_lowest_pn(struct wpa_supplicant *wpa_s, static inline int wpa_drv_get_receive_lowest_pn(struct wpa_supplicant *wpa_s,
u32 channel, u8 an, struct receive_sa *sa)
u32 *lowest_pn)
{ {
if (!wpa_s->driver->get_receive_lowest_pn) if (!wpa_s->driver->get_receive_lowest_pn)
return -1; return -1;
return wpa_s->driver->get_receive_lowest_pn(wpa_s->drv_priv, channel, return wpa_s->driver->get_receive_lowest_pn(wpa_s->drv_priv, sa);
an, lowest_pn);
} }
static inline int wpa_drv_get_transmit_next_pn(struct wpa_supplicant *wpa_s, static inline int wpa_drv_get_transmit_next_pn(struct wpa_supplicant *wpa_s,
u32 channel, u8 an, struct transmit_sa *sa)
u32 *next_pn)
{ {
if (!wpa_s->driver->get_transmit_next_pn) if (!wpa_s->driver->get_transmit_next_pn)
return -1; return -1;
return wpa_s->driver->get_transmit_next_pn(wpa_s->drv_priv, channel, return wpa_s->driver->get_transmit_next_pn(wpa_s->drv_priv, sa);
an, next_pn);
} }
static inline int wpa_drv_set_transmit_next_pn(struct wpa_supplicant *wpa_s, static inline int wpa_drv_set_transmit_next_pn(struct wpa_supplicant *wpa_s,
u32 channel, u8 an, struct transmit_sa *sa)
u32 next_pn)
{ {
if (!wpa_s->driver->set_transmit_next_pn) if (!wpa_s->driver->set_transmit_next_pn)
return -1; return -1;
return wpa_s->driver->set_transmit_next_pn(wpa_s->drv_priv, channel, return wpa_s->driver->set_transmit_next_pn(wpa_s->drv_priv, sa);
an, next_pn);
} }
static inline int wpa_drv_get_available_receive_sc(struct wpa_supplicant *wpa_s, static inline int wpa_drv_get_available_receive_sc(struct wpa_supplicant *wpa_s,

View file

@ -62,24 +62,21 @@ static int wpas_enable_controlled_port(void *wpa_s, Boolean enabled)
} }
static int wpas_get_receive_lowest_pn(void *wpa_s, u32 channel, static int wpas_get_receive_lowest_pn(void *wpa_s, struct receive_sa *sa)
u8 an, u32 *lowest_pn)
{ {
return wpa_drv_get_receive_lowest_pn(wpa_s, channel, an, lowest_pn); return wpa_drv_get_receive_lowest_pn(wpa_s, sa);
} }
static int wpas_get_transmit_next_pn(void *wpa_s, u32 channel, static int wpas_get_transmit_next_pn(void *wpa_s, struct transmit_sa *sa)
u8 an, u32 *next_pn)
{ {
return wpa_drv_get_transmit_next_pn(wpa_s, channel, an, next_pn); return wpa_drv_get_transmit_next_pn(wpa_s, sa);
} }
static int wpas_set_transmit_next_pn(void *wpa_s, u32 channel, static int wpas_set_transmit_next_pn(void *wpa_s, struct transmit_sa *sa)
u8 an, u32 next_pn)
{ {
return wpa_drv_set_transmit_next_pn(wpa_s, channel, an, next_pn); return wpa_drv_set_transmit_next_pn(wpa_s, sa);
} }