ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/gvpe/src/vpn.C
(Generate patch)

Comparing gvpe/src/vpn.C (file contents):
Revision 1.34 by pcg, Sat Mar 26 03:16:24 2005 UTC vs.
Revision 1.38 by pcg, Tue Apr 26 00:55:56 2005 UTC

14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details. 15 GNU General Public License for more details.
16 16
17 You should have received a copy of the GNU General Public License 17 You should have received a copy of the GNU General Public License
18 along with gvpe; if not, write to the Free Software 18 along with gvpe; if not, write to the Free Software
19 Foundation, Inc. 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 Foundation, Inc. 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20*/ 20*/
21 21
22#include "config.h" 22#include "config.h"
23 23
24#include <list> 24#include <list>
108 108
109 if (ipv4_fd < 0) 109 if (ipv4_fd < 0)
110 return -1; 110 return -1;
111 111
112 fcntl (ipv4_fd, F_SETFL, O_NONBLOCK); 112 fcntl (ipv4_fd, F_SETFL, O_NONBLOCK);
113 fcntl (ipv4_fd, F_SETFD, FD_CLOEXEC);
113 114
114#if defined(SOL_IP) && defined(IP_MTU_DISCOVER) 115#if defined(SOL_IP) && defined(IP_MTU_DISCOVER)
115 // this I really consider a linux bug. I am neither connected 116 // this I really consider a linux bug. I am neither connected
116 // nor do I fragment myself. Linux still sets DF and doesn't 117 // nor do I fragment myself. Linux still sets DF and doesn't
117 // fragment for me sometimes. 118 // fragment for me sometimes.
140 141
141 if (udpv4_fd < 0) 142 if (udpv4_fd < 0)
142 return -1; 143 return -1;
143 144
144 fcntl (udpv4_fd, F_SETFL, O_NONBLOCK); 145 fcntl (udpv4_fd, F_SETFL, O_NONBLOCK);
146 fcntl (udpv4_fd, F_SETFD, FD_CLOEXEC);
145 147
146 // standard daemon practise... 148 // standard daemon practise...
147 { 149 {
148 int oval = 1; 150 int oval = 1;
149 setsockopt (udpv4_fd, SOL_SOCKET, SO_REUSEADDR, &oval, sizeof oval); 151 setsockopt (udpv4_fd, SOL_SOCKET, SO_REUSEADDR, &oval, sizeof oval);
179 181
180 if (icmpv4_fd < 0) 182 if (icmpv4_fd < 0)
181 return -1; 183 return -1;
182 184
183 fcntl (icmpv4_fd, F_SETFL, O_NONBLOCK); 185 fcntl (icmpv4_fd, F_SETFL, O_NONBLOCK);
186 fcntl (icmpv4_fd, F_SETFD, FD_CLOEXEC);
184 187
185#ifdef ICMP_FILTER 188#ifdef ICMP_FILTER
186 { 189 {
187 icmp_filter oval; 190 icmp_filter oval;
188 oval.data = 0xffffffff; 191 oval.data = 0xffffffff;
197 // this I really consider a linux bug. I am neither connected 200 // this I really consider a linux bug. I am neither connected
198 // nor do I fragment myself. Linux still sets DF and doesn't 201 // nor do I fragment myself. Linux still sets DF and doesn't
199 // fragment for me sometimes. 202 // fragment for me sometimes.
200 { 203 {
201 int oval = IP_PMTUDISC_DONT; 204 int oval = IP_PMTUDISC_DONT;
202 setsockopt (udpv4_fd, SOL_IP, IP_MTU_DISCOVER, &oval, sizeof oval); 205 setsockopt (icmpv4_fd, SOL_IP, IP_MTU_DISCOVER, &oval, sizeof oval);
203 } 206 }
204#endif 207#endif
205 208
206 sockinfo si (THISNODE, PROT_ICMPv4); 209 sockinfo si (THISNODE, PROT_ICMPv4);
207 210
224 227
225 if (tcpv4_fd < 0) 228 if (tcpv4_fd < 0)
226 return -1; 229 return -1;
227 230
228 fcntl (tcpv4_fd, F_SETFL, O_NONBLOCK); 231 fcntl (tcpv4_fd, F_SETFL, O_NONBLOCK);
232 fcntl (tcpv4_fd, F_SETFD, FD_CLOEXEC);
229 233
230 // standard daemon practise... 234 // standard daemon practise...
231 { 235 {
232 int oval = 1; 236 int oval = 1;
233 setsockopt (tcpv4_fd, SOL_SOCKET, SO_REUSEADDR, &oval, sizeof oval); 237 setsockopt (tcpv4_fd, SOL_SOCKET, SO_REUSEADDR, &oval, sizeof oval);
259 dnsv4_fd = socket (PF_INET, SOCK_DGRAM, IPPROTO_UDP); 263 dnsv4_fd = socket (PF_INET, SOCK_DGRAM, IPPROTO_UDP);
260 264
261 if (dnsv4_fd < 0) 265 if (dnsv4_fd < 0)
262 return -1; 266 return -1;
263 267
268 fcntl (dnsv4_fd, F_SETFL, O_NONBLOCK);
269 fcntl (dnsv4_fd, F_SETFD, FD_CLOEXEC);
270
264#if defined(SOL_IP) && defined(IP_MTU_DISCOVER) 271# if defined(SOL_IP) && defined(IP_MTU_DISCOVER)
265 // this I really consider a linux bug. I am neither connected 272 // this I really consider a linux bug. I am neither connected
266 // nor do I fragment myself. Linux still sets DF and doesn't 273 // nor do I fragment myself. Linux still sets DF and doesn't
267 // fragment for me sometimes. 274 // fragment for me sometimes.
268 { 275 {
269 int oval = IP_PMTUDISC_DONT; 276 int oval = IP_PMTUDISC_DONT;
270 setsockopt (udpv4_fd, SOL_IP, IP_MTU_DISCOVER, &oval, sizeof oval); 277 setsockopt (dnsv4_fd, SOL_IP, IP_MTU_DISCOVER, &oval, sizeof oval);
271 } 278 }
272#endif 279# endif
273 280
274 // standard daemon practise... 281 // standard daemon practise...
275 { 282 {
276 int oval = 1; 283 int oval = 1;
277 setsockopt (dnsv4_fd, SOL_SOCKET, SO_REUSEADDR, &oval, sizeof oval); 284 setsockopt (dnsv4_fd, SOL_SOCKET, SO_REUSEADDR, &oval, sizeof oval);
302 { 309 {
303 slog (L_ERR, _("cannot create network interface '%s'"), conf.ifname); 310 slog (L_ERR, _("cannot create network interface '%s'"), conf.ifname);
304 exit (EXIT_FAILURE); 311 exit (EXIT_FAILURE);
305 } 312 }
306 313
314 fcntl (tap->fd, F_SETFD, FD_CLOEXEC);
315
307 if (tap->if_up () && 316 if (tap->if_up () &&
308 !run_script (run_script_cb (this, &vpn::script_if_init), true)) 317 !run_script (run_script_cb (this, &vpn::script_if_init), true))
309 { 318 {
310 slog (L_ERR, _("interface initialization command '%s' failed, exiting."), 319 slog (L_ERR, _("interface initialization command '%s' failed, exiting."),
311 tap->if_up ()); 320 tap->if_up ());

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines