Browse Source

Add bridge-nf-call-iptables/bridge-nf-call-ipv6tables to docker info

Signed-off-by: Lei Jitang <leijitang@huawei.com>
Lei Jitang 10 years ago
parent
commit
57d12a0e0a
5 changed files with 34 additions and 7 deletions
  1. 6 0
      api/client/info.go
  2. 2 0
      api/types/types.go
  3. 2 0
      daemon/info.go
  4. 9 7
      pkg/sysinfo/sysinfo.go
  5. 15 0
      pkg/sysinfo/sysinfo_linux.go

+ 6 - 0
api/client/info.go

@@ -76,6 +76,12 @@ func (cli *DockerCli) CmdInfo(args ...string) error {
 	if !info.IPv4Forwarding {
 	if !info.IPv4Forwarding {
 		fmt.Fprintf(cli.err, "WARNING: IPv4 forwarding is disabled.\n")
 		fmt.Fprintf(cli.err, "WARNING: IPv4 forwarding is disabled.\n")
 	}
 	}
+	if !info.BridgeNfIptables {
+		fmt.Fprintf(cli.err, "WARNING: bridge-nf-call-iptables is disabled\n")
+	}
+	if !info.BridgeNfIp6tables {
+		fmt.Fprintf(cli.err, "WARNING: bridge-nf-call-ip6tables is disabled\n")
+	}
 	if info.Labels != nil {
 	if info.Labels != nil {
 		fmt.Fprintln(cli.out, "Labels:")
 		fmt.Fprintln(cli.out, "Labels:")
 		for _, attribute := range info.Labels {
 		for _, attribute := range info.Labels {

+ 2 - 0
api/types/types.go

@@ -153,6 +153,8 @@ type Info struct {
 	CpuCfsPeriod       bool
 	CpuCfsPeriod       bool
 	CpuCfsQuota        bool
 	CpuCfsQuota        bool
 	IPv4Forwarding     bool
 	IPv4Forwarding     bool
+	BridgeNfIptables   bool
+	BridgeNfIp6tables  bool
 	Debug              bool
 	Debug              bool
 	NFd                int
 	NFd                int
 	OomKillDisable     bool
 	OomKillDisable     bool

+ 2 - 0
daemon/info.go

@@ -67,6 +67,8 @@ func (daemon *Daemon) SystemInfo() (*types.Info, error) {
 		CpuCfsPeriod:       daemon.SystemConfig().CpuCfsPeriod,
 		CpuCfsPeriod:       daemon.SystemConfig().CpuCfsPeriod,
 		CpuCfsQuota:        daemon.SystemConfig().CpuCfsQuota,
 		CpuCfsQuota:        daemon.SystemConfig().CpuCfsQuota,
 		IPv4Forwarding:     !daemon.SystemConfig().IPv4ForwardingDisabled,
 		IPv4Forwarding:     !daemon.SystemConfig().IPv4ForwardingDisabled,
+		BridgeNfIptables:   !daemon.SystemConfig().BridgeNfCallIptablesDisabled,
+		BridgeNfIp6tables:  !daemon.SystemConfig().BridgeNfCallIp6tablesDisabled,
 		Debug:              os.Getenv("DEBUG") != "",
 		Debug:              os.Getenv("DEBUG") != "",
 		NFd:                fileutils.GetTotalUsedFds(),
 		NFd:                fileutils.GetTotalUsedFds(),
 		OomKillDisable:     daemon.SystemConfig().OomKillDisable,
 		OomKillDisable:     daemon.SystemConfig().OomKillDisable,

+ 9 - 7
pkg/sysinfo/sysinfo.go

@@ -3,11 +3,13 @@ package sysinfo
 // SysInfo stores information about which features a kernel supports.
 // SysInfo stores information about which features a kernel supports.
 // TODO Windows: Factor out platform specific capabilities.
 // TODO Windows: Factor out platform specific capabilities.
 type SysInfo struct {
 type SysInfo struct {
-	MemoryLimit            bool
-	SwapLimit              bool
-	CpuCfsPeriod           bool
-	CpuCfsQuota            bool
-	IPv4ForwardingDisabled bool
-	AppArmor               bool
-	OomKillDisable         bool
+	MemoryLimit                   bool
+	SwapLimit                     bool
+	CpuCfsPeriod                  bool
+	CpuCfsQuota                   bool
+	IPv4ForwardingDisabled        bool
+	AppArmor                      bool
+	OomKillDisable                bool
+	BridgeNfCallIptablesDisabled  bool
+	BridgeNfCallIp6tablesDisabled bool
 }
 }

+ 15 - 0
pkg/sysinfo/sysinfo_linux.go

@@ -63,6 +63,21 @@ func New(quiet bool) *SysInfo {
 		}
 		}
 	}
 	}
 
 
+	// Check if bridge-nf-call-iptables is disabled.
+	if data, err := ioutil.ReadFile("/proc/sys/net/bridge/bridge-nf-call-iptables"); os.IsNotExist(err) {
+		sysInfo.BridgeNfCallIptablesDisabled = true
+	} else {
+		enabled, _ := strconv.Atoi(strings.TrimSpace(string(data)))
+		sysInfo.BridgeNfCallIptablesDisabled = enabled == 0
+	}
+	// Check if bridge-nf-call-ip6tables is disabled.
+	if data, err := ioutil.ReadFile("/proc/sys/net/bridge/bridge-nf-call-ip6tables"); os.IsNotExist(err) {
+		sysInfo.BridgeNfCallIp6tablesDisabled = true
+	} else {
+		enabled, _ := strconv.Atoi(strings.TrimSpace(string(data)))
+		sysInfo.BridgeNfCallIp6tablesDisabled = enabled == 0
+	}
+
 	// Check if AppArmor is supported.
 	// Check if AppArmor is supported.
 	if _, err := os.Stat("/sys/kernel/security/apparmor"); os.IsNotExist(err) {
 	if _, err := os.Stat("/sys/kernel/security/apparmor"); os.IsNotExist(err) {
 		sysInfo.AppArmor = false
 		sysInfo.AppArmor = false