diff options
author | aleksej <aleksej.paschenko@gmail.com> | 2019-10-27 15:14:35 +0300 |
---|---|---|
committer | aleksej <aleksej.paschenko@gmail.com> | 2019-10-27 15:28:15 +0300 |
commit | 352ae1022ce19de28fc72e034cc469872ad79d06 (patch) | |
tree | daab172474c8a917a589a2142fc66ae9cba272c3 /pkg/sentry/socket/netstack/stack.go | |
parent | 1c480abc39b9957606ff8bf125a5c253ad8a76cb (diff) |
Add /proc/sys/net/ipv4/ip_forward
Diffstat (limited to 'pkg/sentry/socket/netstack/stack.go')
-rw-r--r-- | pkg/sentry/socket/netstack/stack.go | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/pkg/sentry/socket/netstack/stack.go b/pkg/sentry/socket/netstack/stack.go index d5db8c17c..d0102cfa3 100644 --- a/pkg/sentry/socket/netstack/stack.go +++ b/pkg/sentry/socket/netstack/stack.go @@ -20,6 +20,7 @@ import ( "gvisor.dev/gvisor/pkg/sentry/inet" "gvisor.dev/gvisor/pkg/sentry/socket/netfilter" "gvisor.dev/gvisor/pkg/syserr" + "gvisor.dev/gvisor/pkg/tcpip" "gvisor.dev/gvisor/pkg/tcpip/header" "gvisor.dev/gvisor/pkg/tcpip/iptables" "gvisor.dev/gvisor/pkg/tcpip/network/ipv4" @@ -291,3 +292,26 @@ func (s *Stack) FillDefaultIPTables() { func (s *Stack) Resume() { s.Stack.Resume() } + +// Forwarding implements inet.Stack.Forwarding. +func (s *Stack) Forwarding(protocol tcpip.NetworkProtocolNumber) bool { + switch protocol { + case ipv4.ProtocolNumber, ipv6.ProtocolNumber: + return s.Stack.Forwarding(protocol) + default: + log.Warningf("Forwarding(%v) failed: unsupported protocol", protocol) + return false + } +} + +// SetForwarding implements inet.Stack.SetForwarding. +func (s *Stack) SetForwarding(protocol tcpip.NetworkProtocolNumber, enable bool) error { + switch protocol { + case ipv4.ProtocolNumber, ipv6.ProtocolNumber: + s.Stack.SetForwarding(protocol, enable) + default: + log.Warningf("SetForwarding(%v) failed: unsupported protocol", protocol) + return syserr.ErrProtocolNotSupported.ToError() + } + return nil +} |