From patchwork Tue Nov 24 02:44:19 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Wang X-Patchwork-Id: 1405207 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=E9XVGZee; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4Cg7fw2yYMz9sSs for ; Tue, 24 Nov 2020 13:45:26 +1100 (AEDT) Received: from localhost ([::1]:35696 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1khOKZ-0008Ga-AH for incoming@patchwork.ozlabs.org; Mon, 23 Nov 2020 21:45:23 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:37302) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1khOJn-0008GL-ES for qemu-devel@nongnu.org; Mon, 23 Nov 2020 21:44:36 -0500 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:47699) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1khOJl-00027J-6w for qemu-devel@nongnu.org; Mon, 23 Nov 2020 21:44:34 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1606185872; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:content-type:content-type:in-reply-to:in-reply-to: references:references; bh=MM1KCRtmdZhv/stmi7fLoaBTZ2wgzxNLrP4QiX2B3kE=; b=E9XVGZeeWiuECfTACJax3F0mK3Q4Fclu1toCyxh4re1pcxKGJxT3dTCZwgDFd/vdJfEzyU RsWXk6v3NkWxQEI60tYOA7vfQGsuJ8uoTLPPOLfSGiMM3jin3upBSjux6699WzECCJ8z+t p+aqnCpludQsEdKh1dg+/YQKfnoh7QM= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-436-oYK2-BD_MNuX1qUPMphyHQ-1; Mon, 23 Nov 2020 21:44:29 -0500 X-MC-Unique: oYK2-BD_MNuX1qUPMphyHQ-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id E8C345212; Tue, 24 Nov 2020 02:44:28 +0000 (UTC) Received: from jason-ThinkPad-T430s.redhat.com (ovpn-13-43.pek2.redhat.com [10.72.13.43]) by smtp.corp.redhat.com (Postfix) with ESMTP id 531A75D9CA; Tue, 24 Nov 2020 02:44:27 +0000 (UTC) From: Jason Wang To: peter.maydell@linaro.org, qemu-devel@nongnu.org Subject: [PULL 1/5] hw/net/e1000e: advance desc_offset in case of null descriptor Date: Tue, 24 Nov 2020 10:44:19 +0800 Message-Id: <1606185863-25996-2-git-send-email-jasowang@redhat.com> In-Reply-To: <1606185863-25996-1-git-send-email-jasowang@redhat.com> References: <1606185863-25996-1-git-send-email-jasowang@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=jasowang@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Received-SPF: pass client-ip=63.128.21.124; envelope-from=jasowang@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Jason Wang , Prasad J Pandit Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Prasad J Pandit While receiving packets via e1000e_write_packet_to_guest() routine, 'desc_offset' is advanced only when RX descriptor is processed. And RX descriptor is not processed if it has NULL buffer address. This may lead to an infinite loop condition. Increament 'desc_offset' to process next descriptor in the ring to avoid infinite loop. Reported-by: Cheol-woo Myung <330cjfdn@gmail.com> Signed-off-by: Prasad J Pandit Signed-off-by: Jason Wang --- hw/net/e1000e_core.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/hw/net/e1000e_core.c b/hw/net/e1000e_core.c index d8b9e4b..095c01e 100644 --- a/hw/net/e1000e_core.c +++ b/hw/net/e1000e_core.c @@ -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); From patchwork Tue Nov 24 02:44:20 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Wang X-Patchwork-Id: 1405208 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=C7pe7FYh; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4Cg7fw5FY2z9sT6 for ; Tue, 24 Nov 2020 13:45:28 +1100 (AEDT) Received: from localhost ([::1]:35796 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1khOKc-0008LY-F6 for incoming@patchwork.ozlabs.org; Mon, 23 Nov 2020 21:45:26 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:37332) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1khOJr-0008Hs-5n for qemu-devel@nongnu.org; Mon, 23 Nov 2020 21:44:39 -0500 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:51935) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1khOJp-000281-6n for qemu-devel@nongnu.org; Mon, 23 Nov 2020 21:44:38 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1606185876; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:content-type:content-type:in-reply-to:in-reply-to: references:references; bh=Dj6qND8KUHYnGns/ra46a7m3rapbWc3KQkUtUfQE218=; b=C7pe7FYhzRhlqZi6+utZ1TbCzh7KSJQ3hQeekwDvsAvQ8ANWVG2WjWwixxYYlahO/o2/9g NUekGZZkWvndeEJxf1OJzoFslM2wEOxDNKOPSX4tYeCdwddvCwWFOg4HX+2UP/5py67Snl sJAYsrwCGp/OL+00S1TXin2CZo8/TMU= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-196-h2eeXb1_NhWsx0w0H5i0XA-1; Mon, 23 Nov 2020 21:44:32 -0500 X-MC-Unique: h2eeXb1_NhWsx0w0H5i0XA-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 32DA81007461; Tue, 24 Nov 2020 02:44:31 +0000 (UTC) Received: from jason-ThinkPad-T430s.redhat.com (ovpn-13-43.pek2.redhat.com [10.72.13.43]) by smtp.corp.redhat.com (Postfix) with ESMTP id 735F45D9CA; Tue, 24 Nov 2020 02:44:29 +0000 (UTC) From: Jason Wang To: peter.maydell@linaro.org, qemu-devel@nongnu.org Subject: [PULL 2/5] net: do not exit on "netdev_add help" monitor command Date: Tue, 24 Nov 2020 10:44:20 +0800 Message-Id: <1606185863-25996-3-git-send-email-jasowang@redhat.com> In-Reply-To: <1606185863-25996-1-git-send-email-jasowang@redhat.com> References: <1606185863-25996-1-git-send-email-jasowang@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=jasowang@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Received-SPF: pass client-ip=63.128.21.124; envelope-from=jasowang@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Paolo Bonzini , Jason Wang Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Paolo Bonzini "netdev_add help" is causing QEMU to exit because the code that invokes show_netdevs is shared between CLI and HMP processing. Move the check to the callers so that exit(0) remains only in the CLI flow. "netdev_add help" is not fixed by this patch; that is left for later work. Signed-off-by: Paolo Bonzini Signed-off-by: Jason Wang --- include/net/net.h | 1 + monitor/hmp-cmds.c | 6 +++++ net/net.c | 68 +++++++++++++++++++++++++++--------------------------- 3 files changed, 41 insertions(+), 34 deletions(-) diff --git a/include/net/net.h b/include/net/net.h index 897b2d7..778fc78 100644 --- a/include/net/net.h +++ b/include/net/net.h @@ -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); diff --git a/monitor/hmp-cmds.c b/monitor/hmp-cmds.c index a6a6684..65d8ff4 100644 --- a/monitor/hmp-cmds.c +++ b/monitor/hmp-cmds.c @@ -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; diff --git a/net/net.c b/net/net.c index 794c652..6362d30 100644 --- a/net/net.c +++ b/net/net.c @@ -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" @@ -1025,7 +1026,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 +1056,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 +1069,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"); - - 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"); + /* 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; - } + 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]; + 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"); + /* 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 +1415,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); } From patchwork Tue Nov 24 02:44:21 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Wang X-Patchwork-Id: 1405210 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=CZMI4ivk; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4Cg7jm0ZpFz9sSs for ; Tue, 24 Nov 2020 13:47:56 +1100 (AEDT) Received: from localhost ([::1]:42730 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1khON0-0002rT-32 for incoming@patchwork.ozlabs.org; Mon, 23 Nov 2020 21:47:54 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:37344) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1khOJs-0008I2-KL for qemu-devel@nongnu.org; Mon, 23 Nov 2020 21:44:40 -0500 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:60053) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1khOJp-000286-Qd for qemu-devel@nongnu.org; Mon, 23 Nov 2020 21:44:40 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1606185876; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:content-type:content-type:in-reply-to:in-reply-to: references:references; bh=TqgxUaXyEV8ciQ2FOlVVvP861BSBMhvXtjEUk93f3EM=; b=CZMI4ivkBMHTu6++DhlomBNy2te5NQqTEGVoc2KSG1WSjAhW5CLH7tBZqjtWNpncbCSctr agfPlPxzCnipxNWl8HmdaFPMz4Kmf/01YwAJ6Ff7AmjWqxCWvrZP71JDpC6f/EhO8WEkJg OsGaJWQrhpA4nruL7GApTt7VA6r+Gtw= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-72-ONs6ZSMFONOdxu9Rdj2WoQ-1; Mon, 23 Nov 2020 21:44:34 -0500 X-MC-Unique: ONs6ZSMFONOdxu9Rdj2WoQ-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 5BD73107AFA5; Tue, 24 Nov 2020 02:44:33 +0000 (UTC) Received: from jason-ThinkPad-T430s.redhat.com (ovpn-13-43.pek2.redhat.com [10.72.13.43]) by smtp.corp.redhat.com (Postfix) with ESMTP id B5D4A5D9CA; Tue, 24 Nov 2020 02:44:31 +0000 (UTC) From: Jason Wang To: peter.maydell@linaro.org, qemu-devel@nongnu.org Subject: [PULL 3/5] net: purge queued rx packets on queue deletion Date: Tue, 24 Nov 2020 10:44:21 +0800 Message-Id: <1606185863-25996-4-git-send-email-jasowang@redhat.com> In-Reply-To: <1606185863-25996-1-git-send-email-jasowang@redhat.com> References: <1606185863-25996-1-git-send-email-jasowang@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=jasowang@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Received-SPF: pass client-ip=63.128.21.124; envelope-from=jasowang@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Yuri Benditovich , Jason Wang Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Yuri Benditovich https://bugzilla.redhat.com/show_bug.cgi?id=1829272 When deleting queue pair, purge pending RX packets if any. Example of problematic flow: 1. Bring up q35 VM with tap (vhost off) and virtio-net or e1000e 2. Run ping flood to the VM NIC ( 1 ms interval) 3. Hot unplug the NIC device (device_del) During unplug process one or more packets come, the NIC can't receive, tap disables read_poll 4. Hot plug the device (device_add) with the same netdev The tap stays with read_poll disabled and does not receive any packets anymore (tap_send never triggered) Signed-off-by: Yuri Benditovich Signed-off-by: Jason Wang --- net/net.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/net/net.c b/net/net.c index 6362d30..6a2c3d9 100644 --- a/net/net.c +++ b/net/net.c @@ -412,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); } } From patchwork Tue Nov 24 02:44:22 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Wang X-Patchwork-Id: 1405211 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=hlJU9eLK; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4Cg7mP2LZRz9sSf for ; Tue, 24 Nov 2020 13:50:13 +1100 (AEDT) Received: from localhost ([::1]:47012 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1khOPD-0004dk-Bp for incoming@patchwork.ozlabs.org; Mon, 23 Nov 2020 21:50:11 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:37368) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1khOJw-0008Kb-0K for qemu-devel@nongnu.org; Mon, 23 Nov 2020 21:44:44 -0500 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:54643) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1khOJu-000295-EU for qemu-devel@nongnu.org; Mon, 23 Nov 2020 21:44:43 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1606185881; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:content-type:content-type:in-reply-to:in-reply-to: references:references; bh=pMeXkB1AB/xl4g4gJSc84NMewiDMIKOU1AYZLOAF3V4=; b=hlJU9eLKVnfHvwlQZGesEbhpLXl4uWX+cixS8j0Xib3SCKwetFvtL8dYgaKR2kBy3AyIex hdi7t3czdgmo2P7Zf5ZmKr7NOg3cRbkz1rlH3wBsVQ6NvzuDOth76Oc8oO8fHhp/Hk5EVb f/i6xMnyBDnJUC5zJ9GezC2P+HAtH7Q= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-158-BR_7kRyAOjqxHdSKgdg2tQ-1; Mon, 23 Nov 2020 21:44:37 -0500 X-MC-Unique: BR_7kRyAOjqxHdSKgdg2tQ-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 80674805BE0; Tue, 24 Nov 2020 02:44:35 +0000 (UTC) Received: from jason-ThinkPad-T430s.redhat.com (ovpn-13-43.pek2.redhat.com [10.72.13.43]) by smtp.corp.redhat.com (Postfix) with ESMTP id DFA7B5D9CA; Tue, 24 Nov 2020 02:44:33 +0000 (UTC) From: Jason Wang To: peter.maydell@linaro.org, qemu-devel@nongnu.org Subject: [PULL 4/5] tap: fix a memory leak Date: Tue, 24 Nov 2020 10:44:22 +0800 Message-Id: <1606185863-25996-5-git-send-email-jasowang@redhat.com> In-Reply-To: <1606185863-25996-1-git-send-email-jasowang@redhat.com> References: <1606185863-25996-1-git-send-email-jasowang@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=jasowang@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Received-SPF: pass client-ip=63.128.21.124; envelope-from=jasowang@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: yuanjungong , Jason Wang Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: yuanjungong Close fd before returning. Buglink: https://bugs.launchpad.net/qemu/+bug/1904486 Signed-off-by: yuanjungong Reviewed-by: Peter Maydell Signed-off-by: Jason Wang --- net/tap.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/net/tap.c b/net/tap.c index c46ff66..fe95fa7 100644 --- a/net/tap.c +++ b/net/tap.c @@ -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) { From patchwork Tue Nov 24 02:44:23 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Wang X-Patchwork-Id: 1405209 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=TeJ6o1KJ; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4Cg7jl1zl4z9sSf for ; Tue, 24 Nov 2020 13:47:55 +1100 (AEDT) Received: from localhost ([::1]:42582 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1khOMz-0002o3-81 for incoming@patchwork.ozlabs.org; Mon, 23 Nov 2020 21:47:53 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:37386) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1khOJx-0008NF-Fo for qemu-devel@nongnu.org; Mon, 23 Nov 2020 21:44:45 -0500 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:41435) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1khOJv-00029V-S6 for qemu-devel@nongnu.org; Mon, 23 Nov 2020 21:44:45 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1606185883; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:content-type:content-type:in-reply-to:in-reply-to: references:references; bh=ABx0p2qmAGxG+XfxGy7HrResy/wTlAIDE6SIuSRFQPY=; b=TeJ6o1KJhsTng1YUUqbT9uqNr1/B9vQhuUwFKIWfQp6LL1BBi9IIEkik3lgfdefNyOxLSu 0w0pycLK6Tj+LmEi5INCnaMBxD8ty3yI8GCM7KcATzxuGEHjSvZVvNO09c7bdhY2va1PWb brWKcW/z1/AAe9EZK21WfwmxXG434aE= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-568-791gNTF_NCugf9wUyYmy0w-1; Mon, 23 Nov 2020 21:44:38 -0500 X-MC-Unique: 791gNTF_NCugf9wUyYmy0w-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 9F46B8049CF; Tue, 24 Nov 2020 02:44:37 +0000 (UTC) Received: from jason-ThinkPad-T430s.redhat.com (ovpn-13-43.pek2.redhat.com [10.72.13.43]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0AF285D9CC; Tue, 24 Nov 2020 02:44:35 +0000 (UTC) From: Jason Wang To: peter.maydell@linaro.org, qemu-devel@nongnu.org Subject: [PULL 5/5] net: Use correct default-path macro for downscript Date: Tue, 24 Nov 2020 10:44:23 +0800 Message-Id: <1606185863-25996-6-git-send-email-jasowang@redhat.com> In-Reply-To: <1606185863-25996-1-git-send-email-jasowang@redhat.com> References: <1606185863-25996-1-git-send-email-jasowang@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=jasowang@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Received-SPF: pass client-ip=63.128.21.124; envelope-from=jasowang@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Jason Wang , Keqian Zhu Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Keqian Zhu Fixes: 63c4db4c2e6d (net: relocate paths to helpers and scripts) Signed-off-by: Keqian Zhu Signed-off-by: Jason Wang --- net/tap.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/net/tap.c b/net/tap.c index fe95fa7..b751285 100644 --- a/net/tap.c +++ b/net/tap.c @@ -953,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) {