Compare commits
3 Commits
b3a72503fb
...
7177d374a7
Author | SHA1 | Date |
---|---|---|
|
7177d374a7 | |
|
c803c0e9e7 | |
|
586337f5ce |
25
rule.go
25
rule.go
|
@ -31,7 +31,6 @@ const (
|
|||
)
|
||||
|
||||
// This constant is missing at unix.NFTA_RULE_POSITION_ID.
|
||||
// TODO: Add the constant in unix and then remove it here.
|
||||
const nfta_rule_position_id = 0xa
|
||||
|
||||
type ruleOperation uint32
|
||||
|
@ -48,6 +47,15 @@ const (
|
|||
type Rule struct {
|
||||
Table *Table
|
||||
Chain *Chain
|
||||
// Position can be set to the Handle of another Rule to insert the new Rule
|
||||
// before (InsertRule) or after (AddRule) the existing rule.
|
||||
Position uint64
|
||||
// Deprecated: The feature for which this field was added never worked.
|
||||
// The field may be removed in a later version.
|
||||
Flags uint32
|
||||
// PositionID can be set to the ID of another Rule, same as Position, for when
|
||||
// the existing rule is not yet committed.
|
||||
PositionID uint32
|
||||
// Handle identifies an existing Rule. For a new Rule, this field is set
|
||||
// during the Flush() in which the rule is committed. Make sure to not access
|
||||
// this field concurrently with this Flush() to avoid data races.
|
||||
|
@ -55,18 +63,7 @@ type Rule struct {
|
|||
// ID is an identifier for a new Rule, which is assigned by
|
||||
// AddRule/InsertRule, and only valid before the rule is committed by Flush().
|
||||
// The field is set to 0 during Flush().
|
||||
ID uint32
|
||||
// Position can be set to the Handle of another Rule to insert the new Rule
|
||||
// before (InsertRule) or after (AddRule) the existing rule.
|
||||
Position uint64
|
||||
// PositionID can be set to the ID of another Rule, same as Position, for when
|
||||
// the existing rule is not yet committed.
|
||||
PositionID uint32
|
||||
// The list of possible flags are specified by nftnl_rule_attr, see
|
||||
// https://git.netfilter.org/libnftnl/tree/include/libnftnl/rule.h#n21
|
||||
// Current nftables go implementation supports only
|
||||
// NFTNL_RULE_POSITION flag for setting rule at position 0
|
||||
Flags uint32
|
||||
ID uint32
|
||||
Exprs []expr.Any
|
||||
UserData []byte
|
||||
}
|
||||
|
@ -186,7 +183,7 @@ func (cc *Conn) newRule(r *Rule, op ruleOperation) *Rule {
|
|||
flags = netlink.Request | netlink.Acknowledge | netlink.Replace
|
||||
}
|
||||
|
||||
if r.Position != 0 || (r.Flags&(1<<unix.NFTA_RULE_POSITION)) != 0 {
|
||||
if r.Position != 0 {
|
||||
msgData = append(msgData, cc.marshalAttr([]netlink.Attribute{
|
||||
{Type: unix.NFTA_RULE_POSITION, Data: binaryutil.BigEndian.PutUint64(r.Position)},
|
||||
})...)
|
||||
|
|
Loading…
Reference in New Issue