struct sockaddr *remoteaddr = &ls->info.lsa->actual.dest.addr.sa;
struct tls_multi *multi = c->c2.tls_multi;
+#ifdef TARGET_FREEBSD
+ /* In Linux in P2P mode the kernel automatically removes an existing peer
+ * when adding a new peer. FreeBSD needs to explicitly be told to do that */
+ if (c->c2.tls_multi->dco_peer_id != -1)
+ {
+ dco_del_peer(&c->c1.tuntap->dco, c->c2.tls_multi->dco_peer_id);
+ c->c2.tls_multi->dco_peer_id = -1;
+ }
+#endif
int ret = dco_new_peer(&c->c1.tuntap->dco, multi->peer_id,
c->c2.link_socket->sd, NULL, remoteaddr, NULL, NULL);
if (ret < 0)
nvlist_t *nvl;
int ret;
+ msg(D_DCO_DEBUG, "%s: peer-id %d", __func__, peerid);
+
nvl = nvlist_create(0);
nvlist_add_number(nvl, "peerid", peerid);
dco_do_read(dco);
+ /* FreeBSD currently sends us removal notifcation with the old peer-id in
+ * p2p mode with the ping timeout reason, so ignore that one to not shoot
+ * ourselves in the foot and removing the just established session */
+ if (dco->dco_message_peer_id != c->c2.tls_multi->dco_peer_id)
+ {
+ msg(D_DCO_DEBUG, "%s: received message for mismatching peer-id %d, "
+ "expected %d", __func__, dco->dco_message_peer_id,
+ c->c2.tls_multi->dco_peer_id);
+ return;
+ }
+
if ((dco->dco_message_type == OVPN_CMD_DEL_PEER)
&& (dco->dco_del_peer_reason == OVPN_DEL_PEER_REASON_EXPIRED))
{
+ msg(D_DCO_DEBUG, "%s: received peer expired notification of for peer-id "
+ "%d", __func__, dco->dco_message_peer_id);
trigger_ping_timeout_signal(c);
return;
}