linux kernel端口耗尽优化

 

bind()源ip之后,分配端口会有端口耗尽问题。 linux kernel 如何bind() VRF端口上的源IP

perf看到如下图:

 

 

 

在bind的时候因为还没有目的ip和port,所以可用端口会很少。

socketopt IP_BIND_ADDRESS_NO_PORT 会把分配端口延后至connect阶段,如下图内核代码:

/net/ipv4/af_inet.c::__inet_bind()

 其中 force_bind_address_no_port 是写死的 false。

 

posted on 2025-01-21 17:28  toong  阅读(31)  评论(0)    收藏  举报