From: Andrei Borzenkov <arvidjaar@gmail.com>
To: Nikunj A Dadhania <nikunj@linux.vnet.ibm.com>
Cc: The development of GNU GRUB <grub-devel@gnu.org>, mpe@ellerman.id.au
Subject: Re: [PATCH] bootp: set is_def while processing dhcp ack
Date: Thu, 17 Mar 2016 21:58:52 +0300 [thread overview]
Message-ID: <56EAFE6C.2080701@gmail.com> (raw)
In-Reply-To: <871t79wl04.fsf@abhimanyu.in.ibm.com>
[-- Attachment #1: Type: text/plain, Size: 1130 bytes --]
17.03.2016 11:45, Nikunj A Dadhania пишет:
> Andrei Borzenkov <arvidjaar@gmail.com> writes:
>
>> On Thu, Mar 17, 2016 at 11:04 AM, Nikunj A Dadhania
>> <nikunj@linux.vnet.ibm.com> wrote:
>>> net_default_interface=ofnet_net:dhcp
>>> net_default_ip=(null)
>>> net_default_mac=(null)
>>> net_default_server=10.0.2.2
>>> net_ofnet_net_dhcp_boot_file=ubuntu-installer/ppc64el/powerpc-ieee1275/core.elf
>>> net_ofnet_net_dhcp_ip=10.0.2.15
>>> net_ofnet_net_dhcp_mac=52:54:00:12:34:56
>>
>>
>> OK, we probably need to export not only name, but also IP to match
>> default case. Could you attach bootp reply packet?
>
> Attached the pcap file, it has the request as well as the ack.
>
>> I wonder if anyone ever seen or used net_if_dhcp_server_name variable;
>> because net_boot sets interface name to card:dhcp, this actually
>> becomes net_card_dhcp_dhcp_server_name. Someone would sure have
>> noticed it.
>
Please test attached patch. It sets net_<card>_dhcp_server_ip variable.
We probably need to offer programmatic way to iterate through all cards
in CLI. But as long as you have single card with known name it should be
OK.
[-- Attachment #2: bootp_server_ip.patch --]
[-- Type: text/x-patch, Size: 2661 bytes --]
From: Andrei Borzenkov <arvidjaar@gmail.com>
Subject: [PATCH] bootp: export server IP as environment variable
---
grub-core/net/bootp.c | 34 ++++++++++++++++++++++------------
1 file changed, 22 insertions(+), 12 deletions(-)
diff --git a/grub-core/net/bootp.c b/grub-core/net/bootp.c
index a088244..c70cc09 100644
--- a/grub-core/net/bootp.c
+++ b/grub-core/net/bootp.c
@@ -142,6 +142,7 @@ grub_net_configure_by_dhcp_ack (const char *name,
grub_net_link_level_address_t hwaddr;
struct grub_net_network_level_interface *inter;
int mask = -1;
+ char *server_ip = 0;
addr.type = GRUB_NET_NETWORK_LEVEL_PROTOCOL_IPV4;
addr.ipv4 = bp->your_ip;
@@ -189,15 +190,27 @@ grub_net_configure_by_dhcp_ack (const char *name,
if (size > OFFSET_OF (boot_file, bp))
grub_env_set_net_property (name, "boot_file", bp->boot_file,
sizeof (bp->boot_file));
+ if (bp->server_ip)
+ {
+ server_ip = grub_xasprintf ("%d.%d.%d.%d",
+ ((grub_uint8_t *) &bp->server_ip)[0],
+ ((grub_uint8_t *) &bp->server_ip)[1],
+ ((grub_uint8_t *) &bp->server_ip)[2],
+ ((grub_uint8_t *) &bp->server_ip)[3]);
+ grub_print_error ();
+ }
+
+ if (server_ip)
+ {
+ grub_env_set_net_property (name, "server_ip", server_ip, grub_strlen (server_ip));
+ grub_print_error ();
+ }
+
if (is_def)
grub_net_default_server = 0;
- if (is_def && !grub_net_default_server && bp->server_ip)
+ if (is_def && !grub_net_default_server && server_ip)
{
- grub_net_default_server = grub_xasprintf ("%d.%d.%d.%d",
- ((grub_uint8_t *) &bp->server_ip)[0],
- ((grub_uint8_t *) &bp->server_ip)[1],
- ((grub_uint8_t *) &bp->server_ip)[2],
- ((grub_uint8_t *) &bp->server_ip)[3]);
+ grub_net_default_server = grub_strdup (server_ip);
grub_print_error ();
}
@@ -207,13 +220,9 @@ grub_net_configure_by_dhcp_ack (const char *name,
grub_env_export ("net_default_interface");
}
- if (device && !*device && bp->server_ip)
+ if (device && !*device && server_ip)
{
- *device = grub_xasprintf ("tftp,%d.%d.%d.%d",
- ((grub_uint8_t *) &bp->server_ip)[0],
- ((grub_uint8_t *) &bp->server_ip)[1],
- ((grub_uint8_t *) &bp->server_ip)[2],
- ((grub_uint8_t *) &bp->server_ip)[3]);
+ *device = grub_xasprintf ("tftp,%s", server_ip);
grub_print_error ();
}
if (size > OFFSET_OF (server_name, bp)
@@ -260,6 +269,7 @@ grub_net_configure_by_dhcp_ack (const char *name,
else
grub_errno = GRUB_ERR_NONE;
+ grub_free (server_ip);
return inter;
}
--
tg: (76eac44..) u/bootp-server-ip (depends on: master)
next prev parent reply other threads:[~2016-03-17 18:59 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-03-16 8:35 [PATCH] bootp: set is_def while processing dhcp ack Nikunj A Dadhania
2016-03-16 9:49 ` Andrei Borzenkov
2016-03-16 10:16 ` Nikunj A Dadhania
2016-03-16 10:33 ` Andrei Borzenkov
2016-03-16 11:00 ` Nikunj A Dadhania
2016-03-16 11:13 ` Andrei Borzenkov
2016-03-17 6:16 ` Nikunj A Dadhania
2016-03-17 7:27 ` Andrei Borzenkov
2016-03-17 8:04 ` Nikunj A Dadhania
2016-03-17 8:09 ` Nikunj A Dadhania
2016-03-17 8:32 ` Andrei Borzenkov
2016-03-17 8:45 ` Nikunj A Dadhania
2016-03-17 18:58 ` Andrei Borzenkov [this message]
2016-03-18 5:06 ` Nikunj A Dadhania
2016-03-18 5:59 ` Andrei Borzenkov
2016-03-18 6:08 ` Nikunj A Dadhania
2016-03-18 6:27 ` Andrei Borzenkov
2016-03-18 6:34 ` Nikunj A Dadhania
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=56EAFE6C.2080701@gmail.com \
--to=arvidjaar@gmail.com \
--cc=grub-devel@gnu.org \
--cc=mpe@ellerman.id.au \
--cc=nikunj@linux.vnet.ibm.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.