Commit Graph

20 Commits

Author SHA1 Message Date
Jan Schär 207a46354c
Set rule handle during flush (#299)
This change makes it possible to delete rules after inserting them,
without needing to query the rules first. Additionally, this allows
positioning a new rule next to an existing rule.

There are two ways to refer to a rule: Either by ID or by handle. The ID
is assigned by userspace, and is only valid within a transaction, so it
can only be used before the flush. The handle is assigned by the kernel
when the transaction is committed, and can thus only be used after the
flush. We thus need to set an ID on each newly created rule, and
retrieve the handle of the rule during the flush.

I extended the message struct with a pointer to the Rule which the
message creates. This allows calling the reply handler callback which
sets the handle.

I updated tests to add a handle to generated replies for the
NFT_MSG_NEWRULE messages.
2025-03-26 09:24:33 +01:00
turekt 5e242ec578
List table or chain by name (#258)
Adds functionality to list table or chain by specifying its name
2024-04-14 11:19:27 +02:00
Daniel Mack 8ffcbc2d36 Chain: add 'device' as hook attribute
NETDEV tables can specify a device the apply to.
Add support for this by augmenting the `Chain` struct.
2024-04-01 11:26:10 +02:00
Daniel Mack 4dbe06f125 chain: add ChainHookEgress
NETDEV tables can have egress hooks. Add the definition to enable that case.
2024-04-01 11:26:10 +02:00
singchia 5555df300c
feat: add monitor on table chain rule set setelem and obj events (#250)
fixes https://github.com/google/nftables/issues/224
2023-12-13 08:23:07 +01:00
Andrew LeFevre cbeb0fb1ec
added ability to create regular chains without a hook priority (#183)
See https://wiki.nftables.org/wiki-nftables/index.php/Configuring_chains#Adding_regular_chains
for info on regular chains.

Closes #179.
2022-09-06 17:27:20 +02:00
TheDiveO 1f0380f5c7
list tables and chains optionally by specific table family (#168) 2022-06-07 17:23:05 +02:00
TheDiveO 06687b6e34
use TableFamilyUnspecified (NFPROTO_UNSPEC) instead of AF_UNSPEC (#165) 2022-05-15 23:16:05 +02:00
TheDiveO eeaebcf552
add New constructor (with options functions, such as lasting connection)
* Close receiver for lasting netlink connections while defaulting to existing temporary netlink connection usage
* add unit test for New lasting connection, Close and correct default connection handling behavior
* refactor tests to use New constructor
* make Conn mutex un-exported (#159)

fixes issue #157
2022-05-09 13:25:29 +02:00
turekt 91d3b4571d
Fix for ListChains policy bug (#144)
Fixes https://github.com/google/nftables/issues/130 | Added a test case for ListChains func
2022-02-06 18:44:06 +01:00
Serguei Bezverkhi 14f3137cde protect cc.messages from racing (#75)
Signed-off-by: Serguei Bezverkhi <sbezverk@cisco.com>
2019-11-14 16:22:42 +01:00
Maxime Demode 22243d5c70 [chain] Add FlushChain function. 2019-10-23 14:20:20 +02:00
Maxime Demode 9c2cb3eeea [chain] Make struct and function code change to use *ChainPolicy field. 2019-10-16 11:43:47 +02:00
Maxime Demode 912284322e [chain] Add ChainPolicy type and its possible values. 2019-10-16 11:43:00 +02:00
Serguei Bezverkhi 1435f3a62c Fix non populated Table Family field (#45)
Signed-off-by: Serguei Bezverkhi <sbezverk@cisco.com>
2019-08-12 08:51:06 +02:00
Michael Stapelberg 0b03b9847f chain: add policy attribute 2019-07-20 18:35:32 +02:00
Serguei Bezverkhi d6b2000800 Add func to Delete a chain (#35) 2019-07-11 14:30:38 +02:00
Serguei Bezverkhi 76dc827b18 Add logic for regular chains (#28)
* Add logic for regular chains

Signed-off-by: Serguei Bezverkhi <sbezverk@cisco.com>
2019-06-24 18:00:28 +02:00
jniewt 900c47abbb List chains (#25) 2019-06-19 13:14:23 +02:00
Ryan Whelan 7bac3e3135 Restructure code base into smaller files (#15)
* Restrcture code base into smaller files

* Package level doc string

* Move ExprsFromMsg back from expr sub-module

* gofmt
2019-05-03 23:54:09 +02:00