Change in openvpn[master]: override ai_family if 'local' numeric address was specified
A message that is not in the archive (sent off-list or not yet received): gerrit.1727098847000.Ie2471e6b2d6974e70423b09918ad1c2136253754@...2715...
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/+/762?usp=email
to review the following change.
Change subject: override ai_family if 'local' numeric address was specified
......................................................................
override ai_family if 'local' numeric address was specified
This change ensures that when a numeric IP address is specified as argument to a 'local' directive, its ai_family overrides the one extracted from the 'proto' config option.
---
M src/openvpn/socket.c
1 file changed, 9 insertions(+), 2 deletions(-)
git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/62/762/1
src/openvpn/socket.c +9 -2
@@ -489,9 +489,8 @@ sig_info = &sigrec; } -/* try numeric ipv6 addr first */ +/* try numeric ip addr first */ CLEAR (hints); - hints.ai_family = ai_family; hints.ai_flags =AI_NUMERICHOST ;if (flags &GETADDR_PASSIVE )
@@ -519,6 +518,10 @@const char *fmt;int level =0 ; +/* this is not a numeric IP, therefore force resolution using the +* provided ai_family */ + hints.ai_family = ai_family; +if (hostname && (flags &GETADDR_RANDOMIZE )) { hostname =hostname_randomize (hostname, &gc);
@@ -1712,6 +1715,10 @@ sock->local_host, sock->local_port, gai_strerror(status)); } + +/* the resolved 'local entry' might have a different family than what +* was globally configured */ + sock->info.af = sock->info.lsa->bind_local->ai_family; }gc_free (&gc);
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/762?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Ie2471e6b2d6974e70423b09918ad1c2136253754
Gerrit-Change-Number: 762
Gerrit-PatchSet: 1
Gerrit-Owner: its_Giaan <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: ordex <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-Attention: ordex <[email protected]...>
Gerrit-MessageType: newchange
Attention is currently required from: flichtenheld, ordex, plaisthos.
Hello flichtenheld, ordex, plaisthos,
I'd like you to reexamine a change. Please visit
http://gerrit.openvpn.net/c/openvpn/+/762?usp=email
to look at the new patch set (#5).
Change subject: override ai_family if 'local' numeric address was specified
......................................................................
override ai_family if 'local' numeric address was specified
This change ensures that when a numeric IP address is specified as argument to a 'local' directive, its ai_family overrides the one extracted from the 'proto' config option.
---
M src/openvpn/socket.c
1 file changed, 9 insertions(+), 2 deletions(-)
git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/62/762/5
src/openvpn/socket.c +9 -2
@@ -488,9 +488,8 @@ sig_info = &sigrec; } -/* try numeric ipv6 addr first */ +/* try numeric ip addr first */ CLEAR (hints); - hints.ai_family = ai_family; hints.ai_flags =AI_NUMERICHOST ;if (flags &GETADDR_PASSIVE )
@@ -518,6 +517,10 @@const char *fmt;int level =0 ; +/* this is not a numeric IP, therefore force resolution using the +* provided ai_family */ + hints.ai_family = ai_family; +if (hostname && (flags &GETADDR_RANDOMIZE )) { hostname =hostname_randomize (hostname, &gc);
@@ -1716,6 +1719,10 @@ sock->local_host, sock->local_port, gai_strerror(status)); } + +/* the resolved 'local entry' might have a different family than what +* was globally configured */ + sock->info.af = sock->info.lsa->bind_local->ai_family; }gc_free (&gc);
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/762?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Ie2471e6b2d6974e70423b09918ad1c2136253754
Gerrit-Change-Number: 762
Gerrit-PatchSet: 5
Gerrit-Owner: its_Giaan <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: ordex <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-Attention: ordex <[email protected]...>
Gerrit-MessageType: newpatchset
Attention is currently required from: flichtenheld, its_Giaan, ordex, plaisthos.
cron2 has posted comments on this change. ( http://gerrit.openvpn.net/c/openvpn/+/762?usp=email )
Change subject: override ai_family if 'local' numeric address was specified
......................................................................
Patch Set 7: Code-Review+2
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/762?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Ie2471e6b2d6974e70423b09918ad1c2136253754
Gerrit-Change-Number: 762
Gerrit-PatchSet: 7
Gerrit-Owner: its_Giaan <[email protected]...>
Gerrit-Reviewer: cron2 <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: ordex <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: its_Giaan <[email protected]...>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-Attention: ordex <[email protected]...>
Gerrit-Comment-Date: Tue, 24 Dec 2024 12:15:23 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment
Attention is currently required from: flichtenheld, its_Giaan, ordex, plaisthos.
cron2 has posted comments on this change. ( http://gerrit.openvpn.net/c/openvpn/+/762?usp=email )
Change subject: override ai_family if 'local' numeric address was specified
......................................................................
Patch Set 7:
(1 comment)
Patchset:
PS7:
Change makes sense, the fbsd12 build fails were due to "local problems on the test machine".
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/762?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Ie2471e6b2d6974e70423b09918ad1c2136253754
Gerrit-Change-Number: 762
Gerrit-PatchSet: 7
Gerrit-Owner: its_Giaan <[email protected]...>
Gerrit-Reviewer: cron2 <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: ordex <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: its_Giaan <[email protected]...>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-Attention: ordex <[email protected]...>
Gerrit-Comment-Date: Tue, 24 Dec 2024 12:16:20 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Gerrit-MessageType: comment
PATCH v7 1/1 override ai_family if 'local' numeric address was specified
In reply to a message not in the archiveFrom: Antonio Quartulli <[email protected]...>
This change ensures that when a numeric IP address is specified as argument to a 'local' directive, its ai_family overrides the one extracted from the 'proto' config option.
---
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/+/762
This mail reflects revision 7 of this Change.
Acked-by according to Gerrit (reflected above):
Gert Doering <[email protected]...>
src/openvpn/socket.c +9 -2
@@ -488,9 +488,8 @@ sig_info = &sigrec; } -/* try numeric ipv6 addr first */ +/* try numeric ip addr first */ CLEAR (hints); - hints.ai_family = ai_family; hints.ai_flags =AI_NUMERICHOST ;if (flags &GETADDR_PASSIVE )
@@ -518,6 +517,10 @@const char *fmt;int level =0 ; +/* this is not a numeric IP, therefore force resolution using the +* provided ai_family */ + hints.ai_family = ai_family; +if (hostname && (flags &GETADDR_RANDOMIZE )) { hostname =hostname_randomize (hostname, &gc);
@@ -1716,6 +1719,10 @@ sock->local_host, sock->local_port, gai_strerror(status)); } + +/* the resolved 'local entry' might have a different family than what +* was globally configured */ + sock->info.af = sock->info.lsa->bind_local->ai_family; }gc_free (&gc);
Attention is currently required from: flichtenheld, its_Giaan, ordex, plaisthos.
cron2 has posted comments on this change. ( http://gerrit.openvpn.net/c/openvpn/+/762?usp=email )
Change subject: override ai_family if 'local' numeric address was specified
......................................................................
Patch Set 7: Code-Review-2
(1 comment)
Patchset:
PS7:
Hah, how annoying.
The client-side behaviour is fine (changing "a mismatch of proto and literal address will fail" to "upgrade to the other proto"), but the *server* side behaviour breaks all my dual-stack servers.
So a config with
``` port 51194 proto udp6 ```
(no local statement whatsoever, so "ANY") ends up IPv4-only
``` $ netstat -an |grep 51194 udp 0 0 0.0.0.0:51194 0.0.0.0:* ```
... which is inacceptable. (This is FreeBSD output, which clearly differentiates between "udp", "udp6" and "0.0.0.0:51194" vs. ":::51194"). Meh.
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/762?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Ie2471e6b2d6974e70423b09918ad1c2136253754
Gerrit-Change-Number: 762
Gerrit-PatchSet: 7
Gerrit-Owner: its_Giaan <[email protected]...>
Gerrit-Reviewer: cron2 <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: ordex <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: its_Giaan <[email protected]...>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-Attention: ordex <[email protected]...>
Gerrit-Comment-Date: Tue, 24 Dec 2024 13:54:26 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment
Attention is currently required from: flichtenheld, its_Giaan, ordex, plaisthos.
cron2 has posted comments on this change. ( http://gerrit.openvpn.net/c/openvpn/+/762?usp=email )
Change subject: override ai_family if 'local' numeric address was specified
......................................................................
Patch Set 7:
(1 comment)
Patchset:
PS7:
adding local :: to said config makes it
``` udp6 0 0 :::51194 :::* ```
so it can be made to work, but I really prefer that we do not break the current behaviour for "ANY".
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/762?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Ie2471e6b2d6974e70423b09918ad1c2136253754
Gerrit-Change-Number: 762
Gerrit-PatchSet: 7
Gerrit-Owner: its_Giaan <[email protected]...>
Gerrit-Reviewer: cron2 <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: ordex <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: its_Giaan <[email protected]...>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-Attention: ordex <[email protected]...>
Gerrit-Comment-Date: Tue, 24 Dec 2024 13:56:34 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Gerrit-MessageType: comment
Attention is currently required from: flichtenheld, its_Giaan, ordex, plaisthos.
cron2 has posted comments on this change. ( http://gerrit.openvpn.net/c/openvpn/+/762?usp=email )
Change subject: override ai_family if 'local' numeric address was specified
......................................................................
Patch Set 7:
(1 comment)
Patchset:
PS7:
So the fix is
```
if ( hostname == NULL ) /* bind to ANY, honour proto */
{
hints.ai_family = ai_family;
}--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/762?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Ie2471e6b2d6974e70423b09918ad1c2136253754
Gerrit-Change-Number: 762
Gerrit-PatchSet: 7
Gerrit-Owner: its_Giaan <[email protected]...>
Gerrit-Reviewer: cron2 <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: ordex <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: its_Giaan <[email protected]...>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-Attention: ordex <[email protected]...>
Gerrit-Comment-Date: Tue, 24 Dec 2024 14:00:18 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Gerrit-MessageType: comment
Attention is currently required from: flichtenheld, its_Giaan, plaisthos.
Hello cron2, flichtenheld, ordex, plaisthos,
I'd like you to reexamine a change. Please visit
http://gerrit.openvpn.net/c/openvpn/+/762?usp=email
to look at the new patch set (#8).
Change subject: override ai_family if 'local' numeric address was specified
......................................................................
override ai_family if 'local' numeric address was specified
This change ensures that when a numeric IP address is specified as argument to a 'local' directive, its ai_family overrides the one extracted from the 'proto' config option.
---
M src/openvpn/socket.c
1 file changed, 14 insertions(+), 2 deletions(-)
git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/62/762/8
src/openvpn/socket.c +14 -2
@@ -488,11 +488,15 @@ sig_info = &sigrec; } -/* try numeric ipv6 addr first */ +/* try numeric ip addr first */ CLEAR (hints); - hints.ai_family = ai_family; hints.ai_flags =AI_NUMERICHOST ; +if (!hostname) + { + hints.ai_family = ai_family; + } +if (flags &GETADDR_PASSIVE ) { hints.ai_flags |=AI_PASSIVE ;
@@ -518,6 +522,10 @@const char *fmt;int level =0 ; +/* this is not a numeric IP, therefore force resolution using the +* provided ai_family */ + hints.ai_family = ai_family; +if (hostname && (flags &GETADDR_RANDOMIZE )) { hostname =hostname_randomize (hostname, &gc);
@@ -1716,6 +1724,10 @@ sock->local_host, sock->local_port, gai_strerror(status)); } + +/* the resolved 'local entry' might have a different family than what +* was globally configured */ + sock->info.af = sock->info.lsa->bind_local->ai_family; }gc_free (&gc);
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/762?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Ie2471e6b2d6974e70423b09918ad1c2136253754
Gerrit-Change-Number: 762
Gerrit-PatchSet: 8
Gerrit-Owner: its_Giaan <[email protected]...>
Gerrit-Reviewer: cron2 <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-CC: ordex <[email protected]...>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: its_Giaan <[email protected]...>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-MessageType: newpatchset
Attention is currently required from: flichtenheld, its_Giaan, plaisthos.
cron2 has posted comments on this change. ( http://gerrit.openvpn.net/c/openvpn/+/762?usp=email )
Change subject: override ai_family if 'local' numeric address was specified
......................................................................
Patch Set 8: Code-Review-2
(1 comment)
File src/openvpn/socket.c:
http://gerrit.openvpn.net/c/openvpn/+/762/comment/46ef8fb5_f1cbeb95 :
PS8, Line 494:
we should have a comment here that explains what !hostname stands for (ANY) and why honouring afi is important in this case (to use what proto requests, and not what the OS defaults to)
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/762?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Ie2471e6b2d6974e70423b09918ad1c2136253754
Gerrit-Change-Number: 762
Gerrit-PatchSet: 8
Gerrit-Owner: its_Giaan <[email protected]...>
Gerrit-Reviewer: cron2 <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-CC: ordex <[email protected]...>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: its_Giaan <[email protected]...>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-Comment-Date: Fri, 27 Dec 2024 11:48:57 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment
Attention is currently required from: flichtenheld, its_Giaan, ordex, plaisthos.
Hello cron2, flichtenheld, ordex, plaisthos,
I'd like you to reexamine a change. Please visit
http://gerrit.openvpn.net/c/openvpn/+/762?usp=email
to look at the new patch set (#9).
Change subject: override ai_family if 'local' numeric address was specified
......................................................................
override ai_family if 'local' numeric address was specified
This change ensures that when a numeric IP address is specified as argument to a 'local' directive, its ai_family overrides the one extracted from the 'proto' config option.
---
M src/openvpn/socket.c
1 file changed, 16 insertions(+), 2 deletions(-)
git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/62/762/9
src/openvpn/socket.c +16 -2
@@ -488,9 +488,8 @@ sig_info = &sigrec; } -/* try numeric ipv6 addr first */ +/* try numeric ip addr first */ CLEAR (hints); - hints.ai_family = ai_family; hints.ai_flags =AI_NUMERICHOST ;if (flags &GETADDR_PASSIVE )
@@ -507,6 +506,13 @@ hints.ai_socktype =SOCK_STREAM ; } +/* if hostname is not set, we want to bind to 'ANY', with +* the correct address family - v4-only or v6/v6-dual-stack */ +if (!hostname) + { + hints.ai_family = ai_family; + } + status =getaddrinfo (hostname, servname, &hints, res);if (status !=0 )/* parse as numeric address failed? */
@@ -518,6 +524,10 @@const char *fmt;int level =0 ; +/* this is not a numeric IP, therefore force resolution using the +* provided ai_family */ + hints.ai_family = ai_family; +if (hostname && (flags &GETADDR_RANDOMIZE )) { hostname =hostname_randomize (hostname, &gc);
@@ -1716,6 +1726,10 @@ sock->local_host, sock->local_port, gai_strerror(status)); } + +/* the resolved 'local entry' might have a different family than what +* was globally configured */ + sock->info.af = sock->info.lsa->bind_local->ai_family; }gc_free (&gc);
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/762?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Ie2471e6b2d6974e70423b09918ad1c2136253754
Gerrit-Change-Number: 762
Gerrit-PatchSet: 9
Gerrit-Owner: its_Giaan <[email protected]...>
Gerrit-Reviewer: cron2 <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: ordex <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: its_Giaan <[email protected]...>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-Attention: ordex <[email protected]...>
Gerrit-MessageType: newpatchset
Attention is currently required from: cron2, flichtenheld, ordex, plaisthos.
its_Giaan has posted comments on this change. ( http://gerrit.openvpn.net/c/openvpn/+/762?usp=email )
Change subject: override ai_family if 'local' numeric address was specified
......................................................................
Patch Set 9:
(1 comment)
File src/openvpn/socket.c:
http://gerrit.openvpn.net/c/openvpn/+/762/comment/b432ca95_7c1c0b14 :
PS8, Line 494:
Quoted 1 line
we should have a comment here that explains what
!hostnamestands for (ANY) and why honouring afi […]
Done
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/762?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Ie2471e6b2d6974e70423b09918ad1c2136253754
Gerrit-Change-Number: 762
Gerrit-PatchSet: 9
Gerrit-Owner: its_Giaan <[email protected]...>
Gerrit-Reviewer: cron2 <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: ordex <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: cron2 <[email protected]...>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-Attention: ordex <[email protected]...>
Gerrit-Comment-Date: Fri, 27 Dec 2024 12:40:14 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: cron2 <[email protected]...>
Gerrit-MessageType: comment
Attention is currently required from: flichtenheld, its_Giaan, ordex, plaisthos.
cron2 has posted comments on this change. ( http://gerrit.openvpn.net/c/openvpn/+/762?usp=email )
Change subject: override ai_family if 'local' numeric address was specified
......................................................................
Patch Set 9: Code-Review+2
(1 comment)
Patchset:
PS9:
looks good, code is understandable, and passes all tests. Go for it ;-)
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/762?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Ie2471e6b2d6974e70423b09918ad1c2136253754
Gerrit-Change-Number: 762
Gerrit-PatchSet: 9
Gerrit-Owner: its_Giaan <[email protected]...>
Gerrit-Reviewer: cron2 <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: ordex <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: its_Giaan <[email protected]...>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-Attention: ordex <[email protected]...>
Gerrit-Comment-Date: Fri, 27 Dec 2024 16:17:34 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment
PATCH v9 1/1 override ai_family if 'local' numeric address was specified
In reply to a message not in the archiveFrom: Antonio Quartulli <[email protected]...>
This change ensures that when a numeric IP address is specified as argument to a 'local' directive, its ai_family overrides the one extracted from the 'proto' config option.
---
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/+/762
This mail reflects revision 9 of this Change.
Acked-by according to Gerrit (reflected above):
Gert Doering <[email protected]...>
src/openvpn/socket.c +16 -2
@@ -488,9 +488,8 @@ sig_info = &sigrec; } -/* try numeric ipv6 addr first */ +/* try numeric ip addr first */ CLEAR (hints); - hints.ai_family = ai_family; hints.ai_flags =AI_NUMERICHOST ;if (flags &GETADDR_PASSIVE )
@@ -507,6 +506,13 @@ hints.ai_socktype =SOCK_STREAM ; } +/* if hostname is not set, we want to bind to 'ANY', with +* the correct address family - v4-only or v6/v6-dual-stack */ +if (!hostname) + { + hints.ai_family = ai_family; + } + status =getaddrinfo (hostname, servname, &hints, res);if (status !=0 )/* parse as numeric address failed? */
@@ -518,6 +524,10 @@const char *fmt;int level =0 ; +/* this is not a numeric IP, therefore force resolution using the +* provided ai_family */ + hints.ai_family = ai_family; +if (hostname && (flags &GETADDR_RANDOMIZE )) { hostname =hostname_randomize (hostname, &gc);
@@ -1716,6 +1726,10 @@ sock->local_host, sock->local_port, gai_strerror(status)); } + +/* the resolved 'local entry' might have a different family than what +* was globally configured */ + sock->info.af = sock->info.lsa->bind_local->ai_family; }gc_free (&gc);
[Openvpn-devel] [PATCH applied] Re: override ai_family if 'local' numeric address was specified
This does change semantics of "local <address>" or "remote <address>", but in a useful way. The old code would just fail on
proto udp4
remote 2001:db8::1
because it tried to force-resolve the v6 address as "proto v4" (and vice versa):
2024-12-24 13:24:18 RESOLVE: Cannot resolve host address: 2001:db8::1:51194 (Name does not resolve) 2024-12-24 13:25:01 RESOLVE: Cannot resolve host address: 199.102.77.82:51194 (Name does not resolve)
The new code will basically change "proto udp4" to "udp6" if a numeric v6 address is seen (and vice versa).
This has a small risk for unforeseen breakage (configs that have v4+v6 connection entries in them, and purposely selecting one or the other using "proto udp4/udp6"), but I'm willing to accept that - if we really need that use case (instead of just letting the transport layer decide if v4 or v6 succeeds) we might enhance --proto-force to also serve as a v4/v6 switch. Or introduce -4/-6.
Tested client-side with the "mismatched" combinations, and subjected to the full client/server side tests - which uncovered a unforeseen surprise in v7 (instead of a dual-stack socket for "ANY", I only got v4 sockets)
- this has been addressed in v9, and my zoo behaves "as before".
Your patch has been applied to the master branch.
commit 8b209d9e5d80799eec931e2fec9b15f7e2c1a7b0
Author: Antonio Quartulli Date: Fri Dec 27 17:17:55 2024 +0100
override ai_family if 'local' numeric address was specified
Signed-off-by: Antonio Quartulli <[email protected]...>
Signed-off-by: Gianmarco De Gregori <[email protected]...>
Acked-by: Gert Doering <[email protected]...>
Message-Id: <[email protected]...>
URL: https://www.mail-archive.com/[email protected]/msg30257.html
Signed-off-by: Gert Doering <[email protected]...>--
kind regards,
Gert Doering
cron2 has uploaded a new patch set (#10) to the change originally created by its_Giaan. ( http://gerrit.openvpn.net/c/openvpn/+/762?usp=email )
The following approvals got outdated and were removed:
Code-Review+2 by cron2
Change subject: override ai_family if 'local' numeric address was specified
......................................................................
override ai_family if 'local' numeric address was specified
This change ensures that when a numeric IP address is specified as argument to a 'local' directive, its ai_family overrides the one extracted from the 'proto' config option.
Message-Id: <[email protected]...>
URL: https://www.mail-archive.com/[email protected]/msg30257.html
---
M src/openvpn/socket.c
1 file changed, 16 insertions(+), 2 deletions(-)
git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/62/762/10
src/openvpn/socket.c +16 -2
@@ -467,9 +467,8 @@ sig_info = &sigrec; } -/* try numeric ipv6 addr first */ +/* try numeric ip addr first */ CLEAR (hints); - hints.ai_family = ai_family; hints.ai_flags =AI_NUMERICHOST ;if (flags &GETADDR_PASSIVE )
@@ -486,6 +485,13 @@ hints.ai_socktype =SOCK_STREAM ; } +/* if hostname is not set, we want to bind to 'ANY', with +* the correct address family - v4-only or v6/v6-dual-stack */ +if (!hostname) + { + hints.ai_family = ai_family; + } + status =getaddrinfo (hostname, servname, &hints, res);if (status !=0 )/* parse as numeric address failed? */
@@ -497,6 +503,10 @@const char *fmt;int level =0 ; +/* this is not a numeric IP, therefore force resolution using the +* provided ai_family */ + hints.ai_family = ai_family; +if (hostname && (flags &GETADDR_RANDOMIZE )) { hostname =hostname_randomize (hostname, &gc);
@@ -1690,6 +1700,10 @@ sock->local_host, sock->local_port, gai_strerror(status)); } + +/* the resolved 'local entry' might have a different family than what +* was globally configured */ + sock->info.af = sock->info.lsa->bind_local->ai_family; }gc_free (&gc);
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/762?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Ie2471e6b2d6974e70423b09918ad1c2136253754
Gerrit-Change-Number: 762
Gerrit-PatchSet: 10
Gerrit-Owner: its_Giaan <[email protected]...>
Gerrit-Reviewer: cron2 <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-CC: ordex <[email protected]...>
Gerrit-MessageType: newpatchset
cron2 has submitted this change. ( http://gerrit.openvpn.net/c/openvpn/+/762?usp=email )
Change subject: override ai_family if 'local' numeric address was specified
......................................................................
override ai_family if 'local' numeric address was specified
This change ensures that when a numeric IP address is specified as argument to a 'local' directive, its ai_family overrides the one extracted from the 'proto' config option.
Message-Id: <[email protected]...>
URL: https://www.mail-archive.com/[email protected]/msg30257.html
---
M src/openvpn/socket.c
1 file changed, 16 insertions(+), 2 deletions(-)
src/openvpn/socket.c +16 -2
@@ -467,9 +467,8 @@ sig_info = &sigrec; } -/* try numeric ipv6 addr first */ +/* try numeric ip addr first */ CLEAR (hints); - hints.ai_family = ai_family; hints.ai_flags =AI_NUMERICHOST ;if (flags &GETADDR_PASSIVE )
@@ -486,6 +485,13 @@ hints.ai_socktype =SOCK_STREAM ; } +/* if hostname is not set, we want to bind to 'ANY', with +* the correct address family - v4-only or v6/v6-dual-stack */ +if (!hostname) + { + hints.ai_family = ai_family; + } + status =getaddrinfo (hostname, servname, &hints, res);if (status !=0 )/* parse as numeric address failed? */
@@ -497,6 +503,10 @@const char *fmt;int level =0 ; +/* this is not a numeric IP, therefore force resolution using the +* provided ai_family */ + hints.ai_family = ai_family; +if (hostname && (flags &GETADDR_RANDOMIZE )) { hostname =hostname_randomize (hostname, &gc);
@@ -1690,6 +1700,10 @@ sock->local_host, sock->local_port, gai_strerror(status)); } + +/* the resolved 'local entry' might have a different family than what +* was globally configured */ + sock->info.af = sock->info.lsa->bind_local->ai_family; }gc_free (&gc);
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/762?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Ie2471e6b2d6974e70423b09918ad1c2136253754
Gerrit-Change-Number: 762
Gerrit-PatchSet: 10
Gerrit-Owner: its_Giaan <[email protected]...>
Gerrit-Reviewer: cron2 <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-CC: ordex <[email protected]...>
Gerrit-MessageType: merged