Skip to contentSkip to conversation

Stub implementation of "--dhcp-option DNS6 <v6addr>"

PATCH Superseded Gert Doering 2 participants 7 messages Nov 20, 2016 – Nov 21, 2016

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Stub implementation of "--dhcp-option DNS6 <v6addr>"

This defines a new DHCP suboption "DNS6", but does not actually implement anything but "document the option and understand it".

If received, it will be put into an "foreign_option_<n>" environment variable where an --up script or plugin could receive and act upon it.

On non-Windows platforms, all "dhcp-option" sub-options end up there, so v4 and v6 DNS options will be reflected like this:

foreign_option_1=dhcp-option DNS6 2001:608::2
foreign_option_2=dhcp-option DNS 195.30.0.2

---
 doc/openvpn.8         | 14 +++++++++++++-
 src/openvpn/options.c | 11 ++++++++++-
 2 files changed, 23 insertions(+), 2 deletions(-)
doc/openvpn.8 +13 -1
index 11564af..d454a36 100644
@@ -5627,9 +5627,21 @@ across the VPN.
 Set Connection-specific DNS Suffix.
 
 .B DNS addr \-\-
-Set primary domain name server address.  Repeat
+Set primary domain name server IPv4 address.  Repeat
 this option to set secondary DNS server addresses.
 
+.B DNS6 addr \-\-
+Set primary domain name server IPv6 address.  Repeat
+this option to set secondary DNS server IPv6 addresses.
+
+Note: currently this is somewhat of a placeholder option - it is
+understood, but OpenVPN has no code to tell Windows about it (the
+existing DHCP code can only do IPv4 DHCP, and that protocol only
+permits IPv4 addresses anywhere).  The option will be put into the
+environment, so an
+.B \-\-up
+script could act upon it.
+
 .B WINS addr \-\-
 Set primary WINS server address (NetBIOS over TCP/IP Name Server).
 Repeat this option to set secondary WINS server addresses.
src/openvpn/options.c +10 -1
index 7f128c3..9e828d8 100644
@@ -704,7 +704,8 @@ static const char usage_message[] =
   "                    which allow multiple addresses,\n"
   "                    --dhcp-option must be repeated.\n"
   "                    DOMAIN name : Set DNS suffix\n"
-  "                    DNS addr    : Set domain name server address(es)\n"
+  "                    DNS addr    : Set domain name server address(es) (IPv4)\n"
+  "                    DNS6 addr   : Set domain name server address(es) (IPv6)\n"
   "                    NTP         : Set NTP server address(es)\n"
   "                    NBDD        : Set NBDD server address(es)\n"
   "                    WINS addr   : Set WINS server address(es)\n"
