Skip to contentSkip to conversation

tests: shell: add testcases for named objects

PATCH In review Harsha Sharma 2 participants 6 messages Oct 5, 2017 – Oct 10, 2017 netfilter

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 tests: shell: add testcases for named objects

Add testcases for creating named objects with unique name, defined by user and referencing them from rule.

---
 tests/shell/testcases/sets/0024named_objects_0 | 41 ++++++++++++++++++++++++++
 1 file changed, 41 insertions(+)
 create mode 100755 tests/shell/testcases/sets/0024named_objects_0
tests/shell/testcases/sets/0024named_objects_0 new file +41 -0
new file mode 100755
index 0000000..de02d65
@@ -0,0 +1,41 @@
+#!/bin/bash
+
+# This is the testscase:
+# * creating valid named objects
+# * referencing them from a valid rule
+
+tmpfile=$(mktemp)
+if [ ! -w $tmpfile ] ; then
+	echo "Failed to create tmp file" >&2
+	exit 0
+fi
+
+trap "rm -rf $tmpfile" EXIT # cleanup if aborted
+
+echo "
+table inet x {
+	counter user123 {
+		packets 12 bytes 1433
+	}
+	quota user123 {
+		over 2000 bytes
+	}
+	quota user124 {
+		over 2000 bytes
+	}
+	set y {
+		type ipv4_addr
+	}
+	map test {
+		type ipv4_addr : quota
+		elements = { 192.168.2.2 : "user124", 192.168.2.3 : "user124"}
+	}
+	chain y {
+		type filter hook input priority 0; policy accept;
+		counter name ip saddr map { 192.168.2.2 : "user123", 1.1.1.1 : "user123", 2.2.2.2 : "user123"}
+		quota name ip saddr map @test drop
+	}
+}" > $tmpfile
+
+set -e
+$NFT -f $tmpfile

--
2.11.0

#1 lore raw
Quoted 2 lines · Harsha Sharma

Add testcases for creating named objects with unique name, defined by user and referencing them from rule.

Also applied, thanks.

Could you add another tests for 'limit' objects too? I think I posted an example to the mailing list.

#2 lore raw
Quoted 8 lines · Pablo Neira Ayuso
Quoted 2 lines · Harsha Sharma

Add testcases for creating named objects with unique name, defined by user and referencing them from rule.

Also applied, thanks.

Could you add another tests for 'limit' objects too? I think I posted an example to the mailing list.

Hello,
I have pulled to latest tree, then make and make installed all changes but still I'm unable to add named 'limit' objects. If there is something that I'm missing, please let me know.
Can you also please suggest some more tasks ?
Thanks in advance.

Regards,
Harsha Sharma

#3 lore raw
Quoted 7 lines · Harsha Sharma
Quoted 6 lines · Pablo Neira Ayuso
Quoted 2 lines · Harsha Sharma

Add testcases for creating named objects with unique name, defined by user and referencing them from rule.

Also applied, thanks.

Quoted 7 lines
Quoted 2 lines

Could you add another tests for 'limit' objects too? I think I posted an example to the mailing list.

Hello,
I have pulled to latest tree, then make and make installed all changes but still I'm unable to add named 'limit' objects. If there is something that I'm missing, please let me know.

Are you using a kernel compiled from nf.git tree?

Quoted 1 line

Can you also please suggest some more tasks ?

Yes. It would be great if you could update tests/py/nft-tests.py to add a new option, basically to take all tests from files, place them in a file and exercise the 'nft -f' path with such an autogenerated large file with all tests.

Would you have a look into that?

Thanks.

#4 lore raw
Quoted 11 lines · Pablo Neira Ayuso
Quoted 10 lines · Harsha Sharma
Quoted 8 lines · Pablo Neira Ayuso
Quoted 2 lines · Harsha Sharma

Add testcases for creating named objects with unique name, defined by user and referencing them from rule.

Also applied, thanks.

Could you add another tests for 'limit' objects too? I think I posted an example to the mailing list.

Quoted 6 lines
Quoted 4 lines

Hello,
I have pulled to latest tree, then make and make installed all changes but still I'm unable to add named 'limit' objects. If there is something that I'm missing, please let me know.

Are you using a kernel compiled from nf.git tree?

No, I was using kernel 4.10 but I have build the kernel 4.14 from nf-git tree now.

Quoted 10 lines
Quoted 2 lines

Can you also please suggest some more tasks ?

Yes. It would be great if you could update tests/py/nft-tests.py to add a new option, basically to take all tests from files, place them in a file and exercise the 'nft -f' path with such an autogenerated large file with all tests.

Would you have a look into that?

Yes, definitely.
Thanks for your time :).

Regards,
Harsha Sharma

Quoted 1 line

Thanks.

#5 lore raw
In reply to Pablo Neira Ayuso
Quoted 18 lines · Pablo Neira Ayuso
Quoted 7 lines · Harsha Sharma
Quoted 6 lines · Pablo Neira Ayuso
Quoted 2 lines · Harsha Sharma

Add testcases for creating named objects with unique name, defined by user and referencing them from rule.

Also applied, thanks.

Quoted 7 lines
Quoted 2 lines

Could you add another tests for 'limit' objects too? I think I posted an example to the mailing list.

Hello,
I have pulled to latest tree, then make and make installed all changes but still I'm unable to add named 'limit' objects. If there is something that I'm missing, please let me know.

Are you using a kernel compiled from nf.git tree?

Quoted 9 lines
Quoted 1 line

Can you also please suggest some more tasks ?

Yes. It would be great if you could update tests/py/nft-tests.py to add a new option, basically to take all tests from files, place them in a file and exercise the 'nft -f' path with such an autogenerated large file with all tests.

Would you have a look into that?

Hi,
I have one doubt, nft-tests.py when executed without any argument or with option -d , already runs all commands in all test files ( don't directly run nft -f path as according to structure of tests in py, for lines starting with '*', table is added and similarly for ':', chain is added and similarly for objects, sets, etc.) so directly exercising 'nft -f' path on autogenerated file containing content of all tests files doesn't make sense. And calling function run_test_file for the large autogenerated file (as is called for each test file) will not make a lot of difference in result
(compared to when executed without any argument) other than not printing total no. of test files executed and total no. of files passed. I hope I'm clear.
Please correct me I'm wrong.
What is exactly that I have to do in this task ?
Thanks a lot for your time.

Regards,
Harsha Sharma

Quoted 1 line

Thanks.