--- gvpe/src/vpn.C 2005/03/05 19:13:16 1.31 +++ gvpe/src/vpn.C 2005/03/23 21:55:39 1.33 @@ -48,7 +48,8 @@ ///////////////////////////////////////////////////////////////////////////// -const char *vpn::script_if_up () +void +vpn::script_init_env () { // the tunnel device mtu should be the physical mtu - overhead // the tricky part is rounding to the cipher key blocksize @@ -67,10 +68,29 @@ asprintf (&env, "MTU=%d", mtu); putenv (env); asprintf (&env, "MAC=%02x:%02x:%02x:%02x:%02x:%02x", 0xfe, 0xfd, 0x80, 0x00, THISNODE->id >> 8, - THISNODE->id & 0xff); - putenv (env); + THISNODE->id & 0xff); putenv (env); + + // TODO: info for other nodes, maybe? +} + +const char *vpn::script_if_init () +{ + script_init_env (); + + return tap->if_up (); +} - return ::conf.script_if_up ? ::conf.script_if_up : "if-up"; +const char *vpn::script_if_up () +{ + script_init_env (); + + char *filename; + asprintf (&filename, + "%s/%s", + confbase, + ::conf.script_if_up ? ::conf.script_if_up : "if-up"); + + return filename; } int @@ -237,6 +257,16 @@ if (dnsv4_fd < 0) return -1; +#if defined(SOL_IP) && defined(IP_MTU_DISCOVER) + // this I really consider a linux bug. I am neither connected + // nor do I fragment myself. Linux still sets DF and doesn't + // fragment for me sometimes. + { + int oval = IP_PMTUDISC_DONT; + setsockopt (udpv4_fd, SOL_IP, IP_MTU_DISCOVER, &oval, sizeof oval); + } +#endif + // standard daemon practise... { int oval = 1; @@ -264,7 +294,19 @@ exit (EXIT_FAILURE); } - run_script (run_script_cb (this, &vpn::script_if_up), true); + if (tap->if_up () && + !run_script (run_script_cb (this, &vpn::script_if_init), true)) + { + slog (L_ERR, _("interface initialization command '%s' failed, exiting."), + tap->if_up ()); + exit (EXIT_FAILURE); + } + + if (!run_script (run_script_cb (this, &vpn::script_if_up), true)) + { + slog (L_ERR, _("if-up command execution failed, exiting.")); + exit (EXIT_FAILURE); + } tap_ev_watcher.start (tap->fd, EVENT_READ);