summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorMehak Mahajan <mmahajan@nicira.com>2012-03-10 15:58:10 -0800
committerMehak Mahajan <mmahajan@nicira.com>2012-03-23 18:13:08 -0700
commitf125905cdd3dc0339ad968c0a70128807884b400 (patch)
treeab389d41b625f2d9e5c820bdac80ec2df825ff8a /lib
parent11460e2316b88f0bd0ea0005d94338d800ea16bd (diff)
downloadopenvswitch-f125905cdd3dc0339ad968c0a70128807884b400.tar.gz
Allow configuring DSCP on controller and manager connections.
The changes allow the user to specify a separate dscp value for the controller connection and the manager connection. The value will take effect on resetting the connections. If no value is specified a default value of 192 is chosen for each of the connections. Feature #10074 Requested-by: Rajiv Ramanathan <rramanathan@nicira.com> Signed-off-by: Mehak Mahajan <mmahajan@nicira.com>
Diffstat (limited to 'lib')
-rw-r--r--lib/jsonrpc.c22
-rw-r--r--lib/jsonrpc.h7
-rw-r--r--lib/netdev-linux.c1
-rw-r--r--lib/rconn.c12
-rw-r--r--lib/rconn.h5
-rw-r--r--lib/reconnect.c18
-rw-r--r--lib/reconnect.h3
-rw-r--r--lib/socket-util.c36
-rw-r--r--lib/socket-util.h15
-rw-r--r--lib/stream-provider.h15
-rw-r--r--lib/stream-ssl.c16
-rw-r--r--lib/stream-tcp.c11
-rw-r--r--lib/stream-unix.c5
-rw-r--r--lib/stream.c18
-rw-r--r--lib/stream.h10
-rw-r--r--lib/unixctl.c5
-rw-r--r--lib/vconn-provider.h14
-rw-r--r--lib/vconn-stream.c8
-rw-r--r--lib/vconn.c12
-rw-r--r--lib/vconn.h5
20 files changed, 176 insertions, 62 deletions
diff --git a/lib/jsonrpc.c b/lib/jsonrpc.c
index 09b10711f..fa3362d17 100644
--- a/lib/jsonrpc.c
+++ b/lib/jsonrpc.c
@@ -60,19 +60,20 @@ static void jsonrpc_error(struct jsonrpc *, int error);
/* 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)
+jsonrpc_stream_open(const char *name, struct stream **streamp, uint8_t dscp)
{
return stream_open_with_default_ports(name, JSONRPC_TCP_PORT,
- JSONRPC_SSL_PORT, streamp);
+ JSONRPC_SSL_PORT, streamp,
+ dscp);
}
/* 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)
+jsonrpc_pstream_open(const char *name, struct pstream **pstreamp, uint8_t dscp)
{
return pstream_open_with_default_ports(name, JSONRPC_TCP_PORT,
- JSONRPC_SSL_PORT, pstreamp);
+ JSONRPC_SSL_PORT, pstreamp, dscp);
}
/* Returns a new JSON-RPC stream that uses 'stream' for input and output. The
@@ -825,12 +826,14 @@ jsonrpc_session_connect(struct jsonrpc_session *s)
jsonrpc_session_disconnect(s);
if (!reconnect_is_passive(s->reconnect)) {
- error = jsonrpc_stream_open(name, &s->stream);
+ error = jsonrpc_stream_open(name, &s->stream,
+ reconnect_get_dscp(s->reconnect));
if (!error) {
reconnect_connecting(s->reconnect, time_msec());
}
} else {
- error = s->pstream ? 0 : jsonrpc_pstream_open(name, &s->pstream);
+ error = s->pstream ? 0 : jsonrpc_pstream_open(name, &s->pstream,
+ reconnect_get_dscp(s->reconnect));
if (!error) {
reconnect_listening(s->reconnect, time_msec());
}
@@ -1041,3 +1044,10 @@ jsonrpc_session_set_probe_interval(struct jsonrpc_session *s,
{
reconnect_set_probe_interval(s->reconnect, probe_interval);
}
+
+void
+jsonrpc_session_set_dscp(struct jsonrpc_session *s,
+ uint8_t dscp)
+{
+ reconnect_set_dscp(s->reconnect, dscp);
+}
diff --git a/lib/jsonrpc.h b/lib/jsonrpc.h
index ff04a547e..16131d333 100644
--- a/lib/jsonrpc.h
+++ b/lib/jsonrpc.h
@@ -22,6 +22,7 @@
#include <stdbool.h>
#include <stddef.h>
+#include "openvswitch/types.h"
struct json;
struct jsonrpc_msg;
@@ -38,8 +39,8 @@ struct stream;
#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 **);
+int jsonrpc_stream_open(const char *name, struct stream **, uint8_t dscp);
+int jsonrpc_pstream_open(const char *name, struct pstream **, uint8_t dscp);
struct jsonrpc *jsonrpc_open(struct stream *);
void jsonrpc_close(struct jsonrpc *);
@@ -123,5 +124,7 @@ void jsonrpc_session_set_max_backoff(struct jsonrpc_session *,
int max_backofF);
void jsonrpc_session_set_probe_interval(struct jsonrpc_session *,
int probe_interval);
+void jsonrpc_session_set_dscp(struct jsonrpc_session *,
+ uint8_t dscp);
#endif /* jsonrpc.h */
diff --git a/lib/netdev-linux.c b/lib/netdev-linux.c
index a5e6d3663..d2a5c7acc 100644
--- a/lib/netdev-linux.c
+++ b/lib/netdev-linux.c
@@ -26,7 +26,6 @@
#include <linux/gen_stats.h>
#include <linux/if_ether.h>
#include <linux/if_tun.h>
-#include <linux/ip.h>
#include <linux/types.h>
#include <linux/ethtool.h>
#include <linux/mii.h>
diff --git a/lib/rconn.c b/lib/rconn.c
index f6d85a7bd..56a7e1976 100644
--- a/lib/rconn.c
+++ b/lib/rconn.c
@@ -121,6 +121,7 @@ struct rconn {
* attempt to the next. */
ovs_be32 local_ip, remote_ip;
ovs_be16 remote_port;
+ uint8_t dscp;
/* Messages sent or received are copied to the monitor connections. */
#define MAX_MONITORS 8
@@ -160,7 +161,7 @@ static bool rconn_logging_connection_attempts__(const struct rconn *);
* The new rconn is initially unconnected. Use rconn_connect() or
* rconn_connect_unreliably() to connect it. */
struct rconn *
-rconn_create(int probe_interval, int max_backoff)
+rconn_create(int probe_interval, int max_backoff, uint8_t dscp)
{
struct rconn *rc = xzalloc(sizeof *rc);
@@ -194,6 +195,7 @@ rconn_create(int probe_interval, int max_backoff)
rc->total_time_connected = 0;
rconn_set_probe_interval(rc, probe_interval);
+ rconn_set_dscp(rc, dscp);
rc->n_monitors = 0;
@@ -219,6 +221,12 @@ rconn_get_max_backoff(const struct rconn *rc)
}
void
+rconn_set_dscp(struct rconn *rc, uint8_t dscp)
+{
+ rc->dscp = dscp;
+}
+
+void
rconn_set_probe_interval(struct rconn *rc, int probe_interval)
{
rc->probe_interval = probe_interval ? MAX(5, probe_interval) : 0;
@@ -335,7 +343,7 @@ reconnect(struct rconn *rc)
VLOG_INFO("%s: connecting...", rc->name);
}
rc->n_attempted_connections++;
- retval = vconn_open(rc->target, OFP10_VERSION, &rc->vconn);
+ retval = vconn_open(rc->target, OFP10_VERSION, &rc->vconn, rc->dscp);
if (!retval) {
rc->remote_ip = vconn_get_remote_ip(rc->vconn);
rc->local_ip = vconn_get_local_ip(rc->vconn);
diff --git a/lib/rconn.h b/lib/rconn.h
index d0326e65a..eea054f37 100644
--- a/lib/rconn.h
+++ b/lib/rconn.h
@@ -37,8 +37,9 @@
struct vconn;
struct rconn_packet_counter;
-struct rconn *rconn_create(int inactivity_probe_interval, int max_backoff);
-
+struct rconn *rconn_create(int inactivity_probe_interval,
+ int max_backoff, uint8_t dscp);
+void rconn_set_dscp(struct rconn *rc, uint8_t dscp);
void rconn_set_max_backoff(struct rconn *, int max_backoff);
int rconn_get_max_backoff(const struct rconn *);
void rconn_set_probe_interval(struct rconn *, int inactivity_probe_interval);
diff --git a/lib/reconnect.c b/lib/reconnect.c
index c16901623..7737fcf7e 100644
--- a/lib/reconnect.c
+++ b/lib/reconnect.c
@@ -54,6 +54,8 @@ struct reconnect {
bool passive;
enum vlog_level info; /* Used for informational messages. */
+ uint8_t dscp;
+
/* State. */
enum state state;
long long int state_entered;
@@ -186,6 +188,14 @@ reconnect_get_probe_interval(const struct reconnect *fsm)
return fsm->probe_interval;
}
+/* Returns the dscp value used for establishing the connection between the
+ * manager and the database. */
+uint8_t
+reconnect_get_dscp(const struct reconnect *fsm)
+{
+ return fsm->dscp;
+}
+
/* Limits the maximum number of times that 'fsm' will ask the client to try to
* reconnect to 'max_tries'. UINT_MAX (the default) means an unlimited number
* of tries.
@@ -245,6 +255,14 @@ reconnect_set_probe_interval(struct reconnect *fsm, int probe_interval)
fsm->probe_interval = probe_interval ? MAX(1000, probe_interval) : 0;
}
+/* Sets the dscp value to be used for establishing a connection between the
+ * manager and the database. */
+void
+reconnect_set_dscp(struct reconnect *fsm, uint8_t dscp)
+{
+ fsm->dscp = dscp;
+}
+
/* Returns true if 'fsm' is in passive mode, false if 'fsm' is in active mode
* (the default). */
bool
diff --git a/lib/reconnect.h b/lib/reconnect.h
index 997a03f21..9dfcfd7df 100644
--- a/lib/reconnect.h
+++ b/lib/reconnect.h
@@ -31,6 +31,7 @@
* revisited later.) */
#include <stdbool.h>
+#include "openvswitch/types.h"
struct reconnect *reconnect_create(long long int now);
void reconnect_destroy(struct reconnect *);
@@ -48,6 +49,7 @@ void reconnect_set_name(struct reconnect *, const char *name);
int reconnect_get_min_backoff(const struct reconnect *);
int reconnect_get_max_backoff(const struct reconnect *);
int reconnect_get_probe_interval(const struct reconnect *);
+uint8_t reconnect_get_dscp(const struct reconnect *);
void reconnect_set_max_tries(struct reconnect *, unsigned int max_tries);
unsigned int reconnect_get_max_tries(struct reconnect *);
@@ -55,6 +57,7 @@ unsigned int reconnect_get_max_tries(struct reconnect *);
void reconnect_set_backoff(struct reconnect *,
int min_backoff, int max_backoff);
void reconnect_set_probe_interval(struct reconnect *, int probe_interval);
+void reconnect_set_dscp(struct reconnect *, uint8_t dscp);
bool reconnect_is_passive(const struct reconnect *);
void reconnect_set_passive(struct reconnect *, bool passive,
diff --git a/lib/socket-util.c b/lib/socket-util.c
index 37f8c9ad4..6554e9721 100644
--- a/lib/socket-util.c
+++ b/lib/socket-util.c
@@ -544,10 +544,13 @@ exit:
* and stores -1 into '*fdp'.
*
* If 'sinp' is non-null, then on success the target address is stored into
- * '*sinp'. */
+ * '*sinp'.
+ *
+ * 'dscp' If not DSCP_INVALID, its value becomes the DSCP bits in the IP
+ * headers for the new connection. */
int
inet_open_active(int style, const char *target, uint16_t default_port,
- struct sockaddr_in *sinp, int *fdp)
+ struct sockaddr_in *sinp, int *fdp, uint8_t dscp)
{
struct sockaddr_in sin;
int fd = -1;
@@ -571,6 +574,17 @@ inet_open_active(int style, const char *target, uint16_t default_port,
goto exit_close;
}
+ /* The socket options set here ensure that the TOS bits are set during
+ * the connection establishment. If set after connect(), the handshake
+ * SYN frames will be sent with a TOS of 0. */
+ if (dscp != DSCP_INVALID) {
+ if (setsockopt(fd, IPPROTO_IP, IP_TOS, &dscp, sizeof dscp)) {
+ VLOG_ERR("%s: socket: %s", target, strerror(errno));
+ error = errno;
+ goto exit;
+ }
+ }
+
/* Connect. */
error = connect(fd, (struct sockaddr *) &sin, sizeof sin) == 0 ? 0 : errno;
if (error == EINPROGRESS) {
@@ -663,10 +677,13 @@ exit:
* negative errno value.
*
* If 'sinp' is non-null, then on success the bound address is stored into
- * '*sinp'. */
+ * '*sinp'.
+ *
+ * 'dscp' If not DSCP_INVALID, its value becomes the DSCP bits in the IP
+ * headers for the new connection. */
int
inet_open_passive(int style, const char *target, int default_port,
- struct sockaddr_in *sinp)
+ struct sockaddr_in *sinp, uint8_t dscp)
{
struct sockaddr_in sin;
int fd = 0, error;
@@ -701,6 +718,17 @@ inet_open_passive(int style, const char *target, int default_port,
goto error;
}
+ /* The socket options set here ensure that the TOS bits are set during
+ * the connection establishment. If set after connect(), the handshake
+ * SYN frames will be sent with a TOS of 0. */
+ if (dscp != DSCP_INVALID) {
+ if (setsockopt(fd, IPPROTO_IP, IP_TOS, &dscp, sizeof dscp)) {
+ VLOG_ERR("%s: socket: %s", target, strerror(errno));
+ error = errno;
+ goto error;
+ }
+ }
+
/* Listen. */
if (style == SOCK_STREAM && listen(fd, 10) < 0) {
error = errno;
diff --git a/lib/socket-util.h b/lib/socket-util.h
index 422cea9c3..32c61e789 100644
--- a/lib/socket-util.h
+++ b/lib/socket-util.h
@@ -23,6 +23,7 @@
#include <netinet/in.h>
#include <stdbool.h>
#include "openvswitch/types.h"
+#include <netinet/ip.h>
int set_nonblocking(int fd);
int get_max_fds(void);
@@ -46,12 +47,12 @@ int get_null_fd(void);
bool inet_parse_active(const char *target, uint16_t default_port,
struct sockaddr_in *sinp);
int inet_open_active(int style, const char *target, uint16_t default_port,
- struct sockaddr_in *sinp, int *fdp);
+ struct sockaddr_in *sinp, int *fdp, uint8_t dscp);
bool inet_parse_passive(const char *target, int default_port,
struct sockaddr_in *sinp);
int inet_open_passive(int style, const char *target, int default_port,
- struct sockaddr_in *sinp);
+ struct sockaddr_in *sinp, uint8_t dscp);
int read_fully(int fd, void *, size_t, size_t *bytes_read);
int write_fully(int fd, const void *, size_t, size_t *bytes_written);
@@ -63,4 +64,14 @@ void xpipe(int fds[2]);
char *describe_fd(int fd);
+/* Default value of dscp bits for connection between controller and manager.
+ * Value of IPTOS_PREC_INTERNETCONTROL = 0xc0 which is defined
+ * in <netinet/ip.h> is used. */
+#define DSCP_DEFAULT IPTOS_PREC_INTERNETCONTROL
+
+/* Invalid dscp value. If the dscp value will not be used, the dscp value
+ * passed must be invalid. Set to 0xFF as the TOS bits passed can only be
+ * 6 bits. */
+#define DSCP_INVALID 0xFF
+
#endif /* socket-util.h */
diff --git a/lib/stream-provider.h b/lib/stream-provider.h
index 03bf777b6..77d0a1060 100644
--- a/lib/stream-provider.h
+++ b/lib/stream-provider.h
@@ -40,6 +40,7 @@ struct stream {
void stream_init(struct stream *, const struct stream_class *,
int connect_status, const char *name);
void stream_set_remote_ip(struct stream *, ovs_be32 remote_ip);
+void stream_set_dscp(struct stream *, uint8_t dscp);
void stream_set_remote_port(struct stream *, ovs_be16 remote_port);
void stream_set_local_ip(struct stream *, ovs_be32 local_ip);
void stream_set_local_port(struct stream *, ovs_be16 local_port);
@@ -58,6 +59,10 @@ struct stream_class {
* messages but must not be modified.
*
* 'suffix' is a copy of 'name' following the colon and may be modified.
+ * 'dscp' is the DSCP value that the new connection should use in the IP
+ * packets it sends. (If no DSCP value should be set in the packet, dscp
+ * will be set to DSCP_INVALID. If no DSCP value is specified, DSCP_DEFAULT
+ * value will be applied.)
*
* Returns 0 if successful, otherwise a positive errno value. If
* successful, stores a pointer to the new connection in '*streamp'.
@@ -66,7 +71,8 @@ struct stream_class {
* If the connection cannot be completed immediately, it should return
* EAGAIN (not EINPROGRESS, as returned by the connect system call) and
* continue the connection in the background. */
- int (*open)(const char *name, char *suffix, struct stream **streamp);
+ int (*open)(const char *name, char *suffix, struct stream **streamp,
+ uint8_t dscp);
/* Closes 'stream' and frees associated memory. */
void (*close)(struct stream *stream);
@@ -150,6 +156,10 @@ struct pstream_class {
* useful for error messages but must not be modified.
*
* 'suffix' is a copy of 'name' following the colon and may be modified.
+ * 'dscp' is the DSCP value that the new connection should use in the IP
+ * packets it sends. (If no DSCP value should be set in the packet, dscp
+ * will be set to DSCP_INVALID. If no DSCP value is specified, DSCP_DEFAULT
+ * value will be applied.)
*
* Returns 0 if successful, otherwise a positive errno value. If
* successful, stores a pointer to the new connection in '*pstreamp'.
@@ -158,7 +168,8 @@ struct pstream_class {
* completed immediately, it should return EAGAIN (not EINPROGRESS, as
* returned by the connect system call) and continue the connection in the
* background. */
- int (*listen)(const char *name, char *suffix, struct pstream **pstreamp);
+ int (*listen)(const char *name, char *suffix, struct pstream **pstreamp,
+ uint8_t dscp);
/* Closes 'pstream' and frees associated memory. */
void (*close)(struct pstream *pstream);
diff --git a/lib/stream-ssl.c b/lib/stream-ssl.c
index 22d4c99ae..5463388ea 100644
--- a/lib/stream-ssl.c
+++ b/lib/stream-ssl.c
@@ -204,8 +204,8 @@ want_to_poll_events(int want)
static int
new_ssl_stream(const char *name, int fd, enum session_type type,
- enum ssl_state state, const struct sockaddr_in *remote,
- struct stream **streamp)
+ enum ssl_state state, const struct sockaddr_in *remote,
+ struct stream **streamp)
{
struct sockaddr_in local;
socklen_t local_len = sizeof local;
@@ -307,7 +307,7 @@ ssl_stream_cast(struct stream *stream)
}
static int
-ssl_open(const char *name, char *suffix, struct stream **streamp)
+ssl_open(const char *name, char *suffix, struct stream **streamp, uint8_t dscp)
{
struct sockaddr_in sin;
int error, fd;
@@ -317,7 +317,8 @@ ssl_open(const char *name, char *suffix, struct stream **streamp)
return error;
}
- error = inet_open_active(SOCK_STREAM, suffix, OFP_SSL_PORT, &sin, &fd);
+ error = inet_open_active(SOCK_STREAM, suffix, OFP_SSL_PORT, &sin, &fd,
+ dscp);
if (fd >= 0) {
int state = error ? STATE_TCP_CONNECTING : STATE_SSL_CONNECTING;
return new_ssl_stream(name, fd, CLIENT, state, &sin, streamp);
@@ -782,7 +783,8 @@ pssl_pstream_cast(struct pstream *pstream)
}
static int
-pssl_open(const char *name OVS_UNUSED, char *suffix, struct pstream **pstreamp)
+pssl_open(const char *name OVS_UNUSED, char *suffix, struct pstream **pstreamp,
+ uint8_t dscp)
{
struct pssl_pstream *pssl;
struct sockaddr_in sin;
@@ -795,7 +797,7 @@ pssl_open(const char *name OVS_UNUSED, char *suffix, struct pstream **pstreamp)
return retval;
}
- fd = inet_open_passive(SOCK_STREAM, suffix, OFP_SSL_PORT, &sin);
+ fd = inet_open_passive(SOCK_STREAM, suffix, OFP_SSL_PORT, &sin, dscp);
if (fd < 0) {
return -fd;
}
@@ -847,7 +849,7 @@ pssl_accept(struct pstream *pstream, struct stream **new_streamp)
sprintf(strchr(name, '\0'), ":%"PRIu16, ntohs(sin.sin_port));
}
return new_ssl_stream(name, new_fd, SERVER, STATE_SSL_CONNECTING, &sin,
- new_streamp);
+ new_streamp);
}
static void
diff --git a/lib/stream-tcp.c b/lib/stream-tcp.c
index 052ad8cb5..c7a2ee2e8 100644
--- a/lib/stream-tcp.c
+++ b/lib/stream-tcp.c
@@ -38,7 +38,7 @@ VLOG_DEFINE_THIS_MODULE(stream_tcp);
static int
new_tcp_stream(const char *name, int fd, int connect_status,
- const struct sockaddr_in *remote, struct stream **streamp)
+ const struct sockaddr_in *remote, struct stream **streamp)
{
struct sockaddr_in local;
socklen_t local_len = sizeof local;
@@ -70,12 +70,12 @@ new_tcp_stream(const char *name, int fd, int connect_status,
}
static int
-tcp_open(const char *name, char *suffix, struct stream **streamp)
+tcp_open(const char *name, char *suffix, struct stream **streamp, uint8_t dscp)
{
struct sockaddr_in sin;
int fd, error;
- error = inet_open_active(SOCK_STREAM, suffix, 0, &sin, &fd);
+ error = inet_open_active(SOCK_STREAM, suffix, 0, &sin, &fd, dscp);
if (fd >= 0) {
return new_tcp_stream(name, fd, error, &sin, streamp);
} else {
@@ -102,13 +102,14 @@ static int ptcp_accept(int fd, const struct sockaddr *sa, size_t sa_len,
struct stream **streamp);
static int
-ptcp_open(const char *name OVS_UNUSED, char *suffix, struct pstream **pstreamp)
+ptcp_open(const char *name OVS_UNUSED, char *suffix, struct pstream **pstreamp,
+ uint8_t dscp)
{
struct sockaddr_in sin;
char bound_name[128];
int fd;
- fd = inet_open_passive(SOCK_STREAM, suffix, -1, &sin);
+ fd = inet_open_passive(SOCK_STREAM, suffix, -1, &sin, dscp);
if (fd < 0) {
return -fd;
}
diff --git a/lib/stream-unix.c b/lib/stream-unix.c
index d2e8e8238..a9d76f257 100644
--- a/lib/stream-unix.c
+++ b/lib/stream-unix.c
@@ -40,7 +40,8 @@ VLOG_DEFINE_THIS_MODULE(stream_unix);
/* Active UNIX socket. */
static int
-unix_open(const char *name, char *suffix, struct stream **streamp)
+unix_open(const char *name, char *suffix, struct stream **streamp,
+ uint8_t dscp OVS_UNUSED)
{
const char *connect_path = suffix;
int fd;
@@ -73,7 +74,7 @@ static int punix_accept(int fd, const struct sockaddr *sa, size_t sa_len,
static int
punix_open(const char *name OVS_UNUSED, char *suffix,
- struct pstream **pstreamp)
+ struct pstream **pstreamp, uint8_t dscp OVS_UNUSED)
{
int fd, error;
diff --git a/lib/stream.c b/lib/stream.c
index 066de4e87..2f418c42a 100644
--- a/lib/stream.c
+++ b/lib/stream.c
@@ -194,7 +194,7 @@ stream_verify_name(const char *name)
* stores a pointer to the new connection in '*streamp', otherwise a null
* pointer. */
int
-stream_open(const char *name, struct stream **streamp)
+stream_open(const char *name, struct stream **streamp, uint8_t dscp)
{
const struct stream_class *class;
struct stream *stream;
@@ -211,7 +211,7 @@ stream_open(const char *name, struct stream **streamp)
/* Call class's "open" function. */
suffix_copy = xstrdup(strchr(name, ':') + 1);
- error = class->open(name, suffix_copy, &stream);
+ error = class->open(name, suffix_copy, &stream, dscp);
free(suffix_copy);
if (error) {
goto error;
@@ -497,7 +497,7 @@ pstream_verify_name(const char *name)
* stores a pointer to the new connection in '*pstreamp', otherwise a null
* pointer. */
int
-pstream_open(const char *name, struct pstream **pstreamp)
+pstream_open(const char *name, struct pstream **pstreamp, uint8_t dscp)
{
const struct pstream_class *class;
struct pstream *pstream;
@@ -514,7 +514,7 @@ pstream_open(const char *name, struct pstream **pstreamp)
/* Call class's "open" function. */
suffix_copy = xstrdup(strchr(name, ':') + 1);
- error = class->listen(name, suffix_copy, &pstream);
+ error = class->listen(name, suffix_copy, &pstream, dscp);
free(suffix_copy);
if (error) {
goto error;
@@ -682,7 +682,8 @@ int
stream_open_with_default_ports(const char *name_,
uint16_t default_tcp_port,
uint16_t default_ssl_port,
- struct stream **streamp)
+ struct stream **streamp,
+ uint8_t dscp)
{
char *name;
int error;
@@ -694,7 +695,7 @@ stream_open_with_default_ports(const char *name_,
} else {
name = xstrdup(name_);
}
- error = stream_open(name, streamp);
+ error = stream_open(name, streamp, dscp);
free(name);
return error;
@@ -707,7 +708,8 @@ int
pstream_open_with_default_ports(const char *name_,
uint16_t default_ptcp_port,
uint16_t default_pssl_port,
- struct pstream **pstreamp)
+ struct pstream **pstreamp,
+ uint8_t dscp)
{
char *name;
int error;
@@ -719,7 +721,7 @@ pstream_open_with_default_ports(const char *name_,
} else {
name = xstrdup(name_);
}
- error = pstream_open(name, pstreamp);
+ error = pstream_open(name, pstreamp, dscp);
free(name);
return error;
diff --git a/lib/stream.h b/lib/stream.h
index 5c111f999..c1f3adb6b 100644
--- a/lib/stream.h
+++ b/lib/stream.h
@@ -32,7 +32,7 @@ void stream_usage(const char *name, bool active, bool passive, bool bootstrap);
/* Bidirectional byte streams. */
int stream_verify_name(const char *name);
-int stream_open(const char *name, struct stream **);
+int stream_open(const char *name, struct stream **, uint8_t dscp);
int stream_open_block(int error, struct stream **);
void stream_close(struct stream *);
const char *stream_get_name(const struct stream *);
@@ -59,7 +59,7 @@ void stream_send_wait(struct stream *);
/* Passive streams: listeners for incoming stream connections. */
int pstream_verify_name(const char *name);
-int pstream_open(const char *name, struct pstream **);
+int pstream_open(const char *name, struct pstream **, uint8_t dscp);
const char *pstream_get_name(const struct pstream *);
void pstream_close(struct pstream *);
int pstream_accept(struct pstream *, struct stream **);
@@ -71,11 +71,13 @@ void pstream_wait(struct pstream *);
int stream_open_with_default_ports(const char *name,
uint16_t default_tcp_port,
uint16_t default_ssl_port,
- struct stream **);
+ struct stream **,
+ uint8_t dscp);
int pstream_open_with_default_ports(const char *name,
uint16_t default_ptcp_port,
uint16_t default_pssl_port,
- struct pstream **);
+ struct pstream **,
+ uint8_t dscp);
bool stream_parse_target_with_default_ports(const char *target,
uint16_t default_tcp_port,
uint16_t default_ssl_port,
diff --git a/lib/unixctl.c b/lib/unixctl.c
index d8974c9e4..e40f17314 100644
--- a/lib/unixctl.c
+++ b/lib/unixctl.c
@@ -221,7 +221,7 @@ unixctl_server_create(const char *path, struct unixctl_server **serverp)
program_name, (long int) getpid());
}
- error = pstream_open(punix_path, &listener);
+ error = pstream_open(punix_path, &listener, DSCP_INVALID);
if (error) {
ovs_error(error, "could not initialize control socket %s", punix_path);
goto exit;
@@ -422,7 +422,8 @@ unixctl_client_create(const char *path, struct jsonrpc **client)
abs_path = abs_file_name(ovs_rundir(), path);
unix_path = xasprintf("unix:%s", abs_path);
- error = stream_open_block(stream_open(unix_path, &stream), &stream);
+ error = stream_open_block(stream_open(unix_path, &stream, DSCP_DEFAULT),
+ &stream);
free(unix_path);
free(abs_path);
diff --git a/lib/vconn-provider.h b/lib/vconn-provider.h
index 682a593c8..43d2072e2 100644
--- a/lib/vconn-provider.h
+++ b/lib/vconn-provider.h
@@ -62,6 +62,10 @@ struct vconn_class {
* useful for error messages but must not be modified.
*
* 'suffix' is a copy of 'name' following the colon and may be modified.
+ * 'dscp' is the DSCP value that the new connection should use in the IP
+ * packets it sends. (If no DSCP value should be set in the packet, dscp
+ * will be set to DSCP_INVALID. If no DSCP value is specified, DSCP_DEFAULT
+ * value will be applied.)
*
* Returns 0 if successful, otherwise a positive errno value. If
* successful, stores a pointer to the new connection in '*vconnp'.
@@ -70,7 +74,8 @@ struct vconn_class {
* If the connection cannot be completed immediately, it should return
* EAGAIN (not EINPROGRESS, as returned by the connect system call) and
* continue the connection in the background. */
- int (*open)(const char *name, char *suffix, struct vconn **vconnp);
+ int (*open)(const char *name, char *suffix, struct vconn **vconnp,
+ uint8_t dscp);
/* Closes 'vconn' and frees associated memory. */
void (*close)(struct vconn *vconn);
@@ -149,6 +154,10 @@ struct pvconn_class {
* is useful for error messages but must not be modified.
*
* 'suffix' is a copy of 'name' following the colon and may be modified.
+ * 'dscp' is the DSCP value that the new connection should use in the IP
+ * packets it sends. (If no DSCP value should be set in the packet, dscp
+ * will be set to DSCP_INVALID. If no DSCP value is specified, DSCP_DEFAULT
+ * value will be applied.)
*
* Returns 0 if successful, otherwise a positive errno value. If
* successful, stores a pointer to the new connection in '*pvconnp'.
@@ -157,7 +166,8 @@ struct pvconn_class {
* completed immediately, it should return EAGAIN (not EINPROGRESS, as
* returned by the connect system call) and continue the connection in the
* background. */
- int (*listen)(const char *name, char *suffix, struct pvconn **pvconnp);
+ int (*listen)(const char *name, char *suffix, struct pvconn **pvconnp,
+ uint8_t dscp);
/* Closes 'pvconn' and frees associated memory. */
void (*close)(struct pvconn *pvconn);
diff --git a/lib/vconn-stream.c b/lib/vconn-stream.c
index a9890b594..03e588185 100644
--- a/lib/vconn-stream.c
+++ b/lib/vconn-stream.c
@@ -78,13 +78,13 @@ vconn_stream_new(struct stream *stream, int connect_status)
* Returns 0 if successful, otherwise a positive errno value. */
static int
vconn_stream_open(const char *name, char *suffix OVS_UNUSED,
- struct vconn **vconnp)
+ struct vconn **vconnp, uint8_t dscp)
{
struct stream *stream;
int error;
error = stream_open_with_default_ports(name, OFP_TCP_PORT, OFP_SSL_PORT,
- &stream);
+ &stream, dscp);
if (!error) {
error = stream_connect(stream);
if (!error || error == EAGAIN) {
@@ -311,14 +311,14 @@ pvconn_pstream_cast(struct pvconn *pvconn)
* implementation never fails.) */
static int
pvconn_pstream_listen(const char *name, char *suffix OVS_UNUSED,
- struct pvconn **pvconnp)
+ struct pvconn **pvconnp, uint8_t dscp)
{
struct pvconn_pstream *ps;
struct pstream *pstream;
int error;
error = pstream_open_with_default_ports(name, OFP_TCP_PORT, OFP_SSL_PORT,
- &pstream);
+ &pstream, dscp);
if (error) {
return error;
}
diff --git a/lib/vconn.c b/lib/vconn.c
index f0be46a3d..4d04c8338 100644
--- a/lib/vconn.c
+++ b/lib/vconn.c
@@ -38,6 +38,7 @@
#include "random.h"
#include "util.h"
#include "vlog.h"
+#include "socket-util.h"
VLOG_DEFINE_THIS_MODULE(vconn);
@@ -219,7 +220,8 @@ vconn_verify_name(const char *name)
* stores a pointer to the new connection in '*vconnp', otherwise a null
* pointer. */
int
-vconn_open(const char *name, int min_version, struct vconn **vconnp)
+vconn_open(const char *name, int min_version, struct vconn **vconnp,
+ uint8_t dscp)
{
struct vconn_class *class;
struct vconn *vconn;
@@ -237,7 +239,7 @@ vconn_open(const char *name, int min_version, struct vconn **vconnp)
/* Call class's "open" function. */
suffix_copy = xstrdup(strchr(name, ':') + 1);
- error = class->open(name, suffix_copy, &vconn);
+ error = class->open(name, suffix_copy, &vconn, dscp);
free(suffix_copy);
if (error) {
goto error;
@@ -282,7 +284,7 @@ vconn_open_block(const char *name, int min_version, struct vconn **vconnp)
fatal_signal_run();
- error = vconn_open(name, min_version, &vconn);
+ error = vconn_open(name, min_version, &vconn, DSCP_DEFAULT);
if (!error) {
while ((error = vconn_connect(vconn)) == EAGAIN) {
vconn_run(vconn);
@@ -899,7 +901,7 @@ pvconn_verify_name(const char *name)
* stores a pointer to the new connection in '*pvconnp', otherwise a null
* pointer. */
int
-pvconn_open(const char *name, struct pvconn **pvconnp)
+pvconn_open(const char *name, struct pvconn **pvconnp, uint8_t dscp)
{
struct pvconn_class *class;
struct pvconn *pvconn;
@@ -916,7 +918,7 @@ pvconn_open(const char *name, struct pvconn **pvconnp)
/* Call class's "open" function. */
suffix_copy = xstrdup(strchr(name, ':') + 1);
- error = class->listen(name, suffix_copy, &pvconn);
+ error = class->listen(name, suffix_copy, &pvconn, dscp);
free(suffix_copy);
if (error) {
goto error;
diff --git a/lib/vconn.h b/lib/vconn.h
index 516e2d3a8..59713275e 100644
--- a/lib/vconn.h
+++ b/lib/vconn.h
@@ -33,7 +33,8 @@ void vconn_usage(bool active, bool passive, bool bootstrap);
/* Active vconns: virtual connections to OpenFlow devices. */
int vconn_verify_name(const char *name);
-int vconn_open(const char *name, int min_version, struct vconn **);
+int vconn_open(const char *name, int min_version,
+ struct vconn **, uint8_t dscp);
void vconn_close(struct vconn *);
const char *vconn_get_name(const struct vconn *);
ovs_be32 vconn_get_remote_ip(const struct vconn *);
@@ -69,7 +70,7 @@ void vconn_send_wait(struct vconn *);
/* Passive vconns: virtual listeners for incoming OpenFlow connections. */
int pvconn_verify_name(const char *name);
-int pvconn_open(const char *name, struct pvconn **);
+int pvconn_open(const char *name, struct pvconn **, uint8_t dscp);
const char *pvconn_get_name(const struct pvconn *);
void pvconn_close(struct pvconn *);
int pvconn_accept(struct pvconn *, int min_version, struct vconn **);