mirror of
https://github.com/clearlinux/libnetwork.git
synced 2026-08-19 04:17:48 +00:00
Add a diagnostic message to ip forwading code
Signed-off-by: Arnaud Porterie <arnaud.porterie@docker.com>
This commit is contained in:
@@ -15,6 +15,11 @@ func SetupIPForwarding(i *Interface) error {
|
||||
if i.Config.EnableIPForwarding == false {
|
||||
return fmt.Errorf("Unexpected request to enable IP Forwarding for: %v", *i)
|
||||
}
|
||||
|
||||
// Enable IPv4 forwarding
|
||||
return ioutil.WriteFile(IPV4_FORW_CONF_FILE, []byte{'1', '\n'}, PERM)
|
||||
if err := ioutil.WriteFile(IPV4_FORW_CONF_FILE, []byte{'1', '\n'}, PERM); err != nil {
|
||||
return fmt.Errorf("Setup IP forwarding failed: %v", err)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ package bridge
|
||||
import (
|
||||
"bytes"
|
||||
"io/ioutil"
|
||||
"strings"
|
||||
"testing"
|
||||
)
|
||||
|
||||
@@ -51,7 +52,9 @@ func TestUnexpectedSetupIPForwarding(t *testing.T) {
|
||||
|
||||
// Attempt Set IP Forwarding
|
||||
if err := SetupIPForwarding(br); err == nil {
|
||||
t.Fatalf(err.Error())
|
||||
t.Fatal("Setup IP forwarding was expected to fail")
|
||||
} else if !strings.Contains(err.Error(), "Unexpected request") {
|
||||
t.Fatalf("Setup IP forwarding failed with unexpected error: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user