Attention is currently required from: Arne Schwabe.

Hello Arne Schwabe,

I'd like you to do a code review.
Please visit

    https://gerrit.openvpn.net/c/openvpn/+/2051?usp=email

to review the following change.


Change subject: multi: drop MPP_CLOSE_ON_SIGNAL
......................................................................

multi: drop MPP_CLOSE_ON_SIGNAL

The UDP path, the last user of MPP_CLOSE_ON_SIGNAL, now goes through
multi_io_action(), which closes the signalled instance itself. Without
the flag multi_process_post() always returns true, and the functions
that only passed its result along return a value nobody reads.

Drop the flag and make multi_process_post(), the incoming and timeout
processing functions and the static write functions of multi_io.c
return void. The check of the multi_process_post() result in
multi_create_instance() could never fail and goes away as well.

Change-Id: Ie755169bb32da856e941a214f43fbb243b768d75
Signed-off-by: Gianmarco De Gregori <[email protected]>
---
M src/openvpn/multi.c
M src/openvpn/multi.h
M src/openvpn/multi_io.c
3 files changed, 26 insertions(+), 74 deletions(-)



  git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/51/2051/1

diff --git a/src/openvpn/multi.c b/src/openvpn/multi.c
index b1d7713..868ebc3 100644
--- a/src/openvpn/multi.c
+++ b/src/openvpn/multi.c
@@ -775,11 +775,7 @@
     mi->inotify_watch = -1;
 #endif

-    if (!multi_process_post(m, mi, MPP_PRE_SELECT))
-    {
-        msg(D_MULTI_ERRORS, "MULTI: signal occurred during client instance 
initialization");
-        goto err;
-    }
+    multi_process_post(m, mi, MPP_PRE_SELECT);

     mi->ev_arg.type = EVENT_ARG_MULTI_INSTANCE;
     mi->ev_arg.u.mi = mi;
@@ -3021,14 +3017,10 @@
  * Figure instance-specific timers, convert
  * earliest to absolute time in mi->wakeup,
  * call scheduler with our future wakeup time.
- *
- * Also close context on signal.
  */
-bool
+void
 multi_process_post(struct multi_context *m, struct multi_instance *mi, const 
unsigned int flags)
 {
-    bool ret = true;
-
     if (!IS_SIG(&mi->context)
         && ((flags & MPP_PRE_SELECT)))
     {
@@ -3086,16 +3078,8 @@
         }
     }

-    if (IS_SIG(&mi->context))
-    {
-        if (flags & MPP_CLOSE_ON_SIGNAL)
-        {
-            multi_close_instance_on_signal(m, mi);
-            ret = false;
-        }
-    }
 #ifdef MULTI_DEBUG_EVENT_LOOP
-    else
+    if (!IS_SIG(&mi->context))
     {
         printf("POST %s[%d] to=%d lo=%d/%d w=%" PRIi64 "/%ld\n", id(mi), 
(int)ANY_OUT(&mi->context),
                mi->context.c2.to_tun.len, mi->context.c2.to_link.len,
@@ -3108,8 +3092,6 @@
     {
         *m->mpp_touched = mi;
     }
-
-    return ret;
 }

 /**
@@ -3541,13 +3523,12 @@
  * Process packets in the TCP/UDP socket -> TUN/TAP interface direction,
  * i.e. client -> server direction.
  */
-bool
+void
 multi_process_incoming_link(struct multi_context *m, struct multi_instance 
*instance,
                             const unsigned int mpp_flags, struct link_socket 
*sock)
 {
     struct multi_instance *mi = instance;
     struct context *c;
-    bool ret = true;
     bool floated = false;

     if (!mi)
@@ -3560,7 +3541,7 @@

     if (!mi)
     {
-        return true;
+        return;
     }
     set_prefix(mi);

@@ -3585,22 +3566,18 @@
     }

     /* postprocess and set wakeup */
-    ret = multi_process_post(m, mi, mpp_flags);
+    multi_process_post(m, mi, mpp_flags);

     clear_prefix();
-
-    return ret;
 }

 /*
  * Process packets in the TUN/TAP interface -> TCP/UDP socket direction,
  * i.e. server -> client direction.
  */
-bool
+void
 multi_process_incoming_tun(struct multi_context *m, const unsigned int 
mpp_flags)
 {
-    bool ret = true;
-
     if (BLEN(&m->top.c2.buf) > 0)
     {
         unsigned int mroute_flags;
@@ -3617,7 +3594,7 @@
             vid = vlan_decapsulate(&m->top, &m->top.c2.buf);
             if (vid < 0)
             {
-                return false;
+                return;
             }
         }

@@ -3668,14 +3645,13 @@
                     process_incoming_tun(c, c->c2.link_sockets[0]);

                     /* postprocess and set wakeup */
-                    ret = multi_process_post(m, mi, mpp_flags);
+                    multi_process_post(m, mi, mpp_flags);

                     clear_prefix();
                 }
             }
         }
     }
