rpc: create valid fd to pass libtirpc validation
Subsystems (2)
PATCH v2 1/1 rpc: create valid fd to pass libtirpc validation
From: Liu Jian via ltp <[email protected]>
The testcase(rpc_svc_destroy, rpc_svcfd_create, rpc_xprt_register, rpc_xprt_unregister) was failing due to an invalid fd, which caused libtirpc's internal validation to reject the operation. This change ensures a valid socket fd is created and can pass the validation checks in libtirpc.
---
v2: Fix a compilation error on Alpine.
.../rpc_svc_destroy.c | 27 +++++++++++++++++++ .../rpc_svcfd_create.c | 26 ++++++++++++++++++ .../rpc_xprt_register.c | 25 +++++++++++++++++ .../rpc_xprt_unregister.c | 25 +++++++++++++++++ 4 files changed, 103 insertions(+)
testcases/network/rpc/rpc-tirpc/tests_pack/rpc_suite/rpc/rpc_createdestroy_svc_destroy/rpc_svc_destroy.c +27 -0
@@ -30,6 +30,12 @@#include <time.h> #include <rpc/rpc.h> +#include <unistd.h> +#include <sys/socket.h> +#include <netinet/in.h> +#include <arpa/inet.h> +#include <string.h> +//Standard define #define PROCNUM 1#define VERSNUM 1
@@ -43,6 +49,27 @@ int main(void)int test_status =1 ;//Default test result set to FAILED int fd =0 ;SVCXPRT *svcr =NULL ; +struct sockaddr_in server_addr; + + fd =socket (AF_INET ,SOCK_DGRAM ,0 ); +if (fd <0 ) { +printf ("socket creation failed" ); +return test_status; + } + +memset (&server_addr,0 ,sizeof (server_addr)); + server_addr.sin_family =AF_INET ; + server_addr.sin_port =htons (9001 ); +if (inet_pton (AF_INET ,"127.0.0.1" , &server_addr.sin_addr) <=0 ) { +printf ("inet_pton failed" ); +close (fd); +return test_status; + } +if (connect (fd, (struct sockaddr *)&server_addr,sizeof (server_addr)) <0 ) { +printf ("connect failed" ); +close (fd); +return test_status; + }//First of all, create a server svcr =svcfd_create (fd,0 ,0 );
testcases/network/rpc/rpc-tirpc/tests_pack/rpc_suite/rpc/rpc_createdestroy_svcfd_create/rpc_svcfd_create.c +26 -0
@@ -29,6 +29,11 @@#include <stdlib.h> #include <time.h> #include <rpc/rpc.h> +#include <unistd.h> +#include <sys/socket.h> +#include <netinet/in.h> +#include <arpa/inet.h> +#include <string.h> //Standard define #define PROCNUM 1
@@ -43,6 +48,27 @@ int main(void)int test_status =1 ;//Default test result set to FAILED int fd =0 ;SVCXPRT *svcr =NULL ; +struct sockaddr_in server_addr; + + fd =socket (AF_INET ,SOCK_DGRAM ,0 ); +if (fd <0 ) { +printf ("socket creation failed" ); +return test_status; + } + +memset (&server_addr,0 ,sizeof (server_addr)); + server_addr.sin_family =AF_INET ; + server_addr.sin_port =htons (9001 ); +if (inet_pton (AF_INET ,"127.0.0.1" , &server_addr.sin_addr) <=0 ) { +printf ("inet_pton failed" ); +close (fd); +return test_status; + } +if (connect (fd, (struct sockaddr *)&server_addr,sizeof (server_addr)) <0 ) { +printf ("connect failed" ); +close (fd); +return test_status; + }//create a server svcr =svcfd_create (fd,0 ,0 );
testcases/network/rpc/rpc-tirpc/tests_pack/rpc_suite/rpc/rpc_regunreg_xprt_register/rpc_xprt_register.c +25 -0
@@ -31,6 +31,10 @@#include <rpc/rpc.h> #include <sys/types.h> #include <sys/socket.h> +#include <unistd.h> +#include <netinet/in.h> +#include <arpa/inet.h> +#include <string.h> //Standard define #define PROCNUM 1
@@ -45,6 +49,27 @@ int main(void)int test_status =1 ;//Default test result set to FAILED SVCXPRT *svcr =NULL ;int fd =0 ; +struct sockaddr_in server_addr; + + fd =socket (AF_INET ,SOCK_DGRAM ,0 ); +if (fd <0 ) { +printf ("socket creation failed" ); +return test_status; + } + +memset (&server_addr,0 ,sizeof (server_addr)); + server_addr.sin_family =AF_INET ; + server_addr.sin_port =htons (9001 ); +if (inet_pton (AF_INET ,"127.0.0.1" , &server_addr.sin_addr) <=0 ) { +printf ("inet_pton failed" ); +close (fd); +return test_status; + } +if (connect (fd, (struct sockaddr *)&server_addr,sizeof (server_addr)) <0 ) { +printf ("connect failed" ); +close (fd); +return test_status; + }//create a server svcr =svcfd_create (fd,1024 ,1024 );
testcases/network/rpc/rpc-tirpc/tests_pack/rpc_suite/rpc/rpc_regunreg_xprt_unregister/rpc_xprt_unregister.c +25 -0
@@ -31,6 +31,10 @@#include <rpc/rpc.h> #include <sys/types.h> #include <sys/socket.h> +#include <unistd.h> +#include <netinet/in.h> +#include <arpa/inet.h> +#include <string.h> //Standard define #define PROCNUM 1
@@ -49,6 +53,27 @@ int main(int argn, char *argc[])int test_status =1 ;//Default test result set to FAILED SVCXPRT *svcr =NULL ;int fd =0 ; +struct sockaddr_in server_addr; + + fd =socket (AF_INET ,SOCK_DGRAM ,0 ); +if (fd <0 ) { +printf ("socket creation failed" ); +return test_status; + } + +memset (&server_addr,0 ,sizeof (server_addr)); + server_addr.sin_family =AF_INET ; + server_addr.sin_port =htons (9001 ); +if (inet_pton (AF_INET ,"127.0.0.1" , &server_addr.sin_addr) <=0 ) { +printf ("inet_pton failed" ); +close (fd); +return test_status; + } +if (connect (fd, (struct sockaddr *)&server_addr,sizeof (server_addr)) <0 ) { +printf ("connect failed" ); +close (fd); +return test_status; + }//create a server svcr =svcfd_create (fd,1024 ,1024 );
Signature · 5 lines
2.34.1 -- Mailing list info: https://lists.linux.it/listinfo/ltp
Hi!
Sigh, for some reasons the CI didn't work this time..patchwork seems to be too slow again.
Quoted 8 lines · Liu Jian
From: Liu Jian via ltp <[email protected]>
The
testcase(rpc_svc_destroy, rpc_svcfd_create, rpc_xprt_register, rpc_xprt_unregister)was failing due to an invalid fd, which caused libtirpc's internal validation to reject the operation. This change ensures a valid socket fd is created and can pass the validation checks in libtirpc.
Do you have a practical example why it was failing and where it was failing? And eventually arch, kernel version, etc. It would be nice to have it inside the description.
Signature · 7 lines
Andrea Cervesato SUSE QE Automation Engineer Linux [email protected] -- Mailing list info: https://lists.linux.it/listinfo/ltp
Hi all,
[ Cc Steve and linux-nfs ]
Quoted 5 lines
The
testcase(rpc_svc_destroy, rpc_svcfd_create, rpc_xprt_register, rpc_xprt_unregister)was failing due to an invalid fd, which caused libtirpc's internal validation to reject the operation. This change ensures a valid socket fd is created and can pass the validation checks in libtirpc.
+ I would also like to know more details about the failure (libtirpc version, or do you still use Sun RPC from old glibc, distro, arch, ...).
Because while we have some problems with some of these tests, I'm not sure if connecting to 127.0.0.1 is a valid approach. And if it is, should it be used in more tests? Also rpc_svc_destroy_stress.c and rpc_svcfd_create_limits.c use svcfd_create().
Below are few minor implementation details. First, maybe add a common header, with code in the function which would be used? But it can be done later (RPC test code is really awful, more duplicity will not make it worse).
Quoted 27 lines
Signed-off-by Liu Jian <[email protected]>---
v2: Fix a compilation error on Alpine..../rpc_svc_destroy.c | 27 +++++++++++++++++++ .../rpc_svcfd_create.c | 26 ++++++++++++++++++ .../rpc_xprt_register.c | 25 +++++++++++++++++ .../rpc_xprt_unregister.c | 25 +++++++++++++++++ 4 files changed, 103 insertions(+)testcases/network/rpc/rpc-tirpc/tests_pack/rpc_suite/rpc/rpc_createdestroy_svc_destroy/rpc_svc_destroy.c +6
-0@@ -30,6 +30,12 @@#include <time.h> #include <rpc/rpc.h> +#include <unistd.h> +#include <sys/socket.h> +#include <netinet/in.h> +#include <arpa/inet.h> +#include <string.h> +//Standard define #define PROCNUM 1#define VERSNUM 1
testcases/network/rpc/rpc-tirpc/tests_pack/rpc_suite/rpc/rpc_createdestroy_svc_destroy/rpc_svc_destroy.c int main(void) · line 56
Quoted 8 lines
testcases/network/rpc/rpc-tirpc/tests_pack/rpc_suite/rpc/rpc_createdestroy_svc_destroy/rpc_svc_destroy.c +5
-0@@ -43,6 +49,27 @@ int main(void)int test_status =1 ;//Default test result set to FAILED int fd =0 ;SVCXPRT *svcr =NULL ; +struct sockaddr_in server_addr; + + fd =socket (AF_INET ,SOCK_DGRAM ,0 ); +if (fd <0 ) { +printf ("socket creation failed" );
Maybe fprintf(stderr, ...) or perror()?
testcases/network/rpc/rpc-tirpc/tests_pack/rpc_suite/rpc/rpc_createdestroy_svc_destroy/rpc_svc_destroy.c int main(void) · line 60
Quoted 4 lines
testcases/network/rpc/rpc-tirpc/tests_pack/rpc_suite/rpc/rpc_createdestroy_svc_destroy/rpc_svc_destroy.c +4
-0+return test_status; + } + +memset (&server_addr,0 ,sizeof (server_addr));
Maybe just:
struct sockaddr_in server_addr = {0};
instead of memset() ?
testcases/network/rpc/rpc-tirpc/tests_pack/rpc_suite/rpc/rpc_createdestroy_svc_destroy/rpc_svc_destroy.c int main(void) · line 70
Quoted 10 lines
testcases/network/rpc/rpc-tirpc/tests_pack/rpc_suite/rpc/rpc_createdestroy_svc_destroy/rpc_svc_destroy.c +10
-0+ server_addr.sin_family =AF_INET ; + server_addr.sin_port =htons (9001 ); +if (inet_pton (AF_INET ,"127.0.0.1" , &server_addr.sin_addr) <=0 ) { +printf ("inet_pton failed" ); +close (fd); +return test_status; + } +if (connect (fd, (struct sockaddr *)&server_addr,sizeof (server_addr)) <0 ) { +printf ("connect failed" ); +close (fd);
Funny that all testsuites don't close fd, but not closing single fd is not that problematic.
Kind regards,
Petr
Quoted 135 lines
testcases/network/rpc/rpc-tirpc/tests_pack/rpc_suite/rpc/rpc_createdestroy_svc_destroy/rpc_svc_destroy.c +2
-0+return test_status; + }//First of all, create a server svcr =svcfd_create (fd,0 ,0 );testcases/network/rpc/rpc-tirpc/tests_pack/rpc_suite/rpc/rpc_createdestroy_svcfd_create/rpc_svcfd_create.c +26
-0@@ -29,6 +29,11 @@#include <stdlib.h> #include <time.h> #include <rpc/rpc.h> +#include <unistd.h> +#include <sys/socket.h> +#include <netinet/in.h> +#include <arpa/inet.h> +#include <string.h> //Standard define #define PROCNUM 1@@ -43,6 +48,27 @@ int main(void)int test_status =1 ;//Default test result set to FAILED int fd =0 ;SVCXPRT *svcr =NULL ; +struct sockaddr_in server_addr; + + fd =socket (AF_INET ,SOCK_DGRAM ,0 ); +if (fd <0 ) { +printf ("socket creation failed" ); +return test_status; + } + +memset (&server_addr,0 ,sizeof (server_addr)); + server_addr.sin_family =AF_INET ; + server_addr.sin_port =htons (9001 ); +if (inet_pton (AF_INET ,"127.0.0.1" , &server_addr.sin_addr) <=0 ) { +printf ("inet_pton failed" ); +close (fd); +return test_status; + } +if (connect (fd, (struct sockaddr *)&server_addr,sizeof (server_addr)) <0 ) { +printf ("connect failed" ); +close (fd); +return test_status; + }//create a server svcr =svcfd_create (fd,0 ,0 );testcases/network/rpc/rpc-tirpc/tests_pack/rpc_suite/rpc/rpc_regunreg_xprt_register/rpc_xprt_register.c +25
-0@@ -31,6 +31,10 @@#include <rpc/rpc.h> #include <sys/types.h> #include <sys/socket.h> +#include <unistd.h> +#include <netinet/in.h> +#include <arpa/inet.h> +#include <string.h> //Standard define #define PROCNUM 1@@ -45,6 +49,27 @@ int main(void)int test_status =1 ;//Default test result set to FAILED SVCXPRT *svcr =NULL ;int fd =0 ; +struct sockaddr_in server_addr; + + fd =socket (AF_INET ,SOCK_DGRAM ,0 ); +if (fd <0 ) { +printf ("socket creation failed" ); +return test_status; + } + +memset (&server_addr,0 ,sizeof (server_addr)); + server_addr.sin_family =AF_INET ; + server_addr.sin_port =htons (9001 ); +if (inet_pton (AF_INET ,"127.0.0.1" , &server_addr.sin_addr) <=0 ) { +printf ("inet_pton failed" ); +close (fd); +return test_status; + } +if (connect (fd, (struct sockaddr *)&server_addr,sizeof (server_addr)) <0 ) { +printf ("connect failed" ); +close (fd); +return test_status; + }//create a server svcr =svcfd_create (fd,1024 ,1024 );testcases/network/rpc/rpc-tirpc/tests_pack/rpc_suite/rpc/rpc_regunreg_xprt_unregister/rpc_xprt_unregister.c +25
-0@@ -31,6 +31,10 @@#include <rpc/rpc.h> #include <sys/types.h> #include <sys/socket.h> +#include <unistd.h> +#include <netinet/in.h> +#include <arpa/inet.h> +#include <string.h> //Standard define #define PROCNUM 1@@ -49,6 +53,27 @@ int main(int argn, char *argc[])int test_status =1 ;//Default test result set to FAILED SVCXPRT *svcr =NULL ;int fd =0 ; +struct sockaddr_in server_addr; + + fd =socket (AF_INET ,SOCK_DGRAM ,0 ); +if (fd <0 ) { +printf ("socket creation failed" ); +return test_status; + } + +memset (&server_addr,0 ,sizeof (server_addr)); + server_addr.sin_family =AF_INET ; + server_addr.sin_port =htons (9001 ); +if (inet_pton (AF_INET ,"127.0.0.1" , &server_addr.sin_addr) <=0 ) { +printf ("inet_pton failed" ); +close (fd); +return test_status; + } +if (connect (fd, (struct sockaddr *)&server_addr,sizeof (server_addr)) <0 ) { +printf ("connect failed" ); +close (fd); +return test_status; + }//create a server svcr =svcfd_create (fd,1024 ,1024 );
Quoted 20 lines
-----Original Message-----
From: Petr Vorel [mailto:[email protected]]
Sent: Tuesday, January 13, 2026 8:26 PM
To: liujian (CE) <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; Steve Dickson <[email protected]>
Subject: Re: [LTP] [PATCH v2] rpc: create valid fd to pass libtirpc validationHi all,
[ Cc Steve and linux-nfs ]
Quoted 5 lines
The
testcase(rpc_svc_destroy, rpc_svcfd_create, rpc_xprt_register, rpc_xprt_unregister)was failing due to an invalid fd, which caused libtirpc's internal validation to reject the operation. This change ensures a valid socket fd is created and can pass the validation checks in libtirpc.
Quoted 4 lines
+ I would also like to know more details about the failure (libtirpc
+ version, or
do you still use Sun RPC from old glibc, distro, arch, ...).
tested this on Debian 12 and Debian 10.
I observed that the latest libtirpc (1.3.7) code has the same logic.
svcfd_create
----svc_fd_create(fd, sendsize, recvsize);
--------...
--------getsockname(fd, (struct sockaddr *)(void *)&ss, &slen) < 0)
--------...
--------getpeername(fd, (struct sockaddr *)(void *)&ss, &slen)
--------...
The above is some code flow of svcfd_create() in libtirpc, where both getsockname() and getpeername() require the file descriptor (fd) to be a valid and connected socket.
Additionally, in glibc, there are no similar operations in svcfd_create(), so there is no issue for this test case.
Quoted 5 lines
Because while we have some problems with some of these tests, I'm not sure if connecting to 127.0.0.1 is a valid approach. And if it is, should it be used in more tests? Also
rpc_svc_destroy_stress.candrpc_svcfd_create_limits.cusesvcfd_create().
For a UDP socket, connect() does not trigger any message transmission and should have no other side effects. What do you all think? However, there are no rpc_svcfd_create_limits or rpc_svc_destroy_stress tests in runtest/net.rpc_tests?
Quoted 232 lines
Below are few minor implementation details. First, maybe add a common header, with code in the function which would be used? But it can be done later (RPC test code is really awful, more duplicity will not make it worse).
Quoted 34 lines
Signed-off-by Liu Jian <[email protected]>---
v2: Fix a compilation error on Alpine..../rpc_svc_destroy.c | 27 +++++++++++++++++++ .../rpc_svcfd_create.c | 26 ++++++++++++++++++ .../rpc_xprt_register.c | 25 +++++++++++++++++ .../rpc_xprt_unregister.c | 25 +++++++++++++++++ 4 files changed, 103 insertions(+)diff --git a/testcases/network/rpc/rpc-tirpc/tests_pack/rpc_suite/rpc/rpc_created
estroy_svc_destroy/rpc_svc_destroy.cb/testcases/network/rpc/rpc-tirpc/tests_pack/rpc_suite/rpc/rpc_createdestroy_svc_destroy/rpc_svc_destroy.c
index22e560843..b9240ccba100644
---
a/testcases/network/rpc/rpc-tirpc/tests_pack/rpc_suite/rpc/rpc_createdestroy_svc_destroy/rpc_svc_destroy.c
+++ b/testcases/network/rpc/rpc-tirpc/tests_pack/rpc_suite/rpc/rpc_cre +++atedestroy_svc_destroy/rpc_svc_destroy.ctestcases/network/rpc/rpc-tirpc/tests_pack/rpc_suite/rpc/rpc_createdestroy_svc_destroy/rpc_svc_destroy.c +6
-0@@ -30,6 +30,12 @@#include <time.h> #include <rpc/rpc.h> +#include <unistd.h> +#include <sys/socket.h> +#include <netinet/in.h> +#include <arpa/inet.h> +#include <string.h> +//Standard define #define PROCNUM 1#define VERSNUM 1testcases/network/rpc/rpc-tirpc/tests_pack/rpc_suite/rpc/rpc_createdestroy_svc_destroy/rpc_svc_destroy.c int main(void) · line 56
Quoted 8 lines
testcases/network/rpc/rpc-tirpc/tests_pack/rpc_suite/rpc/rpc_createdestroy_svc_destroy/rpc_svc_destroy.c +5
-0@@ -43,6 +49,27 @@ int main(void)int test_status =1 ;//Default test result set to FAILED int fd =0 ;SVCXPRT *svcr =NULL ; +struct sockaddr_in server_addr; + + fd =socket (AF_INET ,SOCK_DGRAM ,0 ); +if (fd <0 ) { +printf ("socket creation failed" );Maybe
fprintf(stderr, ...)orperror()?testcases/network/rpc/rpc-tirpc/tests_pack/rpc_suite/rpc/rpc_createdestroy_svc_destroy/rpc_svc_destroy.c int main(void) · line 60
Quoted 4 lines
testcases/network/rpc/rpc-tirpc/tests_pack/rpc_suite/rpc/rpc_createdestroy_svc_destroy/rpc_svc_destroy.c +4
-0+return test_status; + } + +memset (&server_addr,0 ,sizeof (server_addr));Maybe just:
structsockaddr_inserver_addr= {0};
instead ofmemset()?testcases/network/rpc/rpc-tirpc/tests_pack/rpc_suite/rpc/rpc_createdestroy_svc_destroy/rpc_svc_destroy.c int main(void)
Quoted 8 lines
testcases/network/rpc/rpc-tirpc/tests_pack/rpc_suite/rpc/rpc_createdestroy_svc_destroy/rpc_svc_destroy.c +8
-0+ server_addr.sin_family =AF_INET ; + server_addr.sin_port =htons (9001 ); +if (inet_pton (AF_INET ,"127.0.0.1" , &server_addr.sin_addr) <=0 ) { +printf ("inet_pton failed" ); +close (fd); +return test_status; + } + if (connect(fd, (struct sockaddr *)&server_addr, sizeof(server_addr))< 0) {
Review int main(void) · line 70
Quoted 2 lines
(quoted diff) +2
-0+ printf("connect failed"); + close(fd);Funny that all testsuites don't close fd, but not closing single fd is not that problematic.
Kind regards,
PetrQuoted 39 lines
testcases/network/rpc/rpc-tirpc/tests_pack/rpc_suite/rpc/rpc_createdestroy_svc_destroy/rpc_svc_destroy.c +2
-0+return test_status; + }//First of all, create a server svcr =svcfd_create (fd,0 ,0 );diff --git a/testcases/network/rpc/rpc-tirpc/tests_pack/rpc_suite/rpc/rpc_created
estroy_svcfd_create/rpc_svcfd_create.cb/testcases/network/rpc/rpc-tirpc/tests_pack/rpc_suite/rpc/rpc_createdestroy_svcfd_create/rpc_svcfd_create.c
indexf0d89ba48..ea4418961100644
---
a/testcases/network/rpc/rpc-tirpc/tests_pack/rpc_suite/rpc/rpc_createdestroy_svcfd_create/rpc_svcfd_create.c
+++ b/testcases/network/rpc/rpc-tirpc/tests_pack/rpc_suite/rpc/rpc_cre +++atedestroy_svcfd_create/rpc_svcfd_create.ctestcases/network/rpc/rpc-tirpc/tests_pack/rpc_suite/rpc/rpc_createdestroy_svcfd_create/rpc_svcfd_create.c +12
-0@@ -29,6 +29,11 @@#include <stdlib.h> #include <time.h> #include <rpc/rpc.h> +#include <unistd.h> +#include <sys/socket.h> +#include <netinet/in.h> +#include <arpa/inet.h> +#include <string.h> //Standard define #define PROCNUM 1@@ -43,6 +48,27 @@ int main(void)int test_status =1 ;//Default test result set to FAILED int fd =0 ;SVCXPRT *svcr =NULL ; +struct sockaddr_in server_addr; + + fd =socket (AF_INET ,SOCK_DGRAM ,0 ); +if (fd <0 ) { +printf ("socket creation failed" ); +return test_status; + }testcases/network/rpc/rpc-tirpc/tests_pack/rpc_suite/rpc/rpc_createdestroy_svcfd_create/rpc_svcfd_create.c int main(void) · line 67
Quoted 10 lines
testcases/network/rpc/rpc-tirpc/tests_pack/rpc_suite/rpc/rpc_createdestroy_svcfd_create/rpc_svcfd_create.c +10
-0+ +memset (&server_addr,0 ,sizeof (server_addr)); + server_addr.sin_family =AF_INET ; + server_addr.sin_port =htons (9001 ); +if (inet_pton (AF_INET ,"127.0.0.1" , &server_addr.sin_addr) <=0 ) { +printf ("inet_pton failed" ); +close (fd); +return test_status; + } + if (connect(fd, (struct sockaddr *)&server_addr, sizeof(server_addr))< 0) {
Quoted 40 lines
testcases/network/rpc/rpc-tirpc/tests_pack/rpc_suite/rpc/rpc_createdestroy_svcfd_create/rpc_svcfd_create.c +4
-0+printf ("connect failed" ); +close (fd); +return test_status; + }//create a server svcr =svcfd_create (fd,0 ,0 );diff --git a/testcases/network/rpc/rpc-tirpc/tests_pack/rpc_suite/rpc/rpc_regunre
g_xprt_register/rpc_xprt_register.cb/testcases/network/rpc/rpc-tirpc/tests_pack/rpc_suite/rpc/rpc_regunreg_xprt_register/rpc_xprt_register.c
indexb10a1ce5e..a40dad7fe100644
---
a/testcases/network/rpc/rpc-tirpc/tests_pack/rpc_suite/rpc/rpc_regunreg_xprt_register/rpc_xprt_register.c
+++ b/testcases/network/rpc/rpc-tirpc/tests_pack/rpc_suite/rpc/rpc_reg +++unreg_xprt_register/rpc_xprt_register.ctestcases/network/rpc/rpc-tirpc/tests_pack/rpc_suite/rpc/rpc_regunreg_xprt_register/rpc_xprt_register.c +11
-0@@ -31,6 +31,10 @@#include <rpc/rpc.h> #include <sys/types.h> #include <sys/socket.h> +#include <unistd.h> +#include <netinet/in.h> +#include <arpa/inet.h> +#include <string.h> //Standard define #define PROCNUM 1@@ -45,6 +49,27 @@ int main(void)int test_status =1 ;//Default test result set to FAILED SVCXPRT *svcr =NULL ;int fd =0 ; +struct sockaddr_in server_addr; + + fd =socket (AF_INET ,SOCK_DGRAM ,0 ); +if (fd <0 ) { +printf ("socket creation failed" ); +return test_status; + }testcases/network/rpc/rpc-tirpc/tests_pack/rpc_suite/rpc/rpc_regunreg_xprt_register/rpc_xprt_register.c int main(void) · line 68
Quoted 10 lines
testcases/network/rpc/rpc-tirpc/tests_pack/rpc_suite/rpc/rpc_regunreg_xprt_register/rpc_xprt_register.c +10
-0+ +memset (&server_addr,0 ,sizeof (server_addr)); + server_addr.sin_family =AF_INET ; + server_addr.sin_port =htons (9001 ); +if (inet_pton (AF_INET ,"127.0.0.1" , &server_addr.sin_addr) <=0 ) { +printf ("inet_pton failed" ); +close (fd); +return test_status; + } + if (connect(fd, (struct sockaddr *)&server_addr, sizeof(server_addr))< 0) {
Quoted 39 lines
testcases/network/rpc/rpc-tirpc/tests_pack/rpc_suite/rpc/rpc_createdestroy_svcfd_create/rpc_svcfd_create.c +4
-0+printf ("connect failed" ); +close (fd); +return test_status; + }//create a server svcr = svcfd_create(fd, 1024, 1024); diff --gita/testcases/network/rpc/rpc-tirpc/tests_pack/rpc_suite/rpc/rpc_regunre
g_xprt_unregister/rpc_xprt_unregister.cb/testcases/network/rpc/rpc-tirpc/tests_pack/rpc_suite/rpc/rpc_regunreg_xprt_unregister/rpc_xprt_unregister.c
index3b6130eaa..5ac51de41100644
---
a/testcases/network/rpc/rpc-tirpc/tests_pack/rpc_suite/rpc/rpc_regunreg_xprt_unregister/rpc_xprt_unregister.c
+++ b/testcases/network/rpc/rpc-tirpc/tests_pack/rpc_suite/rpc/rpc_reg +++unreg_xprt_unregister/rpc_xprt_unregister.ctestcases/network/rpc/rpc-tirpc/tests_pack/rpc_suite/rpc/rpc_regunreg_xprt_register/rpc_xprt_register.c +11
-0@@ -31,6 +31,10 @@#include <rpc/rpc.h> #include <sys/types.h> #include <sys/socket.h> +#include <unistd.h> +#include <netinet/in.h> +#include <arpa/inet.h> +#include <string.h> //Standard define #define PROCNUM 1@@ -49,6 +53,27 @@ int main(int argn, char *argc[])int test_status =1 ;//Default test result set to FAILED SVCXPRT *svcr =NULL ;int fd =0 ; +struct sockaddr_in server_addr; + + fd =socket (AF_INET ,SOCK_DGRAM ,0 ); +if (fd <0 ) { +printf ("socket creation failed" ); +return test_status; + }testcases/network/rpc/rpc-tirpc/tests_pack/rpc_suite/rpc/rpc_regunreg_xprt_register/rpc_xprt_register.c int main(int argn, char *argc[]) · line 72
Quoted 10 lines
testcases/network/rpc/rpc-tirpc/tests_pack/rpc_suite/rpc/rpc_regunreg_xprt_register/rpc_xprt_register.c +10
-0+ +memset (&server_addr,0 ,sizeof (server_addr)); + server_addr.sin_family =AF_INET ; + server_addr.sin_port =htons (9001 ); +if (inet_pton (AF_INET ,"127.0.0.1" , &server_addr.sin_addr) <=0 ) { +printf ("inet_pton failed" ); +close (fd); +return test_status; + } + if (connect(fd, (struct sockaddr *)&server_addr, sizeof(server_addr))< 0) {
Quoted 7 lines
testcases/network/rpc/rpc-tirpc/tests_pack/rpc_suite/rpc/rpc_regunreg_xprt_register/rpc_xprt_register.c +4
-0+printf ("connect failed" ); +close (fd); +return test_status; + }//create a server svcr =svcfd_create (fd,1024 ,1024 );