- Add t_keepidle to tcpcb, it is initialized to tcp_keepidle
- The accepted socket's t_keepidle is inherited from the listen socket
- Add IPPROTO_TCP/TCP_KEEPIDLE socket option to get and set t_keepidle.
The unit is milliseconds, which is as same as the unit of the sysctl
node net.inet.tcp.keepidle
#define TCP_KEEPINIT 0x20
/* 0x40 unused */
#define TCP_FASTKEEP 0x80
+#define TCP_KEEPIDLE 0x100
#endif
bzero(tp->tt_msg, sizeof(*tp->tt_msg));
tp->t_keepinit = tcp_keepinit;
+ tp->t_keepidle = tcp_keepidle;
if (tcp_do_rfc1323)
tp->t_flags = (TF_REQ_SCALE | TF_REQ_TSTMP);
*/
ltp = intotcpcb(linp);
tp->t_keepinit = ltp->t_keepinit;
+ tp->t_keepidle = ltp->t_keepidle;
tcp_create_timermsg(tp, port);
tcp_callout_reset(tp, tp->tt_keep, tp->t_keepinit, tcp_timer_keep);
if (_tp->t_flags & TF_FASTKEEP)
return (tcp_keepintvl);
else
- return (tcp_keepidle);
+ return (_tp->t_keepidle);
}
static __inline void
error = EINVAL;
break;
+ case TCP_KEEPIDLE:
+ opthz = ((int64_t)optval * hz) / 1000;
+ if (opthz >= 1)
+ tp->t_keepidle = opthz;
+ else
+ error = EINVAL;
+ break;
+
default:
error = ENOPROTOOPT;
break;
case TCP_KEEPINIT:
optval = ((int64_t)tp->t_keepinit * 1000) / hz;
break;
+ case TCP_KEEPIDLE:
+ optval = ((int64_t)tp->t_keepidle * 1000) / hz;
+ break;
default:
error = ENOPROTOOPT;
break;
int rfbuf_cnt; /* recv buffer autoscaling byte count */
int t_keepinit;
+
+ int t_keepidle;
};
#define IN_FASTRECOVERY(tp) (tp->t_flags & TF_FASTRECOVERY)