netfilter: nft_numgen: add number generator expression
Subsystems (2)
PATCH v5 1/1 netfilter: nft_numgen: add number generator expression
Add support for the number generator expression in netfilter.
Signed-off-by Laura Garcia Liebana <[email protected]>
---
Changes in V5:
- Reorder the functions
- Add attributes checks
- Use switch instead of if statements
include/uapi/linux/netfilter/nf_tables.h | 25 ++++ net/netfilter/Kconfig | 6 + net/netfilter/Makefile | 1 + net/netfilter/nft_numgen.c | 192 +++++++++++++++++++++++++++++++ 4 files changed, 224 insertions(+) create mode 100644 net/netfilter/nft_numgen.c
include/uapi/linux/netfilter/nf_tables.h +25 -0
@@ -1082,4 +1082,29 @@ enum nft_trace_types {__NFT_TRACETYPE_MAX };#define NFT_TRACETYPE_MAX (__NFT_TRACETYPE_MAX - 1) + +/** +* enum nft_ng_attributes - nf_tables number generator expression netlink +* attributes +* +* @NFTA_NG_DREG: destination register (NLA_U32) +* @NFTA_NG_UNTIL: source value to increment the counter until reset (NLA_U32) +* @NFTA_NG_TYPE: operation type (NLA_U32) +*/ +enum nft_ng_attributes { +NFTA_NG_UNSPEC , +NFTA_NG_DREG , +NFTA_NG_UNTIL , +NFTA_NG_TYPE , + __NFTA_NG_MAX +}; +#define NFTA_NG_MAX (__NFTA_NG_MAX - 1) + +enum nft_ng_types { +NFT_NG_INCREMENTAL , +NFT_NG_RANDOM , + __NFT_NG_MAX +}; +#define NFT_NG_MAX (__NFT_NG_MAX - 1) +#endif /* _LINUX_NF_TABLES_H */
net/netfilter/Kconfig +6 -0
@@ -474,6 +474,12 @@ config NFT_META This option adds the "meta" expression that you can use to match and to set packet metainformation such as the packet mark. +config NFT_NUMGEN + tristate "Netfilter nf_tables number generator module" + help + This option adds the number generator expression used to perform + operations like the incremental counter until a reset value or random. + config NFT_CT depends on NF_CONNTRACK tristate "Netfilter nf_tables conntrack module"
net/netfilter/Makefile +1 -0
@@ -80,6 +80,7 @@ obj-$(CONFIG_NF_TABLES_NETDEV) += nf_tables_netdev.o obj-$(CONFIG_NFT_COMPAT) += nft_compat.o obj-$(CONFIG_NFT_EXTHDR) += nft_exthdr.o obj-$(CONFIG_NFT_META) += nft_meta.o +obj-$(CONFIG_NFT_NUMGEN) += nft_numgen.o obj-$(CONFIG_NFT_CT) += nft_ct.o obj-$(CONFIG_NFT_LIMIT) += nft_limit.o obj-$(CONFIG_NFT_NAT) += nft_nat.o
net/netfilter/nft_numgen.c new file +192 -0
192 lines not on this page · raw message
Signature · 1 line
2.8.1
Quoted 1 line · Laura Garcia Liebana
Add support for the number generator expression in netfilter.
Applied, thanks.
I have rewritten the description to something larger. Writing larger description is good for the record, specifically it is good to indicate their purpose.
I have fixed this minor glitch here too.
net/netfilter/nft_numgen.c:43:25: warning: symbol 'nft_ng_policy' was not declared. Should it be static?
Thanks Laura!