1 |
blueness 11/12/21 17:32:22 |
2 |
|
3 |
Added: fix-missing-vde.patch fix-compile-vde-uml.patch |
4 |
Log: |
5 |
Added USE flags for raw, uml and vde sockets, bug #371131 |
6 |
|
7 |
(Portage version: 2.1.10.41/cvs/Linux x86_64) |
8 |
|
9 |
Revision Changes Path |
10 |
1.1 net-misc/tinc/files/fix-missing-vde.patch |
11 |
|
12 |
file : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/net-misc/tinc/files/fix-missing-vde.patch?rev=1.1&view=markup |
13 |
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-x86/net-misc/tinc/files/fix-missing-vde.patch?rev=1.1&content-type=text/plain |
14 |
|
15 |
Index: fix-missing-vde.patch |
16 |
=================================================================== |
17 |
diff -Naur src/vde/device.c src/vde/device.c |
18 |
--- src/vde/device.c 1969-12-31 19:00:00.000000000 -0500 |
19 |
+++ src/vde/device.c 2011-12-21 11:20:34.000000000 -0500 |
20 |
@@ -0,0 +1,134 @@ |
21 |
+/* |
22 |
+ device.c -- VDE plug |
23 |
+ Copyright (C) 2011 Guus Sliepen <guus@××××××××.org> |
24 |
+ |
25 |
+ This program is free software; you can redistribute it and/or modify |
26 |
+ it under the terms of the GNU General Public License as published by |
27 |
+ the Free Software Foundation; either version 2 of the License, or |
28 |
+ (at your option) any later version. |
29 |
+ |
30 |
+ This program is distributed in the hope that it will be useful, |
31 |
+ but WITHOUT ANY WARRANTY; without even the implied warranty of |
32 |
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
33 |
+ GNU General Public License for more details. |
34 |
+ |
35 |
+ You should have received a copy of the GNU General Public License along |
36 |
+ with this program; if not, write to the Free Software Foundation, Inc., |
37 |
+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
38 |
+*/ |
39 |
+ |
40 |
+#include "system.h" |
41 |
+ |
42 |
+#include <libvdeplug_dyn.h> |
43 |
+ |
44 |
+#include "conf.h" |
45 |
+#include "device.h" |
46 |
+#include "net.h" |
47 |
+#include "logger.h" |
48 |
+#include "utils.h" |
49 |
+#include "route.h" |
50 |
+#include "xalloc.h" |
51 |
+ |
52 |
+int device_fd = -1; |
53 |
+static struct vdepluglib plug; |
54 |
+static struct vdeconn *conn = NULL; |
55 |
+static int port = 0; |
56 |
+static char *group = NULL; |
57 |
+char *device = NULL; |
58 |
+char *iface = NULL; |
59 |
+static char *device_info; |
60 |
+ |
61 |
+extern char *identname; |
62 |
+extern bool running; |
63 |
+ |
64 |
+static uint64_t device_total_in = 0; |
65 |
+static uint64_t device_total_out = 0; |
66 |
+ |
67 |
+bool setup_device(void) { |
68 |
+ libvdeplug_dynopen(plug); |
69 |
+ |
70 |
+ if(!plug.dl_handle) { |
71 |
+ logger(LOG_ERR, "Could not open libvdeplug library!"); |
72 |
+ return false; |
73 |
+ } |
74 |
+ |
75 |
+ if(!get_config_string(lookup_config(config_tree, "Device"), &device)) |
76 |
+ xasprintf(&device, LOCALSTATEDIR "/run/vde.ctl"); |
77 |
+ |
78 |
+ get_config_string(lookup_config(config_tree, "Interface"), &iface); |
79 |
+ |
80 |
+ get_config_int(lookup_config(config_tree, "VDEPort"), &port); |
81 |
+ |
82 |
+ get_config_string(lookup_config(config_tree, "VDEGroup"), &group); |
83 |
+ |
84 |
+ device_info = "VDE socket"; |
85 |
+ |
86 |
+ struct vde_open_args args = { |
87 |
+ .port = port, |
88 |
+ .group = group, |
89 |
+ .mode = 0700, |
90 |
+ }; |
91 |
+ |
92 |
+ conn = plug.vde_open(device, identname, &args); |
93 |
+ if(!conn) { |
94 |
+ logger(LOG_ERR, "Could not open VDE socket %s", device); |
95 |
+ return false; |
96 |
+ } |
97 |
+ |
98 |
+ device_fd = plug.vde_datafd(conn); |
99 |
+ |
100 |
+ logger(LOG_INFO, "%s is a %s", device, device_info); |
101 |
+ |
102 |
+ if(routing_mode == RMODE_ROUTER) |
103 |
+ overwrite_mac = true; |
104 |
+ |
105 |
+ return true; |
106 |
+} |
107 |
+ |
108 |
+void close_device(void) { |
109 |
+ if(conn) |
110 |
+ plug.vde_close(conn); |
111 |
+ |
112 |
+ if(plug.dl_handle) |
113 |
+ libvdeplug_dynclose(plug); |
114 |
+ |
115 |
+ free(device); |
116 |
+ |
117 |
+ free(iface); |
118 |
+} |
119 |
+ |
120 |
+bool read_packet(vpn_packet_t *packet) { |
121 |
+ int lenin = plug.vde_recv(conn, packet->data, MTU, 0); |
122 |
+ if(lenin <= 0) { |
123 |
+ logger(LOG_ERR, "Error while reading from %s %s: %s", device_info, device, strerror(errno)); |
124 |
+ running = false; |
125 |
+ return false; |
126 |
+ } |
127 |
+ |
128 |
+ packet->len = lenin; |
129 |
+ device_total_in += packet->len; |
130 |
+ ifdebug(TRAFFIC) logger(LOG_DEBUG, "Read packet of %d bytes from %s", packet->len, device_info); |
131 |
+ |
132 |
+ return true; |
133 |
+} |
134 |
+ |
135 |
+bool write_packet(vpn_packet_t *packet) { |
136 |
+ if(plug.vde_send(conn, packet->data, packet->len, 0) < 0) { |
137 |
+ if(errno != EINTR && errno != EAGAIN) { |
138 |
+ logger(LOG_ERR, "Can't write to %s %s: %s", device_info, device, strerror(errno)); |
139 |
+ running = false; |
140 |
+ } |
141 |
+ |
142 |
+ return false; |
143 |
+ } |
144 |
+ |
145 |
+ device_total_out += packet->len; |
146 |
+ |
147 |
+ return true; |
148 |
+} |
149 |
+ |
150 |
+void dump_device_stats(void) { |
151 |
+ logger(LOG_DEBUG, "Statistics for %s %s:", device_info, device); |
152 |
+ logger(LOG_DEBUG, " total bytes in: %10"PRIu64, device_total_in); |
153 |
+ logger(LOG_DEBUG, " total bytes out: %10"PRIu64, device_total_out); |
154 |
+} |
155 |
|
156 |
|
157 |
|
158 |
1.1 net-misc/tinc/files/fix-compile-vde-uml.patch |
159 |
|
160 |
file : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/net-misc/tinc/files/fix-compile-vde-uml.patch?rev=1.1&view=markup |
161 |
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-x86/net-misc/tinc/files/fix-compile-vde-uml.patch?rev=1.1&content-type=text/plain |
162 |
|
163 |
Index: fix-compile-vde-uml.patch |
164 |
=================================================================== |
165 |
diff --git a/src/uml_socket/device.c b/src/uml_socket/device.c |
166 |
index a2da757..a371e7b 100644 |
167 |
--- a/src/uml_socket/device.c |
168 |
+++ b/src/uml_socket/device.c |
169 |
@@ -28,6 +28,7 @@ |
170 |
#include "logger.h" |
171 |
#include "utils.h" |
172 |
#include "route.h" |
173 |
+#include "xalloc.h" |
174 |
|
175 |
int device_fd = -1; |
176 |
static int listen_fd = -1; |
177 |
@@ -40,7 +41,7 @@ char *iface = NULL; |
178 |
static char *device_info; |
179 |
|
180 |
extern char *identname; |
181 |
-extern bool running; |
182 |
+extern volatile bool running; |
183 |
|
184 |
static uint64_t device_total_in = 0; |
185 |
static uint64_t device_total_out = 0; |
186 |
@@ -175,7 +176,7 @@ bool read_packet(vpn_packet_t *packet) { |
187 |
switch(state) { |
188 |
case 0: { |
189 |
struct sockaddr sa; |
190 |
- int salen = sizeof sa; |
191 |
+ socklen_t salen = sizeof sa; |
192 |
|
193 |
request_fd = accept(listen_fd, &sa, &salen); |
194 |
if(request_fd < 0) { |
195 |
@@ -244,6 +245,10 @@ bool read_packet(vpn_packet_t *packet) { |
196 |
|
197 |
return true; |
198 |
} |
199 |
+ |
200 |
+ default: |
201 |
+ logger(LOG_ERR, "Invalid value for state variable in " __FILE__); |
202 |
+ abort(); |
203 |
} |
204 |
} |
205 |
|
206 |
diff --git a/src/vde/device.c b/src/vde/device.c |
207 |
index 63171f9..74cf3b6 100644 |
208 |
--- a/src/vde/device.c |
209 |
+++ b/src/vde/device.c |
210 |
@@ -39,7 +39,7 @@ char *iface = NULL; |
211 |
static char *device_info; |
212 |
|
213 |
extern char *identname; |
214 |
-extern bool running; |
215 |
+extern volatile bool running; |
216 |
|
217 |
static uint64_t device_total_in = 0; |
218 |
static uint64_t device_total_out = 0; |