Recent FreeBSD kernels supply a reason for the OVPN_NOTIF_DEL_PEER
notification. Parse this from the nvlist so we can distinguish
user-requested removals from timeouts.
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>
{
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");
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