svc_create.c: Make sure errors are logged
Subsystems (2)
PATCH 1/1 svc_create.c: Make sure errors are logged
To help debug rpcbind failures, make sure all
errors are logged and log as much info about
the error as possible.
Signed-off-by Steve Dickson <[email protected]>
--- support/nfs/svc_create.c | 12 +++++++----- support/nfs/svc_socket.c | 11 ++++++----- 2 files changed, 13 insertions(+), 10 deletions(-)
support/nfs/svc_create.c +7 -5
@@ -133,7 +133,7 @@ svc_create_bindaddr(struct netconfig *nconf, const uint16_t port) hint.ai_family =AF_INET6 ;#endif /* IPV6_SUPPORTED */ else { -xlog (D_GENERAL ,"Unrecognized bind address family: %s" , +xlog (L_ERROR ,"Unrecognized bind address family: %s" , nconf->nc_protofmly);return NULL ; }
@@ -143,7 +143,7 @@ svc_create_bindaddr(struct netconfig *nconf, const uint16_t port)else if (strcmp (nconf->nc_proto,NC_TCP ) ==0 ) hint.ai_protocol = (int )IPPROTO_TCP ;else { -xlog (D_GENERAL ,"Unrecognized bind address protocol: %s" , +xlog (L_ERROR ,"Unrecognized bind address protocol: %s" , nconf->nc_proto);return NULL ; }
@@ -275,7 +275,7 @@ svc_create_nconf_rand_port(const char *name, const rpcprog_t program, xprt =svc_tli_create (RPC_ANYFD , nconf, &bindaddr,0 ,0 );freeaddrinfo (ai);if (xprt ==NULL ) { -xlog (D_GENERAL ,"Failed to create listener xprt " +xlog (L_ERROR ,"Failed to create listener xprt " "(%s, %u, %s)" , name, version, nconf->nc_netid);return 0 ; }
@@ -286,10 +286,12 @@ svc_create_nconf_rand_port(const char *name, const rpcprog_t program,return 0 ; } + rpc_createerr.cf_stat = rpc_createerr.cf_error.re_errno =0 ;if (!svc_reg (xprt, program, version, dispatch, nconf)) {/* svc_reg(3) destroys @xprt in this case */ -xlog (D_GENERAL ,"Failed to register (%s, %u, %s)" , - name, version, nconf->nc_netid); +xlog (L_ERROR ,"Failed to register (%s, %u, %s): %s" , + name, version, nconf->nc_netid, +clnt_spcreateerror ("svc_reg() err" ));return 0 ; }
support/nfs/svc_socket.c +6 -5
@@ -24,6 +24,7 @@#include <sys/socket.h> #include <sys/fcntl.h> #include <errno.h> +#include "xlog.h" #include "config.h"
@@ -99,9 +100,9 @@ svcsock_nonblock(int sock)* connection. */ if ((flags =fcntl (sock,F_GETFL )) <0 ) -perror (_ ("svc_socket: can't get socket flags" )); +xlog (L_ERROR ,"svc_socket: can't get socket flags: %m" );else if (fcntl (sock,F_SETFL , flags|O_NONBLOCK ) <0 ) -perror (_ ("svc_socket: can't set socket flags" )); +xlog (L_ERROR ,"svc_socket: can't set socket flags: %m" );else return sock;
@@ -119,7 +120,7 @@ svc_socket (u_long number, int type, int protocol, int reuse)if ((sock =__socket (AF_INET , type, protocol)) <0 ) { -perror (_ ("svc_socket: socket creation problem" )); +xlog (L_ERROR ,"svc_socket: socket creation problem: %m" );return sock; }
@@ -130,7 +131,7 @@ svc_socket (u_long number, int type, int protocol, int reuse) sizeof (ret));if (ret <0 ) { -perror (_ ("svc_socket: socket reuse problem" )); +xlog (L_ERROR ,"svc_socket: socket reuse problem: %m" );return ret; } }
@@ -141,7 +142,7 @@ svc_socket (u_long number, int type, int protocol, int reuse)if (bind (sock, (struct sockaddr *) &addr, len) <0 ) { -perror (_ ("svc_socket: bind problem" )); +xlog (L_ERROR ,"svc_socket: bind problem: %m" ); (void )__close (sock); sock =-1 ; }
Signature · 1 line
2.4.3
Quoted 9 lines · Steve Dickson
To help debug rpcbind failures, make sure all
errors are logged and log as much info about
the error as possible.Signed-off-by Steve Dickson <[email protected]>--- support/nfs/svc_create.c | 12 +++++++----- support/nfs/svc_socket.c | 11 ++++++----- 2 files changed, 13 insertions(+), 10 deletions(-)
Committed...
steved
Quoted 99 lines
support/nfs/svc_create.c +7
-5@@ -133,7 +133,7 @@ svc_create_bindaddr(struct netconfig *nconf, const uint16_t port) hint.ai_family =AF_INET6 ;#endif /* IPV6_SUPPORTED */ else { -xlog (D_GENERAL ,"Unrecognized bind address family: %s" , +xlog (L_ERROR ,"Unrecognized bind address family: %s" , nconf->nc_protofmly);return NULL ; }@@ -143,7 +143,7 @@ svc_create_bindaddr(struct netconfig *nconf, const uint16_t port)else if (strcmp (nconf->nc_proto,NC_TCP ) ==0 ) hint.ai_protocol = (int )IPPROTO_TCP ;else { -xlog (D_GENERAL ,"Unrecognized bind address protocol: %s" , +xlog (L_ERROR ,"Unrecognized bind address protocol: %s" , nconf->nc_proto);return NULL ; }@@ -275,7 +275,7 @@ svc_create_nconf_rand_port(const char *name, const rpcprog_t program, xprt =svc_tli_create (RPC_ANYFD , nconf, &bindaddr,0 ,0 );freeaddrinfo (ai);if (xprt ==NULL ) { -xlog (D_GENERAL ,"Failed to create listener xprt " +xlog (L_ERROR ,"Failed to create listener xprt " "(%s, %u, %s)" , name, version, nconf->nc_netid);return 0 ; }@@ -286,10 +286,12 @@ svc_create_nconf_rand_port(const char *name, const rpcprog_t program,return 0 ; } + rpc_createerr.cf_stat = rpc_createerr.cf_error.re_errno =0 ;if (!svc_reg (xprt, program, version, dispatch, nconf)) {/* svc_reg(3) destroys @xprt in this case */ -xlog (D_GENERAL ,"Failed to register (%s, %u, %s)" , - name, version, nconf->nc_netid); +xlog (L_ERROR ,"Failed to register (%s, %u, %s): %s" , + name, version, nconf->nc_netid, +clnt_spcreateerror ("svc_reg() err" ));return 0 ; }support/nfs/svc_socket.c +6
-5@@ -24,6 +24,7 @@#include <sys/socket.h> #include <sys/fcntl.h> #include <errno.h> +#include "xlog.h" #include "config.h" @@ -99,9 +100,9 @@ svcsock_nonblock(int sock)* connection. */ if ((flags =fcntl (sock,F_GETFL )) <0 ) -perror (_ ("svc_socket: can't get socket flags" )); +xlog (L_ERROR ,"svc_socket: can't get socket flags: %m" );else if (fcntl (sock,F_SETFL , flags|O_NONBLOCK ) <0 ) -perror (_ ("svc_socket: can't set socket flags" )); +xlog (L_ERROR ,"svc_socket: can't set socket flags: %m" );else return sock;@@ -119,7 +120,7 @@ svc_socket (u_long number, int type, int protocol, int reuse)if ((sock =__socket (AF_INET , type, protocol)) <0 ) { -perror (_ ("svc_socket: socket creation problem" )); +xlog (L_ERROR ,"svc_socket: socket creation problem: %m" );return sock; }@@ -130,7 +131,7 @@ svc_socket (u_long number, int type, int protocol, int reuse) sizeof (ret));if (ret <0 ) { -perror (_ ("svc_socket: socket reuse problem" )); +xlog (L_ERROR ,"svc_socket: socket reuse problem: %m" );return ret; } }@@ -141,7 +142,7 @@ svc_socket (u_long number, int type, int protocol, int reuse)if (bind (sock, (struct sockaddr *) &addr, len) <0 ) { -perror (_ ("svc_socket: bind problem" )); +xlog (L_ERROR ,"svc_socket: bind problem: %m" ); (void )__close (sock); sock =-1 ; }