[Openvpn-devel,S] Change in openvpn[master]: if a local IPv6 address is provided, socket must be v6-only

Message ID e59f16479c3171bfc1680a6421e991fd0346728d-HTML@gerrit.openvpn.net
State New
Headers show
Series [Openvpn-devel,S] Change in openvpn[master]: if a local IPv6 address is provided, socket must be v6-only | expand

Commit Message

cron2 (Code Review) Sept. 23, 2024, 1:41 p.m. UTC
Attention is currently required from: flichtenheld, ordex, plaisthos.

Hello plaisthos, flichtenheld,

I'd like you to do a code review.
Please visit

    http://gerrit.openvpn.net/c/openvpn/+/761?usp=email

to review the following change.


Change subject: if a local IPv6 address is provided, socket must be v6-only
......................................................................

if a local IPv6 address is provided, socket must be v6-only

Change-Id: I705fd9bf9298a54560eca12e3797351f4af321a7
Signed-off-by: Antonio Quartulli <a@unstable.cc>
---
M src/openvpn/socket.c
1 file changed, 8 insertions(+), 2 deletions(-)



  git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/61/761/1

Patch

diff --git a/src/openvpn/socket.c b/src/openvpn/socket.c
index a7835e0..d1b16c5 100644
--- a/src/openvpn/socket.c
+++ b/src/openvpn/socket.c
@@ -1108,9 +1108,15 @@ 
         }
         else
         {
+            bool v6only = sock->info.bind_ipv6_only;
+
+            /* force binding IPv6-only if an address was specified
+             * an it is a IPv6 */
+            if (sock->local_host && ai_family == AF_INET6)
+                v6only = true;
+
             socket_bind(sock->sd, sock->info.lsa->bind_local,
-                        ai_family,
-                        "TCP/UDP", sock->info.bind_ipv6_only);
+                        ai_family, "TCP/UDP", v6only);
         }
     }
 }