unstick r371

Revision 371

Date:
2008/11/19 20:55:28
Author:
Joerg Mayer
Revision Log:
Fix the order of steps when shutting down. Otherwise we would
get an error message when doing split tunneling.
Files:

Legend:

 
Added
 
Removed
 
Modified
  • tags/vpnc-0.5.3/tunip.c

     
    946 946
    947 947 }
    948 948
    949 tun_close(s->tun_fd, s->tun_name);
    950 949 switch (do_kill) {
    951 950 case -2:
    952 951 syslog(LOG_NOTICE, "connection terminated by dead peer detection");
  • tags/vpnc-0.5.3/vpnc-script.in

     
    473 473 }
    474 474
    475 475 do_disconnect() {
    476 destroy_tun_device
    477 476 if [ -n "$CISCO_SPLIT_INC" ]; then
    478 477 i=0
    479 478 while [ $i -lt $CISCO_SPLIT_INC ] ; do
     
    501 500 if [ -n "$INTERNAL_IP4_DNS" ]; then
    502 501 $RESTORERESOLVCONF
    503 502 fi
    503 destroy_tun_device
    504 504 }
    505 505
    506 506 #### Main
  • tags/vpnc-0.5.3/vpnc.c

     
    363 363 system(config[CONFIG_SCRIPT]);
    364 364 }
    365 365
    366 static void close_tunnel()
    366 static void close_tunnel(struct sa_block *s)
    367 367 {
    368 368 setenv("reason", "disconnect", 1);
    369 369 system(config[CONFIG_SCRIPT]);
    370 tun_close(s->tun_fd, s->tun_name);
    370 371 }
    371 372
    372 373 static int recv_ignore_dup(struct sa_block *s, void *recvbuf, size_t recvbufsize)
     
    2873 2874
    2874 2875 s->esp_fd = socket(PF_INET, SOCK_RAW, IPPROTO_ESP);
    2875 2876 if (s->esp_fd == -1) {
    2876 close_tunnel();
    2877 close_tunnel(s);
    2877 2878 error(1, errno, "Couldn't open socket of ESP. Maybe something registered ESP already.\nPlease try '--natt-mode force-natt' or disable whatever is using ESP.\nsocket(PF_INET, SOCK_RAW, IPPROTO_ESP)");
    2878 2879 }
    2879 2880 #ifdef IP_HDRINCL
    2880 2881 if (setsockopt(s->esp_fd, IPPROTO_IP, IP_HDRINCL, &hincl, sizeof(hincl)) == -1) {
    2881 close_tunnel();
    2882 close_tunnel(s);
    2882 2883 error(1, errno, "setsockopt(esp_fd, IPPROTO_IP, IP_HDRINCL, 1)");
    2883 2884 }
    2884 2885 #endif
     
    3309 3310
    3310 3311 /* Cleanup routing */
    3311 3312 DEBUGTOP(2, printf("S8 close_tunnel\n"));
    3312 close_tunnel();
    3313 close_tunnel(s);
    3313 3314
    3314 3315 /* Free resources */
    3315 3316 DEBUGTOP(2, printf("S9 cleanup\n"));
  • trunk/tunip.c

     
    946 946
    947 947 }
    948 948
    949 tun_close(s->tun_fd, s->tun_name);
    950 949 switch (do_kill) {
    951 950 case -2:
    952 951 syslog(LOG_NOTICE, "connection terminated by dead peer detection");
  • trunk/vpnc-script.in

     
    473 473 }
    474 474
    475 475 do_disconnect() {
    476 destroy_tun_device
    477 476 if [ -n "$CISCO_SPLIT_INC" ]; then
    478 477 i=0
    479 478 while [ $i -lt $CISCO_SPLIT_INC ] ; do
     
    501 500 if [ -n "$INTERNAL_IP4_DNS" ]; then
    502 501 $RESTORERESOLVCONF
    503 502 fi
    503 destroy_tun_device
    504 504 }
    505 505
    506 506 #### Main
  • trunk/vpnc.c

     
    363 363 system(config[CONFIG_SCRIPT]);
    364 364 }
    365 365
    366 static void close_tunnel()
    366 static void close_tunnel(struct sa_block *s)
    367 367 {
    368 368 setenv("reason", "disconnect", 1);
    369 369 system(config[CONFIG_SCRIPT]);
    370 tun_close(s->tun_fd, s->tun_name);
    370 371 }
    371 372
    372 373 static int recv_ignore_dup(struct sa_block *s, void *recvbuf, size_t recvbufsize)
     
    2873 2874
    2874 2875 s->esp_fd = socket(PF_INET, SOCK_RAW, IPPROTO_ESP);
    2875 2876 if (s->esp_fd == -1) {
    2876 close_tunnel();
    2877 close_tunnel(s);
    2877 2878 error(1, errno, "Couldn't open socket of ESP. Maybe something registered ESP already.\nPlease try '--natt-mode force-natt' or disable whatever is using ESP.\nsocket(PF_INET, SOCK_RAW, IPPROTO_ESP)");
    2878 2879 }
    2879 2880 #ifdef IP_HDRINCL
    2880 2881 if (setsockopt(s->esp_fd, IPPROTO_IP, IP_HDRINCL, &hincl, sizeof(hincl)) == -1) {
    2881 close_tunnel();
    2882 close_tunnel(s);
    2882 2883 error(1, errno, "setsockopt(esp_fd, IPPROTO_IP, IP_HDRINCL, 1)");
    2883 2884 }
    2884 2885 #endif
     
    3309 3310
    3310 3311 /* Cleanup routing */
    3311 3312 DEBUGTOP(2, printf("S8 close_tunnel\n"));
    3312 close_tunnel();
    3313 close_tunnel(s);
    3313 3314
    3314 3315 /* Free resources */
    3315 3316 DEBUGTOP(2, printf("S9 cleanup\n"));