grub-devel
[Top][All Lists]
Advanced

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

Re: [PATCH v2 4/9] net: dhcp: make grub_net_process_dhcp take an interfa


From: Daniel Kiper
Subject: Re: [PATCH v2 4/9] net: dhcp: make grub_net_process_dhcp take an interface
Date: Thu, 21 Feb 2019 19:21:19 +0100
User-agent: NeoMutt/20170113 (1.7.2)

On Tue, Feb 12, 2019 at 05:46:55PM +0000, Andre Przywara wrote:
> From: Andrei Borzenkov <address@hidden>
>
> Change the interface of the function dealing with incoming BOOTP packets
> to take an interface instead of a card, to allow more fine per-interface
> state (timeout, handshake state) later on.
>
> Signed-off-by: Andre Przywara <address@hidden>

In general Reviewed-by: Daniel Kiper <address@hidden>

However, please add a blurb to the commit message that you are also
cleaning up the code a bit...

> ---
>  grub-core/net/bootp.c | 29 ++++++++++++++++-------------
>  grub-core/net/ip.c    |  2 +-
>  include/grub/net.h    |  2 +-
>  3 files changed, 18 insertions(+), 15 deletions(-)
>
> diff --git a/grub-core/net/bootp.c b/grub-core/net/bootp.c
> index fd56de907..573398aa4 100644
> --- a/grub-core/net/bootp.c
> +++ b/grub-core/net/bootp.c
> @@ -396,12 +396,19 @@ out:
>    return err;
>  }
>
> +/*
> + * This is called directly from net/ip.c:handle_dgram(), because those
> + * BOOTP/DHCP packets are a bit special due to their improper
> + * sender/receiver IP fields.
> + */
>  void
>  grub_net_process_dhcp (struct grub_net_buff *nb,
> -                    struct grub_net_card *card)
> +                    struct grub_net_network_level_interface *iface)
>  {
>    char *name;
> -  struct grub_net_network_level_interface *inf;
> +  struct grub_net_card *card = iface->card;
> +  const struct grub_net_bootp_packet *bp = (const struct 
> grub_net_bootp_packet *) nb->data;
> +  grub_size_t size = nb->tail - nb->data;
>
>    name = grub_xasprintf ("%s:dhcp", card->name);
>    if (!name)
> @@ -409,22 +416,18 @@ grub_net_process_dhcp (struct grub_net_buff *nb,
>        grub_print_error ();
>        return;
>      }
> -  grub_net_configure_by_dhcp_ack (name, card,
> -                               0, (const struct grub_net_bootp_packet *) 
> nb->data,
> -                               (nb->tail - nb->data), 0, 0, 0);
> +  grub_net_configure_by_dhcp_ack (name, card, 0, bp, size, 0, 0, 0);
>    grub_free (name);
>    if (grub_errno)
>      grub_print_error ();
>    else
>      {
> -      FOR_NET_NETWORK_LEVEL_INTERFACES(inf)
> -     if (grub_memcmp (inf->name, card->name, grub_strlen (card->name)) == 0
> -         && grub_memcmp (inf->name + grub_strlen (card->name),
> -                         ":dhcp_tmp", sizeof (":dhcp_tmp") - 1) == 0)
> -       {
> -         grub_net_network_level_interface_unregister (inf);
> -         break;
> -       }
> +      if (grub_memcmp (iface->name, card->name, grub_strlen (card->name)) == > 0
> +       && grub_memcmp (iface->name + grub_strlen (card->name),
> +                       ":dhcp_tmp", sizeof (":dhcp_tmp") - 1) == 0)
> +     {
> +       grub_net_network_level_interface_unregister (iface);
> +     }
>      }

And I think that you can drop four curly braces here.

Daniel



reply via email to

[Prev in Thread] Current Thread [Next in Thread]