From 533ef6cee7d9d627f8aad1c2bb084b733a2fc40e Mon Sep 17 00:00:00 2001 From: Ma Shimiao Date: Thu, 23 Apr 2015 11:11:23 +0800 Subject: [PATCH] sysinfo: add IPv4Forwarding check Signed-off-by: Ma Shimiao --- sysinfo/sysinfo.go | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/sysinfo/sysinfo.go b/sysinfo/sysinfo.go index 76a61fa..57e5563 100644 --- a/sysinfo/sysinfo.go +++ b/sysinfo/sysinfo.go @@ -4,6 +4,8 @@ import ( "io/ioutil" "os" "path" + "strconv" + "strings" "github.com/Sirupsen/logrus" "github.com/docker/libcontainer/cgroups" @@ -52,6 +54,17 @@ func New(quiet bool) *SysInfo { } } + // Checek if ipv4_forward is disabled. + if data, err := ioutil.ReadFile("/proc/sys/net/ipv4/ip_forward"); os.IsNotExist(err) { + sysInfo.IPv4ForwardingDisabled = true + } else { + if enabled, _ := strconv.Atoi(strings.TrimSpace(string(data))); enabled == 0 { + sysInfo.IPv4ForwardingDisabled = true + } else { + sysInfo.IPv4ForwardingDisabled = false + } + } + // Check if AppArmor is supported. if _, err := os.Stat("/sys/kernel/security/apparmor"); os.IsNotExist(err) { sysInfo.AppArmor = false