summaryrefslogtreecommitdiffhomepage
path: root/runsc/sandbox
diff options
context:
space:
mode:
authorMarek Majkowski <marek@cloudflare.com>2020-09-25 13:20:28 +0200
committerMarek Majkowski <marek@cloudflare.com>2020-09-25 13:23:52 +0200
commit6f5114446a7952d8b2b3098b2845e660d38d4fe1 (patch)
tree981db68fbc6c56ac2df368efd6dd5f5a98f699fd /runsc/sandbox
parentd201feb8c5e425bfa8abc905f24d49b268520aec (diff)
Swallow SO_RCVBUFFORCE and SO_SNDBUFFORCE errors on SOCK_RAW sockets
In --network=sandbox mode, we create SOCK_RAW sockets on the given network device. The code tries to force-set 4MiB rcv and snd buffers on it, but in certain situations it might fail. There is no reason for refusing the sandbox startup in such case - we should bump the buffers to max availabe size and just move on.
Diffstat (limited to 'runsc/sandbox')
-rw-r--r--runsc/sandbox/network.go13
1 files changed, 11 insertions, 2 deletions
diff --git a/runsc/sandbox/network.go b/runsc/sandbox/network.go
index 0b9f39466..8f66dd1f8 100644
--- a/runsc/sandbox/network.go
+++ b/runsc/sandbox/network.go
@@ -309,11 +309,20 @@ func createSocket(iface net.Interface, ifaceLink netlink.Link, enableGSO bool) (
const bufSize = 4 << 20 // 4MB.
if err := syscall.SetsockoptInt(fd, syscall.SOL_SOCKET, syscall.SO_RCVBUFFORCE, bufSize); err != nil {
- return nil, fmt.Errorf("failed to increase socket rcv buffer to %d: %v", bufSize, err)
+ syscall.SetsockoptInt(fd, syscall.SOL_SOCKET, syscall.SO_RCVBUF, bufSize)
+ sz, _ := syscall.GetsockoptInt(fd, syscall.SOL_SOCKET, syscall.SO_RCVBUF)
+
+ if sz < bufSize {
+ log.Warningf("Failed to increase rcv buffer to %d on SOCK_RAW on %s. Current buffer %d: %v", bufSize, iface.Name, sz, err)
+ }
}
if err := syscall.SetsockoptInt(fd, syscall.SOL_SOCKET, syscall.SO_SNDBUFFORCE, bufSize); err != nil {
- return nil, fmt.Errorf("failed to increase socket snd buffer to %d: %v", bufSize, err)
+ syscall.SetsockoptInt(fd, syscall.SOL_SOCKET, syscall.SO_SNDBUF, bufSize)
+ sz, _ := syscall.GetsockoptInt(fd, syscall.SOL_SOCKET, syscall.SO_SNDBUF)
+ if sz < bufSize {
+ log.Warningf("Failed to increase snd buffer to %d on SOCK_RAW on %s. Curent buffer %d: %v", bufSize, iface.Name, sz, err)
+ }
}
return &socketEntry{deviceFile, gsoMaxSize}, nil