Skip to contentSkip to conversation

tests: shell: fetch rule handle with '-a' option and then delete

PATCH Superseded Harsha Sharma 2 participants 2 messages Jan 23, 2018 netfilter

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 tests: shell: fetch rule handle with '-a' option and then delete

Fetch rule handle and then delete rule via that rule handle.

---
 tests/shell/testcases/cache/0001_cache_handling_0 | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
tests/shell/testcases/cache/0001_cache_handling_0 +2 -1
index 9a73769..2bcb8c5 100755
@@ -24,6 +24,7 @@ table inet test {
 set -e
 
 $NFT -f $tmpfile
-$NFT delete rule inet test test handle 2
+rule_handle=$($NFT list ruleset -a | grep "saddr" | awk '{print $NF}')
+$NFT delete rule inet test test handle $rule_handle
 $NFT delete set inet test test
 $NFT -f $tmpfile
Signature · 1 line
2.11.0
#1 lore raw
Quoted 12 lines · Harsha Sharma

Fetch rule handle and then delete rule via that rule handle.

---
 tests/shell/testcases/cache/0001_cache_handling_0 | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
tests/shell/testcases/cache/0001_cache_handling_0 +0 -0
index 9a73769..2bcb8c5 100755

tests/shell/testcases/cache/0001_cache_handling_0 table inet test { · line 28

Quoted 6 lines
tests/shell/testcases/cache/0001_cache_handling_0 +2 -1
@@ -24,6 +24,7 @@ table inet test {
 set -e
 
 $NFT -f $tmpfile
-$NFT delete rule inet test test handle 2
+rule_handle=$($NFT list ruleset -a | grep "saddr" | awk '{print $NF}')
+$NFT delete rule inet test test handle $rule_handle

No need to use both grep and awk in the same pipeline.

If you prefer awk, then
awk '/saddr/ {print $NF}'
would do the same thing.

Signature · 1 line
ldv