mirror of
https://github.com/clearlinux/libnetwork.git
synced 2026-05-15 02:53:54 +00:00
types, except the naked error returns which were just prefixing strings to previously returned error strings. Signed-off-by: Jana Radhakrishnan <mrjana@docker.com>
26 lines
514 B
Go
26 lines
514 B
Go
package bridge
|
|
|
|
import (
|
|
"fmt"
|
|
"io/ioutil"
|
|
)
|
|
|
|
const (
|
|
ipv4ForwardConf = "/proc/sys/net/ipv4/ip_forward"
|
|
ipv4ForwardConfPerm = 0644
|
|
)
|
|
|
|
func setupIPForwarding(config *Configuration, i *bridgeInterface) error {
|
|
// Sanity Check
|
|
if config.EnableIPForwarding == false {
|
|
return (*ipForwardCfgError)(i)
|
|
}
|
|
|
|
// Enable IPv4 forwarding
|
|
if err := ioutil.WriteFile(ipv4ForwardConf, []byte{'1', '\n'}, ipv4ForwardConfPerm); err != nil {
|
|
return fmt.Errorf("Setup IP forwarding failed: %v", err)
|
|
}
|
|
|
|
return nil
|
|
}
|