-----BEGIN PGP SIGNATURE-----

Version: GnuPG v1
 
 iQEcBAABAgAGBQJfvHK9AAoJEO8Ells5jWIR5V0H+wX5bciJyPlOm1H5y8xIewuO
 GagUisjouvPsGTyRDIfotvj9sjai4ebdpP7R9eC8ulGkSN/Zg2FoSRw2v6eTI/GT
 lAZ5s1ZGUyWFQWpSDuH3BU4x9czmhdutr8uej5Wp/Vt+hzGpm0VWnXKiwIy3a62/
 IsJrIBd6VkCzDkKaeY/41otoKDexmklKPgTB1QoHylNIX0O9mfRuhNWcysaf9Qt7
 dd0516aOMIb4LKJja3KlupvgWmFf0dXXpMiT5mfJ3sqLYvHCAmnnAIBKXcbg6WGg
 zI2uL3zL2sKoyePC1/RBCCOY9fzTltQcBQhxn1XXkbuhfvuCyHDqO1ic1aBmsgQ=
 =7hkd
 -----END PGP SIGNATURE-----

Merge remote-tracking branch 'remotes/jasowang/tags/net-pull-request' into staging

# gpg: Signature made Tue 24 Nov 2020 02:41:01 GMT
# gpg:                using RSA key EF04965B398D6211
# gpg: Good signature from "Jason Wang (Jason Wang on RedHat) <jasowang@redhat.com>" [marginal]
# 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:
  net: Use correct default-path macro for downscript
  tap: fix a memory leak
  net: purge queued rx packets on queue deletion
  net: do not exit on "netdev_add help" monitor command
  hw/net/e1000e: advance desc_offset in case of null descriptor

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
This commit is contained in:
Peter Maydell 2020-11-24 10:59:12 +00:00
commit d536d9578e
5 changed files with 59 additions and 45 deletions

View file

@ -1596,13 +1596,13 @@ e1000e_write_packet_to_guest(E1000ECore *core, struct NetRxPkt *pkt,
(const char *) &fcs_pad, e1000x_fcs_len(core->mac));
}
}
desc_offset += desc_size;
if (desc_offset >= total_size) {
is_last = true;
}
} else { /* as per intel docs; skip descriptors with null buf addr */
trace_e1000e_rx_null_descriptor();
}
desc_offset += desc_size;
if (desc_offset >= total_size) {
is_last = true;
}
e1000e_write_rx_descr(core, desc, is_last ? core->rx_pkt : NULL,
rss_info, do_ps ? ps_hdr_len : 0, &bastate.written);

View file

@ -199,6 +199,7 @@ extern const char *host_net_devices[];
/* from net.c */
int net_client_parse(QemuOptsList *opts_list, const char *str);
void show_netdevs(void);
int net_init_clients(Error **errp);
void net_check_clients(void);
void net_cleanup(void);

View file

