OpenFastPath / ofp

OpenFastPath project
BSD 3-Clause "New" or "Revised" License
349 stars 126 forks source link

OFP TCP TIME_WAIT buffer count increment #277

Closed manishmatey closed 2 years ago

manishmatey commented 2 years ago

Hi Team,

In OFP timewait.c file, below function is used to set number of TIME_WAIT buffers: --------------------------------- code -------------------------------------------- static int tcptw_auto_size(void) {

ifdef OFP_TCP_MAX_CONNECTION_RATE

return global_param->pcb_tcp_max;

else

int halfrange;

/*
 * Max out at half the ephemeral port range so that TIME_WAIT
 * sockets don't tie up too many ephemeral ports.
 */
if (V_ipport_lastauto > V_ipport_firstauto)
    halfrange = (V_ipport_lastauto - V_ipport_firstauto) / 2;
else
    halfrange = (V_ipport_firstauto - V_ipport_lastauto) / 2;
/* Protect against goofy port ranges smaller than 32. */
return (imin(imax(halfrange, 32), global_param->pcb_tcp_max / 5));

endif / OFP_TCP_MAX_CONNECTION_RATE/

}

In the above code we are assigning 20% of TCP max buffers for TIME_WAIT using formula as below global_param->pcb_tcp_max / 5

Queries : 1) As we can see above TIME_WAIT buffers are dependent on TCP max buffers (global_param->pcb_tcp_max). Can we increase TIME_WAIT buffer alone using /4 (divide by 4), /3 (divide by 3) OR TCP max buffers need to be increase in order to increase TIME_WAIT buffers?

2) If we increase TCP TIME_WAIT buffers using /4(divide by 4) or /3(divide by 3) then is there any impact of this?

bogdanPricope commented 2 years ago

Hi @manishmatey,

The value for 'pcb_tcp_max' can be configured through OFP configuration file (See OFP_CONF_FILE_ENV). I see no reason not to propose a similar method for tcptw.. e.g: to permit configuration of tcptw size as value or percentage of global_param->pcb_tcp_max.

You can propose a change (pull request) with this... it will take (near) forever to be reviewed but you may have it.

At least a memory impact is expected as the computed value is used on allocation of V_tcptw_zone (that is an ODP pool). If memory is not an issue for your setup, you can enable (define) OFP_TCP_MAX_CONNECTION_RATE in ofp_config.h for the default configuration (tcptw size = pcb_tcp_max)

manishmatey commented 2 years ago

@bogdanPricope Thanks for the reply. I will increase TIME_WAIT buffer and proceed.

bogdanPricope commented 2 years ago

@manishmatey You may also check the NFP repo: https://github.com/NetInoSoftware/nfp NFP is a commercial version of OFP with the 'nfp' repo as 'public'/'demo' part. API is similar and has a lot of cool features (e.g DHCP IPv4 client).