From: "cron2 (Code Review)" Date: Tue, 24 Sep 2024 12:59:19 +0000 In-Reply-To: References: Reply-To: gert@...1296..., arne-openvpn@...1227..., openvpn-devel@lists.sourceforge.net, frank@...2641... Message-ID: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Disposition: inline Content-Type: multipart/alternative; boundary="BmhMxubk4sk="; charset=UTF-8 Subject: [Openvpn-devel] [M] Change in openvpn[master]: Change dev null to be a driver type instead of a special mode of tun/tap List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: plaisthos Cc: flichtenheld , openvpn-devel --BmhMxubk4sk= Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable cron2 has submitted this change. ( http://gerrit.openvpn.net/c/openvpn/+/74= 8?usp=3Demail ) Change subject: Change dev null to be a driver type instead of a special mo= de of tun/tap ...................................................................... Change dev null to be a driver type instead of a special mode of tun/tap Change-Id: I5987ebb7c38ab176eed7efc004ea54f606a77a12 Signed-off-by: Arne Schwabe Acked-by: Gert Doering Message-Id: <20240924124328.3037-1-gert@...1296...> URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg29= 384.html Signed-off-by: Gert Doering --- M src/openvpn/dco.c M src/openvpn/init.c M src/openvpn/proto.h M src/openvpn/tun.c M src/openvpn/tun.h 5 files changed, 92 insertions(+), 113 deletions(-) diff --git a/src/openvpn/dco.c b/src/openvpn/dco.c index 161126b..38f934a 100644 --- a/src/openvpn/dco.c +++ b/src/openvpn/dco.c @@ -305,6 +305,12 @@ return false; } + if (is_dev_type(o->dev, o->dev_type, "null")) + { + msg(msglevel, "Note: null tun type selected, disabling data channe= l offload"); + return false; + } + if (o->connection_list) { const struct connection_list *l =3D o->connection_list; diff --git a/src/openvpn/init.c b/src/openvpn/init.c index 1a14e19..fbf2c5b 100644 --- a/src/openvpn/init.c +++ b/src/openvpn/init.c @@ -1764,6 +1764,10 @@ /* Using AF_UNIX trumps using DCO */ c->c1.tuntap->backend_driver =3D DRIVER_AFUNIX; } + else if (is_dev_type(c->options.dev, c->options.dev_type, "null")) + { + c->c1.tuntap->backend_driver =3D DRIVER_NULL; + } #ifdef _WIN32 else { @@ -1858,7 +1862,12 @@ open_tun_backend(struct context *c) { struct tuntap *tt =3D c->c1.tuntap; - if (tt->backend_driver =3D=3D DRIVER_AFUNIX) + + if (tt->backend_driver =3D=3D DRIVER_NULL) + { + open_tun_null(c->c1.tuntap); + } + else if (tt->backend_driver =3D=3D DRIVER_AFUNIX) { open_tun_afunix(&c->options, c->c2.frame.tun_mtu, tt, c->c2.es); } @@ -2059,6 +2068,11 @@ { close_tun_afunix(c->c1.tuntap); } + else if (c->c1.tuntap->backend_driver =3D=3D DRIVER_NULL) + { + free(c->c1.tuntap->actual_name); + free(c->c1.tuntap); + } else { close_tun(c->c1.tuntap, &c->net_ctx); diff --git a/src/openvpn/proto.h b/src/openvpn/proto.h index 4b6d6d6..a160fb6 100644 --- a/src/openvpn/proto.h +++ b/src/openvpn/proto.h @@ -33,7 +33,6 @@ * Tunnel types */ #define DEV_TYPE_UNDEF 0 -#define DEV_TYPE_NULL 1 #define DEV_TYPE_TUN 2 /* point-to-point IP tunnel */ #define DEV_TYPE_TAP 3 /* ethernet (802.3) tunnel */ diff --git a/src/openvpn/tun.c b/src/openvpn/tun.c index b305b64..770e806 100644 --- a/src/openvpn/tun.c +++ b/src/openvpn/tun.c @@ -75,6 +75,9 @@ case DRIVER_AFUNIX: return "unix"; + case DRIVER_NULL: + return "null"; + case DRIVER_UTUN: return "utun"; @@ -463,7 +466,9 @@ int dev_type_enum(const char *dev, const char *dev_type) { - if (is_dev_type(dev, dev_type, "tun")) + /* We pretend that the null device is also a tun device but it does not + * really matter as it will discard everything anyway */ + if (is_dev_type(dev, dev_type, "tun") || is_dev_type(dev, dev_type, "n= ull")) { return DEV_TYPE_TUN; } @@ -471,10 +476,6 @@ { return DEV_TYPE_TAP; } - else if (is_dev_type(dev, dev_type, "null")) - { - return DEV_TYPE_NULL; - } else { return DEV_TYPE_UNDEF; @@ -492,9 +493,6 @@ case DEV_TYPE_TAP: return "tap"; - case DEV_TYPE_NULL: - return "null"; - default: return "[unknown-dev-type]"; } @@ -768,8 +766,7 @@ bool tun_p2p =3D false; if (tt->type =3D=3D DEV_TYPE_TAP - || (tt->type =3D=3D DEV_TYPE_TUN && tt->topology =3D=3D TOP_SUBNET) - || tt->type =3D=3D DEV_TYPE_NULL) + || (tt->type =3D=3D DEV_TYPE_TUN && tt->topology =3D=3D TOP_SUBNET= )) { tun_p2p =3D false; } @@ -780,7 +777,6 @@ else { msg(M_FATAL, "Error: problem with tun vs. tap setting"); /* JYFIXM= E -- needs to be caught earlier, in init_tun? */ - } return tun_p2p; } @@ -1748,7 +1744,7 @@ void undo_ifconfig(struct tuntap *tt, openvpn_net_ctx_t *ctx) { - if (tt->type !=3D DEV_TYPE_NULL) + if (tt->backend_driver !=3D DRIVER_NULL) { if (tt->did_ifconfig_setup) { @@ -1779,13 +1775,6 @@ #endif } -static void -open_null(struct tuntap *tt) -{ - tt->actual_name =3D string_alloc("null", NULL); -} - - #if defined (TARGET_OPENBSD) || (defined(TARGET_DARWIN) && HAVE_NET_IF_UTU= N_H) /* @@ -1901,78 +1890,72 @@ char dynamic_name[256]; bool dynamic_opened =3D false; - if (tt->type =3D=3D DEV_TYPE_NULL) + /* + * --dev-node specified, so open an explicit device node + */ + if (dev_node) { - open_null(tt); + snprintf(tunname, sizeof(tunname), "%s", dev_node); } else { /* - * --dev-node specified, so open an explicit device node + * dynamic open is indicated by --dev specified without + * explicit unit number. Try opening /dev/[dev]n + * where n =3D [0, 255]. */ - if (dev_node) + + if (!tun_name_is_fixed(dev)) { - snprintf(tunname, sizeof(tunname), "%s", dev_node); + for (int i =3D 0; i < 256; ++i) + { + snprintf(tunname, sizeof(tunname), + "/dev/%s%d", dev, i); + snprintf(dynamic_name, sizeof(dynamic_name), + "%s%d", dev, i); + if ((tt->fd =3D open(tunname, O_RDWR)) > 0) + { + dynamic_opened =3D true; + break; + } + msg(D_READ_WRITE | M_ERRNO, "Tried opening %s (failed)", t= unname); + } + if (!dynamic_opened) + { + msg(M_FATAL, "Cannot allocate TUN/TAP dev dynamically"); + } } + /* + * explicit unit number specified + */ else { - /* - * dynamic open is indicated by --dev specified without - * explicit unit number. Try opening /dev/[dev]n - * where n =3D [0, 255]. - */ - - if (!tun_name_is_fixed(dev)) - { - for (int i =3D 0; i < 256; ++i) - { - snprintf(tunname, sizeof(tunname), - "/dev/%s%d", dev, i); - snprintf(dynamic_name, sizeof(dynamic_name), - "%s%d", dev, i); - if ((tt->fd =3D open(tunname, O_RDWR)) > 0) - { - dynamic_opened =3D true; - break; - } - msg(D_READ_WRITE | M_ERRNO, "Tried opening %s (failed)= ", tunname); - } - if (!dynamic_opened) - { - msg(M_FATAL, "Cannot allocate TUN/TAP dev dynamically"= ); - } - } - /* - * explicit unit number specified - */ - else - { - snprintf(tunname, sizeof(tunname), "/dev/%s", dev); - } + snprintf(tunname, sizeof(tunname), "/dev/%s", dev); } - - if (!dynamic_opened) - { - /* has named device existed before? if so, don't destroy at en= d */ - if (if_nametoindex( dev ) > 0) - { - msg(M_INFO, "TUN/TAP device %s exists previously, keep at = program end", dev ); - tt->persistent_if =3D true; - } - - if ((tt->fd =3D open(tunname, O_RDWR)) < 0) - { - msg(M_ERR, "Cannot open TUN/TAP dev %s", tunname); - } - } - - set_nonblock(tt->fd); - set_cloexec(tt->fd); /* don't pass fd to scripts */ - msg(M_INFO, "TUN/TAP device %s opened", tunname); - - /* tt->actual_name is passed to up and down scripts and used as th= e ifconfig dev name */ - tt->actual_name =3D string_alloc(dynamic_opened ? dynamic_name : d= ev, NULL); } + + if (!dynamic_opened) + { + /* has named device existed before? if so, don't destroy at end */ + if (if_nametoindex( dev ) > 0) + { + msg(M_INFO, "TUN/TAP device %s exists previously, keep at prog= ram end", dev ); + tt->persistent_if =3D true; + } + + if ((tt->fd =3D open(tunname, O_RDWR)) < 0) + { + msg(M_ERR, "Cannot open TUN/TAP dev %s", tunname); + } + } + + set_nonblock(tt->fd); + set_cloexec(tt->fd); /* don't pass fd to scripts */ + msg(M_INFO, "TUN/TAP device %s opened", tunname); + + /* tt->actual_name is passed to up and down scripts and used as the if= config dev name */ + tt->actual_name =3D string_alloc(dynamic_opened ? dynamic_name : dev, = NULL); + } #endif /* !_WIN32 && !TARGET_LINUX && !TARGET_FREEBSD*/ @@ -1984,12 +1967,6 @@ char dynamic_name[256]; bool dynamic_opened =3D false; - if (tt->type =3D=3D DEV_TYPE_NULL) - { - open_null(tt); - return; - } - /* * unlike "open_tun_generic()", DCO on Linux and FreeBSD follows * the device naming model of "non-DCO linux", that is: @@ -2172,14 +2149,7 @@ { struct ifreq ifr; - /* - * We handle --dev null specially, we do not open /dev/null for this. - */ - if (tt->type =3D=3D DEV_TYPE_NULL) - { - open_null(tt); - } - else if (tun_dco_enabled(tt)) + if (tun_dco_enabled(tt)) { open_tun_dco_generic(dev, dev_type, tt, ctx); } @@ -2404,12 +2374,6 @@ */ CLEAR(ifr); - if (tt->type =3D=3D DEV_TYPE_NULL) - { - open_null(tt); - return; - } - if (tt->type =3D=3D DEV_TYPE_TUN) { ip_node =3D "/dev/udp"; @@ -3488,12 +3452,6 @@ char dynamic_name[20]; const char *p; - if (tt->type =3D=3D DEV_TYPE_NULL) - { - open_null(tt); - return; - } - if (tt->type =3D=3D DEV_TYPE_TUN) { msg(M_FATAL, "no support for 'tun' devices on AIX" ); @@ -6835,12 +6793,7 @@ msg( M_INFO, "open_tun"); - if (tt->type =3D=3D DEV_TYPE_NULL) - { - open_null(tt); - return; - } - else if (tt->type !=3D DEV_TYPE_TAP && tt->type !=3D DEV_TYPE_TUN) + if (tt->type !=3D DEV_TYPE_TAP && tt->type !=3D DEV_TYPE_TUN) { msg(M_FATAL|M_NOPREFIX, "Unknown virtual device type: '%s'", dev); } diff --git a/src/openvpn/tun.h b/src/openvpn/tun.h index a38aef0..b2c1b01 100644 --- a/src/openvpn/tun.h +++ b/src/openvpn/tun.h @@ -51,6 +51,7 @@ * This is always defined. We error out if a user tries to open this = type * of backend on unsupported platforms. */ DRIVER_AFUNIX, + DRIVER_NULL, DRIVER_DCO, /** macOS internal tun driver */ DRIVER_UTUN @@ -784,4 +785,10 @@ { return tt && tt->type !=3D DEV_TYPE_UNDEF; } + +static inline void +open_tun_null(struct tuntap *tt) +{ + tt->actual_name =3D string_alloc("null", NULL); +} #endif /* TUN_H */ -- To view, visit http://gerrit.openvpn.net/c/openvpn/+/748?usp=3Demail To unsubscribe, or for help writing mail filters, visit http://gerrit.openv= pn.net/settings Gerrit-Project: openvpn Gerrit-Branch: master Gerrit-Change-Id: I5987ebb7c38ab176eed7efc004ea54f606a77a12 Gerrit-Change-Number: 748 Gerrit-PatchSet: 12 Gerrit-Owner: plaisthos Gerrit-Reviewer: cron2 Gerrit-Reviewer: flichtenheld Gerrit-CC: openvpn-devel Gerrit-MessageType: merged --BmhMxubk4sk= Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable

cron2 submitted this change.

View Change

Change dev null to be a driver type instead of=
 a special mode of tun/tap

Change-Id: I5987ebb7c38ab176eed7efc004ea5= 4f606a77a12
Signed-off-by: Arne Schwabe <arne@...1227...>
Acked= -by: Gert Doering <gert@...1296...>
Message-Id: <20240924124328= .3037-1-gert@...1296...>
URL: https://www.mail-archive.com/openvpn-de= vel@lists.sourceforge.net/msg29384.html
Signed-off-by: Gert Doering <= gert@...1296...>
---
M src/openvpn/dco.c
M src/openvpn/init.cM src/openvpn/proto.h
M src/openvpn/tun.c
M src/openvpn/tun.h
5 = files changed, 92 insertions(+), 113 deletions(-)

diff --git a/src/openvpn/dco.c b/src/openvpn/dco.c
index= 161126b..38f934a 100644
--- a/src/openvpn/dco.c
= +++ b/src/openvpn/dco.c
@@ -305,6 +305,12 @@ return false;
}

