20 Commits
Author SHA1 Message Date
wiegratz 9f109c51e4 fix(stmt): fix named counter
BREAKING CHANGE: Use new enum variants of `Counter`: `Named` and `Anonymous`.
2024-10-06 18:14:32 +02:00
wiegratz 51ccf106da fix: store NfListObjects in heap
BREAKING CHANGE: With enum `NfObject::ListObject`, use `Box::new(NfListObject...)`.
2024-10-06 16:52:49 +02:00
wiegratz c20bcee69d fix race condition in tests
cargo runs tests in parallel.
tests that work on real nftables may be conflicting.
the serial crate is used to mark tests to be run serially.
2024-03-16 15:45:14 +00:00
wiegratz ea5ad7b54d add helper tests and setup
adds a flush command to the top of the example ruleset so that nftables rules are applied on a clean state.
adds tests that check args passing to nft with get_current_ruleset and specifying invalid nft binary.
2024-03-16 15:07:50 +00:00
wiegratz bab0641187 Merge branch 'payload' 2024-03-16 14:59:48 +00:00
wiegratz 6ca00192b3 Run nft tests in netns
Tests that use nft command alter the system's
nftables. By creating a fresh net namespace for
each run, tests will not break system networking.
2024-03-15 23:57:54 +00:00
Paul Holzinger 0deaf7d864 fix payload raw expression
The current code cannot handle the ParloadRaw type, serde is unable to
deserialize the json with a raw payload fields.

This is because serde cannot handle two fields with the same name and I
haven't found a way to make this work like that. Instead we have to use
a untagged enum that share both possible payload values.

Therefore this is an API break: NamedExpression now only contains one
Payload field which contains the Payload enum, the old Payload type is
renamed to PayloadField.

Lastly, export the PayloadRaw fields so they can be used externally.

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2024-03-11 16:35:25 +01:00
wiegratz fd2bd09ad1 chore: fix clippy warnings 2024-01-22 11:56:31 +01:00
wiegratz 04e29d85e8 Merge branch 'add_missing_things' 2024-01-22 11:36:00 +01:00
Marcin Osypka 3c87c233e9 Add the comment field to a map
The comments can be added to the map.
2024-01-18 18:50:51 +01:00
Marcin Osypka 8a31a720a7 Add comment field to set
The comment field on a set is not present in documentation but it is
working and sometimes convenient to use.
2024-01-18 18:48:35 +01:00
Marcin Osypka d1ac323bf9 Implement map support
A Verdict enum was moved from a NamedExpression to an Expression,
placing it in a NamedExpression was a bug. Accroding to
libnftables-json(5) (section VERDICT) a Verdict does not have a
"verdict" key, it is "anonymous". e.g.: { "jump": { "target":
"my_target"}, and not: { "verdict": { "jump": { "target": "my_target"} }
}

Additionally a `Verdict::Jump` and a `Verdict::Goto` data was changed to
a `stmt::JumpTarget` struct from a `String`.

A `Map` and a `Set` use almost the same fields, a map additinally uses a
map field of type `String`.
2024-01-17 19:40:23 +01:00
wiegratz 1bd71ea992 tests: test for error when deleting unknown table 2023-08-12 18:07:27 +02:00
bits0rcerer fd01cfe50d return error instead of panic 2023-08-11 10:54:06 +02:00
Noel 4f427820a7 Fix queue JSON serialisation when flag is none 2023-07-07 14:01:56 +02:00
Noel d08001ffb8 Update queue flags to be optional 2023-07-07 12:00:46 +02:00
wiegratz 720d2c75db schema: implement set type, add test for set 2023-03-19 23:38:56 +00:00
Thomas Spellman eeda434ac9 change insert to match add
This change adds the necessary {"rule": ...} json object, similar to how the add command works.
2022-12-15 21:34:43 -08:00
Thomas Spellman 0c80cf4832 Fix test imports 2022-12-15 21:32:21 -08:00
wiegratz e331c6f8ad lib: first commit 2022-09-30 17:32:07 +00:00