exanic-software icon indicating copy to clipboard operation
exanic-software copied to clipboard

Turning off TCP keepalive does not work on bypassed sockets when no activity is performed

Open vient opened this issue 4 years ago • 0 comments

Expectation: setting SO_KEEPALIVE to 0 on socket turns off keepalive logic.

Reality: setting SO_KEEPALIVE to 0 on socket zeroes out userspace keepalive variables but does not zero out kernel keepalive timer. When time of next keepalive packet comes, no "is keepalive enabled" check is performed.

https://github.com/exablaze-oss/exanic-software/blob/404da33717db8029557eb884fb1285f7c43bc75e/modules/exasock/exasock-tcp.c#L2966-L2989

state->p.tcp.keepalive.probes is zero so tcp->keepalive.probe_cnt < state->p.tcp.keepalive.probes check is never passed. As a result, keepalive is not turned off; on the contrary, socket is invariably closed with ETIMEDOUT when timer goes to zero.


I fixed it for myself by changing line https://github.com/exablaze-oss/exanic-software/blob/404da33717db8029557eb884fb1285f7c43bc75e/modules/exasock/exasock-tcp.c#L2970 to

if (tcp->keepalive.timer == 0 && state->p.tcp.keepalive.probes);

but I'm not sure if that's the best way to do so.

vient avatar Oct 12 '21 20:10 vient