Skip to content

fix(spop): support configurable frame sizes#31

Closed
fionera wants to merge 1 commit into
masterfrom
agent/configurable-frame-size
Closed

fix(spop): support configurable frame sizes#31
fionera wants to merge 1 commit into
masterfrom
agent/configurable-frame-size

Conversation

@fionera

@fionera fionera commented Jul 10, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • add Agent.MaxFrameSize with a zero-value-compatible 65,535-byte default and a 256-byte protocol minimum
  • replace the process-wide fixed frame pool with an Agent-scoped pool sized to the configured ceiling
  • negotiate the lower of HAProxy's offer and the Agent ceiling, then enforce it for inbound frames and outbound ACKs
  • send the defined SPOP disconnect codes and close deterministically on invalid or oversized frames
  • release failed reads and clear consumed scheduler slots so larger pooled buffers are not retained by stale queue references
  • document configuration and memory behavior

Root cause

All connections used one global sync.Pool whose buffers were permanently sized to 65,535 bytes. The HELLO handler also rejected larger HAProxy offers instead of negotiating the lower supported value required by SPOP. Removing only the validation would therefore allow a larger negotiated value to reach an undersized pooled buffer.

The configured Agent ceiling makes every buffer in a listener's shared pool the same size, while each connection still enforces its negotiated limit.

Impact

Existing zero-value Agents retain the 65,535-byte ceiling. Deployments using larger HAProxy buffers can construct an Agent with a matching MaxFrameSize; for example, a 256 KiB HAProxy buffer advertises 262,140 bytes.

Because pooled frame buffers are allocated at the configured ceiling, callers should choose the smallest value that accommodates their HAProxy configuration.

Fixes #14.

Related upstream report: corazawaf/coraza-spoa#194

Validation

  • GOTOOLCHAIN=go1.21.13 go test ./...
  • GOTOOLCHAIN=go1.23.1 go test -race ./...
  • CGO_ENABLED=0 GOARCH=386 go test ./...
  • repository custom vet analyzer
  • pinned staticcheck v0.5.1
  • go test -tags e2e ./spop with HAProxy 3.3.11

@fionera

fionera commented Jul 10, 2026

Copy link
Copy Markdown
Collaborator Author

Superseded by the simpler tests-first stack in #32 and #33. The replacement negotiates HAProxy's advertised size automatically and allocates only for actual frames, so it does not add Agent.MaxFrameSize.

@fionera fionera closed this Jul 10, 2026
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.

Impossible to increase maxFrameSize for coraza-spoa

1 participant