From: James Prestwood <prestwoj@gmail.com>
To: iwd@lists.linux.dev
Cc: James Prestwood <prestwoj@gmail.com>
Subject: [PATCH 02/15] unit: update use of handshake_state with ref/unref
Date: Fri, 22 Nov 2024 07:15:38 -0800 [thread overview]
Message-ID: <20241122151551.286355-3-prestwoj@gmail.com> (raw)
In-Reply-To: <20241122151551.286355-1-prestwoj@gmail.com>
---
unit/test-eapol.c | 38 +++++++++++++++++++++-----------------
unit/test-sae.c | 15 ++++++++-------
unit/test-wsc.c | 10 ++++++----
3 files changed, 35 insertions(+), 28 deletions(-)
diff --git a/unit/test-eapol.c b/unit/test-eapol.c
index 5317f9ad..0e01bfa5 100644
--- a/unit/test-eapol.c
+++ b/unit/test-eapol.c
@@ -94,6 +94,7 @@ static struct handshake_state *test_handshake_state_new(uint32_t ifindex)
ths->super.ifindex = ifindex;
ths->super.free = test_handshake_state_free;
+ ths->super.refcount = 1;
return &ths->super;
}
@@ -2199,7 +2200,7 @@ static void eapol_sm_test_ptk(const void *data)
assert(verify_step4_called);
eapol_sm_free(sm);
- handshake_state_free(hs);
+ handshake_state_unref(hs);
eapol_exit();
}
@@ -2263,7 +2264,7 @@ static void eapol_sm_test_igtk(const void *data)
assert(verify_step4_called);
eapol_sm_free(sm);
- handshake_state_free(hs);
+ handshake_state_unref(hs);
eapol_exit();
}
@@ -2332,7 +2333,7 @@ static void eapol_sm_test_wpa2_ptk_gtk(const void *data)
assert(verify_gtk_step2_called);
eapol_sm_free(sm);
- handshake_state_free(hs);
+ handshake_state_unref(hs);
eapol_exit();
}
@@ -2399,7 +2400,7 @@ static void eapol_sm_test_wpa_ptk_gtk(const void *data)
assert(verify_gtk_step2_called);
eapol_sm_free(sm);
- handshake_state_free(hs);
+ handshake_state_unref(hs);
eapol_exit();
}
@@ -2467,7 +2468,7 @@ static void eapol_sm_test_wpa_ptk_gtk_2(const void *data)
assert(verify_gtk_step2_called);
eapol_sm_free(sm);
- handshake_state_free(hs);
+ handshake_state_unref(hs);
eapol_exit();
}
@@ -2721,7 +2722,7 @@ static void eapol_sm_wpa2_retransmit_test(const void *data)
l_free(ptk);
eapol_sm_free(sm);
- handshake_state_free(hs);
+ handshake_state_unref(hs);
eapol_exit();
}
@@ -3141,7 +3142,7 @@ done:
if (sm)
eapol_sm_free(sm);
- handshake_state_free(hs);
+ handshake_state_unref(hs);
eapol_exit();
eap_exit();
}
@@ -3424,7 +3425,7 @@ static void eapol_sm_test_eap_nak(const void *data)
sizeof(eap_failure), false);
assert(ths->handshake_failed);
- handshake_state_free(hs);
+ handshake_state_unref(hs);
eapol_exit();
eap_exit();
}
@@ -3510,7 +3511,7 @@ static void eapol_ft_handshake_test(const void *data)
assert(verify_step4_called);
eapol_sm_free(sm);
- handshake_state_free(hs);
+ handshake_state_unref(hs);
eapol_exit();
}
@@ -3609,6 +3610,7 @@ static struct handshake_state *test_ap_sta_hs_new(struct test_ap_sta_data *s,
ths->super.ifindex = ifindex;
ths->super.free = (void (*)(struct handshake_state *s)) l_free;
+ ths->super.refcount = 1;
ths->s = s;
return &ths->super;
@@ -3692,8 +3694,10 @@ static void eapol_ap_sta_handshake_test(const void *data)
test_ap_sta_run(&s);
- handshake_state_free(s.ap_hs);
- handshake_state_free(s.sta_hs);
+ l_info("freeing in eapol_ap_sta_handshake_test()");
+
+ handshake_state_unref(s.ap_hs);
+ handshake_state_unref(s.sta_hs);
__handshake_set_install_tk_func(NULL);
assert(s.ap_success && s.sta_success);
@@ -3753,8 +3757,8 @@ static void eapol_ap_sta_handshake_bad_psk_test(const void *data)
test_ap_sta_run(&s);
- handshake_state_free(s.ap_hs);
- handshake_state_free(s.sta_hs);
+ handshake_state_unref(s.ap_hs);
+ handshake_state_unref(s.sta_hs);
__handshake_set_install_tk_func(NULL);
/*
@@ -3825,8 +3829,8 @@ static void eapol_ap_sta_handshake_ip_alloc_ok_test(const void *data)
assert(s.sta_hs->subnet_mask == s.ap_hs->subnet_mask);
assert(s.sta_hs->go_ip_addr == s.ap_hs->go_ip_addr);
- handshake_state_free(s.ap_hs);
- handshake_state_free(s.sta_hs);
+ handshake_state_unref(s.ap_hs);
+ handshake_state_unref(s.sta_hs);
__handshake_set_install_tk_func(NULL);
assert(s.ap_success && s.sta_success);
@@ -3889,8 +3893,8 @@ static void eapol_ap_sta_handshake_ip_alloc_no_req_test(const void *data)
assert(!s.ap_hs->support_ip_allocation);
assert(!s.sta_hs->support_ip_allocation);
- handshake_state_free(s.ap_hs);
- handshake_state_free(s.sta_hs);
+ handshake_state_unref(s.ap_hs);
+ handshake_state_unref(s.sta_hs);
__handshake_set_install_tk_func(NULL);
assert(s.ap_success && s.sta_success);
diff --git a/unit/test-sae.c b/unit/test-sae.c
index 04783d18..2e564133 100644
--- a/unit/test-sae.c
+++ b/unit/test-sae.c
@@ -101,6 +101,7 @@ static struct handshake_state *test_handshake_state_new(uint32_t ifindex)
ths->super.ifindex = ifindex;
ths->super.free = test_handshake_state_free;
+ ths->super.refcount = 1;
return &ths->super;
}
@@ -183,7 +184,7 @@ static struct auth_proto *test_initialize(struct test_data *td)
static void test_destruct(struct test_data *td)
{
- handshake_state_free(td->handshake);
+ handshake_state_unref(td->handshake);
l_free(td);
}
@@ -459,8 +460,8 @@ static void test_bad_confirm(const void *arg)
assert(td1->tx_assoc_called);
assert(td2->status != 0);
- handshake_state_free(hs1);
- handshake_state_free(hs2);
+ handshake_state_unref(hs1);
+ handshake_state_unref(hs2);
ap1->free(ap1);
ap2->free(ap2);
@@ -544,8 +545,8 @@ static void test_confirm_after_accept(const void *arg)
assert(auth_proto_rx_associate(ap1, (uint8_t *)assoc, frame_len) == 0);
assert(auth_proto_rx_associate(ap2, (uint8_t *)assoc, frame_len) == 0);
- handshake_state_free(hs1);
- handshake_state_free(hs2);
+ handshake_state_unref(hs1);
+ handshake_state_unref(hs2);
auth_proto_free(ap1);
auth_proto_free(ap2);
@@ -621,8 +622,8 @@ static void test_end_to_end(const void *arg)
assert(auth_proto_rx_associate(ap1, (uint8_t *)assoc, frame_len) == 0);
assert(auth_proto_rx_associate(ap2, (uint8_t *)assoc, frame_len) == 0);
- handshake_state_free(hs1);
- handshake_state_free(hs2);
+ handshake_state_unref(hs1);
+ handshake_state_unref(hs2);
auth_proto_free(ap1);
auth_proto_free(ap2);
diff --git a/unit/test-wsc.c b/unit/test-wsc.c
index 8b130f45..8022ebf6 100644
--- a/unit/test-wsc.c
+++ b/unit/test-wsc.c
@@ -61,6 +61,7 @@ static struct handshake_state *test_handshake_state_new(uint32_t ifindex)
ths->super.ifindex = ifindex;
ths->super.free = test_handshake_state_free;
+ ths->super.refcount = 1;
return &ths->super;
}
@@ -2093,7 +2094,7 @@ static void wsc_test_pbc_handshake(const void *data)
eap_fail, sizeof(eap_fail), false);
assert(verify.eapol_failed);
- handshake_state_free(hs);
+ handshake_state_unref(hs);
eapol_exit();
eap_exit();
}
@@ -2216,7 +2217,7 @@ static void wsc_test_retransmission_no_fragmentation(const void *data)
sizeof(eap_fail), false);
assert(verify.eapol_failed);
- handshake_state_free(hs);
+ handshake_state_unref(hs);
eapol_exit();
eap_exit();
}
@@ -2335,6 +2336,7 @@ static struct handshake_state *test_ap_sta_hs_new(struct test_ap_sta_data *s,
ths->super.ifindex = ifindex;
ths->super.free = (void (*)(struct handshake_state *s)) l_free;
+ ths->super.refcount = 1;
ths->s = s;
return &ths->super;
@@ -2535,8 +2537,8 @@ static void wsc_r_test_pbc_handshake(const void *data)
test_ap_sta_run(&s);
- handshake_state_free(s.ap_hs);
- handshake_state_free(s.sta_hs);
+ handshake_state_unref(s.ap_hs);
+ handshake_state_unref(s.sta_hs);
__handshake_set_install_tk_func(NULL);
l_settings_free(ap_8021x_settings);
l_settings_free(sta_8021x_settings);
--
2.34.1
next prev parent reply other threads:[~2024-11-22 15:16 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-11-22 15:15 [PATCH 00/15] PMKSA support (SAE only) James Prestwood
2024-11-22 15:15 ` [PATCH 01/15] handshake: add ref counting to handshake_state James Prestwood
2024-11-22 15:15 ` James Prestwood [this message]
2024-11-22 15:15 ` [PATCH 03/15] auto-t: always initialize StationDebug in Device class James Prestwood
2024-11-22 15:15 ` [PATCH 04/15] auto-t: add pmksa_flush() to hostapd module James Prestwood
2024-11-22 15:15 ` [PATCH 05/15] auto-t: update testSAE to disable PMKSA James Prestwood
2024-11-22 15:15 ` [PATCH 06/15] pmksa: Add skeleton James Prestwood
2024-11-22 15:15 ` [PATCH 07/15] unit: Add basic pmksa test James Prestwood
2024-11-22 15:15 ` [PATCH 08/15] pmksa: Add debugging James Prestwood
2024-11-22 15:15 ` [PATCH 09/15] handshake: Add pmksa setter & stealer James Prestwood
2024-11-25 14:56 ` Denis Kenzior
2024-11-25 15:01 ` James Prestwood
2024-11-25 19:25 ` Bryce Johnson
2024-11-25 19:49 ` James Prestwood
2024-11-25 20:18 ` Bryce Johnson
2024-11-22 15:15 ` [PATCH 10/15] handshake: add handshake_state_remove_pmksa James Prestwood
2024-11-22 15:15 ` [PATCH 11/15] netdev: add support to use PMKSA over SAE if available James Prestwood
2024-11-22 15:15 ` [PATCH 12/15] station: hold reference to handshake object James Prestwood
2024-11-22 15:15 ` [PATCH 13/15] station: support PMKSA connections James Prestwood
2024-11-22 15:15 ` [PATCH 14/15] auto-t: add PMKSA tests James Prestwood
2024-11-22 15:15 ` [PATCH 15/15] doc: document DisablePMKSA option James Prestwood
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20241122151551.286355-3-prestwoj@gmail.com \
--to=prestwoj@gmail.com \
--cc=iwd@lists.linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox