Commit e731d71b authored by Arun Sharma's avatar Arun Sharma Committed by Ben Pfaff

Add IPv6 support for OpenFlow, OVSDB, NetFlow, and sFlow.

Does not add IPv6 support for in-band control.
Co-authored-by: default avatarBen Pfaff <blp@nicira.com>
Signed-off-by: default avatarNandan Nivgune <nandan.nivgune@calsoftinc.com>
Signed-off-by: default avatarAbhijit Bhopatkar <abhijit.bhopatkar@calsoftinc.com>
Signed-off-by: default avatarArun Sharma <arun.sharma@calsoftinc.com>
Signed-off-by: default avatarBen Pfaff <blp@nicira.com>
parent 978188b2
......@@ -64,6 +64,7 @@ v2.1.0 - xx xxx xxxx
hard limit on the number of flows in the datapath. It defaults to 200,000
flows. OVS automatically adjusts this number depending on network
conditions.
- Added IPv6 support for active and passive socket communications.
v2.0.0 - 15 Oct 2013
......
/*
* Copyright (c) 2011, 2013 Nicira, Inc.
* Copyright (c) 2011, 2013, 2014 Nicira, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
......@@ -48,6 +48,15 @@ struct in6_addr {
extern const struct in6_addr in6addr_any;
/* Ditto, for IPv6. */
struct sockaddr_in6 {
sa_family_t sin6_family;
in_port_t sin6_port; /* Transport layer port # */
uint32_t sin6_flowinfo; /* IPv6 flow information */
struct in6_addr sin6_addr; /* IPv6 address */
uint32_t sin6_scope_id; /* IPv6 scope-id */
};
#define IPPROTO_IP 0
#define IPPROTO_HOPOPTS 0
#define IPPROTO_ICMP 1
......@@ -84,6 +93,7 @@ extern const struct in6_addr in6addr_any;
#define INADDR_ANY 0x00000000
#define INADDR_BROADCAST 0xffffffff
#define INADDR_LOOPBACK 0x7f000001
#define INADDR_NONE 0xffffffff
#define INET6_ADDRSTRLEN 46
......
This diff is collapsed.
/*
* Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013 Nicira, Inc.
* Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014 Nicira, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
......@@ -48,14 +48,14 @@ ovs_be32 guess_netmask(ovs_be32 ip);
int get_null_fd(void);
bool inet_parse_active(const char *target, uint16_t default_port,
struct sockaddr_in *sinp);
struct sockaddr_storage *ssp);
int inet_open_active(int style, const char *target, uint16_t default_port,
struct sockaddr_in *sinp, int *fdp, uint8_t dscp);
struct sockaddr_storage *ssp, int *fdp, uint8_t dscp);
bool inet_parse_passive(const char *target, int default_port,
struct sockaddr_in *sinp);
struct sockaddr_storage *ssp);
int inet_open_passive(int style, const char *target, int default_port,
struct sockaddr_in *sinp, uint8_t dscp);
struct sockaddr_storage *ssp, 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);
......@@ -79,4 +79,12 @@ int af_inet_ioctl(unsigned long int command, const void *arg);
int af_inet_ifreq_ioctl(const char *name, struct ifreq *,
unsigned long int cmd, const char *cmd_name);
/* Functions for working with sockaddr_storage that might contain an IPv4 or
* IPv6 address. */
uint16_t ss_get_port(const struct sockaddr_storage *);
#define SS_NTOP_BUFSIZE (1 + INET6_ADDRSTRLEN + 1)
char *ss_format_address(const struct sockaddr_storage *,
char *buf, size_t bufsize);
size_t ss_length(const struct sockaddr_storage *);
#endif /* socket-util.h */
/*
* Copyright (c) 2008, 2009, 2010, 2012, 2013 Nicira, Inc.
* Copyright (c) 2008, 2009, 2010, 2012, 2013, 2014 Nicira, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
......@@ -148,7 +148,7 @@ struct fd_pstream
{
struct pstream pstream;
int fd;
int (*accept_cb)(int fd, const struct sockaddr *, size_t sa_len,
int (*accept_cb)(int fd, const struct sockaddr_storage *, size_t ss_len,
struct stream **);
int (*set_dscp_cb)(int fd, uint8_t dscp);
char *unlink_path;
......@@ -179,8 +179,8 @@ fd_pstream_cast(struct pstream *pstream)
* implementation never fails.) */
int
new_fd_pstream(const char *name, int fd,
int (*accept_cb)(int fd, const struct sockaddr *sa,
size_t sa_len, struct stream **streamp),
int (*accept_cb)(int fd, const struct sockaddr_storage *ss,
size_t ss_len, struct stream **streamp),
int (*set_dscp_cb)(int fd, uint8_t dscp),
char *unlink_path, struct pstream **pstreamp)
{
......@@ -227,8 +227,7 @@ pfd_accept(struct pstream *pstream, struct stream **new_streamp)
return retval;
}
return ps->accept_cb(new_fd, (const struct sockaddr *) &ss, ss_len,
new_streamp);
return ps->accept_cb(new_fd, &ss, ss_len, new_streamp);
}
static void
......
/*
* Copyright (c) 2008, 2009, 2012 Nicira, Inc.
* Copyright (c) 2008, 2009, 2012, 2014 Nicira, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
......@@ -23,13 +23,13 @@
struct stream;
struct pstream;
struct sockaddr;
struct sockaddr_storage;
int new_fd_stream(const char *name, int fd, int connect_status,
struct stream **streamp);
int new_fd_pstream(const char *name, int fd,
int (*accept_cb)(int fd, const struct sockaddr *,
size_t sa_len, struct stream **),
int (*accept_cb)(int fd, const struct sockaddr_storage *ss,
size_t ss_len, struct stream **),
int (*set_dscp_cb)(int fd, uint8_t dscp),
char *unlink_path,
struct pstream **pstreamp);
......
/*
* Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013 Nicira, Inc.
* Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014 Nicira, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
......@@ -206,7 +206,7 @@ static int
new_ssl_stream(const char *name, int fd, enum session_type type,
enum ssl_state state, struct stream **streamp)
{
struct sockaddr_in local;
struct sockaddr_storage local;
socklen_t local_len = sizeof local;
struct ssl_stream *sslv;
SSL *ssl = NULL;
......@@ -780,9 +780,11 @@ static int
pssl_open(const char *name OVS_UNUSED, char *suffix, struct pstream **pstreamp,
uint8_t dscp)
{
char bound_name[SS_NTOP_BUFSIZE + 16];
char addrbuf[SS_NTOP_BUFSIZE];
struct sockaddr_storage ss;
struct pssl_pstream *pssl;
struct sockaddr_in sin;
char bound_name[128];
uint16_t port;
int retval;
int fd;
......@@ -791,16 +793,18 @@ pssl_open(const char *name OVS_UNUSED, char *suffix, struct pstream **pstreamp,
return retval;
}
fd = inet_open_passive(SOCK_STREAM, suffix, OFP_OLD_PORT, &sin, dscp);
fd = inet_open_passive(SOCK_STREAM, suffix, OFP_OLD_PORT, &ss, dscp);
if (fd < 0) {
return -fd;
}
sprintf(bound_name, "pssl:%"PRIu16":"IP_FMT,
ntohs(sin.sin_port), IP_ARGS(sin.sin_addr.s_addr));
port = ss_get_port(&ss);
snprintf(bound_name, sizeof bound_name, "ptcp:%"PRIu16":%s",
port, ss_format_address(&ss, addrbuf, sizeof addrbuf));
pssl = xmalloc(sizeof *pssl);
pstream_init(&pssl->pstream, &pssl_pstream_class, bound_name);
pstream_set_bound_port(&pssl->pstream, sin.sin_port);
pstream_set_bound_port(&pssl->pstream, htons(port));
pssl->fd = fd;
*pstreamp = &pssl->pstream;
return 0;
......@@ -818,13 +822,14 @@ static int
pssl_accept(struct pstream *pstream, struct stream **new_streamp)
{
struct pssl_pstream *pssl = pssl_pstream_cast(pstream);
struct sockaddr_in sin;
socklen_t sin_len = sizeof sin;
char name[128];
char name[SS_NTOP_BUFSIZE + 16];
char addrbuf[SS_NTOP_BUFSIZE];
struct sockaddr_storage ss;
socklen_t ss_len = sizeof ss;
int new_fd;
int error;
new_fd = accept(pssl->fd, (struct sockaddr *) &sin, &sin_len);
new_fd = accept(pssl->fd, (struct sockaddr *) &ss, &ss_len);
if (new_fd < 0) {
error = errno;
if (error != EAGAIN) {
......@@ -839,10 +844,9 @@ pssl_accept(struct pstream *pstream, struct stream **new_streamp)
return error;
}
sprintf(name, "ssl:"IP_FMT, IP_ARGS(sin.sin_addr.s_addr));
if (sin.sin_port != htons(OFP_OLD_PORT)) {
sprintf(strchr(name, '\0'), ":%"PRIu16, ntohs(sin.sin_port));
}
snprintf(name, sizeof name, "tcp:%s:%"PRIu16,
ss_format_address(&ss, addrbuf, sizeof addrbuf),
ss_get_port(&ss));
return new_ssl_stream(name, new_fd, SERVER, STATE_SSL_CONNECTING,
new_streamp);
}
......
/*
* Copyright (c) 2008, 2009, 2010, 2012, 2013 Nicira, Inc.
* Copyright (c) 2008, 2009, 2010, 2012, 2013, 2014 Nicira, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
......@@ -21,10 +21,12 @@
#include <sys/types.h>
#include <netinet/in.h>
#include <netinet/tcp.h>
#include <netdb.h>
#include <stdlib.h>
#include <string.h>
#include <sys/socket.h>
#include <unistd.h>
#include "dynamic-string.h"
#include "packets.h"
#include "socket-util.h"
#include "util.h"
......@@ -40,13 +42,13 @@ static int
new_tcp_stream(const char *name, int fd, int connect_status,
struct stream **streamp)
{
struct sockaddr_in local;
struct sockaddr_storage local;
socklen_t local_len = sizeof local;
int on = 1;
int retval;
/* Get the local IP and port information */
retval = getsockname(fd, (struct sockaddr *)&local, &local_len);
retval = getsockname(fd, (struct sockaddr *) &local, &local_len);
if (retval) {
memset(&local, 0, sizeof local);
}
......@@ -90,47 +92,47 @@ const struct stream_class tcp_stream_class = {
/* Passive TCP. */
static int ptcp_accept(int fd, const struct sockaddr *sa, size_t sa_len,
struct stream **streamp);
static int ptcp_accept(int fd, const struct sockaddr_storage *,
size_t, struct stream **streamp);
static int
ptcp_open(const char *name OVS_UNUSED, char *suffix, struct pstream **pstreamp,
uint8_t dscp)
{
struct sockaddr_in sin;
char bound_name[128];
char bound_name[SS_NTOP_BUFSIZE + 16];
char addrbuf[SS_NTOP_BUFSIZE];
struct sockaddr_storage ss;
uint16_t port;
int error;
int fd;
fd = inet_open_passive(SOCK_STREAM, suffix, -1, &sin, dscp);
fd = inet_open_passive(SOCK_STREAM, suffix, -1, &ss, dscp);
if (fd < 0) {
return -fd;
}
sprintf(bound_name, "ptcp:%"PRIu16":"IP_FMT,
ntohs(sin.sin_port), IP_ARGS(sin.sin_addr.s_addr));
port = ss_get_port(&ss);
snprintf(bound_name, sizeof bound_name, "ptcp:%"PRIu16":%s",
port, ss_format_address(&ss, addrbuf, sizeof addrbuf));
error = new_fd_pstream(bound_name, fd, ptcp_accept, set_dscp, NULL,
pstreamp);
if (!error) {
pstream_set_bound_port(*pstreamp, sin.sin_port);
pstream_set_bound_port(*pstreamp, htons(port));
}
return error;
}
static int
ptcp_accept(int fd, const struct sockaddr *sa, size_t sa_len,
struct stream **streamp)
ptcp_accept(int fd, const struct sockaddr_storage *ss,
size_t ss_len OVS_UNUSED, struct stream **streamp)
{
const struct sockaddr_in *sin = ALIGNED_CAST(const struct sockaddr_in *,
sa);
char name[128];
char name[SS_NTOP_BUFSIZE + 16];
char addrbuf[SS_NTOP_BUFSIZE];
if (sa_len == sizeof(struct sockaddr_in) && sin->sin_family == AF_INET) {
sprintf(name, "tcp:"IP_FMT, IP_ARGS(sin->sin_addr.s_addr));
sprintf(strchr(name, '\0'), ":%"PRIu16, ntohs(sin->sin_port));
} else {
strcpy(name, "tcp");
}
snprintf(name, sizeof name, "tcp:%s:%"PRIu16,
ss_format_address(ss, addrbuf, sizeof addrbuf),
ss_get_port(ss));
return new_tcp_stream(name, fd, 0, streamp);
}
......
/*
* Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013 Nicira, Inc.
* Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014 Nicira, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
......@@ -75,8 +75,8 @@ const struct stream_class unix_stream_class = {
/* Passive UNIX socket. */
static int punix_accept(int fd, const struct sockaddr *sa, size_t sa_len,
struct stream **streamp);
static int punix_accept(int fd, const struct sockaddr_storage *ss,
size_t ss_len, struct stream **streamp);
static int
punix_open(const char *name OVS_UNUSED, char *suffix,
......@@ -105,11 +105,11 @@ punix_open(const char *name OVS_UNUSED, char *suffix,
}
static int
punix_accept(int fd, const struct sockaddr *sa, size_t sa_len,
punix_accept(int fd, const struct sockaddr_storage *ss, size_t ss_len,
struct stream **streamp)
{
const struct sockaddr_un *sun = (const struct sockaddr_un *) sa;
int name_len = get_unix_name_len(sa_len);
const struct sockaddr_un *sun = (const struct sockaddr_un *) ss;
int name_len = get_unix_name_len(ss_len);
char name[128];
if (name_len > 0) {
......
......@@ -720,18 +720,18 @@ pstream_open_with_default_port(const char *name_,
/*
* This function extracts IP address and port from the target string.
*
* - On success, function returns true and fills *sin structure with port
* - On success, function returns true and fills *ss structure with port
* and IP address. If port was absent in target string then it will use
* corresponding default port value.
* - On error, function returns false and *sin contains garbage.
* - On error, function returns false and *ss contains garbage.
*/
bool
stream_parse_target_with_default_port(const char *target,
uint16_t default_port,
struct sockaddr_in *sin)
struct sockaddr_storage *ss)
{
return ((!strncmp(target, "tcp:", 4) || !strncmp(target, "ssl:", 4))
&& inet_parse_active(target + 4, default_port, sin));
&& inet_parse_active(target + 4, default_port, ss));
}
/* Attempts to guess the content type of a stream whose first few bytes were
......
......@@ -81,7 +81,7 @@ int pstream_open_with_default_port(const char *name,
uint8_t dscp);
bool stream_parse_target_with_default_port(const char *target,
uint16_t default_port,
struct sockaddr_in *sin);
struct sockaddr_storage *ss);
int stream_or_pstream_needs_probes(const char *name);
/* Error reporting. */
......
.IP "\fBssl:\fIip\fR[\fB:\fIport\fR]"
.IQ "\fBtcp:\fIip\fR[\fB:\fIport\fR]"
The specified \fIport\fR on the host at the given \fIip\fR, which must
be expressed as an IP address (not a DNS name). For \fBssl\fR, the
\fB\-\-private\-key\fR, \fB\-\-certificate\fR, and \fB\-\-ca\-cert\fR
options are mandatory.
be expressed as an IP address (not a DNS name) in IPv4 or IPv6 address
format. Wrap IPv6 addresses in square brackets,
e.g. \fBtcp:[::1]:6633\fR. For \fBssl\fR, the \fB\-\-private\-key\fR,
\fB\-\-certificate\fR, and \fB\-\-ca\-cert\fR options are mandatory.
.IP
If \fIport\fR is not specified, it currently defaults to 6633. In the
future, the default will change to 6653, which is the IANA-defined
......
.IP "\fBpssl:\fR[\fIport\fR][\fB:\fIip\fR]"
.IQ "\fBptcp:\fR[\fIport\fR][\fB:\fIip\fR]"
Listens for OpenFlow connections on \fIport\fR. By
default, connections are not bound to a particular local IP address, but
\fIip\fR may be specified to listen only for connections to the given
\fIip\fR. For \fBpssl\fR, the \fB\-\-private\-key\fR,
\fB\-\-certificate\fR, and \fB\-\-ca\-cert\fR options are mandatory.
Listens for OpenFlow connections on \fIport\fR. The default
\fIport\fR is 6633, but a future version of Open vSwitch will change
the default to the IANA-defined port 6653. By default, connections
are allowed from any IPv4 address. Specify \fIip\fR as an IPv4
address or a bracketed IPv6 address (e.g. \fBptcp:6633:[::1]\fR). DNS
names may not be used. For \fBpssl\fR, the
\fB\-\-private\-key\fR,\fB\-\-certificate\fR, and \fB\-\-ca\-cert\fR
options are mandatory.
.IP
If \fIport\fR is not specified, it currently defaults to 6633. In the
future, the default will change to 6653, which is the IANA-defined
value.
.
.IP "\fBpunix:\fIfile\fR"
Listens for OpenFlow connections on the Unix domain server socket
......
/*
* Copyright (c) 2009, 2010, 2011, 2012, 2013 Nicira, Inc.
* Copyright (c) 2009, 2010, 2011, 2012, 2013, 2014 Nicira, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
......@@ -734,17 +734,13 @@ update_in_band_remotes(struct connmgr *mgr)
/* Add all the remotes. */
HMAP_FOR_EACH (ofconn, hmap_node, &mgr->controllers) {
struct sockaddr_in *sin = &addrs[n_addrs];
const char *target = rconn_get_target(ofconn->rconn);
struct sockaddr_storage ss;
if (ofconn->band == OFPROTO_OUT_OF_BAND) {
continue;
}
if (stream_parse_target_with_default_port(target,
OFP_OLD_PORT,
sin)) {
n_addrs++;
if (ofconn->band == OFPROTO_IN_BAND
&& stream_parse_target_with_default_port(target, OFP_OLD_PORT, &ss)
&& ss.ss_family == AF_INET) {
addrs[n_addrs++] = *(struct sockaddr_in *) &ss;
}
}
for (i = 0; i < mgr->n_extra_remotes; i++) {
......
/*
* Copyright (c) 2009, 2010, 2011, 2012, 2013 Nicira, Inc.
* Copyright (c) 2009, 2010, 2011, 2012, 2013, 2014 Nicira, Inc.
* Copyright (c) 2009 InMon Corp.
*
* Licensed under the Apache License, Version 2.0 (the "License");
......@@ -253,13 +253,16 @@ sflow_choose_agent_address(const char *agent_device,
}
SSET_FOR_EACH (target, targets) {
struct sockaddr_in sin;
struct sockaddr_storage ss;
char name[IFNAMSIZ];
if (inet_parse_active(target, SFL_DEFAULT_COLLECTOR_PORT, &sin)
&& route_table_get_name(sin.sin_addr.s_addr, name)
&& !netdev_get_in4_by_name(name, &in4)) {
goto success;
if (inet_parse_active(target, SFL_DEFAULT_COLLECTOR_PORT, &ss)
&& ss.ss_family == AF_INET) {
struct sockaddr_in *sin = (struct sockaddr_in *) &ss;
if (route_table_get_name(sin->sin_addr.s_addr, name)
&& !netdev_get_in4_by_name(name, &in4)) {
goto success;
}
}
}
......
.IP "\fBssl:\fIip\fB:\fIport\fR"
The specified SSL \fIport\fR on the host at the given \fIip\fR, which
must be expressed as an IP address (not a DNS name). The
\fB\-\-private\-key\fR, \fB\-\-certificate\fR, and \fB\-\-ca\-cert\fR
must be expressed as an IP address (not a DNS name) in IPv4 or IPv6 address
format. If \fIip\fR is an IPv6 address, then wrap \fIip\fR with square
brackets, e.g.: \fBssl:[::1]:6632\fR.
The \fB\-\-private\-key\fR, \fB\-\-certificate\fR, and \fB\-\-ca\-cert\fR
options are mandatory when this form is used.
.
.IP "\fBtcp:\fIip\fB:\fIport\fR"
Connect to the given TCP \fIport\fR on \fIip\fR.
Connect to the given TCP \fIport\fR on \fIip\fR, where \fIip\fR can be IPv4
or IPv6 address. If \fIip\fR is an IPv6 address, then wrap \fIip\fR with
square brackets, e.g.: \fBtcp:[::1]:6632\fR.
.
.IP "\fBunix:\fIfile\fR"
Connect to the Unix domain server socket named \fIfile\fR.
.IP "\fBpssl:\fIport\fR[\fB:\fIip\fR]"
Listen on the given SSL \fIport\fR for a connection. By default,
connections are not bound to a particular local IP address, but
connections are not bound to a particular local IP address and
it listens only on IPv4 (but not IPv6) addresses, but
specifying \fIip\fR limits connections to those from the given
\fIip\fR. The \fB\-\-private\-key\fR, \fB\-\-certificate\fR, and
\fB\-\-ca\-cert\fR options are mandatory when this form is used.
\fIip\fR, either IPv4 or IPv6 address. If \fIip\fR is
an IPv6 address, then wrap \fIip\fR with square brackets, e.g.:
\fBpssl:6632:[::1]\fR. The \fB\-\-private\-key\fR,
\fB\-\-certificate\fR, and \fB\-\-ca\-cert\fR options are mandatory
when this form is used.
.
.IP "\fBptcp:\fIport\fR[\fB:\fIip\fR]"
Listen on the given TCP \fIport\fR for a connection. By default,
connections are not bound to a particular local IP address, but
connections are not bound to a particular local IP address and
it listens only on IPv4 (but not IPv6) addresses, but
\fIip\fR may be specified to listen only for connections to the given
\fIip\fR.
\fIip\fR, either IPv4 or IPv6 address. If \fIip\fR is
an IPv6 address, then wrap \fIip\fR with square brackets, e.g.:
\fBptcp:6632:[::1]\fR.
.
.IP "\fBpunix:\fIfile\fR"
Listen on the Unix domain server socket named \fIfile\fR for a
......
# Copyright (c) 2010, 2012 Nicira, Inc.
# Copyright (c) 2010, 2012, 2014 Nicira, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
......@@ -177,24 +177,44 @@ def check_connection_completion(sock):
return errno.EAGAIN
def is_valid_ipv4_address(address):
try:
socket.inet_pton(socket.AF_INET, address)
except AttributeError:
try:
socket.inet_aton(address)
except socket.error:
return False
except socket.error:
return False
return True
def inet_parse_active(target, default_port):
address = target.split(":")
host_name = address[0]
if not host_name:
raise ValueError("%s: bad peer name format" % target)
if len(address) >= 2:
port = int(address[1])
elif default_port:
port = default_port
host_name = ":".join(address[0:-1]).lstrip('[').rstrip(']')
port = int(address[-1])
else:
raise ValueError("%s: port number must be specified" % target)
if default_port:
port = default_port
else:
raise ValueError("%s: port number must be specified" % target)
host_name = address[0]
if not host_name:
raise ValueError("%s: bad peer name format" % target)
return (host_name, port)
def inet_open_active(style, target, default_port, dscp):
address = inet_parse_active(target, default_port)
try:
sock = socket.socket(socket.AF_INET, style, 0)
is_addr_inet = is_valid_ipv4_address(address[0])
if is_addr_inet:
sock = socket.socket(socket.AF_INET, style, 0)
else:
sock = socket.socket(socket.AF_INET6, style, 0)
except socket.error, e:
return get_exception_errno(e), None
......
This diff is collapsed.
......@@ -21,7 +21,7 @@ s/ hard_age=[0-9]*,//
# log, given that the server was told to listen on a kernel-chosen
# port, file provided on stdin, and prints the port number on stdout.
# You should specify the listening remote as ptcp:0:127.0.0.1 or
# pssl:0:127.0.0.1.
# pssl:0:127.0.0.1, or the equivalent with [::1] instead of 127.0.0.1.
#
# Here's an example of how to use this with ovsdb-server:
#
......@@ -29,7 +29,7 @@ s/ hard_age=[0-9]*,//
# ovsdb-server --log-file --remote=ptcp:0:127.0.0.1 ...
# TCP_PORT=`parse_listening_port < ovsdb-server.log`
parse_listening_port () {
sed -n 's/.*0:127\.0\.0\.1: listening on port \([0-9]*\)$/\1/p'
sed -n 's/.*0:.*: listening on port \([0-9]*\)$/\1/p'
}]
m4_divert_pop([PREPARE_TESTS])
......
......@@ -177,7 +177,7 @@ OVSDB_CHECK_EXECUTION([duplicate uuid-name not allowed],
[[[{"uuid":["uuid","<0>"]},{"details":"This \"uuid-name\" appeared on an earlier \"insert\" operation.","error":"duplicate uuid-name","syntax":"\"x\""}]
]])
m4_define([EXECUTION_EXAMPLES], [
m4_define([ONE_EXECUTION_EXAMPLE], [dnl
dnl At one point the "commit" code ignored new rows with all-default values,
dnl so this checks for that problem.
OVSDB_CHECK_EXECUTION([insert default row, query table],
......@@ -193,7 +193,10 @@ OVSDB_CHECK_EXECUTION([insert default row, query table],
[[[{"uuid":["uuid","<0>"]}]
[{"rows":[{"_uuid":["uuid","<0>"],"_version":["uuid","<1>"],"name":"","number":0}]}]
]])
])
m4_define([EXECUTION_EXAMPLES], [
ONE_EXECUTION_EXAMPLE
OVSDB_CHECK_EXECUTION([insert row, query table],
[ordinal_schema],
[[[["ordinals",
......
......@@ -72,10 +72,33 @@ m4_define([OVSDB_CHECK_IDL_TCP_PY],
OVSDB_SERVER_SHUTDOWN
AT_CLEANUP])
# same as OVSDB_CHECK_IDL but uses the Python IDL implementation with tcp6
m4_define([OVSDB_CHECK_IDL_TCP6_PY],
[AT_SETUP([$1 - Python tcp6])
AT_SKIP_IF([test $HAVE_PYTHON = no])
AT_KEYWORDS([ovsdb server idl positive Python with tcp6 socket $5])
OVS_RUNDIR=`pwd`; export OVS_RUNDIR
OVS_LOGDIR=`pwd`; export OVS_LOGDIR
AT_CHECK([ovsdb-tool create db $abs_srcdir/idltest.ovsschema],
[0], [stdout], [ignore])
AT_CHECK([ovsdb-server --log-file '-vPATTERN:console:ovsdb-server|%c|%m' --detach --no-chdir --pidfile="`pwd`"/pid --remote=ptcp:0:[[::1]] --unixctl="`pwd`"/unixctl db], [0], [ignore], [ignore])
TCP_PORT=`parse_listening_port < ovsdb-server.log`