Repository navigation
Closed
Description
All, and @rwhelan , @sbezverk,
In a nutshell, I want to validate the existence of the following nftables rule:
oifname "cni-podman0" ip daddr 192.168.124.0/24 ct state established,related counter packets 108 bytes 125682 accept # handle 71
The Rule object looks like this:
(*nftables.Rule)(0xc000140780)({
Table: (*nftables.Table)(0xc0001cd660)({
Name: (string) (len=6) "filter",
Use: (uint32) 0,
Flags: (uint32) 0,
Family: (nftables.TableFamily) 0
}),
Chain: (*nftables.Chain)(0xc0001d0580)({
Name: (string) (len=7) "FORWARD",
Table: (*nftables.Table)(<nil>),
Hooknum: (nftables.ChainHook) 0,
Priority: (nftables.ChainPriority) 0,
Type: (nftables.ChainType) "",
Policy: (*nftables.ChainPolicy)(<nil>)
}),
Position: (uint64) 0,
Handle: (uint64) 71,
Exprs: ([]expr.Any) (len=9 cap=16) {
(*expr.Meta)(0xc0001c4ad0)({
Key: (expr.MetaKey) 7,
SourceRegister: (bool) false,
Register: (uint32) 1
}),
(*expr.Cmp)(0xc0001cd760)({
Op: (expr.CmpOp) 0,
Register: (uint32) 1,
Data: ([]uint8) (len=16 cap=16) {
0000000063 6e 69 2d 70 6f 64 6d61 6e 30 00 00 00 00 00|cni-podman0.....|
}
}),
(*expr.Payload)(0xc00012c270)({
OperationType: (expr.PayloadOperationType) 0,
DestRegister: (uint32) 1,
SourceRegister: (uint32) 0,
Base: (expr.PayloadBase) 1,
Offset: (uint32) 16,
Len: (uint32) 4,
CsumType: (expr.PayloadCsumType) 0,
CsumOffset: (uint32) 0,
CsumFlags: (uint32) 0
}),
(*expr.Bitwise)(0xc0001d0a40)({
SourceRegister: (uint32) 1,
DestRegister: (uint32) 1,
Len: (uint32) 4,
Mask: ([]uint8) (len=4 cap=4) {
00000000ff ff ff 00 |....|
},
Xor: ([]uint8) (len=4 cap=4) {
0000000000 00 00 00 |....|
}
}),
(*expr.Cmp)(0xc0001cd920)({
Op: (expr.CmpOp) 0,
Register: (uint32) 1,
Data: ([]uint8) (len=4 cap=4) {
00000000c0 a8 7c 00 |..|.|
}
}),
(*expr.Bitwise)(0xc0001d0dc0)({
SourceRegister: (uint32) 1,
DestRegister: (uint32) 1,
Len: (uint32) 4,
Mask: ([]uint8) (len=4 cap=4) {
0000000006 00 00 00 |....|
},
Xor: ([]uint8) (len=4 cap=4) {
0000000000 00 00 00 |....|
}
}),
(*expr.Cmp)(0xc0001cdaa0)({
Op: (expr.CmpOp) 1,
Register: (uint32) 1,
Data: ([]uint8) (len=4 cap=4) {
0000000000 00 00 00 |....|
}
}),
(*expr.Counter)(0xc0001c4c10)({
Bytes: (uint64) 125682,
Packets: (uint64) 108
}),
(*expr.Verdict)(0xc0001cdc00)({
Kind: (expr.VerdictKind) 1,
Chain: (string) ""
})
},
UserData: ([]uint8) <nil>
})Is there a way to convert Rule struct to text representation (i.e. the output of nft list chain ip filter FORWARD -a? I did not find an existing method to do so for the Rule.
Metadata
Metadata
Assignees
Labels
No labels
Activity
greenpau commentedon Mar 15, 2020
Relevant issue: sbezverk/nftableslib#56
greenpau commentedon Aug 1, 2020
Here is how to add he above rule in Go: