added SAFE_SOCKETPAIR()
--- include/safe_net_fn.h | 3 +++ include/tst_safe_net.h | 3 +++ lib/safe_net.c | 28 ++++++++++++++++++++++++++++ 3 files changed, 34 insertions(+)
include/safe_net_fn.h +3 -0
@@ -33,6 +33,9 @@ int tst_getsockport(const char *file, const int lineno, int sockfd);int safe_socket (const char *file,const int lineno,void (cleanup_fn )(void ),int domain,int type,int protocol); +int safe_socketpair (const char *file,const int lineno,int domain,int type, +int protocol,int sv[]); +int safe_getsockopt (const char *file,const int lineno,int sockfd,int level,int optname,void *optval,socklen_t *optlen);
include/tst_safe_net.h +3 -0
@@ -32,6 +32,9 @@#define SAFE_SOCKET (domain, type, protocol) \ safe_socket(__FILE__, __LINE__, NULL, domain, type, protocol) +#define SAFE_SOCKETPAIR (domain, type, protocol, sv) \ + safe_socketpair(__FILE__, __LINE__, domain, type, protocol, sv) +#define SAFE_GETSOCKOPT (fd, level, optname, optval, optlen) \ safe_getsockopt(__FILE__, __LINE__, fd, level, optname, optval, optlen)
lib/safe_net.c +28 -0
@@ -132,6 +132,34 @@ int safe_socket(const char *file, const int lineno, void (cleanup_fn)(void),return rval; } +int safe_socketpair (const char *file,const int lineno,int domain,int type, +int protocol,int sv[]) +{ +int rval, ttype; + + rval =socketpair (domain, type, protocol, sv); + +if (rval <0 ) { +switch (errno) { +case EPROTONOSUPPORT : +case ESOCKTNOSUPPORT : +case EOPNOTSUPP : +case EPFNOSUPPORT : +case EAFNOSUPPORT : + ttype =TCONF ; +break ; +default : + ttype =TBROK ; + } + +tst_brkm (ttype |TERRNO ,NULL , +"%s:%d: socketpair(%d, %d, %d, %p) failed" , + file, lineno, domain, type, protocol, sv); + } + +return rval; +} +int safe_getsockopt (const char *file,const int lineno,int sockfd,int level,int optname,void *optval,socklen_t *optlen) {
Signature · 6 lines
2.20.0.rc2.403.gdbc3b29805-goog -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.linux.it/pipermail/ltp/attachments/20181206/712d4e6f/attachment.html>
Petr Vorel
Reviewed-byHi Ramon,
...
Quoted 13 lines
+++
b/lib/safe_net.clib/safe_net.c +9
-0@@ -132,6 +132,34 @@ int safe_socket(const char *file, const int lineno, void (cleanup_fn)(void),return rval; } +int safe_socketpair (const char *file,const int lineno,int domain,int type, +int protocol,int sv[]) +{ +int rval, ttype; + + rval =socketpair (domain, type, protocol, sv); + +if (rval <0 ) { +switch (errno) {
lib/safe_net.c int safe_socket(const char *file, const int lineno, void (cleanup_fn)(void), · line 152
Quoted 10 lines
lib/safe_net.c +10
-0+case EPROTONOSUPPORT : +case ESOCKTNOSUPPORT : +case EOPNOTSUPP : +case EPFNOSUPPORT : +case EAFNOSUPPORT : + ttype =TCONF ; +break ; +default : + ttype =TBROK ; + }
It looks like you copy paste errno's from safe_socket(). While it does not harm to have more errno's, I guess these to never come: ESOCKTNOSUPPORT, EPFNOSUPPORT. They're listed in safe_socket() as man socket(2) says "Other errors may be generated by the underlying protocol modules.", it was needed to ad them.
Otherwise LGTM.
lib/safe_net.c int safe_socket(const char *file, const int lineno, void (cleanup_fn)(void), · line 157
Quoted 4 lines
lib/safe_net.c +4
-0+ +tst_brkm (ttype |TERRNO ,NULL , +"%s:%d: socketpair(%d, %d, %d, %p) failed" , + file, lineno, domain, type, protocol, sv);
...
Kind regards,
Petr
Hi Ramon,
Quoted 29 lines
...
Quoted 13 lines
+++
b/lib/safe_net.clib/safe_net.c +9
-0@@ -132,6 +132,34 @@ int safe_socket(const char *file, const int lineno, void (cleanup_fn)(void),return rval; } +int safe_socketpair (const char *file,const int lineno,int domain,int type, +int protocol,int sv[]) +{ +int rval, ttype; + + rval =socketpair (domain, type, protocol, sv); + +if (rval <0 ) { +switch (errno) {lib/safe_net.c int safe_socket(const char *file, const int lineno, void (cleanup_fn)(void), · line 152
Quoted 10 lines
lib/safe_net.c +10
-0+case EPROTONOSUPPORT : +case ESOCKTNOSUPPORT : +case EOPNOTSUPP : +case EPFNOSUPPORT : +case EAFNOSUPPORT : + ttype =TCONF ; +break ; +default : + ttype =TBROK ; + }It looks like you copy paste errno's from
safe_socket(). While it does not harm to have more errno's, I guess these to never come: ESOCKTNOSUPPORT, EPFNOSUPPORT. They're listed insafe_socket()as man socket(2) says "Other errors may be generated by the underlying protocol modules.", it was needed to ad them.
Quoted 1 line
Otherwise LGTM.
Merged with this change.
Thanks for your work.
Kind regards,
Petr