From 7875e0f5d6f1939ab87c5b98a20b55bd06f2dada Mon Sep 17 00:00:00 2001 From: Alexander Sulfrian Date: Tue, 1 Oct 2013 20:50:04 +0200 Subject: vserver.functions: add magically localhost for netns --- vserver.functions | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'vserver.functions') diff --git a/vserver.functions b/vserver.functions index a75d717..8c25f74 100644 --- a/vserver.functions +++ b/vserver.functions @@ -47,6 +47,14 @@ function _netnsProcessSingleGateway() { _addInterfaceCmd IP_ROUTE default via "$gw" dev "$iface" } +function _netnsAddLocalhost() { + if [ -r "${1}/nflags" ]; then + if grep -q '^~LBACK_REMAP$' "${1}/nflags"; then + INTERFACES=( "${INTERFACES[@]}" "127.0.0.1/8" "::1/128" ) + fi + fi +} + function _netnsFilterNetnsUmount() { local args=( "$@" ) @@ -93,13 +101,18 @@ function _generateInterfaceOptions() { ret=$? # add commands for default route + local netns=0 for net in "$VSERVER_DIR/netns/"*; do test -d "$net" || continue test ! -e "${net}/disabled" || continue _netnsProcessSingleGateway "$net" + netns=1 done + # if using netns, automatically add localhost + [ "$netns" != "0" ] && _netnsAddLocalhost "$VSERVER_DIR" + return $ret } -- cgit v1.2.3-1-g7c22