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

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



Hi,

Please ignore this version, I've just sent a better one.

Cheers,
Costin

On 11/28/20 2:38 PM, Costin Lupu wrote:
> 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>
> ---
>  lwip-net.c | 4 ++++
>  netfront.c | 7 +++++--
>  2 files changed, 9 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..a4e4eaa 100644
> --- a/netfront.c
> +++ b/netfront.c
> @@ -393,6 +393,11 @@ static struct netfront_dev *_init_netfront(struct 
> netfront_dev *dev)
>      int i;
>      char path[256];
>  
> +    snprintf(path, sizeof(path), "%s/backend-id", dev->nodename);
> +    dev->dom = xenbus_read_integer(path);
> +    if (dev->dom < 0)
> +        return NULL;
> +
>      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 +412,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);
> 



 


Rackspace

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