[PATCH] irmd, ipcp: Remove socket option in acceptloop

  • From: Dimitri Staessens <dimitri@ouroboros.rocks>
  • To: ouroboros@xxxxxxxxxxxxx
  • Date: Sat, 26 Feb 2022 14:49:46 +0100

We cancel the thread, so the SO_RCVTIMEO is not needed anymore (it
dated from when we checked the state every so often.

The address sanitizer is complaining about the the cleanup handlers in
the acceptloops after the thread gets cancelled in the read(). I've
tried to resolve it, but no avail. Pretty convinced it's a
false-positive, so ASan will ignore these functions for now.

Signed-off-by: Dimitri Staessens <dimitri@ouroboros.rocks>
---
 src/ipcpd/ipcp.c |  7 +------
 src/irmd/main.c  | 10 ++--------
 2 files changed, 3 insertions(+), 14 deletions(-)

diff --git a/src/ipcpd/ipcp.c b/src/ipcpd/ipcp.c
index 12caac17..d19d8e43 100644
--- a/src/ipcpd/ipcp.c
+++ b/src/ipcpd/ipcp.c
@@ -204,11 +204,10 @@ static struct rib_ops r_ops = {
         .getattr = ipcp_rib_getattr
 };
 
+__attribute__((no_sanitize_address))
 static void * acceptloop(void * o)
 {
         int            csockfd;
-        struct timeval tv = {(SOCKET_TIMEOUT / 1000),
-                             (SOCKET_TIMEOUT % 1000) * 1000};
 
         (void) o;
 
@@ -220,10 +219,6 @@ static void * acceptloop(void * o)
                 if (csockfd < 0)
                         continue;
 
-                if (setsockopt(csockfd, SOL_SOCKET, SO_RCVTIMEO,
-                               (void *) &tv, sizeof(tv)))
-                        log_warn("Failed to set timeout on socket.");
-
                 cmd = malloc(sizeof(*cmd));
                 if (cmd == NULL) {
                         log_err("Out of memory");
diff --git a/src/irmd/main.c b/src/irmd/main.c
index a3acc78a..5923286b 100644
--- a/src/irmd/main.c
+++ b/src/irmd/main.c
@@ -70,7 +70,6 @@
 #define IRMD_CLEANUP_TIMER ((IRMD_FLOW_TIMEOUT / 20) * MILLION) /* ns */
 #define SHM_SAN_HOLDOFF    1000 /* ms */
 #define IPCP_HASH_LEN(e)   hash_len(e->dir_hash_algo)
-#define IB_LEN             SOCK_BUF_SIZE
 #define BIND_TIMEOUT       10   /* ms */
 #define DEALLOC_TIME       300  /*  s */
 
@@ -102,7 +101,7 @@ enum irm_state {
 struct cmd {
         struct list_head next;
 
-        uint8_t          cbuf[IB_LEN];
+        uint8_t          cbuf[SOCK_BUF_SIZE];
         size_t           len;
         int              fd;
 };
@@ -1970,11 +1969,10 @@ void * irm_sanitize(void * o)
         }
 }
 
+__attribute__((no_sanitize_address))
 static void * acceptloop(void * o)
 {
         int            csockfd;
-        struct timeval tv = {(SOCKET_TIMEOUT / 1000),
-                             (SOCKET_TIMEOUT % 1000) * 1000};
 
         (void) o;
 
@@ -1985,10 +1983,6 @@ static void * acceptloop(void * o)
                 if (csockfd < 0)
                         continue;
 
-                if (setsockopt(csockfd, SOL_SOCKET, SO_RCVTIMEO,
-                               (void *) &tv, sizeof(tv)))
-                        log_warn("Failed to set timeout on socket.");
-
                 cmd = malloc(sizeof(*cmd));
                 if (cmd == NULL) {
                         log_err("Out of memory.");
-- 
2.35.1


Other related posts:

  • » [PATCH] irmd, ipcp: Remove socket option in acceptloop - Dimitri Staessens