aboutsummaryrefslogtreecommitdiffstats
path: root/security/openvpn-devel/files/patch-tun.c
blob: d2ebe6de6d014f3280dd99698a243f1fb26fa1a1 (plain) (blame)
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
# This patch by Stefan Bethke fixes FreeBSD 8 compatibility
# in topology subnet mode, # and makes sure that the tun interface is
# correctly configured. Contact: stb at lassitu dot de

--- /home/stb/tun.c.orig    2009-08-05 14:25:55.204943408 +0200
+++ tun.c   2009-08-05 17:57:51.886753309 +0200
@@ -863,11 +863,10 @@
       else {
    if (tt->topology == TOP_SUBNET)
             argv_printf (&argv,
-                              "%s %s %s %s netmask %s mtu %d up",
+                              "%s %s %s netmask %s mtu %d up",
                               IFCONFIG_PATH,
                               actual,
                               ifconfig_local,
-                              ifconfig_local,
                               ifconfig_remote_netmask,
                               tun_mtu
                               );
@@ -1745,14 +1744,19 @@
 {
   open_tun_generic (dev, dev_type, dev_node, ipv6, true, true, tt);
 
-  if (tt->fd >= 0)
+  if (tt->fd >= 0 && tt->type == DEV_TYPE_TUN)
     {
       int i = 0;
 
-      /* Disable extended modes */
-      ioctl (tt->fd, TUNSLMODE, &i);
+      i = tt->topology == TOP_SUBNET ? IFF_BROADCAST : IFF_POINTOPOINT;
+      i |= IFF_MULTICAST;
+      if (ioctl (tt->fd, TUNSIFMODE, &i) < 0) {
+   msg (M_WARN | M_ERRNO, "ioctl(TUNSIFMODE): %s", strerror(errno));
+      }
       i = 1;
-      ioctl (tt->fd, TUNSIFHEAD, &i);
+      if (ioctl (tt->fd, TUNSIFHEAD, &i) < 0) {
+   msg (M_WARN | M_ERRNO, "ioctl(TUNSIFHEAD): %s", strerror(errno));
+      }
     }
 }