All of lore.kernel.org
 help / color / mirror / Atom feed
From: Samuel Thibault <samuel.thibault@ens-lyon.org>
To: Juergen Gross <jgross@suse.com>
Cc: minios-devel@lists.xenproject.org,
	xen-devel@lists.xenproject.org, wl@xen.org
Subject: Re: [PATCH 1/2] mini-os: netfront: retrieve netmask and gateway via extra function
Date: Tue, 22 Sep 2020 22:08:12 +0200	[thread overview]
Message-ID: <20200922200812.exxxucoxj27pe3ob@function> (raw)
In-Reply-To: <20200922105826.26274-2-jgross@suse.com>

Juergen Gross, le mar. 22 sept. 2020 12:58:25 +0200, a ecrit:
> 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 <jgross@suse.com>

Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org>

> ---
>  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)
>  
>    tprintk("Waiting for network.\n");
>  
> -  dev = init_netfront(NULL, NULL, rawmac, &ip, &netmask_str, &gw_str);
> +  dev = init_netfront(NULL, NULL, rawmac, &ip);
> +  netmask_str = netfront_get_netmask(dev);
> +  gw_str = netfront_get_gateway(dev);
>    
>    if (ip) {
>      ipaddr.addr = 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 {
>  
>      void (*netif_rx)(unsigned char* data, int len, void* arg);
>      void *netif_rx_arg;
> +
> +    struct netfront_dev_list *ldev;
>  };
>  
>  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));
>  
>      if (_init_netfront(dev, ldev->rawmac, &(ldev->ip), &(ldev->mask), &(ldev->gw))) {
> +        dev->ldev = ldev;
>          ldev->dev = dev;
>          ldev->refcount = 1;
>          ldev->next = NULL;
> @@ -376,15 +379,21 @@ out:
>  	}
>      if (ip)
>          *ip = strdup(ldev->ip);
> -    if (mask)
> -        *mask = strdup(ldev->mask);
> -    if (gw)
> -        *gw = strdup(ldev->gw);
>  
>  err:
>      return dev;
>  }
>  
> +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;
>  
> -    dev = init_netfront(nodename, NETIF_SELECT_RX, NULL, NULL, NULL, NULL);
> +    dev = init_netfront(nodename, NETIF_SELECT_RX, NULL, NULL);
>      if (!dev) {
>  	printk("TAP open failed\n");
>  	errno = 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 = __SEMAPHORE_INITIALIZER(net_sem, 0);
>  
>  static void netfront_thread(void *p)
>  {
> -    net_dev = init_netfront(NULL, NULL, NULL, NULL, NULL, NULL);
> +    net_dev = init_netfront(NULL, NULL, NULL, NULL);
>      up(&net_sem);
>  }
>  #endif
> -- 
> 2.26.2
> 

-- 
Samuel
<k> faut en profiter, aujourd'hui, les blagues bidon sont à 100 dollars
 -+- #sos-bourse -+-


  reply	other threads:[~2020-09-22 20:10 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-22 10:58 [PATCH 0/2] mini-os: netfront: fix some issues Juergen Gross
2020-09-22 10:58 ` [PATCH 1/2] mini-os: netfront: retrieve netmask and gateway via extra function Juergen Gross
2020-09-22 20:08   ` Samuel Thibault [this message]
2020-09-22 10:58 ` [PATCH 2/2] mini-os: netfront: fix suspend/resume handling Juergen Gross
2020-09-22 20:08   ` Samuel Thibault
2020-10-01  9:37 ` [PATCH 0/2] mini-os: netfront: fix some issues Wei Liu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200922200812.exxxucoxj27pe3ob@function \
    --to=samuel.thibault@ens-lyon.org \
    --cc=jgross@suse.com \
    --cc=minios-devel@lists.xenproject.org \
    --cc=wl@xen.org \
    --cc=xen-devel@lists.xenproject.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.