Repository navigation
Conversation
thaJeztah
force-pushed
the
update_consts
branch
from
October 8, 2026 23:48
59c4022 to
674eef4
Compare
There was a problem hiding this comment.
🟢 Approval recommended
The type-safety changes preserve protocol values and consistently update all affected call sites.
0 open findings
What changed in this PR
Introduces type-safe IPVS netlink enums while preserving existing wire values.
Changes:
- Replaces
iotaconstants with documented kernel values. - Adds distinct command and attribute types.
- Converts typed values at netlink API boundaries.
| File | Description |
|---|---|
constants_linux.go |
Defines documented, typed netlink constants. |
netlink_linux.go |
Applies typed constants in encoding and decoding. |
🧠 Review effort: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Replace iota-based constant definitions with explicit values matching the Linux kernel's IPVS generic netlink interface. Add comments identifying the corresponding kernel constants and links to their definitions in the Linux UAPI headers. This makes it easier to verify the values against the kernel and prevents accidental changes to protocol values when constants are added or reordered. Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Introduce an ipvsCmd type for IPVS generic netlink commands and update the command helpers to use it. This groups the command constants under a distinct type, allowing linters such as exhaustive to detect missing cases in switches and providing stronger type checking. Keep the generic netlink request helper accepting uint8, as it is also used for commands outside the IPVS family. Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Introduce dedicated types for IPVS command, service, destination, and statistics attributes, using int as the underlying type to match the netlink package's API. Update the encoding and decoding paths to use these types, with explicit conversions at the netlink API boundaries. This improves type safety and allows linters such as exhaustive to detect missing attribute cases in switch statements. The attribute values and wire format remain unchanged. Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
thaJeztah
force-pushed
the
update_consts
branch
from
October 9, 2026 11:13
674eef4 to
41ce5bd
Compare
Use the ConnFwd* constants as the canonical names for IPVS forwarding methods, and deprecate the duplicate ConnectionFlag* constants while retaining them as aliases for compatibility. Update internal references to use ConnFwd* and document their corresponding Linux kernel definitions. Simplify lookupFwMethod by returning string literals directly instead of indexing into a separate slice, and handle the previously missing LocalNode and Bypass methods. Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Add a reference to the Linux kernel's IPVS scheduler implementations to clarify where the scheduler names originate. Unlike the netlink attributes and forwarding flags, these names are registered as strings by the individual kernel schedulers, rather than defined as UAPI constants. Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Replace nl.FAMILY_* constants with their corresponding unix.AF_* constants. The netlink package aliases these constants to the Linux address family values, so using golang.org/x/sys/unix directly avoids an unnecessary layer of indirection and makes their origin explicit. Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Comment on lines
+80
to
+81
| ipvsSvcAttrStats ipvsSvcAttr = 10 // IPVS_SVC_ATTR_STATS | ||
| ipvsSvcAttrPEName ipvsSvcAttr = 11 // IPVS_SVC_ATTR_PE_NAME |
Member
Author
There was a problem hiding this comment.
Yup; back-filling missing ones is on my list for a follow-up. This PR is just cleaning up the current definitions and correlating them with the upstream (Linux kernel)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

document IPVS netlink constants and use explicit values
Replace iota-based constant definitions with explicit values matching
the Linux kernel's IPVS generic netlink interface.
Add comments identifying the corresponding kernel constants and links
to their definitions in the Linux UAPI headers.
This makes it easier to verify the values against the kernel and
prevents accidental changes to protocol values when constants are
added or reordered.
define a distinct type for IPVS netlink commands
Introduce an ipvsCmd type for IPVS generic netlink commands and
update the command helpers to use it.
This groups the command constants under a distinct type, allowing
linters such as exhaustive to detect missing cases in switches and
providing stronger type checking.
Keep the generic netlink request helper accepting uint8, as it is
also used for commands outside the IPVS family.
define distinct types for IPVS netlink attributes
Introduce dedicated types for IPVS command, service, destination,
and statistics attributes, using int as the underlying type to
match the netlink package's API.
Update the encoding and decoding paths to use these types, with
explicit conversions at the netlink API boundaries.
This improves type safety and allows linters such as exhaustive
to detect missing attribute cases in switch statements.
The attribute values and wire format remain unchanged.
deduplicate IPVS forwarding method constants
Use the ConnFwd* constants as the canonical names for IPVS
forwarding methods, and deprecate the duplicate ConnectionFlag*
constants while retaining them as aliases for compatibility.
Update internal references to use ConnFwd* and document their
corresponding Linux kernel definitions.
Simplify lookupFwMethod by returning string literals directly
instead of indexing into a separate slice, and handle the
previously missing LocalNode and Bypass methods.
document IPVS scheduler name constants
Add a reference to the Linux kernel's IPVS scheduler implementations
to clarify where the scheduler names originate.
Unlike the netlink attributes and forwarding flags, these names
are registered as strings by the individual kernel schedulers,
rather than defined as UAPI constants.
use unix address family constants directly
Replace nl.FAMILY_* constants with their corresponding unix.AF_*
constants.
The netlink package aliases these constants to the Linux address
family values, so using golang.org/x/sys/unix directly avoids an
unnecessary layer of indirection and makes their origin explicit.