Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/815872/?format=api
{ "id": 815872, "url": "http://patchwork.ozlabs.org/api/patches/815872/?format=api", "web_url": "http://patchwork.ozlabs.org/project/openvswitch/patch/20170919220125.32535-7-blp@ovn.org/", "project": { "id": 47, "url": "http://patchwork.ozlabs.org/api/projects/47/?format=api", "name": "Open vSwitch", "link_name": "openvswitch", "list_id": "ovs-dev.openvswitch.org", "list_email": "ovs-dev@openvswitch.org", "web_url": "http://openvswitch.org/", "scm_url": "git@github.com:openvswitch/ovs.git", "webscm_url": "https://github.com/openvswitch/ovs", "list_archive_url": "", "list_archive_url_format": "", "commit_url_format": "" }, "msgid": "<20170919220125.32535-7-blp@ovn.org>", "list_archive_url": null, "date": "2017-09-19T22:00:39", "name": "[ovs-dev,RFC,06/52] jsonrpc: Allow jsonrpc_session to have more than one remote.", "commit_ref": null, "pull_url": null, "state": "rfc", "archived": false, "hash": "a370e4e1d8be3ca5d22d0d6efac43a59df38939a", "submitter": { "id": 67603, "url": "http://patchwork.ozlabs.org/api/people/67603/?format=api", "name": "Ben Pfaff", "email": "blp@ovn.org" }, "delegate": null, "mbox": "http://patchwork.ozlabs.org/project/openvswitch/patch/20170919220125.32535-7-blp@ovn.org/mbox/", "series": [ { "id": 3975, "url": "http://patchwork.ozlabs.org/api/series/3975/?format=api", "web_url": "http://patchwork.ozlabs.org/project/openvswitch/list/?series=3975", "date": "2017-09-19T22:00:34", "name": "clustering implementation", "version": 1, "mbox": "http://patchwork.ozlabs.org/series/3975/mbox/" } ], "comments": "http://patchwork.ozlabs.org/api/patches/815872/comments/", "check": "pending", "checks": "http://patchwork.ozlabs.org/api/patches/815872/checks/", "tags": {}, "related": [], "headers": { "Return-Path": "<ovs-dev-bounces@openvswitch.org>", "X-Original-To": [ "incoming@patchwork.ozlabs.org", "dev@openvswitch.org" ], "Delivered-To": [ "patchwork-incoming@bilbo.ozlabs.org", "ovs-dev@mail.linuxfoundation.org" ], "Authentication-Results": "ozlabs.org;\n\tspf=pass (mailfrom) smtp.mailfrom=openvswitch.org\n\t(client-ip=140.211.169.12; helo=mail.linuxfoundation.org;\n\tenvelope-from=ovs-dev-bounces@openvswitch.org;\n\treceiver=<UNKNOWN>)", "Received": [ "from mail.linuxfoundation.org (mail.linuxfoundation.org\n\t[140.211.169.12])\n\t(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256\n\tbits)) (No client certificate requested)\n\tby ozlabs.org (Postfix) with ESMTPS id 3xxcPq0sSpz9sBW\n\tfor <incoming@patchwork.ozlabs.org>;\n\tWed, 20 Sep 2017 08:05:35 +1000 (AEST)", "from mail.linux-foundation.org (localhost [127.0.0.1])\n\tby mail.linuxfoundation.org (Postfix) with ESMTP id 818A0C21;\n\tTue, 19 Sep 2017 22:01:47 +0000 (UTC)", "from smtp1.linuxfoundation.org (smtp1.linux-foundation.org\n\t[172.17.192.35])\n\tby mail.linuxfoundation.org (Postfix) with ESMTPS id B3F46B55\n\tfor <dev@openvswitch.org>; Tue, 19 Sep 2017 22:01:43 +0000 (UTC)", "from relay4-d.mail.gandi.net (relay4-d.mail.gandi.net\n\t[217.70.183.196])\n\tby smtp1.linuxfoundation.org (Postfix) with ESMTPS id 2E624159\n\tfor <dev@openvswitch.org>; Tue, 19 Sep 2017 22:01:43 +0000 (UTC)", "from sigabrt.benpfaff.org (unknown [208.91.2.3])\n\t(Authenticated sender: blp@ovn.org)\n\tby relay4-d.mail.gandi.net (Postfix) with ESMTPSA id 0DCB217209C;\n\tWed, 20 Sep 2017 00:01:40 +0200 (CEST)" ], "X-Greylist": "domain auto-whitelisted by SQLgrey-1.7.6", "X-Originating-IP": "208.91.2.3", "From": "Ben Pfaff <blp@ovn.org>", "To": "dev@openvswitch.org", "Date": "Tue, 19 Sep 2017 15:00:39 -0700", "Message-Id": "<20170919220125.32535-7-blp@ovn.org>", "X-Mailer": "git-send-email 2.10.2", "In-Reply-To": "<20170919220125.32535-1-blp@ovn.org>", "References": "<20170919220125.32535-1-blp@ovn.org>", "X-Spam-Status": "No, score=-0.7 required=5.0 tests=RCVD_IN_DNSWL_LOW\n\tautolearn=disabled version=3.3.1", "X-Spam-Checker-Version": "SpamAssassin 3.3.1 (2010-03-16) on\n\tsmtp1.linux-foundation.org", "Cc": "Ben Pfaff <blp@ovn.org>", "Subject": "[ovs-dev] [PATCH RFC 06/52] jsonrpc: Allow jsonrpc_session to have\n\tmore than one remote.", "X-BeenThere": "ovs-dev@openvswitch.org", "X-Mailman-Version": "2.1.12", "Precedence": "list", "List-Id": "<ovs-dev.openvswitch.org>", "List-Unsubscribe": "<https://mail.openvswitch.org/mailman/options/ovs-dev>,\n\t<mailto:ovs-dev-request@openvswitch.org?subject=unsubscribe>", "List-Archive": "<http://mail.openvswitch.org/pipermail/ovs-dev/>", "List-Post": "<mailto:ovs-dev@openvswitch.org>", "List-Help": "<mailto:ovs-dev-request@openvswitch.org?subject=help>", "List-Subscribe": "<https://mail.openvswitch.org/mailman/listinfo/ovs-dev>,\n\t<mailto:ovs-dev-request@openvswitch.org?subject=subscribe>", "MIME-Version": "1.0", "Content-Type": "text/plain; charset=\"us-ascii\"", "Content-Transfer-Encoding": "7bit", "Sender": "ovs-dev-bounces@openvswitch.org", "Errors-To": "ovs-dev-bounces@openvswitch.org" }, "content": "The implementation cycles through the remotes in random order. This allows\nclients to perform some load balancing across alternative implementations\nof a service.\n\nSigned-off-by: Ben Pfaff <blp@ovn.org>\n---\n lib/jsonrpc.c | 66 ++++++++++++++++++++++++++++++++++++++++++++++++++++++-----\n lib/jsonrpc.h | 5 ++++-\n 2 files changed, 65 insertions(+), 6 deletions(-)", "diff": "diff --git a/lib/jsonrpc.c b/lib/jsonrpc.c\nindex 2fae057de181..838334daa9a8 100644\n--- a/lib/jsonrpc.c\n+++ b/lib/jsonrpc.c\n@@ -1,5 +1,5 @@\n /*\n- * Copyright (c) 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016 Nicira, Inc.\n+ * Copyright (c) 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017 Nicira, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n@@ -28,6 +28,7 @@\n #include \"openvswitch/ofpbuf.h\"\n #include \"ovs-thread.h\"\n #include \"poll-loop.h\"\n+#include \"random.h\"\n #include \"reconnect.h\"\n #include \"stream.h\"\n #include \"timeval.h\"\n@@ -753,6 +754,10 @@ jsonrpc_msg_to_json(struct jsonrpc_msg *m)\n /* A JSON-RPC session with reconnection. */\n \n struct jsonrpc_session {\n+ char **remotes;\n+ size_t n_remotes;\n+ size_t next_remote;\n+\n struct reconnect *reconnect;\n struct jsonrpc *rpc;\n struct stream *stream;\n@@ -762,6 +767,13 @@ struct jsonrpc_session {\n uint8_t dscp;\n };\n \n+static void\n+jsonrpc_session_pick_remote(struct jsonrpc_session *s)\n+{\n+ reconnect_set_name(s->reconnect,\n+ s->remotes[s->next_remote++ % s->n_remotes]);\n+}\n+\n /* Creates and returns a jsonrpc_session to 'name', which should be a string\n * acceptable to stream_open() or pstream_open().\n *\n@@ -779,12 +791,36 @@ struct jsonrpc_session {\n struct jsonrpc_session *\n jsonrpc_session_open(const char *name, bool retry)\n {\n+ return jsonrpc_session_open_multiple(&name, 1, retry);\n+}\n+\n+struct jsonrpc_session *\n+jsonrpc_session_open_multiple(const char **names, size_t n, bool retry)\n+{\n struct jsonrpc_session *s;\n \n s = xmalloc(sizeof *s);\n+\n+ /* Set 'n' remotes from 'names', shuffling them into random order. */\n+ ovs_assert(n > 0);\n+ s->remotes = xmalloc(n * sizeof *s->remotes);\n+ for (size_t i = 0; i < n; i++) {\n+ s->remotes[i] = xstrdup(names[i]);\n+ }\n+ s->n_remotes = n;\n+ for (size_t i = 0; i < n; i++) {\n+ size_t j = i + random_range(n - i);\n+ char **r = s->remotes;\n+ char *tmp = r[i];\n+ r[i] = r[j];\n+ r[j] = tmp;\n+ }\n+ s->next_remote = 0;\n+\n s->reconnect = reconnect_create(time_msec());\n- reconnect_set_name(s->reconnect, name);\n+ jsonrpc_session_pick_remote(s);\n reconnect_enable(s->reconnect, time_msec());\n+ reconnect_set_backoff_free_tries(s->reconnect, n);\n s->rpc = NULL;\n s->stream = NULL;\n s->pstream = NULL;\n@@ -792,10 +828,11 @@ jsonrpc_session_open(const char *name, bool retry)\n s->dscp = 0;\n s->last_error = 0;\n \n+ const char *name = reconnect_get_name(s->reconnect);\n if (!pstream_verify_name(name)) {\n reconnect_set_passive(s->reconnect, true, time_msec());\n } else if (!retry) {\n- reconnect_set_max_tries(s->reconnect, 1);\n+ reconnect_set_max_tries(s->reconnect, n);\n reconnect_set_backoff(s->reconnect, INT_MAX, INT_MAX);\n }\n \n@@ -817,6 +854,10 @@ jsonrpc_session_open_unreliably(struct jsonrpc *jsonrpc, uint8_t dscp)\n struct jsonrpc_session *s;\n \n s = xmalloc(sizeof *s);\n+ s->remotes = xmalloc(sizeof *s->remotes);\n+ s->remotes[0] = xstrdup(jsonrpc_get_name(jsonrpc));\n+ s->n_remotes = 1;\n+ s->next_remote = 0;\n s->reconnect = reconnect_create(time_msec());\n reconnect_set_quiet(s->reconnect, true);\n reconnect_set_name(s->reconnect, jsonrpc_get_name(jsonrpc));\n@@ -839,6 +880,10 @@ jsonrpc_session_close(struct jsonrpc_session *s)\n reconnect_destroy(s->reconnect);\n stream_close(s->stream);\n pstream_close(s->pstream);\n+ for (size_t i = 0; i < s->n_remotes; i++) {\n+ free(s->remotes[i]);\n+ }\n+ free(s->remotes);\n free(s);\n }\n }\n@@ -850,12 +895,15 @@ jsonrpc_session_disconnect(struct jsonrpc_session *s)\n jsonrpc_error(s->rpc, EOF);\n jsonrpc_close(s->rpc);\n s->rpc = NULL;\n- s->seqno++;\n } else if (s->stream) {\n stream_close(s->stream);\n s->stream = NULL;\n- s->seqno++;\n+ } else {\n+ return;\n }\n+\n+ s->seqno++;\n+ jsonrpc_session_pick_remote(s);\n }\n \n static void\n@@ -882,6 +930,7 @@ jsonrpc_session_connect(struct jsonrpc_session *s)\n \n if (error) {\n reconnect_connect_failed(s->reconnect, time_msec(), error);\n+ jsonrpc_session_pick_remote(s);\n }\n s->seqno++;\n }\n@@ -945,6 +994,7 @@ jsonrpc_session_run(struct jsonrpc_session *s)\n s->stream = NULL;\n } else if (error != EAGAIN) {\n reconnect_connect_failed(s->reconnect, time_msec(), error);\n+ jsonrpc_session_pick_remote(s);\n stream_close(s->stream);\n s->stream = NULL;\n s->last_error = error;\n@@ -1015,6 +1065,12 @@ jsonrpc_session_get_id(const struct jsonrpc_session *s)\n }\n }\n \n+size_t\n+jsonrpc_session_get_n_remotes(const struct jsonrpc_session *s)\n+{\n+ return s->n_remotes;\n+}\n+\n /* Always takes ownership of 'msg', regardless of success. */\n int\n jsonrpc_session_send(struct jsonrpc_session *s, struct jsonrpc_msg *msg)\ndiff --git a/lib/jsonrpc.h b/lib/jsonrpc.h\nindex 9b4fb0e51374..97110c00ff05 100644\n--- a/lib/jsonrpc.h\n+++ b/lib/jsonrpc.h\n@@ -1,5 +1,5 @@\n /*\n- * Copyright (c) 2009, 2010, 2012, 2013 Nicira, Inc.\n+ * Copyright (c) 2009, 2010, 2012, 2013, 2017 Nicira, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n@@ -99,6 +99,8 @@ struct json *jsonrpc_msg_to_json(struct jsonrpc_msg *);\n /* A JSON-RPC session with reconnection. */\n \n struct jsonrpc_session *jsonrpc_session_open(const char *name, bool retry);\n+struct jsonrpc_session *jsonrpc_session_open_multiple(const char **remotes,\n+ size_t n, bool retry);\n struct jsonrpc_session *jsonrpc_session_open_unreliably(struct jsonrpc *,\n uint8_t);\n void jsonrpc_session_close(struct jsonrpc_session *);\n@@ -108,6 +110,7 @@ void jsonrpc_session_wait(struct jsonrpc_session *);\n \n size_t jsonrpc_session_get_backlog(const struct jsonrpc_session *);\n const char *jsonrpc_session_get_name(const struct jsonrpc_session *);\n+size_t jsonrpc_session_get_n_remotes(const struct jsonrpc_session *);\n \n int jsonrpc_session_send(struct jsonrpc_session *, struct jsonrpc_msg *);\n struct jsonrpc_msg *jsonrpc_session_recv(struct jsonrpc_session *);\n", "prefixes": [ "ovs-dev", "RFC", "06/52" ] }