在3.6之前的内核中,您可能已经被ENOBUFS用于常规IPv4 / v6流量,
当net.ipv4.route.max_size或net.ipv6.route.max_size
limit was depleated, accordingly时.
从内核3.6,routing cache was removed和net.ipv4.route.max_size开始,它失去了对dst条目数量的影响.所以,通常情况下,这将不再可能.
但是,在使用IPSec时,您仍然可以像我一样遇到此错误.在创建了一定数量的IPSec隧道之后,我无法ping远程主机:
# ping 10.100.0.1
connect: No buffer space available
从iputils ping创建测试文件描述符,并在其上使用connect()来绑定dst ip.当它发生时,内核创建给定AF的dst缓存条目,
在我的情况下,xfrm4 dst缓存条目限制已经耗尽.此限制由sysctl设置控制:
xfrm4_gc_thresh - INTEGER
The threshold at which we will start garbage collecting for IPv4
destination cache entries. At twice this value the system will
refuse new allocations.
我使用内核3.10.59遇到了这个问题,默认限制非常低 – 1024.
从内核3.10.83开始,此限制增加到32768,并且将是much harder to hit.
所以,我发了:
# sysctl net.ipv4.xfrm4_gc_thresh=32768
它为我做了一件事.
使用IPSec的内核中的近似路径:
ip4_datagram_connect() -> ip_route_connect() -> ip_route_output_flow() ->
xfrm_lookup() -> xfrm_resolve_and_create_bundle() ->
... -> xfrm_alloc_dst() -> dst_alloc() with xfrm4_dst_ops, where gc is set.