Merge pull request #11 from icecrime/ipforward_diagnostic

Add a diagnostic message to ip forwading code
This commit is contained in:
aboch 2015-03-04 11:47:25 -08:00
commit 702915a7a9
2 changed files with 10 additions and 2 deletions

View File

@ -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
}

View File

@ -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)
}
}