openbmc / jsnbd

Apache License 2.0
5 stars 3 forks source link

Configuring keepalive for unix domain socket. #3

Open edineshkumar opened 3 years ago

edineshkumar commented 3 years ago

How can I configure keepalive in unix domain socket for 120sec time period ?

I tried below steps in nbd-proxy.c file, under static int open_nbd_socket(struct ctx *ctx) function:

After socket( );

int idle = 120, interval = 5, maxpkt = 5, optval=1; step 1: setsockopt(sd, SOL_SOCKET, SO_KEEPALIVE, &optval, sizeof(optlval)); // Enabling Keepalive step 2: setsockopt(sd, SOL_TCP, TCP_KEEPIDLE, &idle, sizeof(idle) ); // Overwrite keepidle from default. step 3: setsockopt(sd, SOL_TCP, TCP_KEEPINTVL, &interval, sizeof(interval) ); // Overwrite keepintvl from default. step 4: setsockopt(sd, SOL_TCP, TCP_KEEPCNT, &maxpkt, sizeof(maxpkt) ); // Overwrite keepcnt from default.

Enabling SO_KEEPALIVE has been success, but over write TCP_KEEPIDLE TCP_KEEPINTVL and TCP_KEEPCNT is not getting success, I am getting error like 'Operation not supported' .

Kindly give some inputs to configuring the same .

jk-ozlabs commented 2 years ago

Yep, this is a unix domain socket - so the TCP sockopts do not apply here.

More generally though: there's no such thing as a keepalive for an AF_UNIX socket anyway. Can you explain a little about what you're trying to achieve here?