1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00

Remove unused config check

Signed-off-by: Antonio Murdaca <runcom@linux.com>
This commit is contained in:
Antonio Murdaca 2015-08-04 00:27:53 +02:00
parent 737203a04b
commit c38d2d4601
4 changed files with 3 additions and 43 deletions

View file

@ -442,7 +442,7 @@ func (d *driver) Config(option map[string]interface{}) error {
} }
if config.EnableIPForwarding { if config.EnableIPForwarding {
return setupIPForwarding(config) return setupIPForwarding()
} }
return nil return nil

View file

@ -115,17 +115,6 @@ func (eim ErrInvalidMtu) Error() string {
// BadRequest denotes the type of this error // BadRequest denotes the type of this error
func (eim ErrInvalidMtu) BadRequest() {} func (eim ErrInvalidMtu) BadRequest() {}
// ErrIPFwdCfg is returned when ip forwarding setup is invoked when the configuration
// not enabled.
type ErrIPFwdCfg struct{}
func (eipf *ErrIPFwdCfg) Error() string {
return "unexpected request to enable IP Forwarding"
}
// BadRequest denotes the type of this error
func (eipf *ErrIPFwdCfg) BadRequest() {}
// ErrInvalidPort is returned when the container or host port specified in the port binding is not valid. // ErrInvalidPort is returned when the container or host port specified in the port binding is not valid.
type ErrInvalidPort string type ErrInvalidPort string

View file

@ -10,12 +10,7 @@ const (
ipv4ForwardConfPerm = 0644 ipv4ForwardConfPerm = 0644
) )
func setupIPForwarding(config *configuration) error { func setupIPForwarding() error {
// Sanity Check
if config.EnableIPForwarding == false {
return &ErrIPFwdCfg{}
}
// Enable IPv4 forwarding // Enable IPv4 forwarding
if err := ioutil.WriteFile(ipv4ForwardConf, []byte{'1', '\n'}, ipv4ForwardConfPerm); err != nil { if err := ioutil.WriteFile(ipv4ForwardConf, []byte{'1', '\n'}, ipv4ForwardConfPerm); err != nil {
return fmt.Errorf("Setup IP forwarding failed: %v", err) return fmt.Errorf("Setup IP forwarding failed: %v", err)

View file

@ -16,12 +16,8 @@ func TestSetupIPForwarding(t *testing.T) {
writeIPForwardingSetting(t, []byte{'0', '\n'}) writeIPForwardingSetting(t, []byte{'0', '\n'})
} }
// Create test interface with ip forwarding setting enabled
config := &configuration{
EnableIPForwarding: true}
// Set IP Forwarding // Set IP Forwarding
if err := setupIPForwarding(config); err != nil { if err := setupIPForwarding(); err != nil {
t.Fatalf("Failed to setup IP forwarding: %v", err) t.Fatalf("Failed to setup IP forwarding: %v", err)
} }
@ -32,26 +28,6 @@ func TestSetupIPForwarding(t *testing.T) {
} }
} }
func TestUnexpectedSetupIPForwarding(t *testing.T) {
// Read current setting and ensure the original value gets restored
procSetting := readCurrentIPForwardingSetting(t)
defer reconcileIPForwardingSetting(t, procSetting)
// Create test interface without ip forwarding setting enabled
config := &configuration{
EnableIPForwarding: false}
// Attempt Set IP Forwarding
err := setupIPForwarding(config)
if err == nil {
t.Fatal("Setup IP forwarding was expected to fail")
}
if _, ok := err.(*ErrIPFwdCfg); !ok {
t.Fatalf("Setup IP forwarding failed with unexpected error: %v", err)
}
}
func readCurrentIPForwardingSetting(t *testing.T) []byte { func readCurrentIPForwardingSetting(t *testing.T) []byte {
procSetting, err := ioutil.ReadFile(ipv4ForwardConf) procSetting, err := ioutil.ReadFile(ipv4ForwardConf)
if err != nil { if err != nil {