From b21f89862076397b63eb3ac4a19b9125b6f6477a Mon Sep 17 00:00:00 2001 From: Victor Vieux Date: Mon, 19 Aug 2013 12:34:30 +0000 Subject: [PATCH] assume ip_forwarding = 1 by default --- api.go | 2 +- container.go | 2 +- runtime.go | 10 +++++----- server.go | 2 +- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/api.go b/api.go index 18f42c446d..41edc4f4c5 100644 --- a/api.go +++ b/api.go @@ -526,7 +526,7 @@ func postContainersCreate(srv *Server, version float64, w http.ResponseWriter, r out.Warnings = append(out.Warnings, "Your kernel does not support memory swap capabilities. Limitation discarded.") } - if !srv.runtime.capabilities.IPv4Forwarding { + if srv.runtime.capabilities.IPv4ForwardingDisabled { log.Println("Warning: IPv4 forwarding is disabled.") out.Warnings = append(out.Warnings, "IPv4 forwarding is disabled.") } diff --git a/container.go b/container.go index 472ae3990d..62007ed624 100644 --- a/container.go +++ b/container.go @@ -548,7 +548,7 @@ func (container *Container) Start(hostConfig *HostConfig) error { container.Config.MemorySwap = -1 } - if !container.runtime.capabilities.IPv4Forwarding { + if container.runtime.capabilities.IPv4ForwardingDisabled { log.Printf("WARNING: IPv4 forwarding is disabled. Networking will not work") } diff --git a/runtime.go b/runtime.go index 0f97c01cba..7525680a0e 100644 --- a/runtime.go +++ b/runtime.go @@ -15,9 +15,9 @@ import ( ) type Capabilities struct { - MemoryLimit bool - SwapLimit bool - IPv4Forwarding bool + MemoryLimit bool + SwapLimit bool + IPv4ForwardingDisabled bool } type Runtime struct { @@ -244,8 +244,8 @@ func (runtime *Runtime) UpdateCapabilities(quiet bool) { } content, err3 := ioutil.ReadFile("/proc/sys/net/ipv4/ip_forward") - runtime.capabilities.IPv4Forwarding = err3 == nil && len(content) > 0 && content[0] == '1' - if !runtime.capabilities.IPv4Forwarding && !quiet { + runtime.capabilities.IPv4ForwardingDisabled = err3 != nil || len(content) == 0 || content[0] != '1' + if runtime.capabilities.IPv4ForwardingDisabled && !quiet { log.Printf("WARNING: IPv4 forwarding is disabled.") } } diff --git a/server.go b/server.go index 561d3c7cfe..d86319d0dc 100644 --- a/server.go +++ b/server.go @@ -269,7 +269,7 @@ func (srv *Server) DockerInfo() *APIInfo { Images: imgcount, MemoryLimit: srv.runtime.capabilities.MemoryLimit, SwapLimit: srv.runtime.capabilities.SwapLimit, - IPv4Forwarding: srv.runtime.capabilities.IPv4Forwarding, + IPv4Forwarding: !srv.runtime.capabilities.IPv4ForwardingDisabled, Debug: os.Getenv("DEBUG") != "", NFd: utils.GetTotalUsedFds(), NGoroutines: runtime.NumGoroutine(),