Skip to contentSkip to conversation

netfilter: nft_numgen: add number generator expression

PATCH Superseded Laura Garcia Liebana 2 participants 3 messages Aug 14, 2016 – Aug 17, 2016

Subsystems (2)

v3 of 5 Superseded Latest is v5 →

lore
Share & tools
lore
#0 lore raw

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
index c674ba2..38fd1ef 100644
@@ -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
index 9266cee..31def7d 100644
@@ -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
index 6913454..81f22c3 100644
@@ -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
#1 lore raw
reproduce:

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

#2 lore raw
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=m
CONFIG_NFT_NUMGEN=m

and

CONFIG_NFT_META=y
CONFIG_NFT_NUMGEN=y

but I was unable to reproduce it.

Anyway, I'll rename the identifier in a new patch.

Thanks.