summaryrefslogtreecommitdiffstats
path: root/hw
diff options
context:
space:
mode:
authorAnthony Liguori <aliguori@amazon.com>2013-12-10 16:14:20 -0800
committerAnthony Liguori <aliguori@amazon.com>2013-12-10 16:14:20 -0800
commitb9aad5d68d0fa636d1a1edbbeffa0d7a80370711 (patch)
treeb21dd4d8fecabe85167ce2b889aa1a32d44a47a5 /hw
parent1ead3ed55584a62a12d840a71d3aab71f12ec42e (diff)
parent02d38fcb2caa4454cf4ed728d5908c3cc9ba47be (diff)
downloadhqemu-b9aad5d68d0fa636d1a1edbbeffa0d7a80370711.zip
hqemu-b9aad5d68d0fa636d1a1edbbeffa0d7a80370711.tar.gz
Merge remote-tracking branch 'stefanha/net-next' into staging
# By Vincenzo Maffione (2) and others # Via Stefan Hajnoczi * stefanha/net-next: net: Update netdev peer on link change virtio-net: don't update mac_table in error state MAINTAINERS: Add netmap maintainers net: Adding netmap network backend Message-id: 1386594692-21278-1-git-send-email-stefanha@redhat.com Signed-off-by: Anthony Liguori <aliguori@amazon.com>
Diffstat (limited to 'hw')
-rw-r--r--hw/net/virtio-net.c35
1 files changed, 20 insertions, 15 deletions
diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c
index 90eca9a..d312b9c 100644
--- a/hw/net/virtio-net.c
+++ b/hw/net/virtio-net.c
@@ -610,11 +610,11 @@ static int virtio_net_handle_mac(VirtIONet *n, uint8_t cmd,
return VIRTIO_NET_ERR;
}
- n->mac_table.in_use = 0;
- n->mac_table.first_multi = 0;
- n->mac_table.uni_overflow = 0;
- n->mac_table.multi_overflow = 0;
- memset(n->mac_table.macs, 0, MAC_TABLE_ENTRIES * ETH_ALEN);
+ int in_use = 0;
+ int first_multi = 0;
+ uint8_t uni_overflow = 0;
+ uint8_t multi_overflow = 0;
+ uint8_t *macs = g_malloc0(MAC_TABLE_ENTRIES * ETH_ALEN);
s = iov_to_buf(iov, iov_cnt, 0, &mac_data.entries,
sizeof(mac_data.entries));
@@ -629,19 +629,19 @@ static int virtio_net_handle_mac(VirtIONet *n, uint8_t cmd,
}
if (mac_data.entries <= MAC_TABLE_ENTRIES) {
- s = iov_to_buf(iov, iov_cnt, 0, n->mac_table.macs,
+ s = iov_to_buf(iov, iov_cnt, 0, macs,
mac_data.entries * ETH_ALEN);
if (s != mac_data.entries * ETH_ALEN) {
goto error;
}
- n->mac_table.in_use += mac_data.entries;
+ in_use += mac_data.entries;
} else {
- n->mac_table.uni_overflow = 1;
+ uni_overflow = 1;
}
iov_discard_front(&iov, &iov_cnt, mac_data.entries * ETH_ALEN);
- n->mac_table.first_multi = n->mac_table.in_use;
+ first_multi = in_use;
s = iov_to_buf(iov, iov_cnt, 0, &mac_data.entries,
sizeof(mac_data.entries));
@@ -656,24 +656,29 @@ static int virtio_net_handle_mac(VirtIONet *n, uint8_t cmd,
goto error;
}
- if (n->mac_table.in_use + mac_data.entries <= MAC_TABLE_ENTRIES) {
- s = iov_to_buf(iov, iov_cnt, 0,
- &n->mac_table.macs[n->mac_table.in_use * ETH_ALEN],
+ if (in_use + mac_data.entries <= MAC_TABLE_ENTRIES) {
+ s = iov_to_buf(iov, iov_cnt, 0, &macs[in_use * ETH_ALEN],
mac_data.entries * ETH_ALEN);
if (s != mac_data.entries * ETH_ALEN) {
goto error;
}
- n->mac_table.in_use += mac_data.entries;
+ in_use += mac_data.entries;
} else {
- n->mac_table.multi_overflow = 1;
+ multi_overflow = 1;
}
+ n->mac_table.in_use = in_use;
+ n->mac_table.first_multi = first_multi;
+ n->mac_table.uni_overflow = uni_overflow;
+ n->mac_table.multi_overflow = multi_overflow;
+ memcpy(n->mac_table.macs, macs, MAC_TABLE_ENTRIES * ETH_ALEN);
+ g_free(macs);
rxfilter_notify(nc);
return VIRTIO_NET_OK;
error:
- rxfilter_notify(nc);
+ g_free(macs);
return VIRTIO_NET_ERR;
}
OpenPOWER on IntegriCloud