@ -24,6 +24,7 @@
#include "qemu/option.h"
#include "qemu/timer.h"
#include "qemu/sockets.h"
#include "qemu/help_option.h"
#include "monitor/monitor-internal.h"
#include "qapi/error.h"
#include "qapi/clone-visitor.h"
@ -1631,7 +1632,12 @@ void hmp_netdev_add(Monitor *mon, const QDict *qdict)
{
Error *err = NULL;
QemuOpts *opts;
const char *type = qdict_get_try_str(qdict, "type");
if (type && is_help_option(type)) {
show_netdevs();
return;
}
opts = qemu_opts_from_qdict(qemu_find_opts("netdev"), qdict, &err);
if (err) {
goto out;

View file

@ -44,6 +44,7 @@
#include "qemu/config-file.h"
#include "qemu/ctype.h"
#include "qemu/iov.h"
#include "qemu/qemu-print.h"
#include "qemu/main-loop.h"
#include "qemu/option.h"
#include "qapi/error.h"
@ -411,10 +412,14 @@ void qemu_del_nic(NICState *nic)
qemu_macaddr_set_free(&nic->conf->macaddr);
/* If this is a peer NIC and peer has already been deleted, free it now. */
if (nic->peer_deleted) {
for (i = 0; i < queues; i++) {
qemu_free_net_client(qemu_get_subqueue(nic, i)->peer);
for (i = 0; i < queues; i++) {
NetClientState *nc = qemu_get_subqueue(nic, i);
/* If this is a peer NIC and peer has already been deleted, free it now. */
if (nic->peer_deleted) {
qemu_free_net_client(nc->peer);
} else if (nc->peer) {
/* if there are RX packets pending, complete them */
qemu_purge_queued_packets(nc->peer);
}
}
@ -1025,7 +1030,7 @@ static int net_client_init1(const Netdev *netdev, bool is_netdev, Error **errp)
return 0;
}
static void show_netdevs(void)
void show_netdevs(void)
{
int idx;
const char *available_netdevs[] = {
@ -1055,9 +1060,9 @@ static void show_netdevs(void)
#endif
};
printf("Available netdev backend types:\n");
qemu_printf("Available netdev backend types:\n");
for (idx = 0; idx < ARRAY_SIZE(available_netdevs); idx++) {
puts(available_netdevs[idx]);
qemu_printf("%s\n", available_netdevs[idx]);
}
}
@ -1068,42 +1073,35 @@ static int net_client_init(QemuOpts *opts, bool is_netdev, Error **errp)
int ret = -1;
Visitor *v = opts_visitor_new(opts);
const char *type = qemu_opt_get(opts, "type");
/* Parse convenience option format ip6-net=fec0::0[/64] */
const char *ip6_net = qemu_opt_get(opts, "ipv6-net");
if (is_netdev && type && is_help_option(type)) {
show_netdevs();
exit(0);
} else {
/* Parse convenience option format ip6-net=fec0::0[/64] */
const char *ip6_net = qemu_opt_get(opts, "ipv6-net");
if (ip6_net) {
char *prefix_addr;
unsigned long prefix_len = 64; /* Default 64bit prefix length. */
if (ip6_net) {
char *prefix_addr;
unsigned long prefix_len = 64; /* Default 64bit prefix length. */
substrings = g_strsplit(ip6_net, "/", 2);
if (!substrings || !substrings[0]) {
error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "ipv6-net",
"a valid IPv6 prefix");
goto out;
}
prefix_addr = substrings[0];
/* Handle user-specified prefix length. */
if (substrings[1] &&
qemu_strtoul(substrings[1], NULL, 10, &prefix_len))
{
error_setg(errp, QERR_INVALID_PARAMETER_VALUE,
"ipv6-prefixlen", "a number");
goto out;
}
qemu_opt_set(opts, "ipv6-prefix", prefix_addr, &error_abort);
qemu_opt_set_number(opts, "ipv6-prefixlen", prefix_len,
&error_abort);
qemu_opt_unset(opts, "ipv6-net");
substrings = g_strsplit(ip6_net, "/", 2);
if (!substrings || !substrings[0]) {
error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "ipv6-net",
"a valid IPv6 prefix");
goto out;
}
prefix_addr = substrings[0];
/* Handle user-specified prefix length. */
if (substrings[1] &&
qemu_strtoul(substrings[1], NULL, 10, &prefix_len))
{
error_setg(errp, QERR_INVALID_PARAMETER_VALUE,
"ipv6-prefixlen", "a number");
goto out;
}
qemu_opt_set(opts, "ipv6-prefix", prefix_addr, &error_abort);
qemu_opt_set_number(opts, "ipv6-prefixlen", prefix_len,
&error_abort);
qemu_opt_unset(opts, "ipv6-net");
}
/* Create an ID for -net if the user did not specify one */
@ -1421,6 +1419,12 @@ static int net_init_client(void *dummy, QemuOpts *opts, Error **errp)
static int net_init_netdev(void *dummy, QemuOpts *opts, Error **errp)
{
const char *type = qemu_opt_get(opts, "type");
if (type && is_help_option(type)) {
show_netdevs();
exit(0);
}
return net_client_init(opts, true, errp);
}

View file

@ -817,6 +817,7 @@ int net_init_tap(const Netdev *netdev, const char *name,
if (ret < 0) {
error_setg_errno(errp, -ret, "%s: Can't use file descriptor %d",
name, fd);
close(fd);
return -1;
}
@ -831,6 +832,7 @@ int net_init_tap(const Netdev *netdev, const char *name,
vhostfdname, vnet_hdr, fd, &err);
if (err) {
error_propagate(errp, err);
close(fd);
return -1;
}
} else if (tap->has_fds) {
@ -951,7 +953,8 @@ free_fail:
script = default_script = get_relocated_path(DEFAULT_NETWORK_SCRIPT);
}
if (!downscript) {
downscript = default_downscript = get_relocated_path(DEFAULT_NETWORK_SCRIPT);
downscript = default_downscript =
get_relocated_path(DEFAULT_NETWORK_DOWN_SCRIPT);
}
if (tap->has_ifname) {