diff --git a/modules/ppp/l2tp.nix b/modules/ppp/l2tp.nix index 845d314..5d05285 100644 --- a/modules/ppp/l2tp.nix +++ b/modules/ppp/l2tp.nix @@ -44,8 +44,9 @@ let require authentication = no pppoptfile = ${writeText "ppp-options" ppp-options'} autodial = yes - redial = no - max redials = 1 + redial = yes + redial timeout = 1 + max redials = 2 # this gives 1 actual retry, as xl2tpd can't count ''; control = "/run/xl2tpd/control-${name}"; in diff --git a/overlay.nix b/overlay.nix index 13297c4..80fb0b4 100644 --- a/overlay.nix +++ b/overlay.nix @@ -291,4 +291,8 @@ extraPkgs // { translateManpages = false; capabilitiesSupport = false; }; + + xl2tpd = prev.xl2tpd.overrideAttrs(o: { + patches = [ ./pkgs/xl2tpd-exit-on-close.patch ]; + }); } diff --git a/pkgs/xl2tpd-exit-on-close.patch b/pkgs/xl2tpd-exit-on-close.patch new file mode 100644 index 0000000..f6fe4b2 --- /dev/null +++ b/pkgs/xl2tpd-exit-on-close.patch @@ -0,0 +1,55 @@ +diff --git a/xl2tpd.c b/xl2tpd.c +index 791d5a4..1382b68 100644 +--- a/xl2tpd.c ++++ b/xl2tpd.c +@@ -814,6 +814,33 @@ static struct call *lac_call (int tid, struct lac *lac, struct lns *lns) + return NULL; + } + ++void terminate_if_no_active(void * _unused) ++{ ++ l2tp_log (LOG_WARNING, "%s : is anything still happening?\n", __FUNCTION__); ++ ++ struct lac *lac = (struct lac *) laclist; ++ while(lac) { ++ l2tp_log (LOG_INFO, "%s : lac %s active %s\n", __FUNCTION__, ++ lac->entname, (lac->active ? "yes" : "no")); ++ if(lac->active) ++ return; ++ lac = lac->next; ++ } ++ ++ struct lns *lns = (struct lns *) lnslist; ++ while(lns) { ++ l2tp_log (LOG_INFO, "%s : lns %s active %s\n", __FUNCTION__, ++ lns->entname, (lns->active ? "yes" : "no")); ++ if(lns->active) ++ return; ++ lns = lns->next; ++ } ++ ++ l2tp_log (LOG_WARNING, "%s : apparently nothing\n", __FUNCTION__); ++ ++ death_handler(SIGTERM); ++} ++ + void magic_lac_dial (void *data) + { + struct lac *lac; +@@ -832,7 +859,15 @@ void magic_lac_dial (void *data) + lac->rtries++; + if (lac->rmax && (lac->rtries > lac->rmax)) + { +- l2tp_log (LOG_INFO, "%s: maximum retries exceeded.\n", __FUNCTION__); ++ struct timeval tv; ++ ++ l2tp_log (LOG_INFO, "%s: maximum retries exceeded %d/%d.\n", ++ __FUNCTION__, lac->rtries , lac->rmax); ++ lac->active = 0; ++ tv.tv_sec = 0; ++ tv.tv_usec = 100; ++ schedule (tv, &terminate_if_no_active, NULL); ++ + return; + } + if (!lac->t)