Skip to contentSkip to conversation

containers: Use ltp_syscall for setns incase some libc library do not support it

PATCH In review Hangbin Liu 3 participants 5 messages Jul 1, 2015

lore
Share & tools
lore
#0 lore raw

PATCH v3 1/1 containers: Use ltp_syscall for setns incase some libc library do not support it

Use ltp_syscall for setns incase some libc library do not support it. Also check whether we support setns in setup(). If it's support the syscall will silently fails and test continues. If not, then tst_brkm call will end the test with TCONF.

---
 testcases/kernel/containers/userns/userns04.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
testcases/kernel/containers/userns/userns04.c +3 -2
index 7077679..9836fd9 100644
@@ -35,6 +35,7 @@ int TST_TOTAL = 1;
 static void setup(void)
 {
 	check_newuser();
+	ltp_syscall(__NR_setns, -1, 0);
 	tst_tmpdir();
 	TST_CHECKPOINT_INIT(NULL);
 }
@@ -55,7 +56,7 @@ static int child_fn2(void *arg)
 	int exit_val = 0;
 	int ret;
 
-	ret = setns(((long)arg), CLONE_NEWUSER);
+	ret = ltp_syscall(__NR_setns, ((long)arg), CLONE_NEWUSER);
 	if (ret != -1) {
 		printf("child2 setns() unexpected success\n");
 		exit_val = 1;
@@ -112,7 +113,7 @@ static void test_cap_sys_admin(void)
 	case -1:
 		tst_brkm(TBROK | TERRNO, cleanup, "fork");
 	case 0:
-		if (setns(fd, CLONE_NEWUSER) == -1) {
+		if (ltp_syscall(__NR_setns, fd, CLONE_NEWUSER) == -1) {
 			printf("parent pid setns failure: (%d) %s",
 				errno, strerror(errno));
 			exit(1);
Signature · 13 lines
1.9.3


------------------------------------------------------------------------------
Don't Limit Your Business. Reach for the Cloud.
GigeNET's Cloud Solutions provide you with the tools and support that
you need to offload your IT needs and focus on growing your business.
Configured For All Businesses. Start Your Cloud Today.
https://www.gigenetcloud.com/
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list
#1 lore raw

Opps, there is something wrong with code format. I will correct it. Sorry

2015-07-01 14:35 GMT+08:00 Hangbin Liu <[email protected]>:

Quoted 41 lines

Use ltp_syscall for setns incase some libc library do not support it. Also check whether we support setns in setup(). If it's support the syscall will silently fails and test continues. If not, then tst_brkm call will end the test with TCONF.

---
 testcases/kernel/containers/userns/userns04.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
testcases/kernel/containers/userns/userns04.c +3 -3
index 7077679..9836fd9 100644
@@ -35,6 +35,7 @@ int TST_TOTAL = 1;
 static void setup(void)
 {
        check_newuser();
+       ltp_syscall(__NR_setns, -1, 0);
        tst_tmpdir();
        TST_CHECKPOINT_INIT(NULL);
 }
@@ -55,7 +56,7 @@ static int child_fn2(void *arg)
        int exit_val = 0;
        int ret;
 
-       ret = setns(((long)arg), CLONE_NEWUSER);
+       ret = ltp_syscall(__NR_setns, ((long)arg), CLONE_NEWUSER);
        if (ret != -1) {
                printf("child2 setns() unexpected success\n");
                exit_val = 1;
@@ -112,7 +113,7 @@ static void test_cap_sys_admin(void)
        case -1:
                tst_brkm(TBROK | TERRNO, cleanup, "fork");
        case 0:
-               if (setns(fd, CLONE_NEWUSER) == -1) {
+               if (ltp_syscall(__NR_setns, fd, CLONE_NEWUSER) == -1) {
                        printf("parent pid setns failure: (%d) %s",
                                errno, strerror(errno));
                        exit(1);
--
Quoted 2 lines

1.9.3

------------------------------------------------------------------------------
Don't Limit Your Business. Reach for the Cloud.
GigeNET's Cloud Solutions provide you with the tools and support that you need to offload your IT needs and focus on growing your business. Configured For All Businesses. Start Your Cloud Today.
https://www.gigenetcloud.com/
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list

#2 lore raw

2015-07-01 14:39 GMT+08:00 Hangbin Liu <[email protected]>:

Quoted 1 line

Opps, there is something wrong with code format. I will correct it. Sorry

It seem the gmail webside view make the patch a mess. Form mutt the patch format looks good. Please ignore the last mail and continue review this patch.

Sorry for the disturb.

Regards
Hangbin

------------------------------------------------------------------------------
Don't Limit Your Business. Reach for the Cloud.
GigeNET's Cloud Solutions provide you with the tools and support that you need to offload your IT needs and focus on growing your business. Configured For All Businesses. Start Your Cloud Today.
https://www.gigenetcloud.com/
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list

#3 lore raw
In reply to Hangbin Liu

----- Original Message -----

Quoted 6 lines

From: "Hangbin Liu" <[email protected]>
To: "LTP List" <[email protected]>
Cc: "Jan Stancek" <[email protected]>
Sent: Wednesday, 1 July, 2015 8:35:32 AM
Subject: [LTP][PATCHv3] containers: Use ltp_syscall for setns incase some libc library do not support it

Quoted 6 lines

Use ltp_syscall for setns incase some libc library do not support it. Also check whether we support setns in setup(). If it's support the syscall will silently fails and test continues. If not, then tst_brkm call will end the test with TCONF.

Pushed with cosmetic change to commit message.

Thanks,
Jan

Quoted 36 lines
---
 testcases/kernel/containers/userns/userns04.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
testcases/kernel/containers/userns/userns04.c +3 -3
index 7077679..9836fd9 100644
@@ -35,6 +35,7 @@ int TST_TOTAL = 1;
 static void setup(void)
 {
 	check_newuser();
+	ltp_syscall(__NR_setns, -1, 0);
 	tst_tmpdir();
 	TST_CHECKPOINT_INIT(NULL);
 }
@@ -55,7 +56,7 @@ static int child_fn2(void *arg)
 	int exit_val = 0;
 	int ret;
 
-	ret = setns(((long)arg), CLONE_NEWUSER);
+	ret = ltp_syscall(__NR_setns, ((long)arg), CLONE_NEWUSER);
 	if (ret != -1) {
 		printf("child2 setns() unexpected success\n");
 		exit_val = 1;
@@ -112,7 +113,7 @@ static void test_cap_sys_admin(void)
 	case -1:
 		tst_brkm(TBROK | TERRNO, cleanup, "fork");
 	case 0:
-		if (setns(fd, CLONE_NEWUSER) == -1) {
+		if (ltp_syscall(__NR_setns, fd, CLONE_NEWUSER) == -1) {
 			printf("parent pid setns failure: (%d) %s",
 				errno, strerror(errno));
 			exit(1);
--
Quoted 3 lines

1.9.3

------------------------------------------------------------------------------
Don't Limit Your Business. Reach for the Cloud.
GigeNET's Cloud Solutions provide you with the tools and support that you need to offload your IT needs and focus on growing your business. Configured For All Businesses. Start Your Cloud Today.
https://www.gigenetcloud.com/
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list

#4 lore raw

I was not familiar with ltp_syscall and didn't have comment. Thanks you for updating userns04 case.
Regards.
Yuan

Quoted 62 lines · Jan Stancek

----- Original Message -----

Quoted 6 lines

From: "Hangbin Liu" <[email protected]>
To: "LTP List" <[email protected]>
Cc: "Jan Stancek" <[email protected]>
Sent: Wednesday, 1 July, 2015 8:35:32 AM
Subject: [LTP][PATCHv3] containers: Use ltp_syscall for setns incase some libc library do not support it

Quoted 6 lines

Use ltp_syscall for setns incase some libc library do not support it. Also check whether we support setns in setup(). If it's support the syscall will silently fails and test continues. If not, then tst_brkm call will end the test with TCONF.

Pushed with cosmetic change to commit message.

Thanks,
Jan

Quoted 36 lines
---
  testcases/kernel/containers/userns/userns04.c | 5 +++--
  1 file changed, 3 insertions(+), 2 deletions(-)
testcases/kernel/containers/userns/userns04.c +3 -3
index 7077679..9836fd9 100644
@@ -35,6 +35,7 @@ int TST_TOTAL = 1;
  static void setup(void)
  {
  	check_newuser();
+	ltp_syscall(__NR_setns, -1, 0);
  	tst_tmpdir();
  	TST_CHECKPOINT_INIT(NULL);
  }
@@ -55,7 +56,7 @@ static int child_fn2(void *arg)
  	int exit_val = 0;
  	int ret;
 
-	ret = setns(((long)arg), CLONE_NEWUSER);
+	ret = ltp_syscall(__NR_setns, ((long)arg), CLONE_NEWUSER);
  	if (ret != -1) {
  		printf("child2 setns() unexpected success\n");
  		exit_val = 1;
@@ -112,7 +113,7 @@ static void test_cap_sys_admin(void)
  	case -1:
  		tst_brkm(TBROK | TERRNO, cleanup, "fork");
  	case 0:
-		if (setns(fd, CLONE_NEWUSER) == -1) {
+		if (ltp_syscall(__NR_setns, fd, CLONE_NEWUSER) == -1) {
  			printf("parent pid setns failure: (%d) %s",
  				errno, strerror(errno));
  			exit(1);
--
Quoted 3 lines

1.9.3

------------------------------------------------------------------------------
Don't Limit Your Business. Reach for the Cloud.

Quoted 10 lines

GigeNET's Cloud Solutions provide you with the tools and support that you need to offload your IT needs and focus on growing your business. Configured For All Businesses. Start Your Cloud Today.
https://www.gigenetcloud.com/
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list

------------------------------------------------------------------------------
Don't Limit Your Business. Reach for the Cloud.
GigeNET's Cloud Solutions provide you with the tools and support that you need to offload your IT needs and focus on growing your business. Configured For All Businesses. Start Your Cloud Today.
https://www.gigenetcloud.com/
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list