可以在linux中发送的AF_UNIX数据报消息的最大大小是多少? [英] What is the max size of AF_UNIX datagram message that can be sent in linux?

查看:420
本文介绍了可以在linux中发送的AF_UNIX数据报消息的最大大小是多少?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

目前,我遇到了一个130688字节的极限。如果我尝试在一个消息中发送更大的信息,我会收到一个ENOBUFS错误。



我已经检查了net.core.rmem_default,net.core.wmem_default,net.core .rmem_max,net.core.wmem_max和net.unix.max_dgram_qlen sysctl选项,并增加它们,但它们没有任何影响,因为它们处理总缓冲区大小而不是消息大小。



我也设置了SO_SNDBUF和SO_RCVBUF套接字选项,但这与上面的问题相同。我们已经看过基于_default套接字选项的默认套接字缓冲区大小。



我查看了在套接字堆栈中返回ENOBUFS的内核源,不清楚我来自哪里。似乎返回此错误的唯一地方与无法分配内存有关。



最大大小实际上是130688吗?如果不能重新编译内核,可以更改?



谢谢!

解决方案

AF_UNIX SOCK_DATAGRAM / SOCK_SEQPACKET数据报需要连续的内存。连续的物理内存很难找到,分配失败,在内核日志中记录类似的内容:

  udgc:page分配失败。订单:7,模式: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
正常: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()调用 sock_alloc_send_skb() lxr1 ,它调用 sock_alloc_send_pskb() data_len = 0和 header_len =数据报的大小 lxr2 sock_alloc_send_pskb()从正常skbuff缓冲区空间分配 header_len data_len lxr3 。所以,看起来AF_UNIX套接字不支持当前Linux上的分散/收集。


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, net.core.wmem_default, net.core.rmem_max, net.core.wmem_max, and net.unix.max_dgram_qlen sysctl options and increased them all but they have no effect because these deal with the total buffer size not the message size.

I have also set the SO_SNDBUF and SO_RCVBUF socket options, but this has the same issue as above. The default socket buffer size are set based on the _default socket options anyways.

I've looked at the kernel source where ENOBUFS is returned in the socket stack, but it wasn't clear to me where it was coming from. The only places that seem to return this error have to do with not being able to allocate memory.

Is the max size actually 130688? If not can this be changed without recompiling the kernel?

Thanks!

解决方案

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.

这篇关于可以在linux中发送的AF_UNIX数据报消息的最大大小是多少?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