mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Add warning when net.ipv4.ip_forwarding = 0
Added warnings to api.go, container.go, commands.go, and runtime.go Also updated APIInfo to return whether IPv4Forwarding is enabled
This commit is contained in:
parent
65a4e30825
commit
10190be5d7
7 changed files with 25 additions and 3 deletions
5
api.go
5
api.go
|
@ -522,6 +522,11 @@ 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.")
|
out.Warnings = append(out.Warnings, "Your kernel does not support memory swap capabilities. Limitation discarded.")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if srv.runtime.capabilities.IPv4Forwarding {
|
||||||
|
log.Println("Warning: IPv4 forwarding is disabled.")
|
||||||
|
out.Warnings = append(out.Warnings, "IPv4 forwarding is disabled.")
|
||||||
|
}
|
||||||
|
|
||||||
b, err := json.Marshal(out)
|
b, err := json.Marshal(out)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
|
|
@ -24,6 +24,7 @@ type APIInfo struct {
|
||||||
NGoroutines int `json:",omitempty"`
|
NGoroutines int `json:",omitempty"`
|
||||||
MemoryLimit bool `json:",omitempty"`
|
MemoryLimit bool `json:",omitempty"`
|
||||||
SwapLimit bool `json:",omitempty"`
|
SwapLimit bool `json:",omitempty"`
|
||||||
|
IPv4Forwarding bool `json:",omitempty"`
|
||||||
LXCVersion string `json:",omitempty"`
|
LXCVersion string `json:",omitempty"`
|
||||||
NEventsListener int `json:",omitempty"`
|
NEventsListener int `json:",omitempty"`
|
||||||
KernelVersion string `json:",omitempty"`
|
KernelVersion string `json:",omitempty"`
|
||||||
|
|
|
@ -510,6 +510,9 @@ func (cli *DockerCli) CmdInfo(args ...string) error {
|
||||||
if !out.SwapLimit {
|
if !out.SwapLimit {
|
||||||
fmt.Fprintf(cli.err, "WARNING: No swap limit support\n")
|
fmt.Fprintf(cli.err, "WARNING: No swap limit support\n")
|
||||||
}
|
}
|
||||||
|
if !out.IPv4Forwarding {
|
||||||
|
fmt.Fprintf(cli.err, "WARNING: IPv4 forwarding is disabled.\n")
|
||||||
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -534,6 +534,10 @@ func (container *Container) Start(hostConfig *HostConfig) error {
|
||||||
container.Config.MemorySwap = -1
|
container.Config.MemorySwap = -1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if !container.runtime.capabilities.IPv4Forwarding {
|
||||||
|
log.Printf("WARNING: IPv4 forwarding is disabled. Networking will not work")
|
||||||
|
}
|
||||||
|
|
||||||
// Create the requested bind mounts
|
// Create the requested bind mounts
|
||||||
binds := make(map[string]BindMap)
|
binds := make(map[string]BindMap)
|
||||||
// Define illegal container destinations
|
// Define illegal container destinations
|
||||||
|
|
|
@ -1025,7 +1025,8 @@ Display system-wide information
|
||||||
"NFd": 11,
|
"NFd": 11,
|
||||||
"NGoroutines":21,
|
"NGoroutines":21,
|
||||||
"MemoryLimit":true,
|
"MemoryLimit":true,
|
||||||
"SwapLimit":false
|
"SwapLimit":false,
|
||||||
|
"IPv4Forwarding":true
|
||||||
}
|
}
|
||||||
|
|
||||||
:statuscode 200: no error
|
:statuscode 200: no error
|
||||||
|
|
11
runtime.go
11
runtime.go
|
@ -15,8 +15,9 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
type Capabilities struct {
|
type Capabilities struct {
|
||||||
MemoryLimit bool
|
MemoryLimit bool
|
||||||
SwapLimit bool
|
SwapLimit bool
|
||||||
|
IPv4Forwarding bool
|
||||||
}
|
}
|
||||||
|
|
||||||
type Runtime struct {
|
type Runtime struct {
|
||||||
|
@ -240,6 +241,12 @@ func (runtime *Runtime) UpdateCapabilities(quiet bool) {
|
||||||
if !runtime.capabilities.SwapLimit && !quiet {
|
if !runtime.capabilities.SwapLimit && !quiet {
|
||||||
log.Printf("WARNING: Your kernel does not support cgroup swap limit.")
|
log.Printf("WARNING: Your kernel does not support cgroup swap limit.")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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 {
|
||||||
|
log.Printf("WARNING: IPv4 forwarding is disabled.")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -269,6 +269,7 @@ func (srv *Server) DockerInfo() *APIInfo {
|
||||||
Images: imgcount,
|
Images: imgcount,
|
||||||
MemoryLimit: srv.runtime.capabilities.MemoryLimit,
|
MemoryLimit: srv.runtime.capabilities.MemoryLimit,
|
||||||
SwapLimit: srv.runtime.capabilities.SwapLimit,
|
SwapLimit: srv.runtime.capabilities.SwapLimit,
|
||||||
|
IPv4Forwarding: srv.runtime.capabilities.IPv4Forwarding,
|
||||||
Debug: os.Getenv("DEBUG") != "",
|
Debug: os.Getenv("DEBUG") != "",
|
||||||
NFd: utils.GetTotalUsedFds(),
|
NFd: utils.GetTotalUsedFds(),
|
||||||
NGoroutines: runtime.NumGoroutine(),
|
NGoroutines: runtime.NumGoroutine(),
|
||||||
|
|
Loading…
Reference in a new issue