Skip to content

netlink: add nl80211.key for the AP key control plane - #696

Open
lneto wants to merge 2 commits into
masterfrom
claude_nl80211_key
Open

netlink: add nl80211.key for the AP key control plane#696
lneto wants to merge 2 commits into
masterfrom
claude_nl80211_key

Conversation

@lneto

@lneto lneto commented Aug 9, 2026

Copy link
Copy Markdown
Contributor

Completes the Phase 0 nl80211 control plane (docs/design/wireless-ap/plan.md) with the key object, alongside the merged wiphy/interface/ap/station.

What

  • netlink.nl80211.key():add/del — installs and removes an AP's keys over the "nl80211" family. A group key (GTK) has no MAC; a pairwise key (PTK) has one — the kernel infers the type from the MAC's presence, matching WPA semantics and station.lua's minimalism. index is packed as a u8 (NL80211_ATTR_KEY_IDX is NLA_POLICY_MAX(NLA_U8, 7); strict validation would reject a u32); data/mac/seq are raw bytes.
  • Exposes the WLAN_CIPHER_SUITE_* suites as linux.nl80211.cipher (CCMP, CCMP_256, GCMP, GCMP_256, TKIP) for KEY_CIPHER, plus the NEW_KEY/DEL_KEY commands and KEY_* attributes.

autogen: authoritative include lists

The cipher suites are #define WLAN_CIPHER_SUITE_CCMP SUITE(0x000FAC, 4) — function-like macros that the autogen's integer-expression scan deliberately rejects. The first commit makes an explicit include list authoritative: it emits its names verbatim and lets the C compiler validate them (an unknown name is a build error, not a silent drop). Output is unchanged for the existing enum-member specs; this also unlocks BIT()-based constants in future.

Testing

tests/netlink/nl80211_key.sh on mac80211_hwsim (skips if absent), validated locally — 3/3:

ok 1 key:add installs a group key (GTK)
ok 2 key:add raises on an out-of-range index
ok 3 key:del removes the group key

The test drives the group-key path (install as hostapd does after START_AP, out-of-range index raises, remove). The pairwise path needs a real association — installing a PTK on a manually-added, non-associated station tears the interface down on hwsim — so it belongs to the WPA handshake test (Phase 3), not here.

🤖 Generated with Claude Code

@lneto
lneto force-pushed the claude_nl80211_key branch from 74b80c3 to 5e62bba Compare August 9, 2026 14:17
An `include` list now emits its names verbatim and lets the C compiler
validate them, instead of intersecting them with the integer-expression
scan. This is what lets a curated spec pull in constants defined as
function-like macros (e.g. `WLAN_CIPHER_SUITE_* = SUITE(...)`), which the
scan deliberately rejects; an unknown name becomes a build error rather
than a silent drop. Output is unchanged for the existing enum-member specs.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@lneto
lneto force-pushed the claude_nl80211_key branch from 5e62bba to 697d197 Compare August 9, 2026 17:58
`netlink.nl80211.key():add/del` installs and removes an AP's keys over the
"nl80211" family: a group key (GTK) without a MAC, a pairwise key (PTK)
with one (the kernel infers the type from the MAC's presence). Exposes the
WLAN_CIPHER_SUITE_* suites as `linux.nl80211.cipher` for KEY_CIPHER.

The test drives the group-key path on hwsim (install, out-of-range index
raises, remove); the pairwise path needs a real association and belongs to
the WPA handshake test.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@lneto
lneto force-pushed the claude_nl80211_key branch from 697d197 to c91c123 Compare August 9, 2026 21:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant