{"id":812908,"url":"http://patchwork.ozlabs.org/api/patches/812908/?format=json","web_url":"http://patchwork.ozlabs.org/project/qemu-devel/patch/20170912152153.7729-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":"<20170912152153.7729-4-brandon.carpenter@cypherpath.com>","list_archive_url":null,"date":"2017-09-12T15:21:49","name":"[v3,3/7] 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/20170912152153.7729-4-brandon.carpenter@cypherpath.com/mbox/","series":[{"id":2725,"url":"http://patchwork.ozlabs.org/api/series/2725/?format=json","web_url":"http://patchwork.ozlabs.org/project/qemu-devel/list/?series=2725","date":"2017-09-12T15:21:48","name":"Update websocket code to more fully support the RFC","version":3,"mbox":"http://patchwork.ozlabs.org/series/2725/mbox/"}],"comments":"http://patchwork.ozlabs.org/api/patches/812908/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/812908/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=\"ZHUj937u\"; 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 3xs7t03ZhYz9s7f\n\tfor <incoming@patchwork.ozlabs.org>;\n\tWed, 13 Sep 2017 01:26:00 +1000 (AEST)","from localhost ([::1]:36508 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 1drn4Y-0007Mo-J9\n\tfor incoming@patchwork.ozlabs.org; Tue, 12 Sep 2017 11:25:58 -0400","from eggs.gnu.org ([2001:4830:134:3::10]:40485)\n\tby lists.gnu.org with esmtp (Exim 4.71)\n\t(envelope-from <brandon.carpenter@cypherpath.com>)\n\tid 1drn13-0004jd-5I\n\tfor qemu-devel@nongnu.org; Tue, 12 Sep 2017 11:22:22 -0400","from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)\n\t(envelope-from <brandon.carpenter@cypherpath.com>)\n\tid 1drn12-00071B-7B\n\tfor qemu-devel@nongnu.org; Tue, 12 Sep 2017 11:22:21 -0400","from mail-pg0-x231.google.com ([2607:f8b0:400e:c05::231]:37854)\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 1drn12-00070d-0q\n\tfor qemu-devel@nongnu.org; Tue, 12 Sep 2017 11:22:20 -0400","by mail-pg0-x231.google.com with SMTP id d8so21859067pgt.4\n\tfor <qemu-devel@nongnu.org>; Tue, 12 Sep 2017 08:22:19 -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\td18sm12753054pfk.11.2017.09.12.08.22.17\n\t(version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);\n\tTue, 12 Sep 2017 08:22:18 -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; bh=ynGU1w3AUPeqi+qwRQdEmX20o6+XJQrZapNWIyIuUgE=;\n\tb=ZHUj937u+yUZDzFGFJfcSYbGbqZDnbHu7FIzRRLmLgCy8g7AZe6/p/GSfn9ELnbqto\n\tuXu64pvo0fiOXFAFF+z8ywRjzZKV94jM5y/NDtrwHltMqHVzm8ArrrDAFX/nmEnPDgjN\n\t51ZOOyVK4mLSAWXiBaDjgR+8nC4pce1ODHqHk=","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;\n\tbh=ynGU1w3AUPeqi+qwRQdEmX20o6+XJQrZapNWIyIuUgE=;\n\tb=TVlSZOll6YdVQKaIJdJ9hf/dzcY4i9tVjAnUy+rxd++b8w36lloQcNQOLzMn/sN3e8\n\tURGpW109hbuhVxcvIrYmyFpkOQ+0FGfpP2PGVkedhQVUgwJYWhUd8zedDb64NXg7H9/4\n\tafh0CkyOmRdn7RccV325u+Q5sP99mDT7opPYQSC7fbbV/uJwBct7CKegQM8eGGG/b9vC\n\t6s5rUb05v7mRGw0sRvE9O+EbnSHixcPdROyJRZRqG5F/6ygQyudQ+lop9z7nVZCHyMi/\n\tf1ePlUZoHbcpk4Gf/K/L3jbiPj7X7G9DwCL+SaqARXlRtv2rvCfrDuYvqf/58SkI74++\n\tWIxQ==","X-Gm-Message-State":"AHPjjUgnA0QgBwGqsKjU7NRNsj+jdrMdUz6v6/ygMqcvmVCiFF6tkLoj\n\t398Fc+YfteVDII+O5LNFDXRBqrnXlh41qbOBJWpGliLStgsnDeyIZa8+RKtSkoFm7Jeu6GdUPuW\n\tBHrw7","MIME-Version":"1.0","X-Google-Smtp-Source":"ADKCNb6iImUTblM0l0cwlYjEEx9l0rpES7pQfowKTjFgmTvrDM0tN5DACYeWlkVQTOJNTAjYFiMbHQ==","X-Received":"by 10.84.238.198 with SMTP id l6mr17261859pln.152.1505229738887; \n\tTue, 12 Sep 2017 08:22:18 -0700 (PDT)","From":"Brandon Carpenter <brandon.carpenter@cypherpath.com>","To":"qemu-devel@nongnu.org","Date":"Tue, 12 Sep 2017 08:21:49 -0700","Message-Id":"<20170912152153.7729-4-brandon.carpenter@cypherpath.com>","X-Mailer":"git-send-email 2.14.1","In-Reply-To":"<20170912152153.7729-1-brandon.carpenter@cypherpath.com>","References":"<20170912152153.7729-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::231","Subject":"[Qemu-devel] [PATCH v3 3/7] 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":["v3","3/7"]}