From nobody Sat Sep 21 01:05:40 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=none dis=none) header.from=suse.com ARC-Seal: i=1; a=rsa-sha256; t=1600772336; cv=none; d=zohomail.com; s=zohoarc; b=MNItdnTPfUUDw+FDX9FWJI5hAi9l7N2UUiq9rAsu0JkDeNO/Sj+BWYWsfY2JIxS4W+kGXDk6a5yXHnR0v9f84xENoVEFFt1Nu7UhjRMDYb8QggYkrHL7uIVhMHHC9LYjUlhMSh9nK2o6FHNDkhl2ByN6sFcGsvyuRyp/izDtlT8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1600772336; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=gvV/6AUBRn3iyr7G7MIQr6c1JY593oPOEHum75Oq12E=; b=jediGwR2/ePwotgcQkedueYDGadS1S++6QHa7ZxyJt3Ba5etcGUWlmwwyQ+XoEvARZQVFZudQ3F0hV/1XjhcDvd/+gF0zViN79uX8L/d7L/8dVYaRUVhcTQNbGSMCn/t1Nb6UefKsOaE+Uf5JmfMFZlzG+n/sB8VaUVE0K0RRBs= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1600772336647163.2050232895847; Tue, 22 Sep 2020 03:58:56 -0700 (PDT) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1kKg0M-0002fW-4r; Tue, 22 Sep 2020 10:58:38 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1kKg0K-0002eH-Gn for xen-devel@lists.xenproject.org; Tue, 22 Sep 2020 10:58:36 +0000 Received: from mx2.suse.de (unknown [195.135.220.15]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id a67fb3fc-4d5f-4935-b168-97b0d23d49c5; Tue, 22 Sep 2020 10:58:29 +0000 (UTC) Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 813F0AE09; Tue, 22 Sep 2020 10:59:05 +0000 (UTC) X-Inumbo-ID: a67fb3fc-4d5f-4935-b168-97b0d23d49c5 X-Virus-Scanned: by amavisd-new at test-mx.suse.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1600772308; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=gvV/6AUBRn3iyr7G7MIQr6c1JY593oPOEHum75Oq12E=; b=fPqa7Nk/C5Rdqdxq00C3hckZjNbLUH41347bJRZu1nmecYQjdOqYr5X05x1ajHVG++9udt WOqN9IJj4cuV1Snbcilg1G2FaA76ZCs4zn+KRVYpebDk5qIgSouYNeSiSoUJJ9p2UPxhRG yIGzlQTIpTdY6H8XM9jotsgB8W0mt9s= From: Juergen Gross To: minios-devel@lists.xenproject.org, xen-devel@lists.xenproject.org Cc: samuel.thibault@ens-lyon.org, wl@xen.org, Juergen Gross Subject: [PATCH 1/2] mini-os: netfront: retrieve netmask and gateway via extra function Date: Tue, 22 Sep 2020 12:58:25 +0200 Message-Id: <20200922105826.26274-2-jgross@suse.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200922105826.26274-1-jgross@suse.com> References: <20200922105826.26274-1-jgross@suse.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" X-ZohoMail-DKIM: pass (identity @suse.com) Content-Type: text/plain; charset="utf-8" Commit 1b8ed31f4ce40 ("mini-os: netfront: Read netmask and gateway from Xenstore") modified init_netfront() to take two additional parameters. This broke the Xen build as init_netfront() is used in grub stubdom, too. So instead of tightly coupling Mini-OS and Xen build via this interface modification undo this change of init_netfront() and add two other functions for retrieving the netmask and gateway for a network device. Signed-off-by: Juergen Gross Reviewed-by: Samuel Thibault --- include/netfront.h | 4 +++- lwip-net.c | 4 +++- netfront.c | 21 +++++++++++++++------ test.c | 2 +- 4 files changed, 22 insertions(+), 9 deletions(-) diff --git a/include/netfront.h b/include/netfront.h index bc3080e..ec641c8 100644 --- a/include/netfront.h +++ b/include/netfront.h @@ -7,7 +7,9 @@ struct netfront_dev *init_netfront(char *nodename, void (*netif_rx)(unsigned char *data, int len, void* arg), unsigned char rawmac[6], - char **ip, char **mask, char **gw); + char **ip); +char *netfront_get_netmask(struct netfront_dev *dev); +char *netfront_get_gateway(struct netfront_dev *dev); void netfront_xmit(struct netfront_dev *dev, unsigned char* data,int len); void shutdown_netfront(struct netfront_dev *dev); void suspend_netfront(void); diff --git a/lwip-net.c b/lwip-net.c index 80d1c8f..7e0d871 100644 --- a/lwip-net.c +++ b/lwip-net.c @@ -347,7 +347,9 @@ void start_networking(void) =20 tprintk("Waiting for network.\n"); =20 - dev =3D init_netfront(NULL, NULL, rawmac, &ip, &netmask_str, &gw_str); + dev =3D init_netfront(NULL, NULL, rawmac, &ip); + netmask_str =3D netfront_get_netmask(dev); + gw_str =3D netfront_get_gateway(dev); =20 if (ip) { ipaddr.addr =3D inet_addr(ip); diff --git a/netfront.c b/netfront.c index 205484b..9057908 100644 --- a/netfront.c +++ b/netfront.c @@ -65,6 +65,8 @@ struct netfront_dev { =20 void (*netif_rx)(unsigned char* data, int len, void* arg); void *netif_rx_arg; + + struct netfront_dev_list *ldev; }; =20 struct netfront_dev_list { @@ -303,7 +305,7 @@ struct netfront_dev *init_netfront(char *_nodename, void (*thenetif_rx)(unsigned char* data, int len, void* arg), unsigned char rawmac[6], - char **ip, char **mask, char **gw) + char **ip) { char nodename[256]; struct netfront_dev *dev; @@ -347,6 +349,7 @@ struct netfront_dev *init_netfront(char *_nodename, memset(ldev, 0, sizeof(struct netfront_dev_list)); =20 if (_init_netfront(dev, ldev->rawmac, &(ldev->ip), &(ldev->mask), &(ld= ev->gw))) { + dev->ldev =3D ldev; ldev->dev =3D dev; ldev->refcount =3D 1; ldev->next =3D NULL; @@ -376,15 +379,21 @@ out: } if (ip) *ip =3D strdup(ldev->ip); - if (mask) - *mask =3D strdup(ldev->mask); - if (gw) - *gw =3D strdup(ldev->gw); =20 err: return dev; } =20 +char *netfront_get_netmask(struct netfront_dev *dev) +{ + return dev->ldev->mask ? strdup(dev->ldev->mask) : NULL; +} + +char *netfront_get_gateway(struct netfront_dev *dev) +{ + return dev->ldev->gw ? strdup(dev->ldev->gw) : NULL; +} + static struct netfront_dev *_init_netfront(struct netfront_dev *dev, unsigned char rawmac[6], char **ip, char **mask, char **gw) @@ -576,7 +585,7 @@ error: int netfront_tap_open(char *nodename) { struct netfront_dev *dev; =20 - dev =3D init_netfront(nodename, NETIF_SELECT_RX, NULL, NULL, NULL, NUL= L); + dev =3D init_netfront(nodename, NETIF_SELECT_RX, NULL, NULL); if (!dev) { printk("TAP open failed\n"); errno =3D EIO; diff --git a/test.c b/test.c index 2e5f7f9..42a2666 100644 --- a/test.c +++ b/test.c @@ -91,7 +91,7 @@ static struct semaphore net_sem =3D __SEMAPHORE_INITIALIZ= ER(net_sem, 0); =20 static void netfront_thread(void *p) { - net_dev =3D init_netfront(NULL, NULL, NULL, NULL, NULL, NULL); + net_dev =3D init_netfront(NULL, NULL, NULL, NULL); up(&net_sem); } #endif --=20 2.26.2 From nobody Sat Sep 21 01:05:40 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=none dis=none) header.from=suse.com ARC-Seal: i=1; a=rsa-sha256; t=1600772344; cv=none; d=zohomail.com; s=zohoarc; b=aeLRW+MCJlE00u6NLqFnxD/NArq/AwW9mG5F/bRWaKF32DwhcHWXEZcatY30uYeD1Qlv2HBPnd6gO7JWTabAzMvMI0Rftut3GSjkhR0aI8qBJjDjBK6/+qCof5vH6FvBrR06kEyM0rO+Puc087Wu3w9/5Ro/64Hp+ZZ1sVXsq/I= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1600772344; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=YmJEzG7WE6ySO04WKdM+x0q6b5S1uIVl7WRmYPejCdQ=; b=ViqYJFZ+ij7BTyBGeksZXIRBljpMZMyv0t96mLxSfLvWbwO6G32ZMD9TgrvxVD+xbSnscs6OXp6w63npkLdshRrPZuVCHfo6KgAiB+0ZckNUN0vJyrDEM9+UZWFzKxlUhNvxDIR2VjMVDrVtpNsIN2GyEc2zsAczQcQl+AX1UzY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1600772344568655.3797097834572; Tue, 22 Sep 2020 03:59:04 -0700 (PDT) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1kKg0V-0002j1-GQ; Tue, 22 Sep 2020 10:58:47 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1kKg0U-0002eH-HD for xen-devel@lists.xenproject.org; Tue, 22 Sep 2020 10:58:46 +0000 Received: from mx2.suse.de (unknown [195.135.220.15]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 76342151-97be-4589-ba7d-37626c0cc51e; Tue, 22 Sep 2020 10:58:29 +0000 (UTC) Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id A82E4B22E; Tue, 22 Sep 2020 10:59:05 +0000 (UTC) X-Inumbo-ID: 76342151-97be-4589-ba7d-37626c0cc51e X-Virus-Scanned: by amavisd-new at test-mx.suse.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1600772309; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=YmJEzG7WE6ySO04WKdM+x0q6b5S1uIVl7WRmYPejCdQ=; b=dKVaG9CnFcHwH5IIYZ4o+wPNPBlTRMa9xHVMaOqg/5YJMT9GBrjcbQjBgdwgOBEujNikM1 RB7G/jp9PAp7vTBkuo/Y5yxgLEOM+IiKJBnaeuvCVQNqLFZaAsR1xhqFpAEFcAjgO8Bp8F 31Xz+Nzqd0t/qisYDRJSl584T7qLtMY= From: Juergen Gross To: minios-devel@lists.xenproject.org, xen-devel@lists.xenproject.org Cc: samuel.thibault@ens-lyon.org, wl@xen.org, Juergen Gross Subject: [PATCH 2/2] mini-os: netfront: fix suspend/resume handling Date: Tue, 22 Sep 2020 12:58:26 +0200 Message-Id: <20200922105826.26274-3-jgross@suse.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200922105826.26274-1-jgross@suse.com> References: <20200922105826.26274-1-jgross@suse.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" X-ZohoMail-DKIM: pass (identity @suse.com) Content-Type: text/plain; charset="utf-8" Suspend/resume handling of netfront is completely broken from the beginning. Commit d225f4012d69a1 ("Save/Restore Support: Add suspend/restore support for netfront") introduced a new structure netfront_dev_list referencing the real struct netfront_dev elements. This list is used to setup the devices when resuming again. Unfortunately the netfront_dev elements are released during suspend, so at resume time those references will be stale. Fix this whole mess by dropping struct netfront_dev_list again and link the netfront_dev elements directly into a list. When suspending don't free those elements. The ip-address, netmask and gateway strings can just be released when suspending and reread from xenstore at resume time. Fixes: d225f4012d69a1 ("Save/Restore Support: Add suspend/restore support f= or netfront") Signed-off-by: Juergen Gross Reviewed-by: Samuel Thibault --- netfront.c | 162 ++++++++++++++++++++++------------------------------- 1 file changed, 67 insertions(+), 95 deletions(-) diff --git a/netfront.c b/netfront.c index 9057908..2075410 100644 --- a/netfront.c +++ b/netfront.c @@ -36,6 +36,8 @@ struct net_buffer { }; =20 struct netfront_dev { + int refcount; + domid_t dom; =20 unsigned short tx_freelist[NET_TX_RING_SIZE + 1]; @@ -66,27 +68,19 @@ struct netfront_dev { void (*netif_rx)(unsigned char* data, int len, void* arg); void *netif_rx_arg; =20 - struct netfront_dev_list *ldev; -}; - -struct netfront_dev_list { - struct netfront_dev *dev; unsigned char rawmac[6]; char *ip; char *mask; char *gw; =20 - int refcount; - - struct netfront_dev_list *next; + struct netfront_dev *next; }; =20 -static struct netfront_dev_list *dev_list =3D NULL; +static struct netfront_dev *dev_list =3D NULL; =20 void init_rx_buffers(struct netfront_dev *dev); -static struct netfront_dev *_init_netfront(struct netfront_dev *dev, - unsigned char rawmac[6], char *= *ip, char **mask, char **gw); -static void _shutdown_netfront(struct netfront_dev *dev); +static struct netfront_dev *_init_netfront(struct netfront_dev *dev); +static int _shutdown_netfront(struct netfront_dev *dev); void netfront_set_rx_handler(struct netfront_dev *dev, void (*thenetif_rx)(unsigned char *data, int = len, void *arg), @@ -276,6 +270,7 @@ static void free_netfront(struct netfront_dev *dev) mask_evtchn(dev->evtchn); =20 free(dev->mac); + free(dev->ip); free(dev->backend); =20 gnttab_end_access(dev->rx_ring_ref); @@ -309,8 +304,7 @@ struct netfront_dev *init_netfront(char *_nodename, { char nodename[256]; struct netfront_dev *dev; - struct netfront_dev_list *ldev =3D NULL; - struct netfront_dev_list *list =3D NULL; + struct netfront_dev *list; static int netfrontends =3D 0; =20 if (!_nodename) @@ -321,10 +315,9 @@ struct netfront_dev *init_netfront(char *_nodename, } =20 /* Check if the device is already initialized */ - for (list =3D dev_list; list !=3D NULL; list =3D list->next) { - if (strcmp(nodename, list->dev->nodename) =3D=3D 0) { - list->refcount++; - dev =3D list->dev; + for (dev =3D dev_list; dev !=3D NULL; dev =3D dev->next) { + if (strcmp(nodename, dev->nodename) =3D=3D 0) { + dev->refcount++; if (thenetif_rx) netfront_set_rx_handler(dev, thenetif_rx, NULL); goto out; @@ -345,40 +338,34 @@ struct netfront_dev *init_netfront(char *_nodename, dev->netif_rx =3D thenetif_rx; dev->netif_rx_arg =3D NULL; =20 - ldev =3D malloc(sizeof(struct netfront_dev_list)); - memset(ldev, 0, sizeof(struct netfront_dev_list)); - - if (_init_netfront(dev, ldev->rawmac, &(ldev->ip), &(ldev->mask), &(ld= ev->gw))) { - dev->ldev =3D ldev; - ldev->dev =3D dev; - ldev->refcount =3D 1; - ldev->next =3D NULL; + if (_init_netfront(dev)) { + dev->refcount =3D 1; + dev->next =3D NULL; =20 if (!dev_list) { - dev_list =3D ldev; + dev_list =3D dev; } else { for (list =3D dev_list; list->next !=3D NULL; list =3D list->n= ext) ; - list->next =3D ldev; - } + list->next =3D dev; + } netfrontends++; } else { - free(ldev); dev =3D NULL; goto err; } =20 out: if (rawmac) { - rawmac[0] =3D ldev->rawmac[0]; - rawmac[1] =3D ldev->rawmac[1]; - rawmac[2] =3D ldev->rawmac[2]; - rawmac[3] =3D ldev->rawmac[3]; - rawmac[4] =3D ldev->rawmac[4]; - rawmac[5] =3D ldev->rawmac[5]; + rawmac[0] =3D dev->rawmac[0]; + rawmac[1] =3D dev->rawmac[1]; + rawmac[2] =3D dev->rawmac[2]; + rawmac[3] =3D dev->rawmac[3]; + rawmac[4] =3D dev->rawmac[4]; + rawmac[5] =3D dev->rawmac[5]; } if (ip) - *ip =3D strdup(ldev->ip); + *ip =3D strdup(dev->ip); =20 err: return dev; @@ -386,17 +373,15 @@ err: =20 char *netfront_get_netmask(struct netfront_dev *dev) { - return dev->ldev->mask ? strdup(dev->ldev->mask) : NULL; + return dev->mask ? strdup(dev->mask) : NULL; } =20 char *netfront_get_gateway(struct netfront_dev *dev) { - return dev->ldev->gw ? strdup(dev->ldev->gw) : NULL; + return dev->gw ? strdup(dev->gw) : NULL; } =20 -static struct netfront_dev *_init_netfront(struct netfront_dev *dev, - unsigned char rawmac[6], - char **ip, char **mask, char **gw) +static struct netfront_dev *_init_netfront(struct netfront_dev *dev) { xenbus_transaction_t xbt; char* err =3D NULL; @@ -518,6 +503,8 @@ done: { XenbusState state; char path[strlen(dev->backend) + strlen("/state") + 1]; + char *p; + snprintf(path, sizeof(path), "%s/state", dev->backend); =20 xenbus_watch_path_token(XBT_NIL, path, path, &dev->events); @@ -532,26 +519,18 @@ done: goto error; } =20 - if (ip) { - char *p; - - snprintf(path, sizeof(path), "%s/ip", dev->backend); - xenbus_read(XBT_NIL, path, ip); - - if (mask) { - p =3D strchr(*ip, ' '); - if (p) { - *p++ =3D '\0'; - *mask =3D p; - - if (gw) { - p =3D strchr(p, ' '); - if (p) { - *p++ =3D '\0'; - *gw =3D p; - } - } - } + snprintf(path, sizeof(path), "%s/ip", dev->backend); + xenbus_read(XBT_NIL, path, &dev->ip); + + p =3D strchr(dev->ip, ' '); + if (p) { + *p++ =3D '\0'; + dev->mask =3D p; + + p =3D strchr(p, ' '); + if (p) { + *p++ =3D '\0'; + dev->gw =3D p; } } } @@ -563,14 +542,13 @@ done: /* Special conversion specifier 'hh' needed for __ia64__. Without * this mini-os panics with 'Unaligned reference'. */ - if (rawmac) - sscanf(dev->mac,"%hhx:%hhx:%hhx:%hhx:%hhx:%hhx", - &rawmac[0], - &rawmac[1], - &rawmac[2], - &rawmac[3], - &rawmac[4], - &rawmac[5]); + sscanf(dev->mac,"%hhx:%hhx:%hhx:%hhx:%hhx:%hhx", + &dev->rawmac[0], + &dev->rawmac[1], + &dev->rawmac[2], + &dev->rawmac[3], + &dev->rawmac[4], + &dev->rawmac[5]); =20 return dev; =20 @@ -600,38 +578,33 @@ int netfront_tap_open(char *nodename) { =20 void shutdown_netfront(struct netfront_dev *dev) { - struct netfront_dev_list *list =3D NULL; - struct netfront_dev_list *to_del =3D NULL; + struct netfront_dev *list; =20 /* Check this is a valid device */ - for (list =3D dev_list; list !=3D NULL; list =3D list->next) { - if (list->dev =3D=3D dev) - break; - } + for (list =3D dev_list; list !=3D NULL && list !=3D dev; list =3D list= ->next); =20 if (!list) { printk("Trying to shutdown an invalid netfront device (%p)\n", dev= ); return; } =20 - list->refcount--; - if (list->refcount =3D=3D 0) { - _shutdown_netfront(dev); + dev->refcount--; + if (dev->refcount =3D=3D 0) { + if (_shutdown_netfront(dev)) + return; =20 - to_del =3D list; - if (to_del =3D=3D dev_list) { - free(to_del); - dev_list =3D NULL; + if (dev =3D=3D dev_list) { + dev_list =3D NULL; } else { - for (list =3D dev_list; list->next !=3D to_del; list =3D list-= >next) + for (list =3D dev_list; list->next !=3D dev; list =3D list->ne= xt) ; - list->next =3D to_del->next; - free(to_del); + list->next =3D dev->next; } + free_netfront(dev); } } =20 -static void _shutdown_netfront(struct netfront_dev *dev) +static int _shutdown_netfront(struct netfront_dev *dev) { char* err =3D NULL, *err2; XenbusState state; @@ -692,24 +665,23 @@ close: err2 =3D xenbus_rm(XBT_NIL, nodename); free(err2); =20 - if (!err) - free_netfront(dev); + return err ? -EBUSY : 0; } =20 void suspend_netfront(void) { - struct netfront_dev_list *list; + struct netfront_dev *dev; =20 - for (list =3D dev_list; list !=3D NULL; list =3D list->next) - _shutdown_netfront(list->dev); + for (dev =3D dev_list; dev !=3D NULL; dev =3D dev->next) + _shutdown_netfront(dev); } =20 void resume_netfront(void) { - struct netfront_dev_list *list; + struct netfront_dev *dev; =20 - for (list =3D dev_list; list !=3D NULL; list =3D list->next) - _init_netfront(list->dev, NULL, NULL, NULL, NULL); + for (dev =3D dev_list; dev !=3D NULL; dev =3D dev->next) + _init_netfront(dev); } =20 void init_rx_buffers(struct netfront_dev *dev) --=20 2.26.2