When a connection was spliced in one direction and in copy mode in
authorbluhm <bluhm@openbsd.org>
Mon, 14 Jul 2014 00:11:12 +0000 (00:11 +0000)
committerbluhm <bluhm@openbsd.org>
Mon, 14 Jul 2014 00:11:12 +0000 (00:11 +0000)
the other direction, the timeouts did not work.  They were longer
than specified.  Link the splicing and non-splicing timeouts.
Found by make run-regress-args-timeout-http.pl
OK reyk@

usr.sbin/relayd/relay.c
usr.sbin/relayd/relay_http.c
usr.sbin/relayd/relayd.h

index f4d093f..b5d5f8f 100644 (file)
@@ -1,4 +1,4 @@
-/*     $OpenBSD: relay.c,v 1.174 2014/07/13 00:32:08 benno Exp $       */
+/*     $OpenBSD: relay.c,v 1.175 2014/07/14 00:11:12 bluhm Exp $       */
 
 /*
  * Copyright (c) 2006 - 2014 Reyk Floeter <reyk@openbsd.org>
@@ -811,6 +811,7 @@ relay_read(struct bufferevent *bev, void *arg)
        struct evbuffer         *src = EVBUFFER_INPUT(bev);
 
        getmonotime(&con->se_tv_last);
+       cre->timedout = 0;
 
        if (!EVBUFFER_LENGTH(src))
                return;
@@ -942,6 +943,7 @@ relay_error(struct bufferevent *bev, short error, void *arg)
                                relay_close(con, "buffer event timeout");
                                break;
                        case 1:
+                               cre->timedout = 1;
                                bufferevent_enable(bev, EV_READ);
                                break;
                        }
@@ -962,6 +964,9 @@ relay_error(struct bufferevent *bev, short error, void *arg)
                                bufferevent_enable(bev, EV_READ);
                                break;
                        }
+               } else if (cre->dst->timedout) {
+                       relay_close(con, "splice timeout");
+                       return;
                }
                if (relay_spliceadjust(cre) == -1)
                        goto fail;
index 6a6beaa..bd0449b 100644 (file)
@@ -1,4 +1,4 @@
-/*     $OpenBSD: relay_http.c,v 1.30 2014/07/13 15:39:01 reyk Exp $    */
+/*     $OpenBSD: relay_http.c,v 1.31 2014/07/14 00:11:12 bluhm Exp $   */
 
 /*
  * Copyright (c) 2006 - 2014 Reyk Floeter <reyk@openbsd.org>
@@ -173,6 +173,7 @@ relay_read_http(struct bufferevent *bev, void *arg)
        struct kv               *hdr = NULL;
 
        getmonotime(&con->se_tv_last);
+       cre->timedout = 0;
 
        size = EVBUFFER_LENGTH(src);
        DPRINTF("%s: session %d: size %lu, to read %lld",
@@ -457,6 +458,7 @@ relay_read_httpcontent(struct bufferevent *bev, void *arg)
        size_t                   size;
 
        getmonotime(&con->se_tv_last);
+       cre->timedout = 0;
 
        size = EVBUFFER_LENGTH(src);
        DPRINTF("%s: session %d: size %lu, to read %lld", __func__,
@@ -510,6 +512,7 @@ relay_read_httpchunks(struct bufferevent *bev, void *arg)
        size_t                   size;
 
        getmonotime(&con->se_tv_last);
+       cre->timedout = 0;
 
        size = EVBUFFER_LENGTH(src);
        DPRINTF("%s: session %d: size %lu, to read %lld", __func__,
index 6c86e29..622f871 100644 (file)
@@ -1,4 +1,4 @@
-/*     $OpenBSD: relayd.h,v 1.188 2014/07/13 00:32:08 benno Exp $      */
+/*     $OpenBSD: relayd.h,v 1.189 2014/07/14 00:11:12 bluhm Exp $      */
 
 /*
  * Copyright (c) 2006 - 2014 Reyk Floeter <reyk@openbsd.org>
@@ -183,10 +183,11 @@ struct ctl_relay_event {
        enum sslreneg_state      sslreneg_state;
 
        off_t                    splicelen;
-       int                      line;
-       size_t                   headerlen;
        off_t                    toread;
+       size_t                   headerlen;
+       int                      line;
        int                      done;
+       int                      timedout;
        enum direction           dir;
 
        u_int8_t                *buf;