[v2,2/2] telemetry: add extra log message on socket bind failure

Message ID 20210702125554.606364-2-bruce.richardson@intel.com (mailing list archive)
State Superseded, archived
Delegated to: David Marchand
Headers
Series [v2,1/2] eal: create runtime dir even when shared data is not used |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/github-robot success github build: passed
ci/iol-intel-Functional success Functional Testing PASS
ci/iol-testing fail Testing issues
ci/iol-intel-Performance success Performance Testing PASS
ci/Intel-compilation success Compilation OK
ci/intel-Testing success Testing PASS
ci/iol-abi-testing success Testing PASS

Commit Message

Bruce Richardson July 2, 2021, 12:55 p.m. UTC
  If the library fails to create the needed socket, add an additional
check to report if the error is due to a missing DPDK runtime dir.

Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
---
 lib/telemetry/telemetry.c | 5 +++++
 1 file changed, 5 insertions(+)

--
2.30.2
  

Comments

Morten Brørup July 2, 2021, 2:22 p.m. UTC | #1
> From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Bruce Richardson
> Sent: Friday, 2 July 2021 14.56
> 
> If the library fails to create the needed socket, add an additional
> check to report if the error is due to a missing DPDK runtime dir.
> 
> Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
> ---
>  lib/telemetry/telemetry.c | 5 +++++
>  1 file changed, 5 insertions(+)
> 
> diff --git a/lib/telemetry/telemetry.c b/lib/telemetry/telemetry.c
> index 6baba57ec2..8665db8d03 100644
> --- a/lib/telemetry/telemetry.c
> +++ b/lib/telemetry/telemetry.c
> @@ -7,6 +7,7 @@
>  #include <pthread.h>
>  #include <sys/socket.h>
>  #include <sys/un.h>
> +#include <sys/stat.h>
>  #include <dlfcn.h>
>  #endif /* !RTE_EXEC_ENV_WINDOWS */
> 
> @@ -422,7 +423,11 @@ create_socket(char *path)
>  	strlcpy(sun.sun_path, path, sizeof(sun.sun_path));
>  	unlink(sun.sun_path);
>  	if (bind(sock, (void *) &sun, sizeof(sun)) < 0) {
> +		struct stat st;
> +
>  		TMTY_LOG(ERR, "Error binding socket: %s\n",
> strerror(errno));
> +		if (stat(socket_dir, &st) < 0 || !S_ISDIR(st.st_mode))
> +			TMTY_LOG(ERR, "Cannot access DPDK runtime directory:
> %s\n", socket_dir);
>  		sun.sun_path[0] = 0;
>  		goto error;
>  	}
> --
> 2.30.2
> 
Acked-by: Morten Brørup <mb@smartsharesystems.com>
  
Power, Ciara July 5, 2021, 10:16 a.m. UTC | #2
>-----Original Message-----
>From: Morten Brørup <mb@smartsharesystems.com>
>Sent: Friday 2 July 2021 15:23
>To: Richardson, Bruce <bruce.richardson@intel.com>; dev@dpdk.org
>Cc: Power, Ciara <ciara.power@intel.com>
>Subject: RE: [dpdk-dev] [PATCH v2 2/2] telemetry: add extra log message on
>socket bind failure
>
>> From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Bruce Richardson
>> Sent: Friday, 2 July 2021 14.56
>>
>> If the library fails to create the needed socket, add an additional
>> check to report if the error is due to a missing DPDK runtime dir.
>>
>> Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
>> ---
>>  lib/telemetry/telemetry.c | 5 +++++
>>  1 file changed, 5 insertions(+)
>>
<snip>
>>
>Acked-by: Morten Brørup <mb@smartsharesystems.com>

Acked-by: Ciara Power <ciara.power@intel.com>
  
David Marchand July 5, 2021, 2:11 p.m. UTC | #3
On Fri, Jul 2, 2021 at 2:56 PM Bruce Richardson
<bruce.richardson@intel.com> wrote:
>
> If the library fails to create the needed socket, add an additional
> check to report if the error is due to a missing DPDK runtime dir.
>
> Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>

Reviewed-by: David Marchand <david.marchand@redhat.com>
  

Patch

diff --git a/lib/telemetry/telemetry.c b/lib/telemetry/telemetry.c
index 6baba57ec2..8665db8d03 100644
--- a/lib/telemetry/telemetry.c
+++ b/lib/telemetry/telemetry.c
@@ -7,6 +7,7 @@ 
 #include <pthread.h>
 #include <sys/socket.h>
 #include <sys/un.h>
+#include <sys/stat.h>
 #include <dlfcn.h>
 #endif /* !RTE_EXEC_ENV_WINDOWS */

@@ -422,7 +423,11 @@  create_socket(char *path)
 	strlcpy(sun.sun_path, path, sizeof(sun.sun_path));
 	unlink(sun.sun_path);
 	if (bind(sock, (void *) &sun, sizeof(sun)) < 0) {
+		struct stat st;
+
 		TMTY_LOG(ERR, "Error binding socket: %s\n", strerror(errno));
+		if (stat(socket_dir, &st) < 0 || !S_ISDIR(st.st_mode))
+			TMTY_LOG(ERR, "Cannot access DPDK runtime directory: %s\n", socket_dir);
 		sun.sun_path[0] = 0;
 		goto error;
 	}