What is the max size of AF_UNIX datagram message in Linux?

前端 未结 1 1089
灰色年华
灰色年华 2020-12-03 05:29

Currently I\'m hitting a hard limit of 130688 bytes. If I try and send anything larger in one message I get a ENOBUFS error.

I have checked the net.core.rmem_default

相关标签:
1条回答
  • 2020-12-03 05:56

    AF_UNIX SOCK_DATAGRAM/SOCK_SEQPACKET datagrams need contiguous memory. Contiguous physical memory is hard to find, and the allocation fails, logging something similar to this on the kernel log:

    udgc: page allocation failure. order:7, mode:0x44d0
    [...snip...]
    DMA: 185*4kB 69*8kB 34*16kB 27*32kB 11*64kB 1*128kB 1*256kB 0*512kB 0*1024kB 0*2048kB 0*4096kB = 3788kB
    Normal: 13*4kB 6*8kB 100*16kB 62*32kB 24*64kB 10*128kB 0*256kB 1*512kB 0*1024kB 0*2048kB 0*4096kB = 7012kB
    [...snip...]
    

    unix_dgram_sendmsg() calls sock_alloc_send_skb() lxr1, which calls sock_alloc_send_pskb() with data_len = 0 and header_len = size of datagram lxr2. sock_alloc_send_pskb() allocates header_len from "normal" skbuff buffer space, and data_len from scatter/gather pages lxr3. So, it looks like AF_UNIX sockets don't support scatter/gather on current Linux.

    0 讨论(0)
提交回复
热议问题