You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
this issue involves some reverse engineering done on my system:
cco@firiel:~$ uname -a
Linux firiel 5.8.0-63-generic #71-Ubuntu SMP Tue Jul 13 15:59:12 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux
cco@firiel:~$ lsb_release -a
LSB Version: core-11.1.0ubuntu2-noarch:printing-11.1.0ubuntu2-noarch:security-11.1.0ubuntu2-noarch
Distributor ID: Ubuntu
Description: Ubuntu 20.10
Release: 20.10
Codename: groovy
I ran into some problems when trying use the nftables.Conn.AddRule() and nftables.Conn.InsertRule() for adding or inserting new rules in a specified position.
I have checked with strace which are the systemcalls to which the nft tool translates "rule add/insert with handle" operations; like this for example:
strace -o /tmp/nft_dump nft insert rule ip filter MONITORING handle 382 ip saddr @whitelist counter
I have seen in the output that only the attribute NFTA_RULE_POSITION (0x6) is used in netlink messages for these operations; it should be filled in with the actual handle where the rule should be added or inserted. here is the relevant sendmsg() sycall from the strace output:
as far as I can tell from my reverse engineering sessions, NFTA_RULE_HANDLE is NOT used when adding or inserting rules with specified handle through the nft command line.
now, one can still use the APIs nftables.Conn.AddRule, nftables.Conn.InsertRule by just setting the Rule.Handle to 0 and the actual handle in Rule.Position
maybe:
this behaviour should be documented somehow in nftables;
encoding of Rule.Handle should be removed from the insert/add APIs
The text was updated successfully, but these errors were encountered:
The only reason why NFTA_RULE_HANDLE is passed in netlink messages is because we tried to prevents a breaking change. Before my changes AddRule allow to make replacement operations (more at #86 (comment)). Therefore an AddRule or InsertRule with an handle has the same behavior as ReplaceRule. Indeed, if handle is zeroed it won't be passed, but it's not a problem since zero is the default value of an uint64 field. Imo it's not a concern, do you have an example of where it could be an issue ?
this issue involves some reverse engineering done on my system:
I ran into some problems when trying use the
nftables.Conn.AddRule()
andnftables.Conn.InsertRule()
for adding or inserting new rules in a specified position.I have checked with
strace
which are the systemcalls to which thenft
tool translates "rule add/insert with handle" operations; like this for example:I have seen in the output that only the attribute
NFTA_RULE_POSITION
(0x6) is used in netlink messages for these operations; it should be filled in with the actual handle where the rule should be added or inserted. here is the relevantsendmsg()
sycall from the strace output:as far as I can tell from my reverse engineering sessions,
NFTA_RULE_HANDLE
is NOT used when adding or inserting rules with specified handle through thenft
command line.now, one can still use the APIs
nftables.Conn.AddRule
,nftables.Conn.InsertRule
by just setting theRule.Handle
to0
and the actual handle inRule.Position
maybe:
nftables
;Rule.Handle
should be removed from the insert/add APIsThe text was updated successfully, but these errors were encountered: