netfilter: nft_numgen: add number generator expression
Subsystems (2)
PATCH v3 1/1 netfilter: nft_numgen: add number generator expression
Add support for the number generator expression in netfilter.
---
Changes in V3:
- Include random number generation
- Rename nft_nth by nft_numgen
include/uapi/linux/netfilter/nf_tables.h | 25 ++++ net/netfilter/Kconfig | 6 + net/netfilter/Makefile | 1 + net/netfilter/nft_numgen.c | 193 +++++++++++++++++++++++++++++++ 4 files changed, 225 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 +193 -0
193 lines not on this page · raw message
Signature · 1 line
2.8.1
kbuild test robot
build botreproduce:
Hi Laura,
[auto build test ERROR on nf-next/master]
[also build test ERROR on v4.8-rc1 next-20160812]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]
url: https://github.com/0day-ci/linux/commits/Laura-Garcia-Liebana/netfilter-nft_numgen-add-number-generator-expression/20160814-185132 base: https://git.kernel.org/pub/scm/linux/kernel/git/pablo/nf-next.git master config: i386-allyesconfig (attached as .config) compiler: gcc-6 (Debian 6.1.1-9) 6.1.1 20160705 reproduce: # save the attached .config to linux build tree make ARCH=i386
All errors (new ones prefixed by >>):
>> net/netfilter/nft_numgen.o:(.discard+0x0): multiple definition of `__pcpu_unique_nft_prandom_state'
net/netfilter/nft_meta.o:(.discard+0x0): first defined here
---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation
Quoted 14 lines · kbuild test robot
Hi Laura,
[auto build test ERROR on nf-next/master]
[also build test ERROR on v4.8-rc1 next-20160812]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]url: https://github.com/0day-ci/linux/commits/Laura-Garcia-Liebana/netfilter-nft_numgen-add-number-generator-expression/20160814-185132 base: https://git.kernel.org/pub/scm/linux/kernel/git/pablo/nf-next.git master config: i386-allyesconfig (attached as .config) compiler: gcc-6 (Debian 6.1.1-9) 6.1.1 20160705 reproduce: # save the attached .config to linux build tree make ARCH=i386
Quoted 8 lines
All errors (new ones prefixed by >>):
Quoted 1 line
Quoted 1 line
net/netfilter/nft_numgen.o:(.discard+0x0): multiple definition of `__pcpu_unique_nft_prandom_state'
net/netfilter/nft_meta.o:(.discard+0x0): first defined here
---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation
Hi, I've been compiling with several options like:
CONFIG_NFT_META=mCONFIG_NFT_NUMGEN=m
and
CONFIG_NFT_META=yCONFIG_NFT_NUMGEN=y
but I was unable to reproduce it.
Anyway, I'll rename the identifier in a new patch.
Thanks.