-    return ret;
 }

 /*
@@ -3718,11 +3694,9 @@
  * Called when an I/O wait times out.  Usually means that a particular
  * client instance object needs timer-based service.
  */
-bool
+void
 multi_process_timeout(struct multi_context *m, const unsigned int mpp_flags)
 {
-    bool ret = true;
-
 #ifdef MULTI_DEBUG_EVENT_LOOP
     printf("%s -> TIMEOUT\n", id(m->earliest_wakeup));
 #endif
@@ -3739,12 +3713,11 @@
         else
         {
             set_prefix(m->earliest_wakeup);
-            ret = multi_process_post(m, m->earliest_wakeup, mpp_flags);
+            multi_process_post(m, m->earliest_wakeup, mpp_flags);
             clear_prefix();
         }
         m->earliest_wakeup = NULL;
     }
-    return ret;
 }

 /*
diff --git a/src/openvpn/multi.h b/src/openvpn/multi.h
index 02841af..103c0334 100644
--- a/src/openvpn/multi.h
+++ b/src/openvpn/multi.h
@@ -282,11 +282,10 @@

 void multi_close_instance(struct multi_context *m, struct multi_instance *mi, 
bool shutdown);

-bool multi_process_timeout(struct multi_context *m, const unsigned int 
mpp_flags);
+void multi_process_timeout(struct multi_context *m, const unsigned int 
mpp_flags);

-#define MPP_PRE_SELECT      (1 << 0)
-#define MPP_CLOSE_ON_SIGNAL (1 << 1)
-#define MPP_RECORD_TOUCH    (1 << 2)
+#define MPP_PRE_SELECT   (1 << 0)
+#define MPP_RECORD_TOUCH (1 << 2)


 /**************************************************************************/
@@ -305,13 +304,8 @@
  * @param mi           - The \c multi_instance of the VPN tunnel to be
  *                       postprocessed.
  * @param flags        - Fast I/O optimization flags.
- *
- * @return
- *  - True, if the VPN tunnel instance \a mi was not closed due to a
- *    signal during processing.
- *  - False, if the VPN tunnel instance \a mi was closed.
  */
