c->c2.dco_read_bytes = stats.TransportBytesReceived;
c->c2.dco_write_bytes = stats.TransportBytesSent;
+ c->c2.tun_read_bytes = stats.TunBytesReceived;
+ c->c2.tun_write_bytes = stats.TunBytesSent;
return 0;
}
/*
* Should we exit due to inactivity timeout?
+ *
+ * In the non-dco case, the timeout is reset via register_activity()
+ * whenever there is sufficient activity on tun or link, so this function
+ * is only ever called to raise the TERM signal.
+ *
+ * With DCO, OpenVPN does not see incoming or outgoing data packets anymore
+ * and the logic needs to change - we permit the event to trigger and check
+ * kernel DCO counters here, returning and rearming the timer if there was
+ * sufficient traffic.
*/
static void
check_inactivity_timeout(struct context *c)
{
+ if (dco_enabled(&c->options) && dco_get_peer_stats(c) == 0)
+ {
+ int64_t tot_bytes = c->c2.tun_read_bytes + c->c2.tun_write_bytes;
+ int64_t new_bytes = tot_bytes - c->c2.inactivity_bytes;
+
+ if (new_bytes >= c->options.inactivity_minimum_bytes)
+ {
+ c->c2.inactivity_bytes = tot_bytes;
+ event_timeout_reset(&c->c2.inactivity_interval);
+
+ return;
+ }
+ }
+
msg(M_INFO, "Inactivity timeout (--inactive), exiting");
register_signal(c->sig, SIGTERM, "inactive");
}