@@ -6406,6 +6407,14 @@ add_option (struct options *options,
 	{
 	  dhcp_option_address_parse ("DNS", p[2], o->dns, &o->dns_len, msglevel);
 	}
+      else if (streq (p[1], "DNS6") && p[2])
+	{
+	  /* this is somewhat of a placeholder - we understand the option,
+	   * but cannot act upon it - so we'll just accept it and put it
+	   * into the environment, as we would do on all non-win32 platforms
+	   */
+	  foreign_option (options, p, 3, es);
+	}
       else if (streq (p[1], "WINS") && p[2])
 	{
 	  dhcp_option_address_parse ("WINS", p[2], o->wins, &o->wins_len, msglevel);
Signature · 1 line
2.7.3
#1 lore raw
Quoted 12 lines · Gert Doering

This defines a new DHCP suboption "DNS6", but does not actually implement anything but "document the option and understand it".

If received, it will be put into an "foreign_option_<n>" environment variable where an --up script or plugin could receive and act upon it.

On non-Windows platforms, all "dhcp-option" sub-options end up there, so v4 and v6 DNS options will be reflected like this:

   foreign_option_1=dhcp-option DNS6 2001:608::2
   foreign_option_2=dhcp-option DNS 195.30.0.2

Good enough to get the ball rolling. ACK.

Selva

#2 lore raw

Hi,

Quoted 14 lines · Selva Nair
Quoted 9 lines · Gert Doering

This defines a new DHCP suboption "DNS6", but does not actually implement anything but "document the option and understand it".

If received, it will be put into an "foreign_option_<n>" environment variable where an --up script or plugin could receive and act upon it.

On non-Windows platforms, all "dhcp-option" sub-options end up there, so v4 and v6 DNS options will be reflected like this:

Quoted 7 lines
Quoted 3 lines
   foreign_option_1=dhcp-option DNS6 2001:608::2
   foreign_option_2=dhcp-option DNS 195.30.0.2

Good enough to get the ball rolling. ACK.

I spoke too fast... There is a subtle problem here

+ else if (streq (p[1], "DNS6") && p[2])

src/openvpn/options.c add_option (struct options *options, · line 6417

Quoted 9 lines
src/openvpn/options.c +4 -0
+       {
+         /* this is somewhat of a placeholder - we understand the option,
+          * but cannot act upon it - so we'll just accept it and put it
+          * into the environment, as we would do on all non-win32

platforms

src/openvpn/options.c +3 -0
+          */
+         foreign_option (options, p, 3, es);
+       }

At the end of the "dhcp-option" parsing block there is a

o->dhcp_options = true;

which should be set only if there is a true DHCP option in the config. When DNS6 is the only dhcp-option this causes an empty dhcp-option string being created and the tap IOCTL to set dhcp fails.

Ading a "goto err;", though ugly and confusing, will fix it..

Selva

#3 lore raw

PATCH v2 1/1 Stub implementation of "--dhcp-option DNS6 <v6addr>"

In reply to Gert Doering

This defines a new DHCP suboption "DNS6", but does not actually implement anything but "document the option and understand it".

If received, it will be put into an "foreign_option_<n>" environment variable where an --up script or plugin could receive and act upon it.

On non-Windows platforms, all "dhcp-option" sub-options end up there, so v4 and v6 DNS options will be reflected like this:

foreign_option_1=dhcp-option DNS6 2001:608::2
foreign_option_2=dhcp-option DNS 195.30.0.2

v2: do not set o->dhcp_options if DNS6 is the single dhcp-option seen
(spotted by Selva Nair)

---
 doc/openvpn.8         | 14 +++++++++++++-
 src/openvpn/options.c | 20 ++++++++++++++++++--
 2 files changed, 31 insertions(+), 3 deletions(-)
doc/openvpn.8 +13 -1
index 11564af..d454a36 100644
@@ -5627,9 +5627,21 @@ across the VPN.
 Set Connection-specific DNS Suffix.
 
 .B DNS addr \-\-
-Set primary domain name server address.  Repeat
+Set primary domain name server IPv4 address.  Repeat
 this option to set secondary DNS server addresses.
 
+.B DNS6 addr \-\-
+Set primary domain name server IPv6 address.  Repeat
+this option to set secondary DNS server IPv6 addresses.
+
+Note: currently this is somewhat of a placeholder option - it is
+understood, but OpenVPN has no code to tell Windows about it (the
+existing DHCP code can only do IPv4 DHCP, and that protocol only
+permits IPv4 addresses anywhere).  The option will be put into the
+environment, so an
+.B \-\-up
+script could act upon it.
+
 .B WINS addr \-\-
 Set primary WINS server address (NetBIOS over TCP/IP Name Server).
 Repeat this option to set secondary WINS server addresses.
src/openvpn/options.c +18 -2
index 7f128c3..f30e62d 100644
@@ -704,7 +704,8 @@ static const char usage_message[] =
   "                    which allow multiple addresses,\n"
   "                    --dhcp-option must be repeated.\n"
   "                    DOMAIN name : Set DNS suffix\n"
-  "                    DNS addr    : Set domain name server address(es)\n"
+  "                    DNS addr    : Set domain name server address(es) (IPv4)\n"
+  "                    DNS6 addr   : Set domain name server address(es) (IPv6)\n"
   "                    NTP         : Set NTP server address(es)\n"
   "                    NBDD        : Set NBDD server address(es)\n"
   "                    WINS addr   : Set WINS server address(es)\n"
@@ -6406,6 +6407,14 @@ add_option (struct options *options,
 	{
 	  dhcp_option_address_parse ("DNS", p[2], o->dns, &o->dns_len, msglevel);
 	}
+      else if (streq (p[1], "DNS6") && p[2])
+	{
+	  /* this is somewhat of a placeholder - we understand the option,
+	   * but cannot act upon it - so we'll just accept it and put it
+	   * into the environment, as we would do on all non-win32 platforms
+	   */
+	  foreign_option (options, p, 3, es);
+	}
       else if (streq (p[1], "WINS") && p[2])
 	{
 	  dhcp_option_address_parse ("WINS", p[2], o->wins, &o->wins_len, msglevel);
@@ -6427,7 +6436,14 @@ add_option (struct options *options,
 	  msg (msglevel, "--dhcp-option: unknown option type '%s' or missing or unknown parameter", p[1]);
 	  goto err;
 	}
-      o->dhcp_options = true;
+
+      /* flag that we have options to give to the TAP driver's DHCPv4 server
+       *  - skipped for "DNS6", as that's not a DHCPv4 option
+       */
+      if (!streq (p[1], "DNS6"))
+	{
+	  o->dhcp_options = true;
+	}
     }
 #endif
 #ifdef _WIN32
Signature · 1 line
2.7.3
#4 lore raw

src/openvpn/options.c add_option (struct options *options, · line 6446

Quoted 10 lines · Gert Doering
(quoted diff) +2 -0
+
+      /* flag that we have options to give to the TAP driver's DHCPv4

server

src/openvpn/options.c +6 -0
+       *  - skipped for "DNS6", as that's not a DHCPv4 option
+       */
+      if (!streq (p[1], "DNS6"))
+       {
+         o->dhcp_options = true;
+       }

This will fix it. Hopefully non DHCPv4 options like this wont proliferate. ACK.

#5 lore raw

Hi,

Quoted 1 line · Selva Nair

This will fix it. Hopefully non DHCPv4 options like this wont proliferate.

Not in the short run anyway :-) - medium term we'll see what is needed to provide to windows clients (and *how*) if we run IPv6-only...

gert

Signature · 4 lines
USENET is *not* the non-clickable part of WWW!
                                                           //www.muc.de/~gert/
Gert Doering - Munich, Germany                             [email protected]...
fax: +49-89-35655025                        [email protected]...
#6 lore raw
In reply to Gert Doering

Patch has been applied to the master branch.

commit 94bfc256d4e96e6e91fa5a518352d758c09800f3

Author: Gert Doering <[email protected]...>
Date:   Mon Nov 21 17:42:42 2016 +0100
     Stub implementation of "--dhcp-option DNS6 <v6addr>"

     Signed-off-by: Gert Doering <[email protected]...>
     Acked-by: Selva Nair <[email protected]...>
     Message-Id: <[email protected]...>
     URL: https://www.mail-archive.com/[email protected]/msg13174.html
     Signed-off-by: Gert Doering <[email protected]...>

--
kind regards,

Gert Doering