tcp: Reset keepalive timer, if TCP_KEEPIDLE is changed
authorSepherosa Ziehau <sephe@dragonflybsd.org>
Thu, 19 Apr 2012 06:57:36 +0000 (14:57 +0800)
committerSepherosa Ziehau <sephe@dragonflybsd.org>
Thu, 19 Apr 2012 06:57:36 +0000 (14:57 +0800)
This would cause side effect, if the keepalive probing was underway.
Correcting this side effect could become overkill, so it is suggested
that TCP_KEEPIDLE is set before connect(2) or listen(2).

sys/netinet/tcp_usrreq.c

index fe46bc4..1b3eb0c 100644 (file)
@@ -1428,10 +1428,12 @@ tcp_ctloutput(netmsg_t msg)
 
                case TCP_KEEPIDLE:
                        opthz = ((int64_t)optval * hz) / 1000;
-                       if (opthz >= 1)
+                       if (opthz >= 1) {
                                tp->t_keepidle = opthz;
-                       else
+                               tcp_timer_keep_activity(tp, 0);
+                       } else {
                                error = EINVAL;
+                       }
                        break;
 
                case TCP_KEEPINTVL: