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
44
45
|
$NetBSD: patch-ac,v 1.1 2005/02/21 23:26:24 bad Exp $
--- tun.c.orig Thu Apr 1 13:54:57 2004
+++ tun.c Tue Feb 22 00:14:00 2005
@@ -579,7 +579,13 @@
tun_mtu
);
else
- no_tap_ifconfig ();
+ openvpn_snprintf (command_line, sizeof (command_line),
+ IFCONFIG_PATH " %s %s netmask %s mtu %d up",
+ actual,
+ ifconfig_local,
+ ifconfig_remote_netmask,
+ tun_mtu
+ );
msg (M_INFO, "%s", command_line);
system_check (command_line, "NetBSD ifconfig failed", true);
tt->did_ifconfig = true;
@@ -1263,6 +1269,25 @@
int
write_tun (struct tuntap* tt, uint8_t *buf, int len)
{
+ if (tt->type == DEV_TYPE_TAP)
+ {
+ /* NetBSD's /dev/tap doesn't pad ethernet frames to the minimum length. */
+ ssize_t rv;
+ struct iovec iv[2];
+ char pad[ETHER_MIN_LEN];
+
+ iv[0].iov_base = buf;
+ iv[0].iov_len = len;
+ iv[1].iov_base = &pad;
+ iv[1].iov_len = ETHER_MIN_LEN - len;
+
+ rv = writev(tt->fd, iv, (len < ETHER_MIN_LEN) ? 2 : 1);
+ if (rv > len)
+ return len;
+ else
+ return rv;
+ }
+ else
return write (tt->fd, buf, len);
}
|