Skip to content

Add DSCP class-name keyword support#492

Open
yaakov-stein wants to merge 3 commits intofacebook:mainfrom
yaakov-stein:add_dscp_keywords
Open

Add DSCP class-name keyword support#492
yaakov-stein wants to merge 3 commits intofacebook:mainfrom
yaakov-stein:add_dscp_keywords

Conversation

@yaakov-stein
Copy link
Copy Markdown
Contributor

As mentioned in #383, add support for DSCP class name keywords in ip4.dscp and ip6.dscp matchers. Instead of requiring users to memorize numeric DSCP codepoints, rules can now use standard class names:

ip4.dscp eq ef
ip6.dscp not cs1
ip4.dscp eq af21

Supported keywords follow the IANA DSCP registry and match iptables conventions (see dscp_helper.c):

  • CS0–CS7 (Class Selector)
  • AF11–AF43 (Assured Forwarding)
  • EF (Expedited Forwarding)
  • BE (Best Effort, alias for CS0)

Keywords are case-insensitive. Numeric values (0–63, decimal or hex) continue to work as before.

Testing

  • Unit + e2e tests
  • Manual Testing

@github-actions
Copy link
Copy Markdown

github-actions bot commented Mar 30, 2026

Claude review of PR #492 (f6aec14)

Must fix

  • Lexer rejects voice-admit (hyphenated DSCP class)src/bfcli/lexer.l:212,242 — The DSCP lexer states only accept {int} tokens, which cannot match hyphens. voice-admit fails at lexing; also breaks round-trip since bf_dscp_class_to_str(44) outputs voice-admit which bfcli cannot re-parse. The ICMP type state already handles this with {int}|[0-9a-zA-Z-]+.

Suggestions

  • Document all supported keywordsdoc/usage/bfcli.rst:638 — Docs only mention ef, cs1, af21, be; voice-admit, le, nqb are omitted. Other matchers list all keywords in a tip block.
  • Add e2e tests for le, nqb, voice-admittests/e2e/parsing/ip4_dscp.sh:22, tests/e2e/parsing/ip6_dscp.sh:23 — Newly added Pool 3 keywords lack e2e coverage. voice-admit requires the lexer fix first.
  • Add unit tests for le, nqb, voice-admittests/unit/libbpfilter/matcher.c:394 — Only cs0, ef, af21, BE, Af11, VOICE-ADMIT are tested for from_str; le and nqb are untested. to_str only checks cs0 and ef.
  • Restore generic invalid string test in ip6_dscp_invalidtests/unit/libbpfilter/matcher.c:1185 — Replacing "not_a_number" with "cs8" lost coverage for arbitrary garbage strings; ip4_dscp still tests "invalid" alongside "cs8".

Nits

  • Comment URL missing full pathsrc/libbpfilter/matcher.c:1677 — URL uses dscp-registry without .xhtml suffix, unlike the RST reference and other links in the codebase.

Workflow run

@yaakov-stein yaakov-stein force-pushed the add_dscp_keywords branch 2 times, most recently from 8ecd117 to 262b531 Compare April 1, 2026 16:47
@yaakov-stein yaakov-stein requested a review from qdeslandes April 1, 2026 16:48
Allow DSCP matchers (ip4.dscp, ip6.dscp) to accept symbolic class
names (cs0-cs7, af11-af43, ef, be) in addition to numeric values.
The class name table is based on iptables' dscp_helper.c and the
IANA DSCP registry. Matching is case-insensitive.
Add unit tests for bf_dscp_class_to_str/bf_dscp_class_from_str
conversion functions, keyword parsing in ip4_dscp and ip6_dscp
matchers, and e2e tests exercising class name keywords with both
valid and invalid inputs.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants