netns_netlink: Rewrite into new API
cover netns_netlink: Rewrite into new API
Hi,
this is cleanup before needed fix of check_iproute(). More at second commit.
Kind regards,
Petr
Petr Vorel (1):
libclone: Move test.h include to C file
Richard Palethorpe (1):
netns_netlink: Rewrite into new API
.../kernel/containers/libclone/libclone.c | 1 + .../kernel/containers/libclone/libclone.h | 1 - .../kernel/containers/mqns/mqns_helper.h | 2 +- .../kernel/containers/netns/netns_helper.h | 38 ++---- .../kernel/containers/netns/netns_netlink.c | 115 +++++++----------- 5 files changed, 58 insertions(+), 99 deletions(-)
Signature · 1 line
2.30.1
PATCH 1/2 libclone: Move test.h include to C file
so that libclone.h can be used in new API tests.
This requires to include test.sh earlier in mqns_helper.h.
--- testcases/kernel/containers/libclone/libclone.c | 1 + testcases/kernel/containers/libclone/libclone.h | 1 - testcases/kernel/containers/mqns/mqns_helper.h | 2 +- 3 files changed, 2 insertions(+), 2 deletions(-)
testcases/kernel/containers/libclone/libclone.c +1 -0
@@ -15,6 +15,7 @@* ***************************************************************************/ #include "libclone.h" +#include "test.h" int do_clone_tests(unsigned long clone_flags, int (*fn1) (void *arg), void *arg1,
testcases/kernel/containers/libclone/libclone.h +0 -1
@@ -27,7 +27,6 @@#include <sys/syscall.h> #include <signal.h> #include "lapi/syscalls.h" -#include "test.h" #include "lapi/namespaces_constants.h" #define T_UNSHARE 0
testcases/kernel/containers/mqns/mqns_helper.h +1 -1
@@ -21,9 +21,9 @@#include <sys/types.h> #include <mqueue.h> #include "../libclone/libclone.h" +#include "test.h" #include "lapi/syscalls.h" #include "safe_macros.h" -#include "test.h" static int dummy_child (void *v) {
Signature · 1 line
2.30.1
PATCH 1/2 libclone: Move test.h include to C file
Hi!
Quoted 1 line
Signed-off-by Petr Vorel <[email protected]>
This looks obviously OK.
Signature · 2 lines
Cyril Hrubis [email protected]
PATCH 1/2 libclone: Move test.h include to C file
Hi Cyril,
Quoted 6 lines
Hi!
Quoted 1 line
Signed-off-by Petr Vorel <[email protected]>This looks obviously OK.
Reviewed-by Cyril Hrubis <[email protected]>
FYI libclone.h is no longer needed for netns_netlink.c, thus no need to merge it now. I suppose libclone will not be migrated to new API (mqns_helper.h will use SAFE_CLONE() or something else else if needed to be kept), thus not merging.
Kind regards,
Petr
PATCH 2/2 netns_netlink: Rewrite into new API
In reply to Petr VorelFrom: Richard Palethorpe <[email protected]>
This also require to rewrite netns_helper.h.
New test still uses legacy libclone.h.
---
Hi,
check_iproute() is broken since v5.7.0-77-gb687d1067169 (released in v5.8.0), but that will be fixed by introducing C code, which will be used also by helper binary which will be used by shell tests (netns_helper.sh, mc_cmds.sh). Rewriting netns_helper.h first helps avoiding having to support legacy API.
Kind regards,
Petr
.../kernel/containers/netns/netns_helper.h | 38 ++---- .../kernel/containers/netns/netns_netlink.c | 115 +++++++----------- 2 files changed, 56 insertions(+), 97 deletions(-)
testcases/kernel/containers/netns/netns_helper.h +12 -26
@@ -1,32 +1,20 @@ +// SPDX-License-Identifier: GPL-2.0 /* * Copyright (c) International Business Machines Corp., 2008 -* This program is free software; you can redistribute it and/or modify -* it under the terms of the GNU General Public License as published by -* the Free Software Foundation; either version 2 of the License, or -* (at your option) any later version. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See -* the GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program. If not, see <http://www.gnu.org/licenses/>. * * Author: Veerendra C <[email protected]> * * Net namespaces were introduced around 2.6.25. Kernels before that, * assume they are not enabled. Kernels after that, check for -EINVAL * when trying to use CLONE_NEWNET and CLONE_NEWNS. -***************************************************************************/ +*/ #define _GNU_SOURCE -#include <sched.h> #include "config.h" -#include "libclone.h" +#include <sched.h> #include "lapi/syscalls.h" -#include "test.h" -#include "safe_macros.h" +#include "tst_safe_macros.h" +#include "libclone.h" #ifndef CLONE_NEWNS #define CLONE_NEWNS -1
@@ -40,17 +28,15 @@ static void check_iproute(unsigned int spe_ipver) ipf =popen ("ip -V" ,"r" );if (ipf ==NULL ) -tst_brkm (TCONF ,NULL , -"Failed while opening pipe for iproute check" ); +tst_brk (TCONF ,"Failed while opening pipe for iproute check" ); n =fscanf (ipf,"ip utility, iproute2-ss%u" , &ipver);if (n <1 ) { -tst_brkm (TCONF ,NULL , -"Failed while obtaining version for iproute check" ); +tst_brk (TCONF ,"Failed while obtaining version for iproute check" ); }if (ipver < spe_ipver) { -tst_brkm (TCONF ,NULL ,"The commands in iproute tools do " -"not support required objects" ); +tst_brk (TCONF , +"The commands in iproute tools do not support required objects" ); }pclose (ipf);
@@ -67,14 +53,14 @@ static void check_netns(void)int pid, status;/* Checking if the kernel supports unshare with netns capabilities. */ if (CLONE_NEWNS ==-1 ) -tst_brkm (TCONF |TERRNO ,NULL ,"CLONE_NEWNS (%d) not supported" , +tst_brk (TCONF |TERRNO ,"CLONE_NEWNS (%d) not supported" ,CLONE_NEWNS ); pid =do_clone_unshare_test (T_UNSHARE ,CLONE_NEWNET |CLONE_NEWNS , dummy,NULL );if (pid ==-1 ) -tst_brkm (TCONF |TERRNO ,NULL , +tst_brk (TCONF |TERRNO ,"unshare syscall smoke test failed" ); -SAFE_WAIT (NULL , &status); +SAFE_WAIT (&status); }
testcases/kernel/containers/netns/netns_netlink.c +44 -71
173 lines not on this page · raw message
Signature · 1 line
2.30.1
PATCH 2/2 netns_netlink: Rewrite into new API
Hello,
Quoted 1 line · Petr Vorel
From: Richard Palethorpe <[email protected]>
I don't remember this :-)
Quoted 8 lines
This also require to rewrite
netns_helper.h.
New test still uses legacylibclone.h....
testcases/kernel/containers/netns/netns_helper.h +0
-0pclose (ipf);
testcases/kernel/containers/netns/netns_helper.h static void check_netns(void) · line 60
Quoted 9 lines
testcases/kernel/containers/netns/netns_helper.h +1
-1@@ -67,14 +53,14 @@ static void check_netns(void)int pid, status;/* Checking if the kernel supports unshare with netns capabilities. */ if (CLONE_NEWNS ==-1 ) -tst_brkm (TCONF |TERRNO ,NULL ,"CLONE_NEWNS (%d) not supported" , +tst_brk (TCONF |TERRNO ,"CLONE_NEWNS (%d) not supported" ,CLONE_NEWNS ); pid =do_clone_unshare_test (T_UNSHARE ,CLONE_NEWNET |CLONE_NEWNS , dummy,NULL );
I guess you are considering replacing this with something that uses SAFE_CLONE?
This should be quite easy as this function is not cloning with CLONE_VM or anything special. It is just fork() with CLONE_NEWNET | CLONE_NEWNS, so we probably don't need most of the wierdness in libclone.
Signature · 2 lines
Thank you, Richard.
PATCH 2/2 netns_netlink: Rewrite into new API
Hi Richie,
Quoted 7 lines
Hello,
Quoted 1 line · Petr Vorel
From: Richard Palethorpe <[email protected]>
I don't remember this :-)
I'm sorry, that should be me :). I normally does not have problems with git, but this time I messed things up with rebasing.
Quoted 17 lines
Quoted 7 lines
This also require to rewrite
netns_helper.h.
New test still uses legacylibclone.h....
testcases/kernel/containers/netns/netns_helper.h +0
-0pclose (ipf);testcases/kernel/containers/netns/netns_helper.h static void check_netns(void) · line 60
Quoted 9 lines
testcases/kernel/containers/netns/netns_helper.h +1
-1@@ -67,14 +53,14 @@ static void check_netns(void)int pid, status;/* Checking if the kernel supports unshare with netns capabilities. */ if (CLONE_NEWNS ==-1 ) -tst_brkm (TCONF |TERRNO ,NULL ,"CLONE_NEWNS (%d) not supported" , +tst_brk (TCONF |TERRNO ,"CLONE_NEWNS (%d) not supported" ,CLONE_NEWNS ); pid =do_clone_unshare_test (T_UNSHARE ,CLONE_NEWNET |CLONE_NEWNS , dummy,NULL );
Quoted 6 lines
I guess you are considering replacing this with something that uses
SAFE_CLONE?This should be quite easy as this function is not cloning with
CLONE_VMor anything special. It is justfork()withCLONE_NEWNET|CLONE_NEWNS, so we probably don't need most of the wierdness in libclone.
+1, I'd also like to get rid of libclone.
Kind regards,
Petr