From: Ben Pfaff Date: Thu, 18 Mar 2010 19:59:34 +0000 (-0700) Subject: ovsdb: Use port 6632 as a default port for database connections. X-Git-Tag: v1.0.0~167 X-Git-Url: http://git.onelab.eu/?a=commitdiff_plain;h=0d11f523a371910cb0ed5549a85836f83a7552c2;p=sliver-openvswitch.git ovsdb: Use port 6632 as a default port for database connections. Until now we have required a port number to be specified explicitly for database connections. This commit adopts port 6632 as a default. --- diff --git a/lib/jsonrpc.c b/lib/jsonrpc.c index f0ac27bc9..72590a2f4 100644 --- a/lib/jsonrpc.c +++ b/lib/jsonrpc.c @@ -56,6 +56,24 @@ static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT(5, 5); static void jsonrpc_received(struct jsonrpc *); static void jsonrpc_cleanup(struct jsonrpc *); +/* This is just the same as stream_open() except that it uses the default + * JSONRPC ports if none is specified. */ +int +jsonrpc_stream_open(const char *name, struct stream **streamp) +{ + return stream_open_with_default_ports(name, JSONRPC_TCP_PORT, + JSONRPC_SSL_PORT, streamp); +} + +/* This is just the same as pstream_open() except that it uses the default + * JSONRPC ports if none is specified. */ +int +jsonrpc_pstream_open(const char *name, struct pstream **pstreamp) +{ + return pstream_open_with_default_ports(name, JSONRPC_TCP_PORT, + JSONRPC_SSL_PORT, pstreamp); +} + struct jsonrpc * jsonrpc_open(struct stream *stream) { @@ -727,12 +745,12 @@ jsonrpc_session_connect(struct jsonrpc_session *s) jsonrpc_session_disconnect(s); if (!reconnect_is_passive(s->reconnect)) { - error = stream_open(name, &s->stream); + error = jsonrpc_stream_open(name, &s->stream); if (!error) { reconnect_connecting(s->reconnect, time_msec()); } } else { - error = s->pstream ? 0 : pstream_open(name, &s->pstream); + error = s->pstream ? 0 : jsonrpc_pstream_open(name, &s->pstream); if (!error) { reconnect_listening(s->reconnect, time_msec()); } diff --git a/lib/jsonrpc.h b/lib/jsonrpc.h index ae8b9de31..154c459af 100644 --- a/lib/jsonrpc.h +++ b/lib/jsonrpc.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009 Nicira Networks. + * Copyright (c) 2009, 2010 Nicira Networks. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -25,10 +25,21 @@ struct json; struct jsonrpc_msg; +struct pstream; struct stream; /* API for a JSON-RPC stream. */ +/* Default port numbers. + * + * There is nothing standard about these port numbers. They are simply what + * we have chosen. */ +#define JSONRPC_TCP_PORT 6632 +#define JSONRPC_SSL_PORT 6632 + +int jsonrpc_stream_open(const char *name, struct stream **); +int jsonrpc_pstream_open(const char *name, struct pstream **); + struct jsonrpc *jsonrpc_open(struct stream *); void jsonrpc_close(struct jsonrpc *); diff --git a/ovsdb/SPECS b/ovsdb/SPECS index c926e2122..cbd69defc 100644 --- a/ovsdb/SPECS +++ b/ovsdb/SPECS @@ -251,6 +251,8 @@ over HTTP, for these reasons: * The JSON-RPC specification for HTTP transport is incomplete. +We are using TCP port 6632 for the database JSON-RPC connection. + The database wire protocol consists of the following JSON-RPC methods: list_dbs diff --git a/ovsdb/jsonrpc-server.c b/ovsdb/jsonrpc-server.c index 73c3c1c05..84243d58e 100644 --- a/ovsdb/jsonrpc-server.c +++ b/ovsdb/jsonrpc-server.c @@ -144,7 +144,7 @@ ovsdb_jsonrpc_server_add_remote(struct ovsdb_jsonrpc_server *svr, struct pstream *listener; int error; - error = pstream_open(name, &listener); + error = jsonrpc_pstream_open(name, &listener); if (error && error != EAFNOSUPPORT) { VLOG_ERR_RL(&rl, "%s: listen failed: %s", name, strerror(error)); return; diff --git a/ovsdb/ovsdb-client.c b/ovsdb/ovsdb-client.c index a17c5aa86..7a8310f15 100644 --- a/ovsdb/ovsdb-client.c +++ b/ovsdb/ovsdb-client.c @@ -224,11 +224,11 @@ open_jsonrpc(const char *server) struct stream *stream; int error; - error = stream_open_block(stream_open(server, &stream), &stream); + error = stream_open_block(jsonrpc_stream_open(server, &stream), &stream); if (error == EAFNOSUPPORT) { struct pstream *pstream; - error = pstream_open(server, &pstream); + error = jsonrpc_pstream_open(server, &pstream); if (error) { ovs_fatal(error, "failed to connect or listen to \"%s\"", server); } diff --git a/tests/test-jsonrpc.c b/tests/test-jsonrpc.c index f760b3ca3..d02a65f15 100644 --- a/tests/test-jsonrpc.c +++ b/tests/test-jsonrpc.c @@ -185,7 +185,7 @@ do_listen(int argc OVS_UNUSED, char *argv[]) die_if_already_running(); - error = pstream_open(argv[1], &pstream); + error = jsonrpc_pstream_open(argv[1], &pstream); if (error) { ovs_fatal(error, "could not listen on \"%s\"", argv[1]); } @@ -274,7 +274,7 @@ do_request(int argc OVS_UNUSED, char *argv[]) ovs_fatal(0, "not a valid JSON-RPC request: %s", string); } - error = stream_open_block(stream_open(argv[1], &stream), &stream); + error = stream_open_block(jsonrpc_stream_open(argv[1], &stream), &stream); if (error) { ovs_fatal(error, "could not open \"%s\"", argv[1]); } @@ -313,7 +313,7 @@ do_notify(int argc OVS_UNUSED, char *argv[]) ovs_fatal(0, "not a JSON RPC-valid notification: %s", string); } - error = stream_open_block(stream_open(argv[1], &stream), &stream); + error = stream_open_block(jsonrpc_stream_open(argv[1], &stream), &stream); if (error) { ovs_fatal(error, "could not open \"%s\"", argv[1]); } diff --git a/tests/test-ovsdb.c b/tests/test-ovsdb.c index 8cb6c9433..41308d523 100644 --- a/tests/test-ovsdb.c +++ b/tests/test-ovsdb.c @@ -1764,7 +1764,8 @@ do_idl(int argc, char *argv[]) if (argc > 2) { struct stream *stream; - error = stream_open_block(stream_open(argv[1], &stream), &stream); + error = stream_open_block(jsonrpc_stream_open(argv[1], &stream), + &stream); if (error) { ovs_fatal(error, "failed to connect to \"%s\"", argv[1]); }