tests: shell: flush ruleset with -U after feature probing
Pablo Neira Ayuso
maintainerPATCH 1/1 tests: shell: flush ruleset with -U after feature probing
feature probe script leave a ruleset in place, flush it once probing is complete.
--- tests/shell/run-tests.sh | 3 +++ 1 file changed, 3 insertions(+)
tests/shell/run-tests.sh +3 -0
@@ -602,6 +602,9 @@ for feat in "${_HAVE_OPTS[@]}" ; do val="$(bool_n "${!var}")" fi eval "export $var=$val" + if [ "$NFT_TEST_HAS_UNSHARED" != y ] ; then + $NFT flush ruleset + fi done if [ "$NFT_TEST_JOBS" -eq 0 ] ; then
Signature · 1 line
2.30.2
Florian Westphal
maintainerQuoted 2 lines · Pablo Neira Ayuso
feature probe script leave a ruleset in place, flush it once probing is complete.
Perhaps change feature_probe() to always use 'unshare -n'?
Some scripts also create netdevices.
Quoted 6 lines · Florian Westphal
Quoted 3 lines · Pablo Neira Ayuso
feature probe script leave a ruleset in place, flush it once probing is
complete.Perhaps change
feature_probe()to always use 'unshare -n'?
feature_probe already uses unshare, unless the caller opts out of it. Maybe don't do that.
Quoted 1 line
Some scripts also create netdevices.
Some tests also create netdevices and may not clean them up properly. It's even desirable that tests don't clean them up, because it removes boilerplate from tests. But more importantly: not deleting those devices leaves a certain state after the test, that can be checked by .nft/.json-nft dumps.
The mode without unshare exists for historic reasons, as unshare was added initially. At this point, what is the use of supporting or using that?
Thomas
Pablo Neira Ayuso
maintainerQuoted 9 lines · Thomas Haller
Quoted 6 lines · Florian Westphal
Quoted 3 lines · Pablo Neira Ayuso
feature probe script leave a ruleset in place, flush it once probing is
complete.Perhaps change
feature_probe()to always use 'unshare -n'?
feature_probealready uses unshare, unless the caller opts out of it.
I am opting out with -I as the patch title specifies.
Quoted 9 lines
Maybe don't do that.
Quoted 1 line
Some scripts also create netdevices.
Some tests also create netdevices and may not clean them up properly. It's even desirable that tests don't clean them up, because it removes boilerplate from tests. But more importantly: not deleting those devices leaves a certain state after the test, that can be checked by
.nft/.json-nftdumps.
I see, those were not a problem for me when running -U so far.
Quoted 3 lines
The mode without unshare exists for historic reasons, as unshare was added initially. At this point, what is the use of supporting or using that?
This provides an easy way for me to test 'nft monitor'.
I can keep it out of tree if you prefer -U remains broken.
Florian Westphal
maintainerQuoted 7 lines · Pablo Neira Ayuso
Quoted 3 lines
The mode without unshare exists for historic reasons, as unshare was added initially. At this point, what is the use of supporting or using that?
This provides an easy way for me to test 'nft monitor'.
I can keep it out of tree if you prefer -U remains broken.
No no no, I was just asking if '-U' should still run the feature probes without a netns, which is what its doing right now.
Perhaps -U should just disable the unshare for the actual shell tests, not for the feature probe scripts.
Pablo Neira Ayuso
maintainerQuoted 7 lines · Florian Westphal
Quoted 6 lines · Pablo Neira Ayuso
Quoted 3 lines
The mode without unshare exists for historic reasons, as unshare was added initially. At this point, what is the use of supporting or using that?
This provides an easy way for me to test 'nft monitor'.
Quoted 8 lines
Quoted 1 line
I can keep it out of tree if you prefer -U remains broken.
No no no, I was just asking if '-U' should still run the feature probes without a netns, which is what its doing right now.
Perhaps -U should just disable the unshare for the actual shell tests, not for the feature probe scripts.
Ah, I understand. Fine with me.
Pablo Neira Ayuso
maintainerQuoted 10 lines · Pablo Neira Ayuso
Quoted 9 lines · Florian Westphal
Quoted 7 lines · Pablo Neira Ayuso
Quoted 3 lines
The mode without unshare exists for historic reasons, as unshare was added initially. At this point, what is the use of supporting or using that?
This provides an easy way for me to test 'nft monitor'.
I can keep it out of tree if you prefer -U remains broken.
Quoted 8 lines
Quoted 6 lines
No no no, I was just asking if '-U' should still run the feature probes without a netns, which is what its doing right now.
Perhaps -U should just disable the unshare for the actual shell tests, not for the feature probe scripts.
Ah, I understand. Fine with me.
Maybe this?
tests/shell/run-tests.sh +3 -5
@@ -497,6 +497,7 @@ detect_unshare() { return 1 fi NFT_TEST_UNSHARE_CMD="$1" + NFT_REAL_UNSHARE_CMD="$1" return 0 }
@@ -581,12 +582,12 @@ feature_probe() local with_path="$NFT_TEST_BASEDIR/features/$1" if [ -r "$with_path.nft" ] ; then - $NFT_TEST_UNSHARE_CMD "$NFT_REAL" --check -f "$with_path.nft" &>/dev/null + $NFT_REAL_UNSHARE_CMD "$NFT_REAL" --check -f "$with_path.nft" &>/dev/null return $? fi if [ -x "$with_path.sh" ] ; then - NFT="$NFT_REAL" $NFT_TEST_UNSHARE_CMD "$with_path.sh" &>/dev/null + NFT="$NFT_REAL" $NFT_REAL_UNSHARE_CMD "$with_path.sh" &>/dev/null return $? fi
@@ -602,9 +603,6 @@ for feat in "${_HAVE_OPTS[@]}" ; do val="$(bool_n "${!var}")" fi eval "export $var=$val" - if [ "$NFT_TEST_HAS_UNSHARED" != y ] ; then - $NFT flush ruleset - fi done if [ "$NFT_TEST_JOBS" -eq 0 ] ; then
Florian Westphal
maintainerQuoted 15 lines · Pablo Neira Ayuso
Quoted 14 lines · Pablo Neira Ayuso
Quoted 13 lines · Florian Westphal
Quoted 7 lines · Pablo Neira Ayuso
Quoted 3 lines
The mode without unshare exists for historic reasons, as unshare was added initially. At this point, what is the use of supporting or using that?
This provides an easy way for me to test 'nft monitor'.
I can keep it out of tree if you prefer -U remains broken.
No no no, I was just asking if '-U' should still run the feature probes without a netns, which is what its doing right now.
Quoted 6 lines
Quoted 4 lines
Quoted 2 lines
Perhaps -U should just disable the unshare for the actual shell tests, not for the feature probe scripts.
Ah, I understand. Fine with me.
Maybe this?
Fine with me.
Quoted 18 lines · Florian Westphal
Quoted 17 lines · Pablo Neira Ayuso
Quoted 16 lines · Pablo Neira Ayuso
Quoted 15 lines · Florian Westphal
Quoted 9 lines · Pablo Neira Ayuso
Quoted 5 lines
The mode without unshare exists for historic reasons, as unshare was
added initially. At this point, what is the use of supporting or using
that?This provides an easy way for me to test 'nft monitor'.
I can keep it out of tree if you prefer -U remains broken.
No no no, I was just asking if '-U' should still run the feature probes without a netns, which is what its doing right now.
Quoted 9 lines
Quoted 6 lines
Quoted 4 lines
Quoted 2 lines
Perhaps -U should just disable the unshare for the actual shell tests, not for the feature probe scripts.
Ah, I understand. Fine with me.
Maybe this?
Fine with me.
Running with -U and still use unshare seems a contradiction.
What is the point of "-U" then? I thought, it's to support a kernel where unshare doesn't work.
If the purpose is "easy way [...] to test 'nft monitor'", can you elaborate how you do that? Are there other uses of "-U"?
I think there should be just the proper cleanup after a test/feature- probe. Either by the test/feature-probe themselves, or (better) by "run-test.sh".
Thomas
Quoted 4 lines · Pablo Neira Ayuso
On Wed, Dec 06, 2023 at 07:47:44AM +0100, Thomas Haller wrote:
I can keep it out of tree if you prefer -U remains broken.
IMO the mode definitely should be fixed, as much as possible. Also, I think the patch is fine. Especially if it fixes an obvious issue.
If -U is well supported, then tests and feature-detection should take special care to remove interfaces they create. Maybe they could all use well-known interfaces names (fwtst0, fwtst1, fwtst2). Then run-test.sh and test-wrapper.sh could automatically clean up those interfaces. It doesn't scale to let each test re-implement such cleanup.
Quoted 1 line
This provides an easy way for me to test 'nft monitor'.
OK then.
Thomas
Pablo Neira Ayuso
maintainerQuoted 11 lines · Thomas Haller
Quoted 4 lines · Pablo Neira Ayuso
On Wed, Dec 06, 2023 at 07:47:44AM +0100, Thomas Haller wrote:
I can keep it out of tree if you prefer -U remains broken.
IMO the mode definitely should be fixed, as much as possible. Also, I think the patch is fine. Especially if it fixes an obvious issue.
Quoted 5 lines
If -U is well supported, then tests and feature-detection should take special care to remove interfaces they create. Maybe they could all use well-known interfaces names (fwtst0, fwtst1, fwtst2). Then
run-test.shandtest-wrapper.shcould automatically clean up those interfaces. It doesn't scale to let each test re-implement such cleanup.
I agree with Florian and you that removing toggles is a good idea, but this one is useful for me at this stage, we revisit later on. There is a specific tests infra for the monitor mode but it is rather limited. I can also crash nft monitor with a few scenarios I am looking at to fix it. Maybe -U can go away in the near future and monitor tests can get better coverage.
Quoted 3 lines
Quoted 1 line
This provides an easy way for me to test 'nft monitor'.
OK then.
Thanks!
Pablo Neira Ayuso
maintainerQuoted 5 lines · Florian Westphal
Quoted 2 lines · Pablo Neira Ayuso
feature probe script leave a ruleset in place, flush it once probing is complete.
Perhaps change
feature_probe()to always use 'unshare -n'?
I am currently using this to test 'nft monitor' and make sure it survives a run-tests.sh
Quoted 1 line
Some scripts also create netdevices.
Indeed, they are leaving things in place.