Skip to content

feat: add SEG6_LOCAL_FLAVORS support for seg6local NEXT-CSID#1199

Open
privateip wants to merge 2 commits into
vishvananda:mainfrom
privateip:seg6local-next-csid-flavors
Open

feat: add SEG6_LOCAL_FLAVORS support for seg6local NEXT-CSID#1199
privateip wants to merge 2 commits into
vishvananda:mainfrom
privateip:seg6local-next-csid-flavors

Conversation

@privateip

@privateip privateip commented Jul 6, 2026

Copy link
Copy Markdown

Add the SEG6_LOCAL_FLAVORS attribute and its nested sub-attributes (SEG6_LOCAL_FLV_OPERATION, SEG6_LOCAL_FLV_LCBLOCK_BITS, SEG6_LOCAL_FLV_LCNODE_FN_BITS), introduced in Linux 6.1 (commit 848f3c0d47, "seg6: add support for the SRv6 End* flavors").

This exposes the NEXT-CSID flavor operation on SEG6LocalEncap, letting callers configure the locator-block and node-function bit lengths used for compressed SID (uSID/C-SID) behaviors, matching what iproute2 exposes as flavors next-csid lblen <n> nflen <n>.

Summary by CodeRabbit

  • New Features

    • Added support for segment-routing “flavors” in local encapsulation handling, including encode/decode, equality checks, and expanded string output (operation plus bit-length parameters).
    • Extended available flavor-related constants and added a helper that renders flavor operation names, returning a fallback for unknown values.
  • Tests

    • Added round-trip tests for multiple flavor configurations, including an unsupported operation, validating equality and string formatting.

Add the SEG6_LOCAL_FLAVORS attribute and its nested sub-attributes
(SEG6_LOCAL_FLV_OPERATION, SEG6_LOCAL_FLV_LCBLOCK_BITS,
SEG6_LOCAL_FLV_LCNODE_FN_BITS), introduced in Linux 6.1
(commit 848f3c0d47, "seg6: add support for the SRv6 End* flavors").

This exposes the NEXT-CSID flavor operation on SEG6LocalEncap,
letting callers configure the locator-block and node-function bit
lengths used for compressed SID (uSID/C-SID) behaviors, matching
what iproute2 exposes as `flavors next-csid lblen <n> nflen <n>`.
@coderabbitai

coderabbitai Bot commented Jul 6, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 4eac43d2-c4fb-40db-9115-729a03ecbd73

📥 Commits

Reviewing files that changed from the base of the PR and between c286917 and 290b871.

📒 Files selected for processing (1)
  • route_linux.go
🚧 Files skipped from review as they are similar to previous changes (1)
  • route_linux.go

📝 Walkthrough

Walkthrough

Adds SEG6_LOCAL_FLAVORS support across netlink constants, SEG6LocalEncap encoding/decoding and formatting, and test coverage for flavor round-tripping and string output.

Changes

SEG6 Local Flavors Support

Layer / File(s) Summary
Flavor constants and string helper
nl/seg6local_linux.go
Adds SEG6_LOCAL_COUNTERS, SEG6_LOCAL_FLAVORS, SEG6_LOCAL_FLV_* and SEG6_LOCAL_FLV_OP_* constants, plus SEG6LocalFlavorOperationString mapping operation codes to names.
SEG6LocalEncap Flavors field and encode/decode logic
route_linux.go
Adds Flavors field and SEG6LocalFlavors type; Decode parses SEG6_LOCAL_FLAVORS sub-attributes; Encode serializes them when set.
String and Equal updates
route_linux.go
String output includes a flavors segment; Equal comparison now covers the Flavors field.
Flavors test coverage
route_test.go
Adds TestSEG6LocalEncapFlavors covering encode/decode round-trips, equality, and String formatting including an unknown-operation case.

Estimated code review effort: 2 (Simple) | ~15 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Caller
  participant SEG6LocalEncap
  participant nl as nl package

  Caller->>SEG6LocalEncap: Decode(attrs)
  SEG6LocalEncap->>nl: parse SEG6_LOCAL_FLAVORS sub-attrs
  nl-->>SEG6LocalEncap: Operation, LcBlockBits, LcNodeFnBits
  SEG6LocalEncap-->>Caller: Flavors populated

  Caller->>SEG6LocalEncap: Encode()
  SEG6LocalEncap->>nl: emit SEG6_LOCAL_FLAVORS attrs
  nl-->>Caller: encoded bytes

  Caller->>SEG6LocalEncap: String()
  SEG6LocalEncap->>nl: SEG6LocalFlavorOperationString(op)
  nl-->>SEG6LocalEncap: operation name
  SEG6LocalEncap-->>Caller: formatted string
Loading

Related PRs: None specified.

Suggested labels: enhancement, seg6

Suggested reviewers: vishvananda

Poem

A rabbit hops through netlink's maze,
Flavors added, bits ablaze,
NEXT-CSID whispers in the wire,
Encode, decode, never tire,
Tests confirm the paths are true,
Hop, hop, hooray — a feature new!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: adding SEG6_LOCAL_FLAVORS support for seg6local NEXT-CSID.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@route_linux.go`:
- Around line 356-373: The unknown-attribute error in the SEG6_LOCAL_FLAVORS
decode path is formatting the wrong value with %d, because flvAttr.Attr is a
syscall.RtAttr struct rather than the attribute type. Update the error
construction in the SEG6_LOCAL_FLAVORS case to report flvAttr.Attr.Type instead,
matching the intended behavior and avoiding confusing Len/Type output; use the
same pattern as the other SEG6_LOCAL_* decoding branches.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 9b4debca-a495-4d77-a39c-181b8a2932db

📥 Commits

Reviewing files that changed from the base of the PR and between 4e35dc9 and c286917.

📒 Files selected for processing (3)
  • nl/seg6local_linux.go
  • route_linux.go
  • route_test.go

Comment thread route_linux.go
- Report flvAttr.Attr.Type rather than the raw syscall.RtAttr struct in the SEG6_LOCAL_FLAVORS unknown-attribute error
- Prevents %d from printing the struct's Len/Type fields together, which produced a confusing error message
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