This commit consists of two parts.
- explicitly removing an existing peer in p2p mode
- ignoring the ping timeout notification that is generated by the first
part
Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20221201110128.271064-1-arne@rfc2549.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg25602.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
| ... | ... |
@@ -458,6 +458,15 @@ dco_p2p_add_new_peer(struct context *c) |
| 458 | 458 |
|
| 459 | 459 |
struct sockaddr *remoteaddr = &ls->info.lsa->actual.dest.addr.sa; |
| 460 | 460 |
struct tls_multi *multi = c->c2.tls_multi; |
| 461 |
+#ifdef TARGET_FREEBSD |
|
| 462 |
+ /* In Linux in P2P mode the kernel automatically removes an existing peer |
|
| 463 |
+ * when adding a new peer. FreeBSD needs to explicitly be told to do that */ |
|
| 464 |
+ if (c->c2.tls_multi->dco_peer_id != -1) |
|
| 465 |
+ {
|
|
| 466 |
+ dco_del_peer(&c->c1.tuntap->dco, c->c2.tls_multi->dco_peer_id); |
|
| 467 |
+ c->c2.tls_multi->dco_peer_id = -1; |
|
| 468 |
+ } |
|
| 469 |
+#endif |
|
| 461 | 470 |
int ret = dco_new_peer(&c->c1.tuntap->dco, multi->peer_id, |
| 462 | 471 |
c->c2.link_socket->sd, NULL, remoteaddr, NULL, NULL); |
| 463 | 472 |
if (ret < 0) |
| ... | ... |
@@ -1174,9 +1174,22 @@ process_incoming_dco(struct context *c) |
| 1174 | 1174 |
|
| 1175 | 1175 |
dco_do_read(dco); |
| 1176 | 1176 |
|
| 1177 |
+ /* FreeBSD currently sends us removal notifcation with the old peer-id in |
|
| 1178 |
+ * p2p mode with the ping timeout reason, so ignore that one to not shoot |
|
| 1179 |
+ * ourselves in the foot and removing the just established session */ |
|
| 1180 |
+ if (dco->dco_message_peer_id != c->c2.tls_multi->dco_peer_id) |
|
| 1181 |
+ {
|
|
| 1182 |
+ msg(D_DCO_DEBUG, "%s: received message for mismatching peer-id %d, " |
|
| 1183 |
+ "expected %d", __func__, dco->dco_message_peer_id, |
|
| 1184 |
+ c->c2.tls_multi->dco_peer_id); |
|
| 1185 |
+ return; |
|
| 1186 |
+ } |
|
| 1187 |
+ |
|
| 1177 | 1188 |
if ((dco->dco_message_type == OVPN_CMD_DEL_PEER) |
| 1178 | 1189 |
&& (dco->dco_del_peer_reason == OVPN_DEL_PEER_REASON_EXPIRED)) |
| 1179 | 1190 |
{
|
| 1191 |
+ msg(D_DCO_DEBUG, "%s: received peer expired notification of for peer-id " |
|
| 1192 |
+ "%d", __func__, dco->dco_message_peer_id); |
|
| 1180 | 1193 |
trigger_ping_timeout_signal(c); |
| 1181 | 1194 |
return; |
| 1182 | 1195 |
} |