Message ID | 20221205164103.9190-4-kprovost@netgate.com |
---|---|
State | Accepted |
Headers | show |
Series | [Openvpn-devel,1/4] Read DCO traffic stats from the kernel | expand |
Acked-by: Gert Doering <gert@greenie.muc.de> Makes sense & goes hand in hand with kernel change "commit da69782bf06", which has landed in the official tree now. So I've tested this, of course :-) As the change only touches dco_freebsd.c I have only tested this on FreeBSD (but client/server, with/without DCO). Logging is a bit thin there, so I added a msg() to my local tree print out the reason given (just to verify that "yes, it's coming up"). I can see counters and disconnect reason coming out of the kernel - which is very nice - but after a few connect/disconnects the box crashes hard on me. So something is not good there... OTOH, this is a kernel side thing, doesn't stop me from shipping this userland patch. Your patch has been applied to the master and release/2.6 branch. commit 10ea19092ded38ff25a445f987ad948aa9eac49f (master) commit 3186566e6967f0afb31e0426f5ec3490b0a363e9 (release/2.6) Author: Kristof Provost Date: Mon Dec 5 17:41:02 2022 +0100 Read the peer deletion reason from the kernel Signed-off-by: Kristof Provost <kprovost@netgate.com> Acked-by: Gert Doering <gert@greenie.muc.de> Message-Id: <20221205164103.9190-4-kprovost@netgate.com> URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg25617.html Signed-off-by: Gert Doering <gert@greenie.muc.de> -- kind regards, Gert Doering
diff --git a/src/openvpn/dco_freebsd.c b/src/openvpn/dco_freebsd.c index 2ae46589..8d7ceb70 100644 --- a/src/openvpn/dco_freebsd.c +++ b/src/openvpn/dco_freebsd.c @@ -529,6 +529,19 @@ dco_do_read(dco_context_t *dco) { dco->dco_del_peer_reason = OVPN_DEL_PEER_REASON_EXPIRED; + if (nvlist_exists_number(nvl, "del_reason")) + { + uint32_t reason = nvlist_get_number(nvl, "del_reason"); + if (reason == OVPN_DEL_REASON_TIMEOUT) + { + dco->dco_del_peer_reason = OVPN_DEL_PEER_REASON_EXPIRED; + } + else + { + dco->dco_del_peer_reason = OVPN_DEL_PEER_REASON_USERSPACE; + } + } + if (nvlist_exists_nvlist(nvl, "bytes")) { const nvlist_t *bytes = nvlist_get_nvlist(nvl, "bytes"); diff --git a/src/openvpn/ovpn_dco_freebsd.h b/src/openvpn/ovpn_dco_freebsd.h index cc90111e..fec33835 100644 --- a/src/openvpn/ovpn_dco_freebsd.h +++ b/src/openvpn/ovpn_dco_freebsd.h @@ -38,6 +38,11 @@ enum ovpn_notif_type { OVPN_NOTIF_DEL_PEER, }; +enum ovpn_del_reason { + OVPN_DEL_REASON_REQUESTED = 0, + OVPN_DEL_REASON_TIMEOUT = 1 +}; + enum ovpn_key_slot { OVPN_KEY_SLOT_PRIMARY = 0, OVPN_KEY_SLOT_SECONDARY = 1