Skip to contentSkip to conversation

bitwise shift support

PATCH New Jeremy Sowden 1 participant 3 messages Jan 10, 2020 netfilter

lore
Share & tools
lore
#0 lore raw

cover bitwise shift support

The kernel supports bitwise shift operations. This patch-set adds the netlink support.

There is a preliminary patch adding some editor artefacts to .gitignore.

Jeremy Sowden (2):
gitignore: add tag and Emacs back-up files.
bitwise: add support for left and right shifts.

 .gitignore                          |   9 ++
 include/libnftnl/expr.h             |   2 +
 include/linux/netfilter/nf_tables.h |   4 +
 src/expr/bitwise.c                  |  68 ++++++++--
 tests/nft-expr_bitwise-test.c       | 186 +++++++++++++++++++++++++---
 5 files changed, 241 insertions(+), 28 deletions(-)
Signature · 1 line
2.24.1
#1 lore raw

PATCH 1/2 gitignore: add tag and Emacs back-up files.

---
 .gitignore | 9 +++++++++
 1 file changed, 9 insertions(+)
.gitignore +9 -0
index 1650e5853cd0..e62f850fddf6 100644
@@ -29,3 +29,12 @@ examples/*
 tests/*
 !tests/*.c
 !tests/Makefile.am
+
+# Tag files for Vim and Emacs.
+TAGS
+tags
+
+# Emacs back-up files
+*~
+\#*\#
+.\#*
Signature · 1 line
2.24.1
#2 lore raw

PATCH 2/2 bitwise: add support for left and right shifts.

In reply to Jeremy Sowden

Add new attributes to bitwise expressions to implement bit-shifts.

---
 include/libnftnl/expr.h             |   2 +
 include/linux/netfilter/nf_tables.h |   4 +
 src/expr/bitwise.c                  |  52 +++++++-
 tests/nft-expr_bitwise-test.c       | 186 +++++++++++++++++++++++++---
 4 files changed, 225 insertions(+), 19 deletions(-)
include/libnftnl/expr.h +2 -0
index 3e0f5b078c7a..062261a2dc38 100644
@@ -116,6 +116,8 @@ enum {
 	NFTNL_EXPR_BITWISE_LEN,
 	NFTNL_EXPR_BITWISE_MASK,
 	NFTNL_EXPR_BITWISE_XOR,
+	NFTNL_EXPR_BITWISE_LSHIFT,
+	NFTNL_EXPR_BITWISE_RSHIFT,
 };
 
 enum {
include/linux/netfilter/nf_tables.h +4 -0
index e237ecbdcd8a..36cc99407eb6 100644
@@ -492,6 +492,8 @@ enum nft_immediate_attributes {
  * @NFTA_BITWISE_LEN: length of operands (NLA_U32)
  * @NFTA_BITWISE_MASK: mask value (NLA_NESTED: nft_data_attributes)
  * @NFTA_BITWISE_XOR: xor value (NLA_NESTED: nft_data_attributes)
+ * @NFTA_BITWISE_LSHIFT: left shift value (NLA_U32)
+ * @NFTA_BITWISE_RSHIFT: right shift value (NLA_U32)
  *
  * The bitwise expression performs the following operation:
  *
@@ -512,6 +514,8 @@ enum nft_bitwise_attributes {
 	NFTA_BITWISE_LEN,
 	NFTA_BITWISE_MASK,
 	NFTA_BITWISE_XOR,
+	NFTA_BITWISE_LSHIFT,
+	NFTA_BITWISE_RSHIFT,
 	__NFTA_BITWISE_MAX
 };
 #define NFTA_BITWISE_MAX	(__NFTA_BITWISE_MAX - 1)
src/expr/bitwise.c +50 -2

105 lines not on this page · raw message

tests/nft-expr_bitwise-test.c +169 -17

247 lines not on this page · raw message

Signature · 1 line
2.24.1