[Openvpn-devel,v10] mudp.c: keep offset value when resetting buffer

Message ID 20250121161025.37545-1-frank@lichtenheld.com
State Accepted
Headers show
Series [Openvpn-devel,v10] mudp.c: keep offset value when resetting buffer | expand

Commit Message

Frank Lichtenheld Jan. 21, 2025, 4:10 p.m. UTC
From: Lev Stipakov <lev@openvpn.net>

dco-win requires control packets to be prepended
with sockaddr. For that, an offset value in buffer
must be kept. Doing it always doesn't harm and makes
code cleaner compared to adding "if (dco_win_server)"
condition.

Change-Id: I145573555aaace5e94774b5f977d032d3747ed72
Signed-off-by: Lev Stipakov <lev@openvpn.net>
Acked-by: Frank Lichtenheld <frank@lichtenheld.com>
---

This change was reviewed on Gerrit and approved by at least one
developer. I request to merge it to master.

Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/814
This mail reflects revision 10 of this Change.

Acked-by according to Gerrit (reflected above):
Frank Lichtenheld <frank@lichtenheld.com>

Comments

Gert Doering Jan. 31, 2025, 7:10 p.m. UTC | #1
Just for clarification: I'm taking the patch "v10" from the list, while
gerrit claims to have a "v12" - this is just due to rebasing and re-pushing,
but nothing at all has changed there.

I admit I haven't really closely looked what happens here, but it was
stared-at by Frank and Antonio, and both are fine.  The ASSERT() is
"this can never fail, but if it does, something is really wrong", so
we do not expect this to ever misfire ("all other buf_init() calls
also have an ASSERT()").

Tested on client and server testbed, with lots of UDP activity :-) - no
complaints.

Your patch has been applied to the master branch.

commit bfa5f0bdfe89d181f7b5f7af2ba34ab9357a1d13
Author: Lev Stipakov
Date:   Tue Jan 21 17:10:25 2025 +0100

     mudp.c: keep offset value when resetting buffer

     Signed-off-by: Lev Stipakov <lev@openvpn.net>
     Acked-by: Frank Lichtenheld <frank@lichtenheld.com>
     Message-Id: <20250121161025.37545-1-frank@lichtenheld.com>
     URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg30519.html
     Signed-off-by: Gert Doering <gert@greenie.muc.de>


--
kind regards,

Gert Doering

Patch

diff --git a/src/openvpn/mudp.c b/src/openvpn/mudp.c
index 6137578..1a3a4c7 100644
--- a/src/openvpn/mudp.c
+++ b/src/openvpn/mudp.c
@@ -54,7 +54,9 @@ 
 
     struct context *c = &m->top;
 
-    buf_reset_len(&c->c2.buffers->aux_buf);
+    /* dco-win server requires prepend with sockaddr, so preserve offset */
+    ASSERT(buf_init(&c->c2.buffers->aux_buf, buf.offset));
+
     buf_copy(&c->c2.buffers->aux_buf, &buf);
     m->hmac_reply = c->c2.buffers->aux_buf;
     m->hmac_reply_dest = &m->top.c2.from;