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

Message ID 66f4e0fa28801d0720f6992c646f3d790c2cfeb3-HTML@gerrit.openvpn.net
State Not Applicable
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) Nov. 15, 2023, 1:45 p.m. UTC
Attention is currently required from: flichtenheld, plaisthos.

Hello plaisthos, flichtenheld,

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

    http://gerrit.openvpn.net/c/openvpn/+/435?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: I7a3349c7de4202b5eb2f576e3f8a82a9af6f7f31
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/35/435/1

Patch

diff --git a/src/openvpn/socket.c b/src/openvpn/socket.c
index f2bd624..17bd263 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);
         }
     }
 }