Allow more than 255 sec-mod instances

The sec-mod instance index is stored in one byte, so ocserv can run at most 255 instances. Machines with more than 256 cores are common in datacenters, so this limit can now be reached in practice.

Before !612 (merged), the limit wasn't enforced. Instance 256 and above wrote a truncated index into the session ID, and resumed cookies were sent to the wrong instance. !612 (merged) enforces the limit: a configured sec-mod-scale above 255 is an error, and the automatic value is capped at 255.

Affected areas

  • sec-mod
    • src/sec-mod-db.c:134: write the index into sid[0..1] instead of sid[0].
    • sec_mod_server() in src/sec-mod.c and src/sec-mod.h, and run_sec_mod() in src/main-sec-mod-cmd.c: the instance index parameter becomes uint16_t (it is currently uint8_t).
  • main
    • src/main-worker-cmd.c:450: route AUTH_COOKIE_REQ using the two-byte index from cookie.data[0..1], and keep checking it against sec_mod_instance_count.
    • MAX_SEC_MOD_INSTANCES in src/vpn.h: raise it to 65535, or to a lower limit chosen on purpose, and update its comment.
    • The sec-mod-scale check in src/config.c and the automatic cap in src/main.c both follow the new limit.
  • OIDC browser login (state and token from !612 (merged))
    • src/auth/openidconnect.c: write the two-byte index at the start of the state and token, and compare both bytes against the instance's own index when checking a value.
    • sso_key_data_st.instance in src/sec-mod.h becomes uint16_t.
    • oidc_value_instance() in src/worker-oidc.c: decode 4 hex characters instead of 2.
  • Docs and requirements
    • doc/sample.config and doc/ocserv.8.md: update the sec-mod-scale limit.
    • Requirements: update REQ-MAIN-INIT-003 and REQ-IPC-021 (cookie routing), REQ-IPC-093 (OIDC state and token), and the requirement that covers the sec-mod-scale limit.