Repository navigation
rtnl: send a rule's iif and oif as interface names - #517
Open
WiFiGUY512 wants to merge 1 commit into
Open
WiFiGUY512 wants to merge 1 commit into
WiFiGUY512 wants to merge 1 commit into
Conversation
FRA_IFNAME and FRA_OIFNAME carry an interface name, a NUL-terminated
string; the kernel's fib rule policy reads them as NLA_STRING. The rule
spec declared them DT_NETDEV, so rtnl sent the interface's index as a
32-bit number. The kernel then took those four bytes for a name that
matches no device, accepted the rule, and marked it detached:
rtnl.request(rtnl.const.RTM_NEWRULE, rtnl.const.NLM_F_CREATE,
{ family: rtnl.const.AF_INET, oif: "lo", table: 100,
priority: 100 });
leaves a rule whose dump has FIB_RULE_OIF_DETACHED (0x10) in its flags,
and which never matches; with iif, FIB_RULE_IIF_DETACHED (0x8). Reading
such a rule back gave null for the interface, the name string being
decoded as an index the same way.
Declare both as DT_STRING, which sends and reads the name, as iproute2
does. A script passes the same value as before. Tested on an OpenWrt
IPQ4019 AP (32-bit ARM): with this change both rules have flags 0 and
read back as "lo".
Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Christopher Griffin <christophergriffin05@gmail.com>
This branch has not been deployed
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.
A rule's
iifandoifgo to the kernel asFRA_IFNAMEandFRA_OIFNAME, which carry an interface name: a NUL-terminated string, read withNLA_STRINGby the kernel's fib rule policy. The rule spec declared themDT_NETDEV, so rtnl sent the interface's index as a 32-bit number instead.The kernel takes those four bytes for a name. No device matches it, so it accepts the rule and marks it detached:
This leaves a rule with
FIB_RULE_OIF_DETACHED(0x10) in its flags, and it never matches. Withiif, the flag isFIB_RULE_IIF_DETACHED(0x8). Reading such a rule back gives null for the interface, because the name string is decoded as an index the same way.This commit declares both as
DT_STRING, which sends and reads the name, as iproute2 does. Scripts pass the same value as before.Tested on an Arista W-118 (IPQ4019, 32-bit ARM) with OpenWrt main, loading the patched
rtnl.sowithucode -L:oifrule flagsiifrule flags"lo"🤖 Generated with Claude Code