From 59355bafe59d15582c0bf67fc12c010c9b7a1744 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Mon, 20 Jun 2011 18:12:47 +0000 Subject: [PATCH] * Initialise bridges before doing the configuration specified in networking.interfaces and networking.localCommands. svn path=/nixos/trunk/; revision=27505 --- modules/tasks/network-interfaces.nix | 44 ++++++++++++++-------------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/modules/tasks/network-interfaces.nix b/modules/tasks/network-interfaces.nix index c64bb624d34..fab61b79c98 100644 --- a/modules/tasks/network-interfaces.nix +++ b/modules/tasks/network-interfaces.nix @@ -209,6 +209,28 @@ in ip link set "$i" up done + # Create bridge devices. + ${concatStrings (attrValues (flip mapAttrs cfg.bridges (n: v: '' + echo "Creating bridge ${n}..." + ${pkgs.bridge_utils}/sbin/brctl addbr "${n}" + + ${flip concatMapStrings v.interfaces (i: '' + ${pkgs.bridge_utils}/sbin/brctl addif "${n}" "${i}" + ip addr flush dev "${i}" + '')} + + # For some reason enslaving an interface to a bridge + # causes traffic to be blocked for a few seconds, long + # enough for IPv6 router solicitations to get lost. + # So increase the number of attemts. + ${optionalString cfg.enableIPv6 '' + echo 5 > /proc/sys/net/ipv6/conf/${n}/router_solicitations + ''} + + # !!! Should delete (brctl delif) any interfaces that + # no longer belong to the bridge. + '')))} + # Configure the manually specified interfaces. ${flip concatMapStrings cfg.interfaces (i: optionalString (i.ipAddress != "") @@ -238,28 +260,6 @@ in # Run any user-specified commands. ${pkgs.stdenv.shell} ${pkgs.writeText "local-net-cmds" cfg.localCommands} - # Create bridge devices. - ${concatStrings (attrValues (flip mapAttrs cfg.bridges (n: v: '' - echo "Creating bridge ${n}..." - ${pkgs.bridge_utils}/sbin/brctl addbr "${n}" - - ${flip concatMapStrings v.interfaces (i: '' - ${pkgs.bridge_utils}/sbin/brctl addif "${n}" "${i}" - ip addr flush dev "${i}" - '')} - - # For some reason enslaving an interface to a bridge - # causes traffic to be blocked for a few seconds, long - # enough for IPv6 router solicitations to get lost. - # So increase the number of attemts. - ${optionalString cfg.enableIPv6 '' - echo 5 > /proc/sys/net/ipv6/conf/${n}/router_solicitations - ''} - - # !!! Should delete (brctl delif) any interfaces that - # no longer belong to the bridge. - '')))} - ${optionalString (cfg.interfaces != [] || cfg.localCommands != "") '' # Emit the ip-up event (e.g. to start ntpd). initctl emit -n ip-up