[PATCH 0/6] mka cleanups

Jouni Malinen j at w1.fi
Sun Aug 28 12:40:35 PDT 2016


On Mon, Aug 15, 2016 at 11:40:37AM +0200, Sabrina Dubroca wrote:
> This patchset contains a variety of cleanups for the MKA code (src/pae).

> Sabrina Dubroca (6):
>   mka: some cleanups
>   mka: cleanups, part 2
>   mka: cleanups, part 3
>   mka: cleanups, part 4
>   mka: move structs {transmit,receive}_{sa,sc} to a common header
>   mka: pass full structures down the stack in ops callbacks

Thanks, I applied patches 1..4, but left patches 5 and 6 waiting for
updates as noted in the earlier messages. Please note that I split the
patches in significantly smaller independent changes (total of 29
patches instead of just 4) to make it easier to review them. I did some
cleanup and fixes, e.g., sci_equal() was using sizeof(a) where a is a
pointer while this was supposed to use the size of the data structure;
it happened to be 8 so no difference on 64-bit builds, but for 32-bit
builds, this could have resulted in incorrect behavior. Please check
that I did not end up breaking any functionality with the changes.

For any followup cleanup, please consider making smaller patches. That
would make it significantly easier to review the changes by finding the
obvious changes without having to figure out which parts of the patch
apply to which item in the commit message (and which parts are missing
altogether from the commit message).


I left out one change since I did not find any justification in the
commit message for it and did not see it as an obvious improvement
myself. Please resubmit this with more descriptive commit message if you
still want this included:


[PATCH] mka: Move kay_ops struct out of ieee802_1x_alloc_kay_sm()

TODO: Explain why this would be done.

Signed-off-by: Sabrina Dubroca <sd at queasysnail.net>
---
 wpa_supplicant/wpas_kay.c | 50 +++++++++++++++++++++++++----------------------
 1 file changed, 27 insertions(+), 23 deletions(-)

diff --git a/wpa_supplicant/wpas_kay.c b/wpa_supplicant/wpas_kay.c
index d6ec8c5..81bcaba 100644
--- a/wpa_supplicant/wpas_kay.c
+++ b/wpa_supplicant/wpas_kay.c
@@ -183,6 +183,31 @@ static int wpas_disable_transmit_sa(void *wpa_s, u32 channel, u8 an)
 }
 
 
+static const struct ieee802_1x_kay_ctx kay_ops = {
+	.macsec_init			= wpas_macsec_init,
+	.macsec_deinit			= wpas_macsec_deinit,
+	.enable_protect_frames		= wpas_enable_protect_frames,
+	.set_replay_protect		= wpas_set_replay_protect,
+	.set_current_cipher_suite	= wpas_set_current_cipher_suite,
+	.enable_controlled_port		= wpas_enable_controlled_port,
+	.get_receive_lowest_pn		= wpas_get_receive_lowest_pn,
+	.get_transmit_next_pn		= wpas_get_transmit_next_pn,
+	.set_transmit_next_pn		= wpas_set_transmit_next_pn,
+	.get_available_receive_sc	= wpas_get_available_receive_sc,
+	.create_receive_sc		= wpas_create_receive_sc,
+	.delete_receive_sc		= wpas_delete_receive_sc,
+	.create_receive_sa		= wpas_create_receive_sa,
+	.enable_receive_sa		= wpas_enable_receive_sa,
+	.disable_receive_sa		= wpas_disable_receive_sa,
+	.get_available_transmit_sc	= wpas_get_available_transmit_sc,
+	.create_transmit_sc		= wpas_create_transmit_sc,
+	.delete_transmit_sc		= wpas_delete_transmit_sc,
+	.create_transmit_sa		= wpas_create_transmit_sa,
+	.enable_transmit_sa		= wpas_enable_transmit_sa,
+	.disable_transmit_sa		= wpas_disable_transmit_sa,
+};
+
+
 int ieee802_1x_alloc_kay_sm(struct wpa_supplicant *wpa_s, struct wpa_ssid *ssid)
 {
 	struct ieee802_1x_kay_ctx *kay_ctx;
@@ -196,34 +221,13 @@ int ieee802_1x_alloc_kay_sm(struct wpa_supplicant *wpa_s, struct wpa_ssid *ssid)
 
 	policy = ssid->macsec_policy == 1 ? SHOULD_SECURE : DO_NOT_SECURE;
 
-	kay_ctx = os_zalloc(sizeof(*kay_ctx));
+	kay_ctx = os_malloc(sizeof(*kay_ctx));
 	if (!kay_ctx)
 		return -1;
 
+	os_memcpy(kay_ctx, &kay_ops, sizeof(*kay_ctx));
 	kay_ctx->ctx = wpa_s;
 
-	kay_ctx->macsec_init = wpas_macsec_init;
-	kay_ctx->macsec_deinit = wpas_macsec_deinit;
-	kay_ctx->enable_protect_frames = wpas_enable_protect_frames;
-	kay_ctx->set_replay_protect = wpas_set_replay_protect;
-	kay_ctx->set_current_cipher_suite = wpas_set_current_cipher_suite;
-	kay_ctx->enable_controlled_port = wpas_enable_controlled_port;
-	kay_ctx->get_receive_lowest_pn = wpas_get_receive_lowest_pn;
-	kay_ctx->get_transmit_next_pn = wpas_get_transmit_next_pn;
-	kay_ctx->set_transmit_next_pn = wpas_set_transmit_next_pn;
-	kay_ctx->get_available_receive_sc = wpas_get_available_receive_sc;
-	kay_ctx->create_receive_sc = wpas_create_receive_sc;
-	kay_ctx->delete_receive_sc = wpas_delete_receive_sc;
-	kay_ctx->create_receive_sa = wpas_create_receive_sa;
-	kay_ctx->enable_receive_sa = wpas_enable_receive_sa;
-	kay_ctx->disable_receive_sa = wpas_disable_receive_sa;
-	kay_ctx->get_available_transmit_sc = wpas_get_available_transmit_sc;
-	kay_ctx->create_transmit_sc = wpas_create_transmit_sc;
-	kay_ctx->delete_transmit_sc = wpas_delete_transmit_sc;
-	kay_ctx->create_transmit_sa = wpas_create_transmit_sa;
-	kay_ctx->enable_transmit_sa = wpas_enable_transmit_sa;
-	kay_ctx->disable_transmit_sa = wpas_disable_transmit_sa;
-
 	res = ieee802_1x_kay_init(kay_ctx, policy, wpa_s->ifname,
 				  wpa_s->own_addr);
 	if (res == NULL) {
-- 
1.9.1

 
-- 
Jouni Malinen                                            PGP id EFC895FA



More information about the Hostap mailing list