|
|
f731ee |
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
|
f731ee |
From: Michael Chang <mchang@suse.com>
|
|
|
f731ee |
Date: Wed, 15 Apr 2015 14:48:30 +0800
|
|
|
f731ee |
Subject: [PATCH] efinet: UEFI IPv6 PXE support
|
|
|
f731ee |
|
|
|
f731ee |
When grub2 image is booted from UEFI IPv6 PXE, the DHCPv6 Reply packet is
|
|
|
f731ee |
cached in firmware buffer which can be obtained by PXE Base Code protocol. The
|
|
|
f731ee |
network interface can be setup through the parameters in that obtained packet.
|
|
|
f731ee |
|
|
|
f731ee |
Signed-off-by: Michael Chang <mchang@suse.com>
|
|
|
f731ee |
Signed-off-by: Ken Lin <ken.lin@hpe.com>
|
|
|
f731ee |
---
|
|
|
f731ee |
grub-core/net/drivers/efi/efinet.c | 22 ++++++------
|
|
|
f731ee |
include/grub/efi/api.h | 71 +++++++++++++++++++++++---------------
|
|
|
f731ee |
2 files changed, 54 insertions(+), 39 deletions(-)
|
|
|
f731ee |
|
|
|
f731ee |
diff --git a/grub-core/net/drivers/efi/efinet.c b/grub-core/net/drivers/efi/efinet.c
|
|
|
f731ee |
index b9ed13fcad1..8bb0db014ac 100644
|
|
|
f731ee |
--- a/grub-core/net/drivers/efi/efinet.c
|
|
|
f731ee |
+++ b/grub-core/net/drivers/efi/efinet.c
|
|
|
f731ee |
@@ -404,9 +404,6 @@ grub_efi_net_config_real (grub_efi_handle_t hnd, char **device,
|
|
|
f731ee |
pxe_mode = pxe->mode;
|
|
|
f731ee |
if (pxe_mode->using_ipv6)
|
|
|
f731ee |
{
|
|
|
f731ee |
- grub_net_link_level_address_t hwaddr;
|
|
|
f731ee |
- struct grub_net_network_level_interface *intf;
|
|
|
f731ee |
-
|
|
|
f731ee |
grub_dprintf ("efinet", "using ipv6 and dhcpv6\n");
|
|
|
f731ee |
grub_dprintf ("efinet", "dhcp_ack_received: %s%s\n",
|
|
|
f731ee |
pxe_mode->dhcp_ack_received ? "yes" : "no",
|
|
|
f731ee |
@@ -414,16 +411,17 @@ grub_efi_net_config_real (grub_efi_handle_t hnd, char **device,
|
|
|
f731ee |
if (!pxe_mode->dhcp_ack_received)
|
|
|
f731ee |
continue;
|
|
|
f731ee |
|
|
|
f731ee |
- hwaddr.type = GRUB_NET_LINK_LEVEL_PROTOCOL_ETHERNET;
|
|
|
f731ee |
- grub_memcpy (hwaddr.mac,
|
|
|
f731ee |
- card->efi_net->mode->current_address,
|
|
|
f731ee |
- sizeof (hwaddr.mac));
|
|
|
f731ee |
-
|
|
|
f731ee |
- intf = grub_net_configure_by_dhcpv6_ack (card->name, card, 0, &hwaddr,
|
|
|
f731ee |
- (const struct grub_net_dhcpv6_packet *)&pxe_mode->dhcp_ack.dhcpv6,
|
|
|
f731ee |
- 1, device, path);
|
|
|
f731ee |
- if (intf && device && path)
|
|
|
f731ee |
+ grub_net_configure_by_dhcpv6_reply (card->name, card, 0,
|
|
|
f731ee |
+ (struct grub_net_dhcp6_packet *)
|
|
|
f731ee |
+ &pxe_mode->dhcp_ack,
|
|
|
f731ee |
+ sizeof (pxe_mode->dhcp_ack),
|
|
|
f731ee |
+ 1, device, path);
|
|
|
f731ee |
+ if (grub_errno)
|
|
|
f731ee |
+ grub_print_error ();
|
|
|
f731ee |
+ if (device && path)
|
|
|
f731ee |
grub_dprintf ("efinet", "device: `%s' path: `%s'\n", *device, *path);
|
|
|
f731ee |
+ if (grub_errno)
|
|
|
f731ee |
+ grub_print_error ();
|
|
|
f731ee |
}
|
|
|
f731ee |
else
|
|
|
f731ee |
{
|
|
|
f731ee |
diff --git a/include/grub/efi/api.h b/include/grub/efi/api.h
|
|
|
f731ee |
index 9422ba9a9db..2d0f37a8164 100644
|
|
|
f731ee |
--- a/include/grub/efi/api.h
|
|
|
f731ee |
+++ b/include/grub/efi/api.h
|
|
|
f731ee |
@@ -1446,31 +1446,6 @@ typedef union
|
|
|
f731ee |
grub_efi_pxe_dhcpv6_packet_t dhcpv6;
|
|
|
f731ee |
} grub_efi_pxe_packet_t;
|
|
|
f731ee |
|
|
|
f731ee |
-#define GRUB_EFI_PXE_MAX_IPCNT 8
|
|
|
f731ee |
-#define GRUB_EFI_PXE_MAX_ARP_ENTRIES 8
|
|
|
f731ee |
-#define GRUB_EFI_PXE_MAX_ROUTE_ENTRIES 8
|
|
|
f731ee |
-
|
|
|
f731ee |
-typedef struct grub_efi_pxe_ip_filter
|
|
|
f731ee |
-{
|
|
|
f731ee |
- grub_efi_uint8_t filters;
|
|
|
f731ee |
- grub_efi_uint8_t ip_count;
|
|
|
f731ee |
- grub_efi_uint8_t reserved;
|
|
|
f731ee |
- grub_efi_ip_address_t ip_list[GRUB_EFI_PXE_MAX_IPCNT];
|
|
|
f731ee |
-} grub_efi_pxe_ip_filter_t;
|
|
|
f731ee |
-
|
|
|
f731ee |
-typedef struct grub_efi_pxe_arp_entry
|
|
|
f731ee |
-{
|
|
|
f731ee |
- grub_efi_ip_address_t ip_addr;
|
|
|
f731ee |
- grub_efi_mac_address_t mac_addr;
|
|
|
f731ee |
-} grub_efi_pxe_arp_entry_t;
|
|
|
f731ee |
-
|
|
|
f731ee |
-typedef struct grub_efi_pxe_route_entry
|
|
|
f731ee |
-{
|
|
|
f731ee |
- grub_efi_ip_address_t ip_addr;
|
|
|
f731ee |
- grub_efi_ip_address_t subnet_mask;
|
|
|
f731ee |
- grub_efi_ip_address_t gateway_addr;
|
|
|
f731ee |
-} grub_efi_pxe_route_entry_t;
|
|
|
f731ee |
-
|
|
|
f731ee |
typedef struct grub_efi_pxe_icmp_error
|
|
|
f731ee |
{
|
|
|
f731ee |
grub_efi_uint8_t type;
|
|
|
f731ee |
@@ -1496,6 +1471,48 @@ typedef struct grub_efi_pxe_tftp_error
|
|
|
f731ee |
grub_efi_char8_t error_string[127];
|
|
|
f731ee |
} grub_efi_pxe_tftp_error_t;
|
|
|
f731ee |
|
|
|
f731ee |
+typedef struct {
|
|
|
f731ee |
+ grub_uint8_t addr[4];
|
|
|
f731ee |
+} grub_efi_pxe_ipv4_address_t;
|
|
|
f731ee |
+
|
|
|
f731ee |
+typedef struct {
|
|
|
f731ee |
+ grub_uint8_t addr[16];
|
|
|
f731ee |
+} grub_efi_pxe_ipv6_address_t;
|
|
|
f731ee |
+
|
|
|
f731ee |
+typedef struct {
|
|
|
f731ee |
+ grub_uint8_t addr[32];
|
|
|
f731ee |
+} grub_efi_pxe_mac_address_t;
|
|
|
f731ee |
+
|
|
|
f731ee |
+typedef union {
|
|
|
f731ee |
+ grub_uint32_t addr[4];
|
|
|
f731ee |
+ grub_efi_pxe_ipv4_address_t v4;
|
|
|
f731ee |
+ grub_efi_pxe_ipv6_address_t v6;
|
|
|
f731ee |
+} grub_efi_pxe_ip_address_t;
|
|
|
f731ee |
+
|
|
|
f731ee |
+#define GRUB_EFI_PXE_BASE_CODE_MAX_IPCNT 8
|
|
|
f731ee |
+typedef struct grub_efi_pxe_ip_filter
|
|
|
f731ee |
+{
|
|
|
f731ee |
+ grub_efi_uint8_t filters;
|
|
|
f731ee |
+ grub_efi_uint8_t ip_count;
|
|
|
f731ee |
+ grub_efi_uint16_t reserved;
|
|
|
f731ee |
+ grub_efi_ip_address_t ip_list[GRUB_EFI_PXE_BASE_CODE_MAX_IPCNT];
|
|
|
f731ee |
+} grub_efi_pxe_ip_filter_t;
|
|
|
f731ee |
+
|
|
|
f731ee |
+typedef struct {
|
|
|
f731ee |
+ grub_efi_pxe_ip_address_t ip_addr;
|
|
|
f731ee |
+ grub_efi_pxe_mac_address_t mac_addr;
|
|
|
f731ee |
+} grub_efi_pxe_arp_entry_t;
|
|
|
f731ee |
+
|
|
|
f731ee |
+typedef struct {
|
|
|
f731ee |
+ grub_efi_pxe_ip_address_t ip_addr;
|
|
|
f731ee |
+ grub_efi_pxe_ip_address_t subnet_mask;
|
|
|
f731ee |
+ grub_efi_pxe_ip_address_t gw_addr;
|
|
|
f731ee |
+} grub_efi_pxe_route_entry_t;
|
|
|
f731ee |
+
|
|
|
f731ee |
+
|
|
|
f731ee |
+#define GRUB_EFI_PXE_BASE_CODE_MAX_ARP_ENTRIES 8
|
|
|
f731ee |
+#define GRUB_EFI_PXE_BASE_CODE_MAX_ROUTE_ENTRIES 8
|
|
|
f731ee |
+
|
|
|
f731ee |
typedef struct grub_efi_pxe_mode
|
|
|
f731ee |
{
|
|
|
f731ee |
grub_efi_boolean_t started;
|
|
|
f731ee |
@@ -1527,9 +1544,9 @@ typedef struct grub_efi_pxe_mode
|
|
|
f731ee |
grub_efi_pxe_packet_t pxe_bis_reply;
|
|
|
f731ee |
grub_efi_pxe_ip_filter_t ip_filter;
|
|
|
f731ee |
grub_efi_uint32_t arp_cache_entries;
|
|
|
f731ee |
- grub_efi_pxe_arp_entry_t arp_cache[GRUB_EFI_PXE_MAX_ARP_ENTRIES];
|
|
|
f731ee |
+ grub_efi_pxe_arp_entry_t arp_cache[GRUB_EFI_PXE_BASE_CODE_MAX_ARP_ENTRIES];
|
|
|
f731ee |
grub_efi_uint32_t route_table_entries;
|
|
|
f731ee |
- grub_efi_pxe_route_entry_t route_table[GRUB_EFI_PXE_MAX_ROUTE_ENTRIES];
|
|
|
f731ee |
+ grub_efi_pxe_route_entry_t route_table[GRUB_EFI_PXE_BASE_CODE_MAX_ROUTE_ENTRIES];
|
|
|
f731ee |
grub_efi_pxe_icmp_error_t icmp_error;
|
|
|
f731ee |
grub_efi_pxe_tftp_error_t tftp_error;
|
|
|
f731ee |
} grub_efi_pxe_mode_t;
|