History

netfilter: nf_tables: add quota expression

This patch adds the quota expression. This new stateful expression integrate easily into the dynset expression to build 'hashquota' flow tables. Arguably, we could use instead "counter bytes > 1000" instead, but this approach has several problems: 1) We only support for one single stateful expression in dynamic set definitions, and the expression above is a composite of two expressions: get counter + comparison. 2) We would need to restore the packed counter representation (that we used to have) based on seqlock to synchronize this, since per-cpu is not suitable for this. So instead of bloating the counter expression back with the seqlock representation and extending the existing set infrastructure to make it more complex for the composite described above, let's follow the more simple approach of adding a quota expression that we can plug into our existing infrastructure.

Pablo Neira Ayuso committed 10 years ago

Commit 3d2f30a1 parent 2567c4e4 files · +147 −0Browse files

Showing the changes to include/uapi (1 of 4 files). Show all

Unified · Split

include/uapi/linux/netfilter/nf_tables.h+19−0
@@ -900,6 +900,25 @@ enum nft_queue_attributes { · 899 unmodified lines
900900 #define NFT_QUEUE_FLAG_CPU_FANOUT 0x02 /* use current CPU (no hashing) */
901901 #define NFT_QUEUE_FLAG_MASK 0x03
902902
903+enum nft_quota_flags {
904+ NFT_QUOTA_F_INV = (1 << 0),
905+};
906+
907+/**
908+ * enum nft_quota_attributes - nf_tables quota expression netlink attributes
909+ *
910+ * @NFTA_QUOTA_BYTES: quota in bytes (NLA_U16)
911+ * @NFTA_QUOTA_FLAGS: flags (NLA_U32)
912+ */
913+enum nft_quota_attributes {
914+ NFTA_QUOTA_UNSPEC,
915+ NFTA_QUOTA_BYTES,
916+ NFTA_QUOTA_FLAGS,
917+ NFTA_QUOTA_PAD,
918+ __NFTA_QUOTA_MAX
919+};
920+#define NFTA_QUOTA_MAX (__NFTA_QUOTA_MAX - 1)
921+
903922 /**
904923 * enum nft_reject_types - nf_tables reject expression reject types
905924 *

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t