1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
$NetBSD: patch-ac,v 1.4 2007/02/20 09:40:49 sborrill Exp $
--- tun.c.orig 2006-10-15 23:30:20.000000000 +0100
+++ tun.c 2007-02-12 10:52:42.000000000 +0000
@@ -945,7 +945,37 @@
if (dynamic && !has_digit((unsigned char *)dev))
{
int i;
- for (i = 0; i < 256; ++i)
+#if defined(TAPGIFNAME)
+ /*
+ * Perhaps we have a cloning device. Try opening
+ * the device without any appended digits,
+ * and use ioctl(,TAPGIFNAME,) to get the resulting
+ * interface name.
+ */
+ openvpn_snprintf (tunname, sizeof (tunname), "/dev/%s", dev);
+ if ((tt->fd = open (tunname, O_RDWR)) > 0)
+ {
+ struct ifreq ifr;
+ if (ioctl (tt->fd, TAPGIFNAME, (void*)&ifr) < 0)
+ {
+ msg (D_READ_WRITE | M_ERRNO,
+ "ioctl(,TAPGIFNAME,) failed for %s", tunname);
+ close(tt->fd);
+ }
+ else
+ {
+ strlcpy (dynamic_name, ifr.ifr_name,
+ sizeof (dynamic_name));
+ dynamic_opened = true;
+ msg (M_INFO, "TUN/TAP dynamic interface %s opened",
+ dynamic_name);
+ }
+ }
+ if (!dynamic_opened)
+ msg (D_READ_WRITE | M_ERRNO, "Tried opening %s (failed)",
+ tunname);
+#endif /* TAPGIFNAME */
+ for (i = 0; i < 256 && !dynamic_opened; ++i)
{
openvpn_snprintf (tunname, sizeof (tunname),
"/dev/%s%d", dev, i);
|