better alien packet handling
authorMazet Laurent <laurent.mazet@thalesgroup.com>
Thu, 12 Jun 2025 13:48:13 +0000 (15:48 +0200)
committerMazet Laurent <laurent.mazet@thalesgroup.com>
Thu, 12 Jun 2025 13:48:13 +0000 (15:48 +0200)
ulvpn.c

diff --git a/ulvpn.c b/ulvpn.c
index efb1e5ad28e4a91b4ea319d61431896afe145bae..f6ca9e37081322c03d80f06002a4c07da9048838 100644 (file)
--- a/ulvpn.c
+++ b/ulvpn.c
@@ -344,11 +344,10 @@ int main (int argc, char **argv)
     signal(SIGTERM, sig_handler);
 
     /* main loop */
-    int rc;
+    int rc = 0;
     int seqrx = -1;
     int seqtx = -1;
     while (!stop) {
-        rc = 2;
 
         fd_set readset;
         int max_fd = 0;
@@ -374,6 +373,7 @@ int main (int argc, char **argv)
         if (-1 == select (max_fd + 1, &readset, NULL, NULL, NULL)) {
             if (!stop) {
                 VERBOSE (ulvpn, ERROR, PRINTF ("select error\n"));
+                rc = 2;
             }
             break;
         }
@@ -445,6 +445,9 @@ int main (int argc, char **argv)
             uint8_t msgtype = -1;
             int rxlen = 0;
             seqrx = MOREP_Receive (rxblack_fd, &msgtype, buffer, &rxlen);
+            if (seqrx == -2) {
+                continue;
+            }
 
             if (rxlen <= 0) {
                 VERBOSE (ulvpn, WARNING, PRINTF ("error when receiving from CM black\n"));
@@ -481,6 +484,9 @@ int main (int argc, char **argv)
             uint8_t msgtype = -1;
             int rxlen = 0;
             seqrx = MOREP_Receive (rxred_fd, &msgtype, buffer, &rxlen);
+            if (seqrx == -2) {
+                continue;
+            }
 
             if (rxlen <= 0) {
                 VERBOSE (ulvpn, WARNING, PRINTF ("error when receiving from CM bred\n"));
@@ -514,7 +520,6 @@ int main (int argc, char **argv)
 
         }
 
-        rc = 0;
     }
 
     /* cleaning */