|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [PATCH v2] mini-os: netfront: Fix parsing of IP value provided by Xenstore
Costin Lupu, le ven. 04 sept. 2020 13:40:23 +0300, a ecrit:
> This patch fixes the following issues:
> - commit 1b8ed31f introduced support for reading netmask and gateway values
> from Xenstore. However it did not take care of the initial scenario when
> these values are not provided.
> - gateway is not set when passing mask=NULL to _init_netfront()
> - mini-os crashes when IP is not provided at all in the xl config file.
>
> The current implementation supports only dot-decimal representations of IP,
> netmask and gateway.
>
> Reported-by: Jan Beulich <jbeulich@xxxxxxxx>
> Signed-off-by: Costin Lupu <costin.lupu@xxxxxxxxx>
Reviewed-by: Samuel Thibault <samuel.thibault@xxxxxxxxxxxx>
> ---
> netfront.c | 24 ++++++++++++------------
> 1 file changed, 12 insertions(+), 12 deletions(-)
>
> diff --git a/netfront.c b/netfront.c
> index 205484b..d066bd9 100644
> --- a/netfront.c
> +++ b/netfront.c
> @@ -375,11 +375,11 @@ out:
> rawmac[5] = ldev->rawmac[5];
> }
> if (ip)
> - *ip = strdup(ldev->ip);
> + *ip = ldev->ip ? strdup(ldev->ip) : NULL;
> if (mask)
> - *mask = strdup(ldev->mask);
> + *mask = ldev->mask ? strdup(ldev->mask) : NULL;
> if (gw)
> - *gw = strdup(ldev->gw);
> + *gw = ldev->gw ? strdup(ldev->gw) : NULL;
>
> err:
> return dev;
> @@ -524,23 +524,23 @@ done:
> }
>
> if (ip) {
> - char *p;
> -
> snprintf(path, sizeof(path), "%s/ip", dev->backend);
> xenbus_read(XBT_NIL, path, ip);
>
> - if (mask) {
> + if (*ip) {
> + char *p;
> +
> p = strchr(*ip, ' ');
> if (p) {
> *p++ = '\0';
> - *mask = p;
> + if (mask)
> + *mask = p;
>
> - if (gw) {
> - p = strchr(p, ' ');
> - if (p) {
> - *p++ = '\0';
> + p = strchr(p, ' ');
> + if (p) {
> + *p++ = '\0';
> + if (gw)
> *gw = p;
> - }
> }
> }
> }
> --
> 2.20.1
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |