From: Andrei Borzenkov <arvidjaar@gmail.com>
To: Michael Chang <mchang@suse.com>
Cc: grub-devel@gnu.org
Subject: Re: [PATCH 1/3] Added net_bootp6 command
Date: Sat, 30 May 2015 10:25:15 +0300 [thread overview]
Message-ID: <20150530102515.5cc45d91@opensuse.site> (raw)
In-Reply-To: <20150519084200.GB2363@linux-dsax.tai.apac.novell.com>
В Tue, 19 May 2015 16:42:00 +0800
Michael Chang <mchang@suse.com> пишет:
> >
> > > +#define GRUB_DHCPv6_OPTION_CLIENTID 1
> > > +#define GRUB_DHCPv6_OPTION_SERVERID 2
> > > +#define GRUB_DHCPv6_OPTION_IA_NA 3
> > > +#define GRUB_DHCPv6_OPTION_IAADDR 5
> > > +#define GRUB_DHCPv6_OPTION_ORO 6
> > > +#define GRUB_DHCPv6_OPTION_ELAPSED_TIME 8
> > > +#define GRUB_DHCPv6_OPTION_DNS_SERVERS 23
> > > +#define GRUB_DHCPv6_OPTION_BOOTFILE_URL 59
> > > +
> >
> > enum please. These can also be anonymous, no need to invent fancy
> > names.
>
> I don't understand. Do you want me to use enum type here rather than
> macro ? Where are the fancy names invented here ?
Sorry I mean there is no need to name enume type. Just
enum
{
GRUB_DHCPv6_OPTION_CLIENTID = 1
...
};
> > > +static void
> > > +get_dhcpv6_dns_address (const struct grub_net_dhcpv6_packet *packet, grub_size_t size,
> > > + grub_net_network_level_address_t **addr, grub_uint16_t *naddr)
> > > +{
> > > + const struct grub_dhcpv6_option* popt;
> > > + grub_uint16_t len, ln;
> > > + const grub_uint8_t *pa;
> > > + grub_net_network_level_address_t *la;
> > > +
> > > + if (!addr || !naddr)
> > > + {
> > > + grub_error (GRUB_ERR_BAD_ARGUMENT, N_("bad argument for get_dhcpv6_dns_address"));
> > > + return;
> > > + }
> > > +
> >
> > it is called exactly once and grub_errno is immediately reset to
> > GRUB_ERR_NONE. So what's the point of returning error at all?
>
> Because a function wants to report error for bad inputs, while it's
> caller wants to suppress the error message because dns information could
> be missing in packets and is allowed (not treated as error).
>
Sure but it is called exactly once and result is not used. It is not
like this is library function, it is more of a convenience macro. For
the same reasons NULL check on input is probably redundant as well.
> >
> > > + if (len == 0 || len & 0xf)
> > > + {
> > > + grub_error (GRUB_ERR_IO, N_("invalid dns address length"));
> > > + return;
> > > + }
> > > +
> >
> > same question about grub_error. May be grub_debug?
>
> No grub_debug, maybe grub_dprintf ? Maybe we should keep it and use
> specific error number for option not found ? See below for details.
>
Sure, I mean dprintf, sorry.
> > > +
> > > + /* Follow elilo and edk2 that check for starting and ending delimiter '[..]'
> > > + in which IPv6 server address is enclosed. */
> > > + if (*ip_start != '[')
> > > + ip_start = NULL;
> > > + else
> > > + ip_end = grub_strchr (++ip_start, ']');
> > > +
> > > + if (!ip_start || !ip_end)
> > > + {
> > > + grub_error (GRUB_ERR_IO, N_("IPv6-address not in square brackets"));
> > > + goto cleanup;
> > > + }
> > > +
> >
> > RFC5970 says "Clients that have DNS implementations SHOULD support the
> > use of domain names in the URL" and in general string can also be valid
> > IPv4 address, nothing restricts it to IPv6.
>
> But the descriptions preceding it did explicitly say IPv6:
>
> " If the host in the URL is expressed using an IPv6 address rather than
> a domain name, the address in the URL then MUST be enclosed in "[" and
> "]" characters, conforming to [RFC3986]. "
>
it says "*if* it is using IPv6". Or at least so I understand it.
> > So I do not think you
> > should return error here, just return full string. I wish grub supported
> > IPv6 literals so we could just skip this check entirely.
>
> OK. I'll return the string by assuming it's domain name.
>
...
> >
> > > +
> > > + get_dhcpv6_dns_address (v6, size, &dns, &num_dns);
> > > +
> > > + if (grub_errno)
> > > + grub_errno = GRUB_ERR_NONE;
> > > +
> >
> > This ignores legitimate errors like out of memory. As mentioned above,
> > does it need to set any grub_errno on its own? If not, errors should
> > not be ignored.
>
> Because missing dns option is totally fine so that I don't want to treat
> it as error. We can use a specific error number for missing options and
> report other errors, but I can't find a suitable one for it (in
> include/grub/err.h).
>
If missing DNS option is totally fine it should not be returned as
error. You already have indication (num_dns == 0) which is enough if
you want to inform user. Errors should be returned in case of e-h-h
errors :)
Thanks! And sorry for delay.
next prev parent reply other threads:[~2015-05-30 7:25 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-05-12 8:49 [PATCH v1] Support DHCPv6 and UEFI IPv6 PXE Michael Chang
2015-05-12 8:49 ` [PATCH 1/3] Added net_bootp6 command Michael Chang
2015-05-15 6:26 ` Andrei Borzenkov
2015-05-15 13:57 ` Michael Chang
2015-05-16 5:42 ` Andrei Borzenkov
2015-05-19 8:42 ` Michael Chang
2015-05-30 7:25 ` Andrei Borzenkov [this message]
2015-05-12 8:49 ` [PATCH 2/3] UEFI IPv6 PXE support Michael Chang
2015-05-12 8:49 ` [PATCH 3/3] Update document for net_bootp6 command Michael Chang
2015-05-15 6:40 ` [PATCH v1] Support DHCPv6 and UEFI IPv6 PXE Andrei Borzenkov
2015-05-15 14:15 ` Michael Chang
-- strict thread matches above, loose matches on Subject: below --
2015-04-15 9:05 [RFC] " Michael Chang
2015-04-15 9:05 ` [PATCH 1/3] Added net_bootp6 command Michael Chang
2015-04-16 14:40 ` Andrei Borzenkov
2015-04-17 5:04 ` Michael Chang
2015-04-19 8:15 ` Andrei Borzenkov
2015-04-20 3:09 ` Michael Chang
2015-04-20 3:38 ` Andrei Borzenkov
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=20150530102515.5cc45d91@opensuse.site \
--to=arvidjaar@gmail.com \
--cc=grub-devel@gnu.org \
--cc=mchang@suse.com \
/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.