From 688dc4e4c3fd76cc77c75839082631d88c942794 Mon Sep 17 00:00:00 2001 From: Volth Date: Thu, 27 Jul 2017 13:17:13 +0000 Subject: [PATCH] tinc_pre: avoid infinite loop with EBADFD on network restart --- nixos/modules/services/networking/tinc.nix | 3 ++- pkgs/tools/networking/tinc/pre.nix | 10 +++++++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/nixos/modules/services/networking/tinc.nix b/nixos/modules/services/networking/tinc.nix index 42341b2d412..31a588318f6 100644 --- a/nixos/modules/services/networking/tinc.nix +++ b/nixos/modules/services/networking/tinc.nix @@ -169,7 +169,8 @@ in serviceConfig = { Type = "simple"; PIDFile = "/run/tinc.${network}.pid"; - Restart = "on-failure"; + Restart = "always"; + RestartSec = "3"; }; preStart = '' mkdir -p /etc/tinc/${network}/hosts diff --git a/pkgs/tools/networking/tinc/pre.nix b/pkgs/tools/networking/tinc/pre.nix index c09c9a45756..1d80db68991 100644 --- a/pkgs/tools/networking/tinc/pre.nix +++ b/pkgs/tools/networking/tinc/pre.nix @@ -1,4 +1,4 @@ -{ stdenv, fetchgit, autoreconfHook, texinfo, ncurses, readline, zlib, lzo, openssl }: +{ stdenv, fetchgit, fetchpatch, autoreconfHook, texinfo, ncurses, readline, zlib, lzo, openssl }: stdenv.mkDerivation rec { name = "tinc-${version}"; @@ -19,6 +19,14 @@ stdenv.mkDerivation rec { substituteInPlace configure.ac --replace UNKNOWN ${version} ''; + patches = [ + # Avoid infinite loop with "Error while reading from Linux tun/tap device (tun mode) /dev/net/tun: File descriptor in bad state" on network restart + (fetchpatch { + url = https://github.com/gsliepen/tinc/compare/acefa66...e4544db.patch; + sha256 = "1jz7anqqzk7j96l5ifggc2knp14fmbsjdzfrbncxx0qhb6ihdcvn"; + }) + ]; + postInstall = '' rm $out/bin/tinc-gui '';