sock: Add spdk sock opts related three functions.
Purpose: This is used to make users can specify some options on the socket, e.g., the different priority for the socket. While creating sockets, the priority needs to be set before connect() and listen system calls, so better to add one parameter in spdk_sock_opts which can contain options (e.g., priority) in spdk_sock_listen_ext and spdk_sock_connect_ext functions. Signed-off-by: Ziye Yang <ziye.yang@intel.com> Signed-off-by: Sudheer Mogilappagari <sudheer.mogilappagari@intel.com> Change-Id: I406238e9da7abd69f937b7072535a19124ed0169 Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/1874 Community-CI: Mellanox Build Bot Community-CI: Broadcom CI Tested-by: SPDK CI Jenkins <sys_sgci@intel.com> Reviewed-by: Jim Harris <james.r.harris@intel.com> Reviewed-by: Ben Walker <benjamin.walker@intel.com>
This commit is contained in:
parent
b75e7bd261
commit
b9a7313e2e
@ -135,6 +135,7 @@ Poll groups per session have been replaced by SPDK threads per vhost controller.
|
||||
|
||||
Remove `spdk_sock_set_priority` function since the feature to set the sock priority will be
|
||||
contained in two new functions, i.e., `spdk_sock_listen_ext` and `spdk_sock_connect_ext`.
|
||||
Users may now specify the priority of the socket in the opts that they want to use.
|
||||
|
||||
## v20.01
|
||||
|
||||
|
@ -79,6 +79,37 @@ struct spdk_sock_request {
|
||||
|
||||
#define SPDK_SOCK_REQUEST_IOV(req, i) ((struct iovec *)(((uint8_t *)req + sizeof(struct spdk_sock_request)) + (sizeof(struct iovec) * i)))
|
||||
|
||||
/**
|
||||
* Spdk socket initialization options.
|
||||
*
|
||||
* A pointer to this structure will be used by spdk_sock_listen_ext() or spdk_sock_connect_ext() to
|
||||
* allow the user to request non-default options on the socket.
|
||||
*/
|
||||
struct spdk_sock_opts {
|
||||
/**
|
||||
* The size of spdk_sock_opts according to the caller of this library is used for ABI
|
||||
* compatibility. The library uses this field to know how many fields in this
|
||||
* structure are valid. And the library will populate any remaining fields with default values.
|
||||
*/
|
||||
size_t opts_size;
|
||||
|
||||
/**
|
||||
* The priority on the socket and default value is zero.
|
||||
*/
|
||||
int priority;
|
||||
};
|
||||
|
||||
/**
|
||||
* Initialize the default value of opts.
|
||||
*
|
||||
* \param opts Data structure where SPDK will initialize the default sock options.
|
||||
* Users must set opts_size to sizeof(struct spdk_sock_opts). This will ensure that the
|
||||
* libraryonly tries to fill as many fields as allocated by the caller. This allows ABI
|
||||
* compatibility with future versions of this library that may extend the spdk_sock_opts
|
||||
* structure.
|
||||
*/
|
||||
void spdk_sock_get_default_opts(struct spdk_sock_opts *opts);
|
||||
|
||||
/**
|
||||
* Get client and server addresses of the given socket.
|
||||
*
|
||||
@ -103,14 +134,32 @@ int spdk_sock_getaddr(struct spdk_sock *sock, char *saddr, int slen, uint16_t *s
|
||||
* \param ip IP address of the server.
|
||||
* \param port Port number of the server.
|
||||
* \param impl_name The sock_implementation to use, such as "posix". If impl_name is
|
||||
* specified, it will *only* try to listen on that impl. If it is NULL, it will try
|
||||
* specified, it will *only* try to connect on that impl. If it is NULL, it will try
|
||||
* all the sock implementations in order and uses the first sock implementation which
|
||||
* can connect. For example, it will try vpp, posix as an example.
|
||||
* can connect. For example, it may try vpp first, then fall back to posix.
|
||||
*
|
||||
* \return a pointer to the connected socket on success, or NULL on failure.
|
||||
*/
|
||||
struct spdk_sock *spdk_sock_connect(const char *ip, int port, char *impl_name);
|
||||
|
||||
/**
|
||||
* Create a socket using the specific sock implementation, connect the socket
|
||||
* to the specified address and port (of the server), and then return the socket.
|
||||
* This function is used by client.
|
||||
*
|
||||
* \param ip IP address of the server.
|
||||
* \param port Port number of the server.
|
||||
* \param impl_name The sock_implementation to use, such as "posix". If impl_name is
|
||||
* specified, it will *only* try to connect on that impl. If it is NULL, it will try
|
||||
* all the sock implementations in order and uses the first sock implementation which
|
||||
* can connect. For example, it may try vpp first, then fall back to posix.
|
||||
* \param opts The sock option pointer provided by the user which should not be NULL pointer.
|
||||
*
|
||||
* \return a pointer to the connected socket on success, or NULL on failure.
|
||||
*/
|
||||
struct spdk_sock *spdk_sock_connect_ext(const char *ip, int port, char *impl_name,
|
||||
struct spdk_sock_opts *opts);
|
||||
|
||||
/**
|
||||
* Create a socket using the specific sock implementation, bind the socket to
|
||||
* the specified address and port and listen on the socket, and then return the socket.
|
||||
@ -121,12 +170,30 @@ struct spdk_sock *spdk_sock_connect(const char *ip, int port, char *impl_name);
|
||||
* \param impl_name The sock_implementation to use, such as "posix". If impl_name is
|
||||
* specified, it will *only* try to listen on that impl. If it is NULL, it will try
|
||||
* all the sock implementations in order and uses the first sock implementation which
|
||||
* can listen. For example, it will try vpp, posix as an example.
|
||||
* can listen. For example, it may try vpp first, then fall back to posix.
|
||||
*
|
||||
* \return a pointer to the listened socket on success, or NULL on failure.
|
||||
*/
|
||||
struct spdk_sock *spdk_sock_listen(const char *ip, int port, char *impl_name);
|
||||
|
||||
/**
|
||||
* Create a socket using the specific sock implementation, bind the socket to
|
||||
* the specified address and port and listen on the socket, and then return the socket.
|
||||
* This function is used by server.
|
||||
*
|
||||
* \param ip IP address to listen on.
|
||||
* \param port Port number.
|
||||
* \param impl_name The sock_implementation to use, such as "posix". If impl_name is
|
||||
* specified, it will *only* try to listen on that impl. If it is NULL, it will try
|
||||
* all the sock implementations in order and uses the first sock implementation which
|
||||
* can listen. For example, it may try vpp first, then fall back to posix.
|
||||
* \param opts The sock option pointer provided by the user, which should not be NULL pointer.
|
||||
*
|
||||
* \return a pointer to the listened socket on success, or NULL on failure.
|
||||
*/
|
||||
struct spdk_sock *spdk_sock_listen_ext(const char *ip, int port, char *impl_name,
|
||||
struct spdk_sock_opts *opts);
|
||||
|
||||
/**
|
||||
* Accept a new connection from a client on the specified socket and return a
|
||||
* socket structure which holds the connection.
|
||||
|
@ -51,6 +51,7 @@ extern "C" {
|
||||
|
||||
struct spdk_sock {
|
||||
struct spdk_net_impl *net_impl;
|
||||
struct spdk_sock_opts opts;
|
||||
int cb_cnt;
|
||||
spdk_sock_cb cb_fn;
|
||||
void *cb_arg;
|
||||
@ -91,8 +92,8 @@ struct spdk_net_impl {
|
||||
|
||||
int (*getaddr)(struct spdk_sock *sock, char *saddr, int slen, uint16_t *sport, char *caddr,
|
||||
int clen, uint16_t *cport);
|
||||
struct spdk_sock *(*connect)(const char *ip, int port);
|
||||
struct spdk_sock *(*listen)(const char *ip, int port);
|
||||
struct spdk_sock *(*connect)(const char *ip, int port, struct spdk_sock_opts *opts);
|
||||
struct spdk_sock *(*listen)(const char *ip, int port, struct spdk_sock_opts *opts);
|
||||
struct spdk_sock *(*accept)(struct spdk_sock *sock);
|
||||
int (*close)(struct spdk_sock *sock);
|
||||
ssize_t (*recv)(struct spdk_sock *sock, void *buf, size_t len);
|
||||
|
@ -38,6 +38,9 @@
|
||||
#include "spdk_internal/sock.h"
|
||||
#include "spdk/queue.h"
|
||||
|
||||
#define SPDK_SOCK_DEFAULT_PRIORITY 0
|
||||
#define SPDK_SOCK_OPTS_FIELD_OK(opts, field) (offsetof(struct spdk_sock_opts, field) + sizeof(opts->field) <= (opts->opts_size))
|
||||
|
||||
static STAILQ_HEAD(, spdk_net_impl) g_net_impls = STAILQ_HEAD_INITIALIZER(g_net_impls);
|
||||
|
||||
struct spdk_sock_placement_id_entry {
|
||||
@ -164,19 +167,68 @@ spdk_sock_getaddr(struct spdk_sock *sock, char *saddr, int slen, uint16_t *sport
|
||||
return sock->net_impl->getaddr(sock, saddr, slen, sport, caddr, clen, cport);
|
||||
}
|
||||
|
||||
void
|
||||
spdk_sock_get_default_opts(struct spdk_sock_opts *opts)
|
||||
{
|
||||
assert(opts);
|
||||
|
||||
if (SPDK_SOCK_OPTS_FIELD_OK(opts, priority)) {
|
||||
opts->priority = SPDK_SOCK_DEFAULT_PRIORITY;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* opts The opts allocated in the current library.
|
||||
* opts_user The opts passed by the caller.
|
||||
* */
|
||||
static void
|
||||
spdk_sock_init_opts(struct spdk_sock_opts *opts, struct spdk_sock_opts *opts_user)
|
||||
{
|
||||
assert(opts);
|
||||
assert(opts_user);
|
||||
|
||||
opts->opts_size = sizeof(*opts);
|
||||
spdk_sock_get_default_opts(opts);
|
||||
|
||||
/* reset the size according to the user */
|
||||
opts->opts_size = opts_user->opts_size;
|
||||
if (SPDK_SOCK_OPTS_FIELD_OK(opts, priority)) {
|
||||
opts->priority = opts_user->priority;
|
||||
}
|
||||
}
|
||||
|
||||
struct spdk_sock *
|
||||
spdk_sock_connect(const char *ip, int port, char *impl_name)
|
||||
{
|
||||
struct spdk_sock_opts opts;
|
||||
|
||||
opts.opts_size = sizeof(opts);
|
||||
spdk_sock_get_default_opts(&opts);
|
||||
return spdk_sock_connect_ext(ip, port, impl_name, &opts);
|
||||
}
|
||||
|
||||
struct spdk_sock *
|
||||
spdk_sock_connect_ext(const char *ip, int port, char *impl_name, struct spdk_sock_opts *opts)
|
||||
{
|
||||
struct spdk_net_impl *impl = NULL;
|
||||
struct spdk_sock *sock;
|
||||
struct spdk_sock_opts opts_local;
|
||||
|
||||
if (opts == NULL) {
|
||||
SPDK_ERRLOG("the opts should not be NULL pointer\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
STAILQ_FOREACH_FROM(impl, &g_net_impls, link) {
|
||||
if (impl_name && strncmp(impl_name, impl->name, strlen(impl->name) + 1)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
sock = impl->connect(ip, port);
|
||||
spdk_sock_init_opts(&opts_local, opts);
|
||||
sock = impl->connect(ip, port, &opts_local);
|
||||
if (sock != NULL) {
|
||||
/* Copy the contents, both the two structures are the same ABI version */
|
||||
memcpy(&sock->opts, &opts_local, sizeof(sock->opts));
|
||||
sock->net_impl = impl;
|
||||
TAILQ_INIT(&sock->queued_reqs);
|
||||
TAILQ_INIT(&sock->pending_reqs);
|
||||
@ -189,17 +241,36 @@ spdk_sock_connect(const char *ip, int port, char *impl_name)
|
||||
|
||||
struct spdk_sock *
|
||||
spdk_sock_listen(const char *ip, int port, char *impl_name)
|
||||
{
|
||||
struct spdk_sock_opts opts;
|
||||
|
||||
opts.opts_size = sizeof(opts);
|
||||
spdk_sock_get_default_opts(&opts);
|
||||
return spdk_sock_listen_ext(ip, port, impl_name, &opts);
|
||||
}
|
||||
|
||||
struct spdk_sock *
|
||||
spdk_sock_listen_ext(const char *ip, int port, char *impl_name, struct spdk_sock_opts *opts)
|
||||
{
|
||||
struct spdk_net_impl *impl = NULL;
|
||||
struct spdk_sock *sock;
|
||||
struct spdk_sock_opts opts_local;
|
||||
|
||||
if (opts == NULL) {
|
||||
SPDK_ERRLOG("the opts should not be NULL pointer\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
STAILQ_FOREACH_FROM(impl, &g_net_impls, link) {
|
||||
if (impl_name && strncmp(impl_name, impl->name, strlen(impl->name) + 1)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
sock = impl->listen(ip, port);
|
||||
spdk_sock_init_opts(&opts_local, opts);
|
||||
sock = impl->listen(ip, port, &opts_local);
|
||||
if (sock != NULL) {
|
||||
/* Copy the contents, both the two structures are the same ABI version */
|
||||
memcpy(&sock->opts, &opts_local, sizeof(sock->opts));
|
||||
sock->net_impl = impl;
|
||||
/* Don't need to initialize the request queues for listen
|
||||
* sockets. */
|
||||
@ -217,6 +288,9 @@ spdk_sock_accept(struct spdk_sock *sock)
|
||||
|
||||
new_sock = sock->net_impl->accept(sock);
|
||||
if (new_sock != NULL) {
|
||||
/* Inherit the opts from the "accept sock" */
|
||||
new_sock->opts = sock->opts;
|
||||
memcpy(&new_sock->opts, &sock->opts, sizeof(new_sock->opts));
|
||||
new_sock->net_impl = sock->net_impl;
|
||||
TAILQ_INIT(&new_sock->queued_reqs);
|
||||
TAILQ_INIT(&new_sock->pending_reqs);
|
||||
|
@ -329,7 +329,9 @@ _spdk_posix_sock_alloc(int fd)
|
||||
}
|
||||
|
||||
static struct spdk_sock *
|
||||
spdk_posix_sock_create(const char *ip, int port, enum spdk_posix_sock_create_type type)
|
||||
spdk_posix_sock_create(const char *ip, int port,
|
||||
enum spdk_posix_sock_create_type type,
|
||||
struct spdk_sock_opts *opts)
|
||||
{
|
||||
struct spdk_posix_sock *sock;
|
||||
char buf[MAX_TMPBUF];
|
||||
@ -400,6 +402,17 @@ retry:
|
||||
continue;
|
||||
}
|
||||
|
||||
#if defined(SO_PRIORITY)
|
||||
if (opts != NULL && opts->priority) {
|
||||
rc = setsockopt(fd, SOL_SOCKET, SO_PRIORITY, &opts->priority, sizeof val);
|
||||
if (rc != 0) {
|
||||
close(fd);
|
||||
/* error */
|
||||
continue;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
if (res->ai_family == AF_INET6) {
|
||||
rc = setsockopt(fd, IPPROTO_IPV6, IPV6_V6ONLY, &val, sizeof val);
|
||||
if (rc != 0) {
|
||||
@ -481,15 +494,15 @@ retry:
|
||||
}
|
||||
|
||||
static struct spdk_sock *
|
||||
spdk_posix_sock_listen(const char *ip, int port)
|
||||
spdk_posix_sock_listen(const char *ip, int port, struct spdk_sock_opts *opts)
|
||||
{
|
||||
return spdk_posix_sock_create(ip, port, SPDK_SOCK_CREATE_LISTEN);
|
||||
return spdk_posix_sock_create(ip, port, SPDK_SOCK_CREATE_LISTEN, opts);
|
||||
}
|
||||
|
||||
static struct spdk_sock *
|
||||
spdk_posix_sock_connect(const char *ip, int port)
|
||||
spdk_posix_sock_connect(const char *ip, int port, struct spdk_sock_opts *opts)
|
||||
{
|
||||
return spdk_posix_sock_create(ip, port, SPDK_SOCK_CREATE_CONNECT);
|
||||
return spdk_posix_sock_create(ip, port, SPDK_SOCK_CREATE_CONNECT, opts);
|
||||
}
|
||||
|
||||
static struct spdk_sock *
|
||||
@ -522,6 +535,17 @@ spdk_posix_sock_accept(struct spdk_sock *_sock)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
#if defined(SO_PRIORITY)
|
||||
/* The priority is not inherited, so call this function again */
|
||||
if (sock->base.opts.priority) {
|
||||
rc = setsockopt(fd, SOL_SOCKET, SO_PRIORITY, &sock->base.opts.priority, sizeof(int));
|
||||
if (rc != 0) {
|
||||
close(fd);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
new_sock = _spdk_posix_sock_alloc(fd);
|
||||
if (new_sock == NULL) {
|
||||
close(fd);
|
||||
|
@ -34,6 +34,10 @@
|
||||
SPDK_ROOT_DIR := $(abspath $(CURDIR)/../../..)
|
||||
include $(SPDK_ROOT_DIR)/mk/spdk.common.mk
|
||||
|
||||
SO_VER := 1
|
||||
SO_MINOR := 0
|
||||
SO_SUFFIX := $(SO_VER).$(SO_MINOR)
|
||||
|
||||
LIBNAME = sock_uring
|
||||
C_SRCS = uring.c
|
||||
|
||||
|
@ -339,7 +339,9 @@ _spdk_uring_sock_alloc(int fd)
|
||||
}
|
||||
|
||||
static struct spdk_sock *
|
||||
spdk_uring_sock_create(const char *ip, int port, enum spdk_uring_sock_create_type type)
|
||||
spdk_uring_sock_create(const char *ip, int port,
|
||||
enum spdk_uring_sock_create_type type,
|
||||
struct spdk_sock_opts *opts)
|
||||
{
|
||||
struct spdk_uring_sock *sock;
|
||||
char buf[MAX_TMPBUF];
|
||||
@ -410,6 +412,16 @@ retry:
|
||||
continue;
|
||||
}
|
||||
|
||||
#if defined(SO_PRIORITY)
|
||||
if (opts != NULL && opts->priority) {
|
||||
rc = setsockopt(fd, SOL_SOCKET, SO_PRIORITY, &opts->priority, sizeof val);
|
||||
if (rc != 0) {
|
||||
close(fd);
|
||||
/* error */
|
||||
continue;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
if (res->ai_family == AF_INET6) {
|
||||
rc = setsockopt(fd, IPPROTO_IPV6, IPV6_V6ONLY, &val, sizeof val);
|
||||
if (rc != 0) {
|
||||
@ -486,15 +498,15 @@ retry:
|
||||
}
|
||||
|
||||
static struct spdk_sock *
|
||||
spdk_uring_sock_listen(const char *ip, int port)
|
||||
spdk_uring_sock_listen(const char *ip, int port, struct spdk_sock_opts *opts)
|
||||
{
|
||||
return spdk_uring_sock_create(ip, port, SPDK_SOCK_CREATE_LISTEN);
|
||||
return spdk_uring_sock_create(ip, port, SPDK_SOCK_CREATE_LISTEN, opts);
|
||||
}
|
||||
|
||||
static struct spdk_sock *
|
||||
spdk_uring_sock_connect(const char *ip, int port)
|
||||
spdk_uring_sock_connect(const char *ip, int port, struct spdk_sock_opts *opts)
|
||||
{
|
||||
return spdk_uring_sock_create(ip, port, SPDK_SOCK_CREATE_CONNECT);
|
||||
return spdk_uring_sock_create(ip, port, SPDK_SOCK_CREATE_CONNECT, opts);
|
||||
}
|
||||
|
||||
static struct spdk_sock *
|
||||
@ -527,6 +539,17 @@ spdk_uring_sock_accept(struct spdk_sock *_sock)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
#if defined(SO_PRIORITY)
|
||||
/* The priority is not inherited, so call this function again */
|
||||
if (sock->base.opts.priority) {
|
||||
rc = setsockopt(fd, SOL_SOCKET, SO_PRIORITY, &sock->base.opts.priority, sizeof(int));
|
||||
if (rc != 0) {
|
||||
close(fd);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
new_sock = _spdk_uring_sock_alloc(fd);
|
||||
if (new_sock == NULL) {
|
||||
close(fd);
|
||||
|
@ -700,7 +700,8 @@ _spdk_vpp_session_listen(struct spdk_vpp_session *session)
|
||||
}
|
||||
|
||||
static struct spdk_sock *
|
||||
spdk_vpp_sock_create(const char *ip, int port, enum spdk_vpp_create_type type)
|
||||
spdk_vpp_sock_create(const char *ip, int port, enum spdk_vpp_create_type type,
|
||||
struct spdk_sock_opts *opts)
|
||||
{
|
||||
struct spdk_vpp_session *session;
|
||||
int rc;
|
||||
@ -760,15 +761,15 @@ err:
|
||||
}
|
||||
|
||||
static struct spdk_sock *
|
||||
spdk_vpp_sock_listen(const char *ip, int port)
|
||||
spdk_vpp_sock_listen(const char *ip, int port, struct spdk_sock_opts *opts)
|
||||
{
|
||||
return spdk_vpp_sock_create(ip, port, SPDK_SOCK_CREATE_LISTEN);
|
||||
return spdk_vpp_sock_create(ip, port, SPDK_SOCK_CREATE_LISTEN, opts);
|
||||
}
|
||||
|
||||
static struct spdk_sock *
|
||||
spdk_vpp_sock_connect(const char *ip, int port)
|
||||
spdk_vpp_sock_connect(const char *ip, int port, struct spdk_sock_opts *opts)
|
||||
{
|
||||
return spdk_vpp_sock_create(ip, port, SPDK_SOCK_CREATE_CONNECT);
|
||||
return spdk_vpp_sock_create(ip, port, SPDK_SOCK_CREATE_CONNECT, opts);
|
||||
}
|
||||
|
||||
static struct spdk_sock *
|
||||
|
@ -75,7 +75,7 @@ spdk_ut_sock_getaddr(struct spdk_sock *_sock, char *saddr, int slen, uint16_t *s
|
||||
}
|
||||
|
||||
static struct spdk_sock *
|
||||
spdk_ut_sock_listen(const char *ip, int port)
|
||||
spdk_ut_sock_listen(const char *ip, int port, struct spdk_sock_opts *opts)
|
||||
{
|
||||
struct spdk_ut_sock *sock;
|
||||
|
||||
@ -93,7 +93,7 @@ spdk_ut_sock_listen(const char *ip, int port)
|
||||
}
|
||||
|
||||
static struct spdk_sock *
|
||||
spdk_ut_sock_connect(const char *ip, int port)
|
||||
spdk_ut_sock_connect(const char *ip, int port, struct spdk_sock_opts *opts)
|
||||
{
|
||||
struct spdk_ut_sock *sock;
|
||||
|
||||
@ -809,6 +809,40 @@ posix_sock_close(void)
|
||||
_sock_close("127.0.0.1", UT_PORT, "posix");
|
||||
}
|
||||
|
||||
static void
|
||||
sock_get_default_opts(void)
|
||||
{
|
||||
struct spdk_sock_opts opts;
|
||||
|
||||
/* opts_size is 0 */
|
||||
opts.opts_size = 0;
|
||||
opts.priority = 3;
|
||||
spdk_sock_get_default_opts(&opts);
|
||||
CU_ASSERT(opts.priority == 3);
|
||||
CU_ASSERT(opts.opts_size == 0);
|
||||
|
||||
/* opts_size is less than sizeof(opts) */
|
||||
opts.opts_size = 4;
|
||||
opts.priority = 3;
|
||||
spdk_sock_get_default_opts(&opts);
|
||||
CU_ASSERT(opts.priority == 3);
|
||||
CU_ASSERT(opts.opts_size == 4);
|
||||
|
||||
/* opts_size is equal to sizeof(opts) */
|
||||
opts.opts_size = sizeof(opts);
|
||||
opts.priority = 3;
|
||||
spdk_sock_get_default_opts(&opts);
|
||||
CU_ASSERT(opts.priority == SPDK_SOCK_DEFAULT_PRIORITY);
|
||||
CU_ASSERT(opts.opts_size == sizeof(opts));
|
||||
|
||||
/* opts_size is larger then sizeof(opts) */
|
||||
opts.opts_size = sizeof(opts) + 1;
|
||||
opts.priority = 3;
|
||||
spdk_sock_get_default_opts(&opts);
|
||||
CU_ASSERT(opts.priority == SPDK_SOCK_DEFAULT_PRIORITY);
|
||||
CU_ASSERT(opts.opts_size == (sizeof(opts) + 1));
|
||||
}
|
||||
|
||||
int
|
||||
main(int argc, char **argv)
|
||||
{
|
||||
@ -826,6 +860,7 @@ main(int argc, char **argv)
|
||||
CU_ADD_TEST(suite, ut_sock_group);
|
||||
CU_ADD_TEST(suite, posix_sock_group_fairness);
|
||||
CU_ADD_TEST(suite, posix_sock_close);
|
||||
CU_ADD_TEST(suite, sock_get_default_opts);
|
||||
|
||||
CU_basic_set_mode(CU_BRM_VERBOSE);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user