Permalink
Browse files

Handle OpenVPN bug: busy loop with high transfer on mgmt_rwrite when …

…disconnect underlying conn
  • Loading branch information...
hypatia2 committed Apr 18, 2016
1 parent 17916cc commit 275e39f9e4f49f3bb6d586a9df05d386b5af6a26
Showing with 22 additions and 0 deletions.
  1. +18 −0 fruhod/main.tcl
  2. +4 −0 fruhod/model.tcl
@@ -97,6 +97,24 @@ proc daemon-model-report {} {
}
proc cyclic-daemon-model-report {} {
# report interval in ms
set interval 400
# fix openvpn bug: when disconnecting underlying connection (tested with wi-fi) openvpn enters busy loop, consumes 100% CPU, and shows high rrwrite transfer on tun0
# detect the incident = bug manifestation
# mgmt_rread is constant and mgmt_rwrite is growing fast (at least 10MB/s)
if {$::model::Prev_mgmt_rwrite > 0 && ($::model::mgmt_rwrite - $::model::Prev_mgmt_rwrite)/$interval > 10000 && $::model::Prev_mgmt_rread == $::model::mgmt_rread} {
log "Detected OpenVPN bug: busy loop with high transfer on mgmt_rwrite. Killing OpenVPN."
log "mgmt_rread: $::model::mgmt_rread"
log "mgmt_rwrite: $::model::mgmt_rwrite"
log "mgmt_vread: $::model::mgmt_vread"
log "mgmt_vwrite: $::model::mgmt_vwrite"
kill-ovpn-by-saved-pid
OvpnExit 0
}
set ::model::Prev_mgmt_rwrite $::model::mgmt_rwrite
set ::model::Prev_mgmt_rread $::model::mgmt_rread
daemon-model-report
after 400 cyclic-daemon-model-report
}
@@ -42,8 +42,10 @@ namespace eval ::model {
variable mgmt_vwrite 0
# TCP/UDP read bytes
variable mgmt_rread 0
variable Prev_mgmt_rread 0
# TCP/UDP write bytes
variable mgmt_rwrite 0
variable Prev_mgmt_rwrite 0
# connection state from mgmt console: AUTH,GET_CONFIG,ASSIGN_IP,CONNECTED
# model::mgmt_connstatus may store stale value - it is valid only when ovpn_pid is not zero
variable mgmt_connstatus ""
@@ -81,7 +83,9 @@ proc ::model::reset-ovpn-state {} {
set ::model::mgmt_vread 0
set ::model::mgmt_vwrite 0
set ::model::mgmt_rread 0
set ::model::Prev_mgmt_rread 0
set ::model::mgmt_rwrite 0
set ::model::Prev_mgmt_rwrite 0
set ::model::mgmt_connstatus ""
set ::model::mgmt_vip ""
set ::model::mgmt_rip ""

0 comments on commit 275e39f

Please sign in to comment.