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