Skip to content

Commit

Permalink
Merge remote-tracking branch 'remotes/jasowang/tags/net-pull-request'…
Browse files Browse the repository at this point in the history
… into staging

# gpg: Signature made Wed 06 Apr 2016 03:21:19 BST using RSA key ID 398D6211
# 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:
  filter-buffer: fix segfault when starting qemu with status=off property
  rtl8139: using CP_TX_OWN for ownership transferring during tx
  net: fix OptsVisitor memory leak
  net: Allocating Large sized arrays to heap
  util: Improved qemu_hexmap() to include an ascii dump of the buffer

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
  • Loading branch information
pm215 committed Apr 7, 2016
2 parents 7acbff9 + e0a039e commit 0f9d6bd
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 46 deletions.
2 changes: 1 addition & 1 deletion hw/net/rtl8139.c
Expand Up @@ -2046,7 +2046,7 @@ static int rtl8139_cplus_transmit_one(RTL8139State *s)
}

/* transfer ownership to target */
txdw0 &= ~CP_RX_OWN;
txdw0 &= ~CP_TX_OWN;

/* reset error indicator bits */
txdw0 &= ~CP_TX_STATUS_UNF;
Expand Down
2 changes: 1 addition & 1 deletion net/filter.c
Expand Up @@ -164,7 +164,7 @@ static void netfilter_set_status(Object *obj, const char *str, Error **errp)
return;
}
nf->on = !nf->on;
if (nfc->status_changed) {
if (nf->netdev && nfc->status_changed) {
nfc->status_changed(nf, errp);
}
}
Expand Down
44 changes: 11 additions & 33 deletions net/net.c
Expand Up @@ -81,34 +81,6 @@ int default_net = 1;
/***********************************************************/
/* network device redirectors */

#if defined(DEBUG_NET)
static void hex_dump(FILE *f, const uint8_t *buf, int size)
{
int len, i, j, c;

for(i=0;i<size;i+=16) {
len = size - i;
if (len > 16)
len = 16;
fprintf(f, "%08x ", i);
for(j=0;j<16;j++) {
if (j < len)
fprintf(f, " %02x", buf[i+j]);
else
fprintf(f, " ");
}
fprintf(f, " ");
for(j=0;j<len;j++) {
c = buf[i+j];
if (c < ' ' || c > '~')
c = '.';
fprintf(f, "%c", c);
}
fprintf(f, "\n");
}
}
#endif

static int get_str_sep(char *buf, int buf_size, const char **pp, int sep)
{
const char *p, *p1;
Expand Down Expand Up @@ -664,7 +636,7 @@ static ssize_t qemu_send_packet_async_with_flags(NetClientState *sender,

#ifdef DEBUG_NET
printf("qemu_send_packet_async:\n");
hex_dump(stdout, buf, size);
qemu_hexdump((const char *)buf, stdout, "net", size);
#endif

if (sender->link_down || !sender->peer) {
Expand Down Expand Up @@ -711,23 +683,28 @@ ssize_t qemu_send_packet_raw(NetClientState *nc, const uint8_t *buf, int size)
static ssize_t nc_sendv_compat(NetClientState *nc, const struct iovec *iov,
int iovcnt, unsigned flags)
{
uint8_t buf[NET_BUFSIZE];
uint8_t *buf = NULL;
uint8_t *buffer;
size_t offset;
ssize_t ret;

if (iovcnt == 1) {
buffer = iov[0].iov_base;
offset = iov[0].iov_len;
} else {
buf = g_new(uint8_t, NET_BUFSIZE);
buffer = buf;
offset = iov_to_buf(iov, iovcnt, 0, buf, sizeof(buf));
offset = iov_to_buf(iov, iovcnt, 0, buf, NET_BUFSIZE);
}

if (flags & QEMU_NET_PACKET_FLAG_RAW && nc->info->receive_raw) {
return nc->info->receive_raw(nc, buffer, offset);
ret = nc->info->receive_raw(nc, buffer, offset);
} else {
return nc->info->receive(nc, buffer, offset);
ret = nc->info->receive(nc, buffer, offset);
}

g_free(buf);
return ret;
}

ssize_t qemu_deliver_packet_iov(NetClientState *sender,
Expand Down Expand Up @@ -1100,6 +1077,7 @@ int net_client_init(QemuOpts *opts, int is_netdev, Error **errp)
}

error_propagate(errp, err);
opts_visitor_cleanup(ov);
return ret;
}

Expand Down
33 changes: 22 additions & 11 deletions util/hexdump.c
Expand Up @@ -18,21 +18,32 @@

void qemu_hexdump(const char *buf, FILE *fp, const char *prefix, size_t size)
{
unsigned int b;
unsigned int b, len, i, c;

for (b = 0; b < size; b++) {
if ((b % 16) == 0) {
fprintf(fp, "%s: %04x:", prefix, b);
for (b = 0; b < size; b += 16) {
len = size - b;
if (len > 16) {
len = 16;
}
if ((b % 4) == 0) {
fprintf(fp, " ");
fprintf(fp, "%s: %04x:", prefix, b);
for (i = 0; i < 16; i++) {
if ((i % 4) == 0) {
fprintf(fp, " ");
}
if (i < len) {
fprintf(fp, " %02x", (unsigned char)buf[b + i]);
} else {
fprintf(fp, " ");
}
}
fprintf(fp, " %02x", (unsigned char)buf[b]);
if ((b % 16) == 15) {
fprintf(fp, "\n");
fprintf(fp, " ");
for (i = 0; i < len; i++) {
c = buf[b + i];
if (c < ' ' || c > '~') {
c = '.';
}
fprintf(fp, "%c", c);
}
}
if ((b % 16) != 0) {
fprintf(fp, "\n");
}
}

0 comments on commit 0f9d6bd

Please sign in to comment.