-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1 iQEcBAABAgAGBQJZN3MQAAoJEO8Ells5jWIRhfkH/1iV+DDT0caXqdxEbHktVpiY ZuFxjKId63PhpyJXurmevJ3oiTYdUe5glX/GtN/0q0FRD+16kAD5SzxiIBqfWr3z uR8PQ73rdf9ts8jZHth1ZKgP00MC9RDS3YikYyQSBW0+TkvlulrRlD0vJfogCEYj EQO1OElrllXFmTqlHFHXR7mT4Cbcfw0xXARBJ+PfrWixhIuVuPwEKjZM4jsSoF62 BuK33cXrX8ovSg7cER7gjhet89TbZejXtEhqVQndub7byARIJi+Hvi6oE4fBslzK 1693WOvNz6T1Emv98XrdiBeLBfBDGEP+DLHz6Ih5ysuGdNYWvUVGNpgOzV+9vLc= =OjxD -----END PGP SIGNATURE----- Merge remote-tracking branch 'remotes/jasowang/tags/net-pull-request' into staging # gpg: Signature made Wed 07 Jun 2017 04:29:20 BST # gpg: using RSA key 0xEF04965B398D6211 # gpg: Good signature from "Jason Wang (Jason Wang on RedHat) <jasowang@redhat.com>" # gpg: WARNING: This key is not certified with sufficiently trusted signatures! # gpg: It is not certain that the signature belongs to the owner. # Primary key fingerprint: 215D 46F4 8246 689E C77F 3562 EF04 965B 398D 6211 * remotes/jasowang/tags/net-pull-request: Revert "Change net/socket.c to use socket_*() functions" again net/rocker: Cleanup the useless return value check Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
This commit is contained in:
commit
b187e2b530
@ -244,11 +244,9 @@ static int tx_consume(Rocker *r, DescInfo *info)
|
|||||||
goto err_no_mem;
|
goto err_no_mem;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pci_dma_read(dev, frag_addr, iov[iovcnt].iov_base,
|
pci_dma_read(dev, frag_addr, iov[iovcnt].iov_base,
|
||||||
iov[iovcnt].iov_len)) {
|
iov[iovcnt].iov_len);
|
||||||
err = -ROCKER_ENXIO;
|
|
||||||
goto err_bad_io;
|
|
||||||
}
|
|
||||||
iovcnt++;
|
iovcnt++;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -261,7 +259,6 @@ static int tx_consume(Rocker *r, DescInfo *info)
|
|||||||
err = fp_port_eg(r->fp_port[port], iov, iovcnt);
|
err = fp_port_eg(r->fp_port[port], iov, iovcnt);
|
||||||
|
|
||||||
err_too_many_frags:
|
err_too_many_frags:
|
||||||
err_bad_io:
|
|
||||||
err_no_mem:
|
err_no_mem:
|
||||||
err_bad_attr:
|
err_bad_attr:
|
||||||
for (i = 0; i < ROCKER_TX_FRAGS_MAX; i++) {
|
for (i = 0; i < ROCKER_TX_FRAGS_MAX; i++) {
|
||||||
|
@ -69,9 +69,7 @@ char *desc_get_buf(DescInfo *info, bool read_only)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pci_dma_read(dev, le64_to_cpu(info->desc.buf_addr), info->buf, size)) {
|
pci_dma_read(dev, le64_to_cpu(info->desc.buf_addr), info->buf, size);
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
return info->buf;
|
return info->buf;
|
||||||
}
|
}
|
||||||
|
127
net/socket.c
127
net/socket.c
@ -489,106 +489,91 @@ static int net_socket_listen_init(NetClientState *peer,
|
|||||||
{
|
{
|
||||||
NetClientState *nc;
|
NetClientState *nc;
|
||||||
NetSocketState *s;
|
NetSocketState *s;
|
||||||
SocketAddress *saddr;
|
struct sockaddr_in saddr;
|
||||||
int ret;
|
int fd, ret;
|
||||||
Error *local_error = NULL;
|
|
||||||
|
|
||||||
saddr = socket_parse(host_str, &local_error);
|
if (parse_host_port(&saddr, host_str) < 0)
|
||||||
if (saddr == NULL) {
|
return -1;
|
||||||
error_report_err(local_error);
|
|
||||||
|
fd = qemu_socket(PF_INET, SOCK_STREAM, 0);
|
||||||
|
if (fd < 0) {
|
||||||
|
perror("socket");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
qemu_set_nonblock(fd);
|
||||||
|
|
||||||
ret = socket_listen(saddr, &local_error);
|
socket_set_fast_reuse(fd);
|
||||||
|
|
||||||
|
ret = bind(fd, (struct sockaddr *)&saddr, sizeof(saddr));
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
qapi_free_SocketAddress(saddr);
|
perror("bind");
|
||||||
error_report_err(local_error);
|
closesocket(fd);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
ret = listen(fd, 0);
|
||||||
|
if (ret < 0) {
|
||||||
|
perror("listen");
|
||||||
|
closesocket(fd);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
nc = qemu_new_net_client(&net_socket_info, peer, model, name);
|
nc = qemu_new_net_client(&net_socket_info, peer, model, name);
|
||||||
s = DO_UPCAST(NetSocketState, nc, nc);
|
s = DO_UPCAST(NetSocketState, nc, nc);
|
||||||
s->fd = -1;
|
s->fd = -1;
|
||||||
s->listen_fd = ret;
|
s->listen_fd = fd;
|
||||||
s->nc.link_down = true;
|
s->nc.link_down = true;
|
||||||
net_socket_rs_init(&s->rs, net_socket_rs_finalize);
|
net_socket_rs_init(&s->rs, net_socket_rs_finalize);
|
||||||
|
|
||||||
qemu_set_fd_handler(s->listen_fd, net_socket_accept, NULL, s);
|
qemu_set_fd_handler(s->listen_fd, net_socket_accept, NULL, s);
|
||||||
qapi_free_SocketAddress(saddr);
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
NetClientState *peer;
|
|
||||||
SocketAddress *saddr;
|
|
||||||
char *model;
|
|
||||||
char *name;
|
|
||||||
} socket_connect_data;
|
|
||||||
|
|
||||||
static void socket_connect_data_free(socket_connect_data *c)
|
|
||||||
{
|
|
||||||
qapi_free_SocketAddress(c->saddr);
|
|
||||||
g_free(c->model);
|
|
||||||
g_free(c->name);
|
|
||||||
g_free(c);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void net_socket_connected(int fd, Error *err, void *opaque)
|
|
||||||
{
|
|
||||||
socket_connect_data *c = opaque;
|
|
||||||
NetSocketState *s;
|
|
||||||
char *addr_str = NULL;
|
|
||||||
Error *local_error = NULL;
|
|
||||||
|
|
||||||
addr_str = socket_address_to_string(c->saddr, &local_error);
|
|
||||||
if (addr_str == NULL) {
|
|
||||||
error_report_err(local_error);
|
|
||||||
closesocket(fd);
|
|
||||||
goto end;
|
|
||||||
}
|
|
||||||
|
|
||||||
s = net_socket_fd_init(c->peer, c->model, c->name, fd, true);
|
|
||||||
if (!s) {
|
|
||||||
closesocket(fd);
|
|
||||||
goto end;
|
|
||||||
}
|
|
||||||
|
|
||||||
snprintf(s->nc.info_str, sizeof(s->nc.info_str),
|
|
||||||
"socket: connect to %s", addr_str);
|
|
||||||
|
|
||||||
end:
|
|
||||||
g_free(addr_str);
|
|
||||||
socket_connect_data_free(c);
|
|
||||||
}
|
|
||||||
|
|
||||||
static int net_socket_connect_init(NetClientState *peer,
|
static int net_socket_connect_init(NetClientState *peer,
|
||||||
const char *model,
|
const char *model,
|
||||||
const char *name,
|
const char *name,
|
||||||
const char *host_str)
|
const char *host_str)
|
||||||
{
|
{
|
||||||
socket_connect_data *c = g_new0(socket_connect_data, 1);
|
NetSocketState *s;
|
||||||
int fd = -1;
|
int fd, connected, ret;
|
||||||
Error *local_error = NULL;
|
struct sockaddr_in saddr;
|
||||||
|
|
||||||
c->peer = peer;
|
if (parse_host_port(&saddr, host_str) < 0)
|
||||||
c->model = g_strdup(model);
|
return -1;
|
||||||
c->name = g_strdup(name);
|
|
||||||
c->saddr = socket_parse(host_str, &local_error);
|
|
||||||
if (c->saddr == NULL) {
|
|
||||||
goto err;
|
|
||||||
}
|
|
||||||
|
|
||||||
fd = socket_connect(c->saddr, net_socket_connected, c, &local_error);
|
fd = qemu_socket(PF_INET, SOCK_STREAM, 0);
|
||||||
if (fd < 0) {
|
if (fd < 0) {
|
||||||
goto err;
|
perror("socket");
|
||||||
|
return -1;
|
||||||
}
|
}
|
||||||
|
qemu_set_nonblock(fd);
|
||||||
|
|
||||||
|
connected = 0;
|
||||||
|
for(;;) {
|
||||||
|
ret = connect(fd, (struct sockaddr *)&saddr, sizeof(saddr));
|
||||||
|
if (ret < 0) {
|
||||||
|
if (errno == EINTR || errno == EWOULDBLOCK) {
|
||||||
|
/* continue */
|
||||||
|
} else if (errno == EINPROGRESS ||
|
||||||
|
errno == EALREADY ||
|
||||||
|
errno == EINVAL) {
|
||||||
|
break;
|
||||||
|
} else {
|
||||||
|
perror("connect");
|
||||||
|
closesocket(fd);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
connected = 1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
s = net_socket_fd_init(peer, model, name, fd, connected);
|
||||||
|
if (!s)
|
||||||
|
return -1;
|
||||||
|
snprintf(s->nc.info_str, sizeof(s->nc.info_str),
|
||||||
|
"socket: connect to %s:%d",
|
||||||
|
inet_ntoa(saddr.sin_addr), ntohs(saddr.sin_port));
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
err:
|
|
||||||
error_report_err(local_error);
|
|
||||||
socket_connect_data_free(c);
|
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int net_socket_mcast_init(NetClientState *peer,
|
static int net_socket_mcast_init(NetClientState *peer,
|
||||||
|
Loading…
Reference in New Issue
Block a user