Skip to content

Commit

Permalink
Merge pull request moby#434 from runcom/remove-unused-config-check
Browse files Browse the repository at this point in the history
Remove unused config check
  • Loading branch information
mavenugo committed Aug 4, 2015
2 parents bdcd5a8 + f657962 commit 84d8c77
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 43 deletions.
2 changes: 1 addition & 1 deletion drivers/bridge/bridge.go
Original file line number Diff line number Diff line change
Expand Up @@ -447,7 +447,7 @@ func (d *driver) Config(option map[string]interface{}) error {
}

if config.EnableIPForwarding {
return setupIPForwarding(config)
return setupIPForwarding()
}

return nil
Expand Down
11 changes: 0 additions & 11 deletions drivers/bridge/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,17 +115,6 @@ func (eim ErrInvalidMtu) Error() string {
// BadRequest denotes the type of this error
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.
type ErrInvalidPort string

Expand Down
7 changes: 1 addition & 6 deletions drivers/bridge/setup_ip_forwarding.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,7 @@ const (
ipv4ForwardConfPerm = 0644
)

func setupIPForwarding(config *configuration) error {
// Sanity Check
if config.EnableIPForwarding == false {
return &ErrIPFwdCfg{}
}

func setupIPForwarding() error {
// Enable IPv4 forwarding
if err := ioutil.WriteFile(ipv4ForwardConf, []byte{'1', '\n'}, ipv4ForwardConfPerm); err != nil {
return fmt.Errorf("Setup IP forwarding failed: %v", err)
Expand Down
26 changes: 1 addition & 25 deletions drivers/bridge/setup_ip_forwarding_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,8 @@ func TestSetupIPForwarding(t *testing.T) {
writeIPForwardingSetting(t, []byte{'0', '\n'})
}

// Create test interface with ip forwarding setting enabled
config := &configuration{
EnableIPForwarding: true}

// Set IP Forwarding
if err := setupIPForwarding(config); err != nil {
if err := setupIPForwarding(); err != nil {
t.Fatalf("Failed to setup IP forwarding: %v", err)
}

Expand All @@ -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 {
procSetting, err := ioutil.ReadFile(ipv4ForwardConf)
if err != nil {
Expand Down

0 comments on commit 84d8c77

Please sign in to comment.