Merge pull request #11 from icecrime/ipforward_diagnostic
Add a diagnostic message to ip forwading code
This commit is contained in:
commit
702915a7a9
|
@ -15,6 +15,11 @@ func SetupIPForwarding(i *Interface) error {
|
||||||
if i.Config.EnableIPForwarding == false {
|
if i.Config.EnableIPForwarding == false {
|
||||||
return fmt.Errorf("Unexpected request to enable IP Forwarding for: %v", *i)
|
return fmt.Errorf("Unexpected request to enable IP Forwarding for: %v", *i)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Enable IPv4 forwarding
|
// 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 (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -51,7 +52,9 @@ func TestUnexpectedSetupIPForwarding(t *testing.T) {
|
||||||
|
|
||||||
// Attempt Set IP Forwarding
|
// Attempt Set IP Forwarding
|
||||||
if err := SetupIPForwarding(br); err == nil {
|
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)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue