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/+/2041?usp=email

to review the following change.


Change subject: mtcp: make set_global_rw_flags TCP only again
......................................................................

mtcp: make set_global_rw_flags TCP only again

UDP sockets are shared among instances and are already set in
multi_io_wait(), so calling socket_set() on them per instance is
redundant.

On a server with two UDP and one TCP listener this saves about one
epoll_ctl() per received packet (syscalls per received packet
5.75 -> 4.61, UDP only 6.82 -> 5.28) and, at saturation, delivers
about 10% more traffic with UDP only.

Move the function back to mtcp.c as multi_tcp_set_global_rw_flags()
and skip datagram instances.

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



  git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/41/2041/1

diff --git a/src/openvpn/mtcp.c b/src/openvpn/mtcp.c
index c744638..2b5c5b1 100644
--- a/src/openvpn/mtcp.c
+++ b/src/openvpn/mtcp.c
@@ -115,6 +115,18 @@
     multi_io->n_esr = 0;
 }

+void
+multi_tcp_set_global_rw_flags(struct multi_context *m, struct multi_instance 
*mi)
+{
+    if (mi && !proto_is_dgram(mi->context.c2.link_sockets[0]->info.proto))
+    {
+        mi->socket_set_called = true;
+        socket_set(mi->context.c2.link_sockets[0], m->multi_io->es,
+                   mbuf_defined(mi->tcp_link_out_deferred) ? EVENT_WRITE : 
EVENT_READ, &mi->ev_arg,
+                   &mi->tcp_rwflags);
+    }
+}
+
 bool
 multi_tcp_process_outgoing_link_ready(struct multi_context *m, struct 
multi_instance *mi,
                                       const unsigned int mpp_flags)
diff --git a/src/openvpn/mtcp.h b/src/openvpn/mtcp.h
index bb117fa..de9d7ba 100644
--- a/src/openvpn/mtcp.h
+++ b/src/openvpn/mtcp.h
@@ -39,6 +39,8 @@

 void multi_tcp_instance_specific_free(struct multi_instance *mi);

+void multi_tcp_set_global_rw_flags(struct multi_context *m, struct 
multi_instance *mi);
+
 bool multi_tcp_process_outgoing_link(struct multi_context *m, bool defer,
                                      const unsigned int mpp_flags);

diff --git a/src/openvpn/multi_io.c b/src/openvpn/multi_io.c
index bb5dde58..ebee86c 100644
--- a/src/openvpn/multi_io.c
+++ b/src/openvpn/multi_io.c
@@ -122,28 +122,6 @@
 }

 void
-multi_io_set_global_rw_flags(struct multi_context *m, struct multi_instance 
*mi)
-{
-    if (!mi)
-    {
-        return;
-    }
-
-    mi->socket_set_called = true;
-    if (proto_is_dgram(mi->context.c2.link_sockets[0]->info.proto))
-    {
-        socket_set(mi->context.c2.link_sockets[0], m->multi_io->es, EVENT_READ,
-                   &mi->context.c2.link_sockets[0]->ev_arg, NULL);
-    }
-    else
-    {
-        socket_set(mi->context.c2.link_sockets[0], m->multi_io->es,
-                   mbuf_defined(mi->tcp_link_out_deferred) ? EVENT_WRITE : 
EVENT_READ, &mi->ev_arg,
-                   &mi->tcp_rwflags);
-    }
-}
-
-void
 multi_io_free(struct multi_io *multi_io)
 {
     if (multi_io)
@@ -378,7 +356,7 @@

         case TA_INITIAL:
             ASSERT(mi);
-            multi_io_set_global_rw_flags(m, mi);
+            multi_tcp_set_global_rw_flags(m, mi);
             multi_process_post(m, mi, mpp_flags);
             break;

@@ -428,7 +406,7 @@
             }
             else
             {
-                multi_io_set_global_rw_flags(m, mi);
+                multi_tcp_set_global_rw_flags(m, mi);
             }
             break;

diff --git a/src/openvpn/multi_io.h b/src/openvpn/multi_io.h
index d6734bd..4299cba 100644
--- a/src/openvpn/multi_io.h
+++ b/src/openvpn/multi_io.h
@@ -68,8 +68,6 @@

 void multi_io_process_io(struct multi_context *m);

-void multi_io_set_global_rw_flags(struct multi_context *m, struct 
multi_instance *mi);
-
 void multi_io_action(struct multi_context *m, struct multi_instance *mi, int 
action, bool poll);

 void multi_io_delete_event(struct multi_io *multi_io, event_t event);

--
To view, visit https://gerrit.openvpn.net/c/openvpn/+/2041?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: I603585c6bb4e407d0df62f4233ff2c135aa00db0
Gerrit-Change-Number: 2041
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