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:
parent
737203a04b
commit
c38d2d4601
4 changed files with 3 additions and 43 deletions
|
@ -442,7 +442,7 @@ func (d *driver) Config(option map[string]interface{}) error {
|
|||
}
|
||||
|
||||
if config.EnableIPForwarding {
|
||||
return setupIPForwarding(config)
|
||||
return setupIPForwarding()
|
||||
}
|
||||
|
||||
return nil
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
|
||||
|
@ -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 {
|
||||
|
|
Loading…
Reference in a new issue