[PATCH] tests: ap_ciphers: read debugfs conf_flags if it exists
Johannes Berg
johannes at sipsolutions.net
Sat Aug 1 01:04:13 PDT 2026
From: Johannes Berg <johannes.berg at intel.com>
The code here in the tests differentiates pairwise and
group keys by the presence of the 'station' file in
mac80211's key debugfs. This currently works because
the code is only invoked on the client, where keys are
in fact currently installed that way by mac80211. In
other modes (IBSS, mesh, NAN) it wouldn't work, since
GTKs are installed per STA as well.
Given the complexity of this difference in mac80211,
I'm working on changing that, robbing the test of a
way to differentiate pairwise and group keys. To still
be able to differentiate, mac80211 will then expose a
new 'conf_flags' file, where we can check the pairwise
flag (bit 3) instead, if it exists.
Signed-off-by: Johannes Berg <johannes.berg at intel.com>
---
tests/hwsim/test_ap_ciphers.py | 26 ++++++++++++++++++++++----
1 file changed, 22 insertions(+), 4 deletions(-)
diff --git a/tests/hwsim/test_ap_ciphers.py b/tests/hwsim/test_ap_ciphers.py
index 9078e4497c1a..57fe47f6937c 100644
--- a/tests/hwsim/test_ap_ciphers.py
+++ b/tests/hwsim/test_ap_ciphers.py
@@ -550,8 +550,17 @@ def get_rx_spec(phy, keytype=KT_PTK):
files = os.listdir(keydir)
if keytype == KT_PTK and "station" not in files:
continue
- if keytype != KT_PTK and "station" in files:
- continue
+ try:
+ # if present, check pairwise flag
+ with open(keydir + '/conf_flags') as f:
+ flags = int(f.read(), 0)
+ if keytype != KT_PTK and flags & (1 << 3):
+ continue
+ if keytype == KT_PTK and not (flags & (1 << 3)):
+ continue
+ except OSError as e:
+ if keytype != KT_PTK and "station" in files:
+ continue
with open(keydir + "/rx_spec") as f:
return f.read()
except OSError as e:
@@ -574,8 +583,17 @@ def get_tk_replay_counter(phy, keytype=KT_PTK):
files = os.listdir(keydir)
if keytype == KT_PTK and "station" not in files:
continue
- if keytype != KT_PTK and "station" in files:
- continue
+ try:
+ # if present, check pairwise flag
+ with open(keydir + '/conf_flags') as f:
+ flags = int(f.read(), 0)
+ if keytype != KT_PTK and flags & (1 << 3):
+ continue
+ if keytype == KT_PTK and not (flags & (1 << 3)):
+ continue
+ except OSError as e:
+ if keytype != KT_PTK and "station" in files:
+ continue
with open(keydir + "/replays") as f:
return int(f.read())
except OSError as e:
--
2.55.0
More information about the Hostap
mailing list