1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00
moby--moby/libnetwork/drivers/bridge/setup_ip_forwarding.go
Arnaud Porterie 58a3934282 Add a diagnostic message to ip forwading code
Signed-off-by: Arnaud Porterie <arnaud.porterie@docker.com>
2015-03-04 11:37:16 -08:00

25 lines
521 B
Go

package bridge
import (
"fmt"
"io/ioutil"
)
const (
IPV4_FORW_CONF_FILE = "/proc/sys/net/ipv4/ip_forward"
PERM = 0644
)
func SetupIPForwarding(i *Interface) error {
// Sanity Check
if i.Config.EnableIPForwarding == false {
return fmt.Errorf("Unexpected request to enable IP Forwarding for: %v", *i)
}
// Enable IPv4 forwarding
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
}