-
Notifications
You must be signed in to change notification settings - Fork 800
Closed
Description
Summary
TCA_FLOWER_FLAGS (skip_hw/skip_sw) are encoded in big-endian via htonl, but netlink attributes are expected in native endian. On little-endian (x86) this flips the bits (e.g., 0x00000001 → 0x01000000), so skip_hw/skip_sw are not applied and tc flower filter add returns EINVAL or the flags are ignored. The tc CLI works because it encodes flags in native endian.
Details
- Affected: v1.3.1 and current master
- In
filter_linux.go,encodedoes:
var flags uint32
if filter.SkipHw { flags |= nl.TCA_CLS_FLAGS_SKIP_HW }
if filter.SkipSw { flags |= nl.TCA_CLS_FLAGS_SKIP_SW }
parent.AddRtAttr(nl.TCA_FLOWER_FLAGS, htonl(flags)) // << big endianhtonlinorder.gousesbinary.BigEndianTCA_FLOWER_FLAGSisNLA_U32and should use native endian (like other u32 attrs vianl.Uint32Attr)
Reproduce
- Create a Flower filter with
SkipHw: trueorSkipSw: trueon x86 netlink.FilterAddreturnsEINVALor the flag is not applied (skip_hw/skip_sw missing)- Adding the same rule via
tcCLI succeeds
Fix
- parent.AddRtAttr(nl.TCA_FLOWER_FLAGS, htonl(flags))
+ parent.AddRtAttr(nl.TCA_FLOWER_FLAGS, nl.Uint32Attr(flags))Impact
With the fix, skip_hw/skip_sw are correctly set, matching tc CLI behavior; avoids EINVAL and ensures flower rules respect offload flags.
Metadata
Metadata
Assignees
Labels
No labels