[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[mini-os master] mini-os: netfront: Handle init failure when no vifs are provided



commit cc8b330e5729312a0632fd0e9f28e8f136a76182
Author:     Costin Lupu <costin.lupu@xxxxxxxxx>
AuthorDate: Tue Dec 15 16:50:12 2020 +0000
Commit:     Wei Liu <wl@xxxxxxx>
CommitDate: Tue Dec 15 16:52:00 2020 +0000

    mini-os: netfront: Handle init failure when no vifs are provided
    
    These changes deal with the case when no vifs are created. This can happen 
when
    no vif is provided in the config file for mini-os images with netfront 
support.
    
    Signed-off-by: Costin Lupu <costin.lupu@xxxxxxxxx>
    Reviewed-by: Samuel Thibault <samuel.thibault@@ens-lyon.org>
---
 lwip-net.c | 4 ++++
 netfront.c | 9 +++++++--
 2 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/lwip-net.c b/lwip-net.c
index 7e0d871..16950d3 100644
--- a/lwip-net.c
+++ b/lwip-net.c
@@ -348,6 +348,10 @@ void start_networking(void)
   tprintk("Waiting for network.\n");
 
   dev = init_netfront(NULL, NULL, rawmac, &ip);
+  if (!dev) {
+      tprintk("Error initializing netfront.\n");
+      return;
+  }
   netmask_str = netfront_get_netmask(dev);
   gw_str = netfront_get_gateway(dev);
   
diff --git a/netfront.c b/netfront.c
index 2075410..f927e99 100644
--- a/netfront.c
+++ b/netfront.c
@@ -383,6 +383,7 @@ char *netfront_get_gateway(struct netfront_dev *dev)
 
 static struct netfront_dev *_init_netfront(struct netfront_dev *dev)
 {
+    int domid;
     xenbus_transaction_t xbt;
     char* err = NULL;
     char* message=NULL;
@@ -393,6 +394,12 @@ static struct netfront_dev *_init_netfront(struct 
netfront_dev *dev)
     int i;
     char path[256];
 
+    snprintf(path, sizeof(path), "%s/backend-id", dev->nodename);
+    domid = xenbus_read_integer(path);
+    if (domid < 0)
+        return NULL;
+    dev->dom = domid;
+
     printk("net TX ring size %lu\n", (unsigned long) NET_TX_RING_SIZE);
     printk("net RX ring size %lu\n", (unsigned long) NET_RX_RING_SIZE);
     init_SEMAPHORE(&dev->tx_sem, NET_TX_RING_SIZE);
@@ -407,8 +414,6 @@ static struct netfront_dev *_init_netfront(struct 
netfront_dev *dev)
         BUG_ON(dev->rx_buffers[i].page == NULL);
     }
 
-    snprintf(path, sizeof(path), "%s/backend-id", dev->nodename);
-    dev->dom = xenbus_read_integer(path);
 #ifdef HAVE_LIBC
     if (dev->netif_rx == NETIF_SELECT_RX)
         evtchn_alloc_unbound(dev->dom, netfront_select_handler, dev, 
&dev->evtchn);
--
generated by git-patchbot for /home/xen/git/mini-os.git#master



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.