Skip to content

Commit 9c2e0a2

Browse files
committed
Merge OpenVPN 3 Core version 3.11.6
Issues fixed in this release: * Create DCO virtual interfaces with dynamic names instead of a single configuration based hard-coded device name. Signed-off-by: David Sommerseth <dazo@eurephia.org>
2 parents 94b9a79 + 5b7841a commit 9c2e0a2

1 file changed

Lines changed: 38 additions & 3 deletions

File tree

openvpn/dco/ovpndcocli.hpp

Lines changed: 38 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -547,12 +547,47 @@ class OvpnDcoClient : public Client,
547547
return;
548548
}
549549

550-
std::ostringstream os;
551-
int res = TunNetlink::iface_new(os, config->dev_name, OVPN_FAMILY_NAME);
550+
int res = -ENOENT;
551+
const int max_units = 256;
552+
// attempt creating the device using the provided name, in case
553+
// of error append a counter starting at 1 and try again until 256.
554+
for (int unit = 0; unit < max_units; ++unit)
555+
{
556+
std::string n = config->dev_name;
557+
if (unit)
558+
n += openvpn::to_string(unit);
559+
if (n.length() >= IFNAMSIZ)
560+
{
561+
stop_();
562+
transport_parent->transport_error(Error::TUN_IFACE_CREATE,
563+
"DCO: ifname name too long: " + n);
564+
return;
565+
}
566+
567+
568+
OPENVPN_LOG("DCO: attempting to open iface " + n);
569+
570+
std::ostringstream os;
571+
res = TunNetlink::iface_new(os, n, OVPN_FAMILY_NAME);
572+
if (res)
573+
{
574+
OPENVPN_LOG("DCO: couldn't open iface " + n + ": " << os.str());
575+
continue;
576+
}
577+
578+
// iface creation was successful
579+
config->dev_name = n;
580+
break;
581+
}
582+
583+
// no successful creation. bail out
552584
if (res != 0)
553585
{
554586
stop_();
555-
transport_parent->transport_error(Error::TUN_IFACE_CREATE, os.str());
587+
transport_parent->transport_error(Error::TUN_IFACE_CREATE,
588+
"DCO: failed to open iface " + config->dev_name
589+
+ " after trying " + openvpn::to_string(max_units)
590+
+ " units");
556591
return;
557592
}
558593

0 commit comments

Comments
 (0)