Skip to content

feat: multi-value rodata infrastructure#49

Open
leodido wants to merge 4 commits intofeat/dispatcher-chainfrom
feat/multi-value-rodata
Open

feat: multi-value rodata infrastructure#49
leodido wants to merge 4 commits intofeat/dispatcher-chainfrom
feat/multi-value-rodata

Conversation

@leodido
Copy link
Copy Markdown
Owner

@leodido leodido commented May 4, 2026

Extends the input model from single scalars to arrays, enabling future
multi-value programs (allow_ethertype, allow_proto).

Changes

  1. refactor: extend input unions with multi-value structs — adds
    ethertypes (__u16[8] + count) and protos (__u8[8] + count)
    structs to the input union in both chain_entry and struct config.
    MAX_MULTI_VALUES = 8 shared across all multi-value types.

  2. feat: add multi-value input parsers for ethertypes and protos
    parse_ethertypes() splits on +, accepts symbolic names (ipv4,
    arp, ipv6) and 0x-prefixed hex. parse_protos() splits on +,
    accepts symbolic names (tcp, udp, icmp) and decimal numbers.
    Both validate: no empty lists, no duplicates, no overflow, no
    out-of-range values.

  3. feat: add multi-value rodata support to build system template
    api.lua now supports table-format input_fields entries
    ({ field = "ethertypes", multi = true }) alongside plain strings.

What this enables

When allow_ethertype or allow_proto land, they need only:

  • The .bpf.c file
  • A case in load_chain_program()
  • An input_fields entry in api.lua
  • parse_input() / program_requires_input() wiring

The parsers and rodata plumbing are ready.

Stacked on

leodido and others added 4 commits May 4, 2026 10:02
Add ethertypes and protos structs to the input union in both
chain_entry (api/chain.h) and struct config (api/api.h.in).
Add MAX_MULTI_VALUES define (8) shared across all multi-value types.

No behavioral change — the new union members are not yet populated
by any parser or consumed by any BPF program.

Co-authored-by: Ona <no-reply@ona.com>
Add parse_ethertypes() and parse_protos() helpers to input_parse.h.

parse_ethertypes() splits on '+', accepts symbolic names (ipv4, ipv6,
arp) and 0x-prefixed hex values. parse_protos() splits on '+', accepts
symbolic names (tcp, udp, icmp) and decimal numbers.

Both validate: no empty lists, no duplicates, no overflow beyond
MAX_MULTI_VALUES, no out-of-range values.

These helpers are not yet wired into parse_input() — the cases will
be added when the corresponding BPF programs land and the enum values
exist.

Co-authored-by: Ona <no-reply@ona.com>
Extend api.lua to support table-format input_fields entries alongside
plain strings. Multi-value programs use { field = "name", multi = true }
which sets PROGNAME_IS_MULTI_VALUE in the template variables.

The template's memcpy already handles both scalars and structs via
sizeof(), so no template file changes are needed. The new variable is
available for future template branching if needed.

No input_fields entries are added yet — those come when the BPF
programs (allow_ethertype, allow_proto) land.

Co-authored-by: Ona <no-reply@ona.com>
Add validate_delimited_input() that rejects leading '+', trailing '+',
and consecutive '++' before tokenization. strtok_r collapses adjacent
delimiters, so without this check 'ipv4+', '+ipv4', and 'ipv4++arp'
would be silently accepted as valid input.

Co-authored-by: Ona <no-reply@ona.com>
@leodido leodido requested a review from fntlnz May 4, 2026 10:02
@leodido leodido force-pushed the feat/multi-value-rodata branch from 95679b3 to 3f99ffb Compare May 4, 2026 10:02
@leodido leodido force-pushed the feat/dispatcher-chain branch from 93071f5 to 29e8571 Compare May 4, 2026 10:02
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.

2 participants