+ if (is_dev_type(o-&= gt;dev, o->dev_type, "null"))
+ {
+ msg(msglevel, "Note: null tun type selected, disablin= g data channel offload");
+ return false;
+ }
+<= /span>
if (o->connection_list)
{
const struct connection_list *l =3D o->connection_l= ist;
diff --git a/src/openvpn/init.c b/src/openvpn/init.c
index 1a14e19..fbf2c5b 100644
--- a/src/open= vpn/init.c
+++ b/src/openvpn/init.c
@@ -176= 4,6 +1764,10 @@
/* Using AF_UNIX trumps using DCO = */
c->c1.tuntap->backend_driver =3D DRIVER_A= FUNIX;
}
+ else if (is_dev_type(c->options.dev, c->options.dev_ty= pe, "null"))
+ c-&= gt;c1.tuntap->backend_driver =3D DRIVER_NULL;
+ }
#ifdef _WIN32 else
{
@@ -1858,7 +1862,12= @@
open_tun_backend(struct context *c)
{=
struct tuntap *tt =3D c->c1.tuntap;
- if (tt->backend_driver =3D=3D= DRIVER_AFUNIX)

+
+ if (tt->backend_= driver =3D=3D DRIVER_NULL)
+ {
+ = open_tun_null(c->c1.tuntap);
+ }
+ = else if (tt->backend_driver =3D=3D DRIVER_AFUNIX)
= {
open_tun_afunix(&c->options, c->c2.f= rame.tun_mtu, tt, c->c2.es);
}
@@ -= 2059,6 +2068,11 @@
{
= close_tun_afunix(c->c1.tuntap);
}
+ else if (c->c1.tuntap-= >backend_driver =3D=3D DRIVER_NULL)

+ {
+ free(c->c1.tuntap->actual_name);
+ free(c->c1.tuntap);<= /span>
+ }
= else
{
= close_tun(c->c1.tuntap, &c->net_ctx);
diff --git= a/src/openvpn/proto.h b/src/openvpn/proto.h
index 4b6d6d6.= .a160fb6 100644
--- a/src/openvpn/proto.h
+= ++ b/src/openvpn/proto.h
@@ -33,7 +33,6 @@
= * Tunnel types
*/
#define DEV_TYPE_UND= EF 0
-#define DEV_TYPE_= NULL 1
#define DEV_TYPE_TUN 2 /* point-to-point IP t= unnel */
#define DEV_TYPE_TAP 3 /* ethernet (802.3) t= unnel */

diff --git a/src/openvpn/tun.c b= /src/openvpn/tun.c
index b305b64..770e806 100644
= --- a/src/openvpn/tun.c
+++ b/src/openvpn/tun.c

@@ -75,6 +75,9 @@
case DRIVER_AFUNIX:
return "unix";

+ case DRIVER_NULL= :
+ return= "null";
+<= /span>
case DRIVER_UTUN:
ret= urn "utun";

@@ -463,7 +466,9 @@=
int
dev_type_enum(const char *dev, const= char *dev_type)
{
- if (is_dev_type(dev, dev_type, "tun"))+ /* We pretend that the n= ull device is also a tun device but it does not
+ * really matter as it will discard everyth= ing anyway */
+ if= (is_dev_type(dev, dev_type, "tun") || is_dev_type(dev, dev_type,= "null"))
{
return = DEV_TYPE_TUN;
}
@@ -471,10 +476,6 @@
{
return DEV_TYPE_TAP;<= br> }
- el= se if (is_dev_type(dev, dev_type, "null"))
- {
- return DEV_TYPE_NULL;
- }
else
= {
return DEV_TYPE_UNDEF;
@@ -492= ,9 +493,6 @@
case DEV_TYPE_TAP:
= return "tap";

- case DEV_TYPE_NULL:
- return "null";<= /span>
-
= default:
return "[unknown-dev-type]&q= uot;;
}
@@ -768,8 +766,7 @@
= bool tun_p2p =3D false;

i= f (tt->type =3D=3D DEV_TYPE_TAP
- || (tt->type =3D=3D DEV_TYPE_TUN && tt->= topology =3D=3D TOP_SUBNET)
- || tt->type =3D=3D DEV_TYPE_NULL)
+ || (tt->type =3D=3D DEV_TYPE_TUN = && tt->topology =3D=3D TOP_SUBNET))
{

tun_p2p =3D false;
}
@@ -780,7 +777,6 @@

else
{
msg(M_FATAL, "Error: problem with tun vs. tap se= tting"); /* JYFIXME -- needs to be caught earlier, in init_tun? */
-
}
return tun_p2p;
}
@@ -= 1748,7 +1744,7 @@
void
undo_ifconfig(stru= ct tuntap *tt, openvpn_net_ctx_t *ctx)
{
- if (tt->type !=3D DEV_TYPE_NULL)=
+ if (tt->back= end_driver !=3D DRIVER_NULL)
{
= if (tt->did_ifconfig_setup)
{
@@ -1779,13 +1775,6 @@

#endif
}
-static void<= /span>
-open_null(struct tunta= p *tt)
-{
- tt->actual_name =3D string_a= lloc("null", NULL);

-}
-
<= span style=3D"color: hsl(0, 100%, 40%);">-

#if defined (TA= RGET_OPENBSD) || (defined(TARGET_DARWIN) && HAVE_NET_IF_UTUN_H)

/*
@@ -1901,78 +1890,72 @@<= /span>
char dynamic_name[256];
bool dyna= mic_opened =3D false;

- if (tt->type =3D=3D DEV_TYPE_NULL)
+ /*

+ * --dev-node specified, so open an explicit= device node
+ */=
+ if (dev_node)
{
-= open_null(tt);
= - * --dev-node specified, so open an explicit device node+ * dynamic open is in= dicated by --dev specified without
+ * explicit unit number. Try opening /dev/[dev]n
+ * where n =3D= [0, 255].
*/
- if (dev_node)
+
= + if (!tun_name_is_fixed(dev))
{
= - snprintf(tunname, si= zeof(tunname), "%s", dev_node);
+ for (int i =3D 0; i < 256; ++i)=
+ {
+ snprintf(tunname= , sizeof(tunname),

+ = "/dev/%s%d", dev, i);
+ snprintf(dynamic_name, = sizeof(dynamic_name),
+ "%s%d", dev, i);
+ if ((tt->fd =3D open(t= unname, O_RDWR)) > 0)
+ {
+ break;
+ }
+ msg(D_READ_WRITE | M_ERRN= O, "Tried opening %s (failed)", tunname);
+ }
+ if (!dynamic_opened)
+ {

+ msg(M_FATAL, "Canno= t allocate TUN/TAP dev dynamically");
+ }
}
<= span style=3D"color: hsl(120, 100%, 40%);">+ /*

+ * explicit unit number specifie= d
+ */=
else
{
- /*
- * dynamic open is indicated by --dev spe= cified without
- = * explicit unit number. Try opening /dev/[dev]n
- * where n =3D [0, 255].
- */
<= span style=3D"color: hsl(0, 100%, 40%);">-

- if (!tun_name_is_fixed(dev))
- {

- for (int i =3D 0; i < 25= 6; ++i)
- = {
- = snprintf(tunname, sizeof(tunname),
- "/dev/%s%d", dev, i);=
- s= nprintf(dynamic_name, sizeof(dynamic_name),
- "%s%d", dev, i= );
- = if ((tt->fd =3D open(tunname, O_RDWR)) > 0)
- {
- dynamic_opened =3D tru= e;
- = break;
- = }
- = msg(D_READ_WRITE | M_ERRNO, "Tried opening %s (failed)"= , tunname);
- = }
- = if (!dynamic_opened)
= - {
- = msg(M_FATAL, "Cannot allocate TUN/TAP dev dynamically= ");
- = }
- }
- /*
= - * explicit unit num= ber specified
- = */
- el= se
- {
- snprintf(tu= nname, sizeof(tunname), "/dev/%s", dev);
- }
+ snprintf(tunname, sizeof(tunname), "= ;/dev/%s", dev);
}
-
- if (!dynamic_opened)
- {
= - /* has named device existed before? if so, don't destroy a= t end */
- i= f (if_nametoindex( dev ) > 0)
- {
- tt->persistent_if =3D true;
- }
-
- if ((tt->fd =3D open(tunname, O_RDWR)) < 0)=
- {
- msg(M_ERR, "Can= not open TUN/TAP dev %s", tunname);

- }
- }
-<= /span>
- set_nonblock(t= t->fd);
- set= _cloexec(tt->fd); /* don't pass fd to scripts */
- msg(M_INFO, "TUN/TAP device = %s opened", tunname);
-
- /* tt-&g= t;actual_name is passed to up and down scripts and used as the ifconfig dev= name */
- tt-&g= t;actual_name =3D string_alloc(dynamic_opened ? dynamic_name : dev, NULL);<= /span>
}
+ if (!dynamic= _opened)
+ {
+ /* has named devi= ce existed before? if so, don't destroy at end */
+ if (if_nametoindex( dev ) > 0)=
+ {+ msg(M_INFO, "= ;TUN/TAP device %s exists previously, keep at program end", dev );
+ tt->pers= istent_if =3D true;
+= }
++ if ((tt->fd =3D op= en(tunname, O_RDWR)) < 0)
+ {
+ = msg(M_ERR, "Cannot open TUN/TAP dev %s", tunname);
+ }
+ }

+
+ set_nonblock(tt->fd);
+ set_cloexec(tt->fd); /* don't pass fd to scrip= ts */
+ msg(M_INFO= , "TUN/TAP device %s opened", tunname);
+
+ /* tt->actual_name is passed to up and down scripts and u= sed as the ifconfig dev name */
+ tt->actual_name =3D string_alloc(dynamic_opened ? dynami= c_name : dev, NULL);
= +
}
#endif /* !_WIN32 && !TARGET_= LINUX && !TARGET_FREEBSD*/

@@ -19= 84,12 +1967,6 @@
char dynamic_name[256];
bool dynamic_opened =3D false;


- if (tt->type =3D=3D DEV_TYPE_NULL= )
- {
- open_null(tt);

- return;

- }
-
/*
* unlike &= quot;open_tun_generic()", DCO on Linux and FreeBSD follows
<= span> * the device naming model of "non-DCO linux", that is:=

@@ -2172,14 +2149,7 @@
{
= struct ifreq ifr;

- /*
- * We handle --dev null specially, we do not open /dev/null for thi= s.
- */
<= span style=3D"color: hsl(0, 100%, 40%);">- if (tt->type =3D=3D DEV_TY= PE_NULL)

- {<= br>- open_null(tt);=
- }
- else if (tun_dco_enabled(tt))+ if (tun_dco_enabled(tt))<= /span>
{
open_tun_dco_generic(dev, d= ev_type, tt, ctx);
}
@@ -2404,12 +2374= ,6 @@
*/
CLEAR(ifr);
<= span>

- if (tt->= type =3D=3D DEV_TYPE_NULL)
- {
- ope= n_null(tt);
- re= turn;
- }
= -
if (tt->= ;type =3D=3D DEV_TYPE_TUN)
{
= ip_node =3D "/dev/udp";
@@ -3488,12 +3452,6 @@
char dynamic_name[20];
const char *= p;

- = if (tt->type =3D=3D DEV_TYPE_NULL)
- {
- return;
- = }
-
= if (tt->type =3D=3D DEV_TYPE_TUN)
{
<= span> msg(M_FATAL, "no support for 'tun' devices on AI= X" );

@@ -6835,12 +6793,7 @@
<= br> msg( M_INFO, "open_tun");
<= br>- if (tt->type =3D=3D DE= V_TYPE_NULL)
- {
- open_null(tt);
- return;- }
- else if (tt->type !=3D DEV_TYPE_TAP &am= p;& tt->type !=3D DEV_TYPE_TUN)
+ if (tt->type !=3D DEV_TYPE_TAP && tt->= type !=3D DEV_TYPE_TUN)
{
msg= (M_FATAL|M_NOPREFIX, "Unknown virtual device type: '%s'",= dev);
}
diff --git a/src/openvpn/tun.= h b/src/openvpn/tun.h
index a38aef0..b2c1b01 100644<= br>--- a/src/openvpn/tun.h
+++ b/src/openvpn/tun.h
@@ -51,6 +51,7 @@
* This is always def= ined. We error out if a user tries to open this type
= * of backend on unsupported platforms. */
DRIVER_AFUN= IX,
+ DRIVER_NULL,=
DRIVER_DCO,
/** macOS internal t= un driver */
DRIVER_UTUN
@@ -784,4 +78= 5,10 @@
{
return tt && tt->= ;type !=3D DEV_TYPE_UNDEF;
}
+
+static inline void
+open_tun_null(struct tuntap *tt)
+{
= + tt->actual_name =3D string_alloc("null", NULL);+}
#endif /* = TUN_H */

To view, visit change 748. To unsub= scribe, or for help writing mail filters, visit settings.

Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I5987ebb7c38ab176eed7efc004e= a54f606a77a12
Gerrit-Change-Number: 748
Gerrit-PatchSet: 12
Gerrit-Owner: plaisthos <arne-openvpn@...1711...= 27...>
Gerrit-Reviewer: cron2 <gert@...1296...>=
Gerrit-Reviewer: flichtenheld <frank@...2716...= 1...>
Gerrit-CC: openvpn-devel <openvpn-devel@...1484...= ts.sourceforge.net>
Gerrit-MessageType: merged
--BmhMxubk4sk=--