-bool multi_process_post(struct multi_context *m, struct multi_instance *mi,
+void multi_process_post(struct multi_context *m, struct multi_instance *mi,
                         const unsigned int flags);

 /**
@@ -345,7 +339,7 @@
  * @param mpp_flags    - Fast I/O optimization flags.
  * @param sock         - Socket where the packet was received.
  */
-bool multi_process_incoming_link(struct multi_context *m, struct 
multi_instance *instance,
+void multi_process_incoming_link(struct multi_context *m, struct 
multi_instance *instance,
                                  const unsigned int mpp_flags, struct 
link_socket *sock);


@@ -364,7 +358,7 @@
  * @param m            - The single \c multi_context structure.
  * @param mpp_flags    - Fast I/O optimization flags.
  */
-bool multi_process_incoming_tun(struct multi_context *m, const unsigned int 
mpp_flags);
+void multi_process_incoming_tun(struct multi_context *m, const unsigned int 
mpp_flags);


 struct multi_instance *multi_get_queue(struct mbuf_set *ms);
diff --git a/src/openvpn/multi_io.c b/src/openvpn/multi_io.c
index 59afb51..31da970 100644
--- a/src/openvpn/multi_io.c
+++ b/src/openvpn/multi_io.c
@@ -253,26 +253,18 @@
  * @param m            - The single \c multi_context structure.
  * @param mi           - The \c multi_instance with the packet to send.
  * @param mpp_flags    - Fast I/O optimization flags.
- *
- * @return
- *  - True, if the \c multi_instance associated with the packet sent was
- *    not closed due to a signal during processing.
- *  - Falls, if the \c multi_instance was closed.
  */
-static bool
+static void
 multi_io_write_tun(struct multi_context *m, struct multi_instance *mi, const 
unsigned int mpp_flags)
 {
-    bool ret = true;
-
 #ifdef MULTI_DEBUG_EVENT_LOOP
     printf("%s -> TUN len=%d\n", id(mi), mi->context.c2.to_tun.len);
 #endif
     set_prefix(mi);
     vlan_process_outgoing_tun(m, mi);
     process_outgoing_tun(&mi->context, mi->context.c2.link_sockets[0]);
-    ret = multi_process_post(m, mi, mpp_flags);
+    multi_process_post(m, mi, mpp_flags);
     clear_prefix();
-    return ret;
 }

 /*
@@ -311,23 +303,20 @@
     return NULL;
 }

-static bool
+static void
 multi_io_send_link(struct multi_context *m, struct multi_instance *mi, const 
unsigned int mpp_flags)
 {
-    bool ret = true;
     set_prefix(mi);
     process_outgoing_link(&mi->context, mi->context.c2.link_sockets[0]);
-    ret = multi_process_post(m, mi, mpp_flags);
+    multi_process_post(m, mi, mpp_flags);
     clear_prefix();
-    return ret;
 }

-static bool
+static void
 multi_io_write_link_deferred(struct multi_context *m, struct multi_instance 
*mi,
                              const unsigned int mpp_flags)
 {
     struct mbuf_item item;
-    bool ret = true;
     ASSERT(mi);

     /* extract from queue */
@@ -337,18 +326,15 @@

         ASSERT(mi == item.instance);
         mi->context.c2.to_link = item.buffer->buf;
-        ret = multi_io_send_link(m, mi, mpp_flags);
+        multi_io_send_link(m, mi, mpp_flags);
         mbuf_free_buf(item.buffer);
     }
-    return ret;
 }

-static bool
+static void
 multi_io_write_link(struct multi_context *m, struct multi_instance *mi, bool 
defer,
                     const unsigned int mpp_flags)
 {
-    bool ret = true;
-
     mi = multi_io_write_link_pre(m, mi);
     if (mi)
     {
@@ -369,16 +355,15 @@
                 mbuf_add_item(mi->tcp_link_out_deferred, &item);
                 mbuf_free_buf(mb);
                 buf_reset(buf);
-                ret = multi_process_post(m, mi, mpp_flags);
+                multi_process_post(m, mi, mpp_flags);
                 clear_prefix();
             }
         }
         else
         {
-            ret = multi_io_send_link(m, mi, mpp_flags);
+            multi_io_send_link(m, mi, mpp_flags);
         }
     }
-    return ret;
 }

 static struct multi_instance *

--
To view, visit https://gerrit.openvpn.net/c/openvpn/+/2051?usp=email
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.openvpn.net/settings?usp=email

Gerrit-MessageType: newchange
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Ie755169bb32da856e941a214f43fbb243b768d75
Gerrit-Change-Number: 2051
Gerrit-PatchSet: 1
Gerrit-Owner: Gianmarco De Gregori <[email protected]>
Gerrit-Reviewer: Arne Schwabe <[email protected]>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: Arne Schwabe <[email protected]>
_______________________________________________
Openvpn-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openvpn-devel

Reply via email to