{"id":811751,"url":"http://patchwork.ozlabs.org/api/patches/811751/?format=json","web_url":"http://patchwork.ozlabs.org/project/qemu-devel/patch/20170908173801.15205-4-brandon.carpenter@cypherpath.com/","project":{"id":14,"url":"http://patchwork.ozlabs.org/api/projects/14/?format=json","name":"QEMU Development","link_name":"qemu-devel","list_id":"qemu-devel.nongnu.org","list_email":"qemu-devel@nongnu.org","web_url":"","scm_url":"","webscm_url":"","list_archive_url":"","list_archive_url_format":"","commit_url_format":""},"msgid":"<20170908173801.15205-4-brandon.carpenter@cypherpath.com>","list_archive_url":null,"date":"2017-09-08T17:37:58","name":"[v2,3/6] io: Add support for fragmented websocket binary frames","commit_ref":null,"pull_url":null,"state":"new","archived":false,"hash":"daa60920ccdf1d7eabc668ccc43af792d7ad5d00","submitter":{"id":72031,"url":"http://patchwork.ozlabs.org/api/people/72031/?format=json","name":"Brandon Carpenter","email":"brandon.carpenter@cypherpath.com"},"delegate":null,"mbox":"http://patchwork.ozlabs.org/project/qemu-devel/patch/20170908173801.15205-4-brandon.carpenter@cypherpath.com/mbox/","series":[{"id":2262,"url":"http://patchwork.ozlabs.org/api/series/2262/?format=json","web_url":"http://patchwork.ozlabs.org/project/qemu-devel/list/?series=2262","date":"2017-09-08T17:37:56","name":"Update websocket code to more fully support the RFC","version":2,"mbox":"http://patchwork.ozlabs.org/series/2262/mbox/"}],"comments":"http://patchwork.ozlabs.org/api/patches/811751/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/811751/checks/","tags":{},"related":[],"headers":{"Return-Path":"<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>","X-Original-To":"incoming@patchwork.ozlabs.org","Delivered-To":"patchwork-incoming@bilbo.ozlabs.org","Authentication-Results":["ozlabs.org;\n\tspf=pass (mailfrom) smtp.mailfrom=nongnu.org\n\t(client-ip=2001:4830:134:3::11; helo=lists.gnu.org;\n\tenvelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org;\n\treceiver=<UNKNOWN>)","ozlabs.org;\n\tdkim=fail reason=\"signature verification failed\" (1024-bit key;\n\tunprotected) header.d=cypherpath.com header.i=@cypherpath.com\n\theader.b=\"c1tdrJVK\"; dkim-atps=neutral"],"Received":["from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11])\n\t(using TLSv1 with cipher AES256-SHA (256/256 bits))\n\t(No client certificate requested)\n\tby ozlabs.org (Postfix) with ESMTPS id 3xplDx2NhQz9s8J\n\tfor <incoming@patchwork.ozlabs.org>;\n\tSat,  9 Sep 2017 03:49:05 +1000 (AEST)","from localhost ([::1]:46722 helo=lists.gnu.org)\n\tby lists.gnu.org with esmtp (Exim 4.71) (envelope-from\n\t<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>)\n\tid 1dqNOp-0000m3-DS\n\tfor incoming@patchwork.ozlabs.org; Fri, 08 Sep 2017 13:49:03 -0400","from eggs.gnu.org ([2001:4830:134:3::10]:40091)\n\tby lists.gnu.org with esmtp (Exim 4.71)\n\t(envelope-from <brandon.carpenter@cypherpath.com>)\n\tid 1dqNFQ-0000KE-4X\n\tfor qemu-devel@nongnu.org; Fri, 08 Sep 2017 13:39:21 -0400","from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)\n\t(envelope-from <brandon.carpenter@cypherpath.com>)\n\tid 1dqNFN-0008JN-Uw\n\tfor qemu-devel@nongnu.org; Fri, 08 Sep 2017 13:39:20 -0400","from mail-pg0-x22b.google.com ([2607:f8b0:400e:c05::22b]:35052)\n\tby eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16)\n\t(Exim 4.71) (envelope-from <brandon.carpenter@cypherpath.com>)\n\tid 1dqNFN-0008J1-Ot\n\tfor qemu-devel@nongnu.org; Fri, 08 Sep 2017 13:39:17 -0400","by mail-pg0-x22b.google.com with SMTP id 188so5918619pgb.2\n\tfor <qemu-devel@nongnu.org>; Fri, 08 Sep 2017 10:39:17 -0700 (PDT)","from servo.cypherpath.com (68-113-0-218.static.knwc.wa.charter.com.\n\t[68.113.0.218]) by smtp.gmail.com with ESMTPSA id\n\tc30sm4556833pgn.33.2017.09.08.10.39.15\n\t(version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);\n\tFri, 08 Sep 2017 10:39:15 -0700 (PDT)"],"DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=cypherpath.com; s=google;\n\th=mime-version:from:to:cc:subject:date:message-id:in-reply-to\n\t:references:in-reply-to:references;\n\tbh=ynGU1w3AUPeqi+qwRQdEmX20o6+XJQrZapNWIyIuUgE=;\n\tb=c1tdrJVKAqrUPv1C8T71iD7LAXeuo+3nRECtLiB19TlWNUhIdGLGHnYCXK7gzHZ3jB\n\tlzi4aqU6nyWVnxsncnyh/dhMzpTKKc6R7XCPgnrClLFATO96opsKNuDMPlOKSUGNri8N\n\txpfZ7CUjejX5rzPNsX2wMy7CcvHLuizcT517U=","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20161025;\n\th=x-gm-message-state:mime-version:from:to:cc:subject:date:message-id\n\t:in-reply-to:references:in-reply-to:references;\n\tbh=ynGU1w3AUPeqi+qwRQdEmX20o6+XJQrZapNWIyIuUgE=;\n\tb=Tg7nj4Rum/FL3fZW4LNxvWyV7HC9tSAaeZXAfVqv4PhLTC7IrhZkw4DvqWiFcvFoSq\n\tCCARhj/SU4eZrpJCYRMSsGnmgoydKkHDjGXnqzfp4YiAuzh3GL1eTz8W181+/UtSO14r\n\tLO26HZTwkD7+gx81TefgqI/YVFn3IZYcFir/BwjyYvozkGXB6bqkdaXJvTjVp5WBEwtw\n\tucVV5LHOPyRGnlnbTNI1ieOARrl5zZLvw7kcE9x2qPTD84ZAla87SGOZEhaOfJCBFE0i\n\t0S08v6vHj837XdvdodH1tzO8B2eUWgLtWoEin04h6PNZQbhW2DuLfZOKOo4aUxqX1KO3\n\tRT4A==","X-Gm-Message-State":"AHPjjUheiRXekiH8tgVmj9NXUn/cLHAUSbecGywhcSLN9ukyZPdy2nOf\n\taY9lXhZlCgMMcW5AvrEFJmbDGQDtdAD7RQdWM9KwgiitXRZ+AspJeNkX/9fzOEO/vfzT4Y0SOcT\n\tzgKgj","MIME-Version":"1.0","X-Google-Smtp-Source":"ADKCNb4AcdqioabXSeoDEzxCr9MHAVAFhEoEJze+oWToDBbfe+L/1DdwAkegZBirNDeZOQ/C9LD1Vg==","X-Received":"by 10.98.64.138 with SMTP id f10mr3899132pfd.246.1504892356611; \n\tFri, 08 Sep 2017 10:39:16 -0700 (PDT)","From":"Brandon Carpenter <brandon.carpenter@cypherpath.com>","To":"qemu-devel@nongnu.org","Date":"Fri,  8 Sep 2017 10:37:58 -0700","Message-Id":"<20170908173801.15205-4-brandon.carpenter@cypherpath.com>","X-Mailer":"git-send-email 2.14.1","In-Reply-To":["<20170908173801.15205-1-brandon.carpenter@cypherpath.com>","<20170724184217.21381-1-brandon.carpenter@cypherpath.com>"],"References":["<20170908173801.15205-1-brandon.carpenter@cypherpath.com>","<20170724184217.21381-1-brandon.carpenter@cypherpath.com>"],"Content-Type":"text/plain; charset=\"US-ASCII\"","X-detected-operating-system":"by eggs.gnu.org: Genre and OS details not\n\trecognized.","X-Received-From":"2607:f8b0:400e:c05::22b","Subject":"[Qemu-devel] [PATCH v2 3/6] io: Add support for fragmented\n\twebsocket binary frames","X-BeenThere":"qemu-devel@nongnu.org","X-Mailman-Version":"2.1.21","Precedence":"list","List-Id":"<qemu-devel.nongnu.org>","List-Unsubscribe":"<https://lists.nongnu.org/mailman/options/qemu-devel>,\n\t<mailto:qemu-devel-request@nongnu.org?subject=unsubscribe>","List-Archive":"<http://lists.nongnu.org/archive/html/qemu-devel/>","List-Post":"<mailto:qemu-devel@nongnu.org>","List-Help":"<mailto:qemu-devel-request@nongnu.org?subject=help>","List-Subscribe":"<https://lists.nongnu.org/mailman/listinfo/qemu-devel>,\n\t<mailto:qemu-devel-request@nongnu.org?subject=subscribe>","Cc":"brandon.carpenter@cypherpath.com","Errors-To":"qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org","Sender":"\"Qemu-devel\"\n\t<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>"},"content":"Allows fragmented binary frames by saving the previous opcode. Handles\nthe case where an intermediary (i.e., web proxy) fragments frames\noriginally sent unfragmented by the client.\n\nSigned-off-by: Brandon Carpenter <brandon.carpenter@cypherpath.com>\n---\n include/io/channel-websock.h |  1 +\n io/channel-websock.c         | 26 ++++++++++++++++++--------\n 2 files changed, 19 insertions(+), 8 deletions(-)","diff":"diff --git a/include/io/channel-websock.h b/include/io/channel-websock.h\nindex 3c9ff84727..7c896557c5 100644\n--- a/include/io/channel-websock.h\n+++ b/include/io/channel-websock.h\n@@ -65,6 +65,7 @@ struct QIOChannelWebsock {\n     guint io_tag;\n     Error *io_err;\n     gboolean io_eof;\n+    uint8_t opcode;\n };\n \n /**\ndiff --git a/io/channel-websock.c b/io/channel-websock.c\nindex 185bd31be5..ced24135ec 100644\n--- a/io/channel-websock.c\n+++ b/io/channel-websock.c\n@@ -542,28 +542,38 @@ static int qio_channel_websock_decode_header(QIOChannelWebsock *ioc,\n     has_mask = header->b1 & QIO_CHANNEL_WEBSOCK_HEADER_FIELD_HAS_MASK;\n     payload_len = header->b1 & QIO_CHANNEL_WEBSOCK_HEADER_FIELD_PAYLOAD_LEN;\n \n+    /* Save or restore opcode. */\n+    if (opcode) {\n+        ioc->opcode = opcode;\n+    } else {\n+        opcode = ioc->opcode;\n+    }\n+\n     if (opcode == QIO_CHANNEL_WEBSOCK_OPCODE_CLOSE) {\n         /* disconnect */\n         return 0;\n     }\n \n     /* Websocket frame sanity check:\n-     * * Websocket fragmentation is not supported.\n-     * * All  websockets frames sent by a client have to be masked.\n+     * * Fragmentation is only supported for binary frames.\n+     * * All frames sent by a client MUST be masked.\n      * * Only binary encoding is supported.\n      */\n     if (!fin) {\n-        error_setg(errp, \"websocket fragmentation is not supported\");\n-        return -1;\n+        if (opcode != QIO_CHANNEL_WEBSOCK_OPCODE_BINARY_FRAME) {\n+            error_setg(errp, \"only binary websocket frames may be fragmented\");\n+            return -1;\n+        }\n+    } else {\n+        if (opcode != QIO_CHANNEL_WEBSOCK_OPCODE_BINARY_FRAME) {\n+            error_setg(errp, \"only binary websocket frames are supported\");\n+            return -1;\n+        }\n     }\n     if (!has_mask) {\n         error_setg(errp, \"client websocket frames must be masked\");\n         return -1;\n     }\n-    if (opcode != QIO_CHANNEL_WEBSOCK_OPCODE_BINARY_FRAME) {\n-        error_setg(errp, \"only binary websocket frames are supported\");\n-        return -1;\n-    }\n \n     if (payload_len < QIO_CHANNEL_WEBSOCK_PAYLOAD_LEN_MAGIC_16_BIT) {\n         ioc->payload_remain = payload_len;\n","prefixes":["v2","3/6"]}