Skip to contentSkip to conversation

dco: fix source IP selection when multihome

PATCH In review Qingfang Deng 3 participants 3 messages Feb 27, 2025 – Mar 13, 2025

lore
Share & tools
lore
#0 lore raw

PATCH v3 1/1 dco: fix source IP selection when multihome

When multihome option is enabled, OpenVPN passes ipi_addr to DCO, which is always 0.0.0.0. It should use ipi_spec_dst instead.

---
 src/openvpn/dco.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
src/openvpn/dco.c +1 -1
index 02fae816..d6e8ec5f 100644
@@ -562,7 +562,7 @@ dco_multi_get_localaddr(struct multi_context *m, struct multi_instance *mi,
         {
             struct sockaddr_in *sock_in4 = (struct sockaddr_in *)local;
 #if defined(HAVE_IN_PKTINFO) && defined(HAVE_IPI_SPEC_DST)
-            sock_in4->sin_addr = actual->pi.in4.ipi_addr;
+            sock_in4->sin_addr = actual->pi.in4.ipi_spec_dst;
 #elif defined(IP_RECVDSTADDR)
             sock_in4->sin_addr = actual->pi.in4;
 #else
Signature · 1 line
2.43.0
Acked-by on v3 1/1
#1 lore raw
Quoted 13 lines · Qingfang Deng

When multihome option is enabled, OpenVPN passes ipi_addr to DCO, which is always 0.0.0.0. It should use ipi_spec_dst instead.

---
  src/openvpn/dco.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
src/openvpn/dco.c +0 -0
index 02fae816..d6e8ec5f 100644

src/openvpn/dco.c dco_multi_get_localaddr(struct multi_context *m, struct multi_instance *mi, · line 568

Quoted 8 lines
src/openvpn/dco.c +1 -1
@@ -562,7 +562,7 @@ dco_multi_get_localaddr(struct multi_context *m, struct multi_instance *mi,
          {
              struct sockaddr_in *sock_in4 = (struct sockaddr_in *)local;
  #if defined(HAVE_IN_PKTINFO) && defined(HAVE_IPI_SPEC_DST)
-            sock_in4->sin_addr = actual->pi.in4.ipi_addr;
+            sock_in4->sin_addr = actual->pi.in4.ipi_spec_dst;
  #elif defined(IP_RECVDSTADDR)
              sock_in4->sin_addr = actual->pi.in4;
  #else

Tested and confirmed it does what it says.

Signature · 1 line
Antonio Quartulli
#2 lore raw
In reply to Qingfang Deng

At last :-) - thanks, Antonio for testing, thanks Quingfang for your patience.

I haven't tested it (do I look like I understand DCO stuff? :-) ) but from looking at other places, "ipi_spec_dst" is what is used elsewhere as "this is our IP" as well ("dest" might be confusing here, but it's the "dest of the incoming UDP packet" = "our source for outgoing packets")

Again, I had to link to the sourceforge.net mail archive as the mail-archive.org one seems to not have the v3 patch at all. Highly annoying.

Your patch has been applied to the master and release/2.6 branch (bugfix).

commit e4beaf7a610793f57984ec8006d26f9a695b0c74 (master) commit b9ad768ae2daf76f9ee2f20da70ecf8d62b6d4e5 (release/2.6)

Author: Qingfang Deng
Date:   Thu Feb 27 11:25:22 2025 +0800
     dco: fix source IP selection when multihome

     Signed-off-by: Qingfang Deng <[email protected]...>
     Acked-by: Antonio Quartulli <[email protected]...>
     Message-Id: <[email protected]...>
     URL: https://sourceforge.net/p/openvpn/mailman/message/59154010/
     Signed-off-by: Gert Doering <[email protected]...>

--
kind regards,

Gert Doering