Attention is currently required from: Arne Schwabe.
Hello Arne Schwabe,
I'd like you to do a code review.
Please visit
https://gerrit.openvpn.net/c/openvpn/+/2057?usp=email
to review the following change.
Change subject: p2p: don't let new sessions reset the ping-restart timer
......................................................................
p2p: don't let new sessions reset the ping-restart timer
Any control packet resets the ping-restart timer, including a hard reset
that starts a new session. Without tls-auth/tls-crypt such a packet can
come from anybody, so a dead tunnel that keeps receiving stray hard
resets (e.g. from a scanner) never restarts.
Once a session is established, only reset the timer for control packets
of that session.
Change-Id: I2579c0643fa0b26df29d63af306d9ef10f74b3b3
Signed-off-by: Antonio Quartulli <[email protected]>
---
M src/openvpn/forward.c
M src/openvpn/ssl.c
M src/openvpn/ssl.h
3 files changed, 18 insertions(+), 5 deletions(-)
git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/57/2057/1
diff --git a/src/openvpn/forward.c b/src/openvpn/forward.c
index 681210d..ca5f052 100644
--- a/src/openvpn/forward.c
+++ b/src/openvpn/forward.c
@@ -1088,12 +1088,14 @@
* will load crypto_options with the correct encryption key
* and return false.
*/
- if (tls_pre_decrypt(c->c2.tls_multi, &c->c2.from, &c->c2.buf, &co,
floated, &ad_start))
+ bool from_peer;
+ if (tls_pre_decrypt(c->c2.tls_multi, &c->c2.from, &c->c2.buf, &co,
floated, &ad_start,
+ &from_peer))
{
interval_action(&c->c2.tmp_int);
- /* reset packet received timer if TLS packet */
- if (c->options.ping_rec_timeout)
+ /* reset packet received timer if TLS packet from our peer */
+ if (c->options.ping_rec_timeout && from_peer)
{
event_timeout_reset(&c->c2.ping_rec_interval);
}
diff --git a/src/openvpn/ssl.c b/src/openvpn/ssl.c
index 086a6fc..924de74 100644
--- a/src/openvpn/ssl.c
+++ b/src/openvpn/ssl.c
@@ -3754,8 +3754,11 @@
bool
tls_pre_decrypt(struct tls_multi *multi, const struct link_socket_actual
*from, struct buffer *buf,
- struct crypto_options **opt, bool floated, const uint8_t
**ad_start)
+ struct crypto_options **opt, bool floated, const uint8_t
**ad_start,
+ bool *from_peer)
{
+ *from_peer = false;
+
if (buf->len <= 0)
{
buf->len = 0;
@@ -4006,6 +4009,10 @@
/* Let our caller know we processed a control channel packet */
ret = true;
+ /* Once a session is established, only its packets show that the peer is
+ * alive: a new session can be started by anybody */
+ *from_peer = (i == TM_ACTIVE || multi->multi_state < CAS_CONNECT_DONE);
+
/*
* Set our remote address and remote session_id
*/
diff --git a/src/openvpn/ssl.h b/src/openvpn/ssl.h
index 76c3610..0a4ed4c 100644
--- a/src/openvpn/ssl.h
+++ b/src/openvpn/ssl.h
@@ -291,6 +291,10 @@
* @param[in] floated Set whether the peer is allowed to have floated.
* @param[out] ad_start Returns a pointer to the start of the authenticated
data
* of this packet
+ * @param[out] from_peer Set to true if the packet is a control channel packet
+ * from our established peer (or if there is none yet). A packet that
+ * starts a new, not yet authenticated session can come from anybody and
+ * does not show that the peer is alive.
*
* @return
* @li True if the packet is a control channel packet that has been
@@ -300,7 +304,7 @@
*/
bool tls_pre_decrypt(struct tls_multi *multi, const struct link_socket_actual
*from,
struct buffer *buf, struct crypto_options **opt, bool
floated,
- const uint8_t **ad_start);
+ const uint8_t **ad_start, bool *from_peer);
/**************************************************************************/
--
To view, visit https://gerrit.openvpn.net/c/openvpn/+/2057?usp=email
To unsubscribe, or for help writing mail filters, visit
https://gerrit.openvpn.net/settings?usp=email
Gerrit-MessageType: newchange
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I2579c0643fa0b26df29d63af306d9ef10f74b3b3
Gerrit-Change-Number: 2057
Gerrit-PatchSet: 1
Gerrit-Owner: Antonio Quartulli <[email protected]>
Gerrit-Reviewer: Arne Schwabe <[email protected]>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: Arne Schwabe <[email protected]>
_______________________________________________
Openvpn-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openvpn-devel