[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v5 05/20] efinet: add structures for PXE messages
From: |
Robbie Harwood |
Subject: |
[PATCH v5 05/20] efinet: add structures for PXE messages |
Date: |
Tue, 25 Apr 2023 11:05:16 -0400 |
From: Michael Chang <mchang@suse.com>
When grub2 image is booted from UEFI IPv6 PXE, the DHCPv6 Reply packet
is cached in firmware buffer which can be obtained by PXE Base Code
protocol. The network interface can be setup through the parameters in
that obtained packet.
Augment existing structures to represent this, and make them agnostic
between ipv4 and ipv6.
Signed-off-by: Michael Chang <mchang@suse.com>
Signed-off-by: Ken Lin <ken.lin@hpe.com>
Co-authored-by: Robbie Harwood <rharwood@redhat.com>
Signed-off-by: Robbie Harwood <rharwood@redhat.com>
---
grub-core/net/drivers/efi/efinet.c | 2 +
include/grub/efi/api.h | 71 ++++++++++++++++++------------
2 files changed, 46 insertions(+), 27 deletions(-)
diff --git a/grub-core/net/drivers/efi/efinet.c
b/grub-core/net/drivers/efi/efinet.c
index 75bbfd1bbf..a10383bb6d 100644
--- a/grub-core/net/drivers/efi/efinet.c
+++ b/grub-core/net/drivers/efi/efinet.c
@@ -426,6 +426,8 @@ grub_efi_net_config_real (grub_efi_handle_t hnd, char
**device,
grub_print_error ();
if (device && path)
grub_dprintf ("efinet", "device: `%s' path: `%s'\n", *device, *path);
+ if (grub_errno)
+ grub_print_error ();
}
else
{
diff --git a/include/grub/efi/api.h b/include/grub/efi/api.h
index 43895756b7..4090b66e0f 100644
--- a/include/grub/efi/api.h
+++ b/include/grub/efi/api.h
@@ -1565,31 +1565,6 @@ typedef union
grub_efi_pxe_dhcpv6_packet_t dhcpv6;
} grub_efi_pxe_packet_t;
-#define GRUB_EFI_PXE_MAX_IPCNT 8
-#define GRUB_EFI_PXE_MAX_ARP_ENTRIES 8
-#define GRUB_EFI_PXE_MAX_ROUTE_ENTRIES 8
-
-typedef struct grub_efi_pxe_ip_filter
-{
- grub_efi_uint8_t filters;
- grub_efi_uint8_t ip_count;
- grub_efi_uint16_t reserved;
- grub_efi_ip_address_t ip_list[GRUB_EFI_PXE_MAX_IPCNT];
-} grub_efi_pxe_ip_filter_t;
-
-typedef struct grub_efi_pxe_arp_entry
-{
- grub_efi_ip_address_t ip_addr;
- grub_efi_mac_address_t mac_addr;
-} grub_efi_pxe_arp_entry_t;
-
-typedef struct grub_efi_pxe_route_entry
-{
- grub_efi_ip_address_t ip_addr;
- grub_efi_ip_address_t subnet_mask;
- grub_efi_ip_address_t gateway_addr;
-} grub_efi_pxe_route_entry_t;
-
typedef struct grub_efi_pxe_icmp_error
{
grub_efi_uint8_t type;
@@ -1615,6 +1590,48 @@ typedef struct grub_efi_pxe_tftp_error
grub_efi_char8_t error_string[127];
} grub_efi_pxe_tftp_error_t;
+typedef struct {
+ grub_uint8_t addr[4];
+} grub_efi_pxe_ipv4_address_t;
+
+typedef struct {
+ grub_uint8_t addr[16];
+} grub_efi_pxe_ipv6_address_t;
+
+typedef struct {
+ grub_uint8_t addr[32];
+} grub_efi_pxe_mac_address_t;
+
+typedef union {
+ grub_uint32_t addr[4];
+ grub_efi_pxe_ipv4_address_t v4;
+ grub_efi_pxe_ipv6_address_t v6;
+} grub_efi_pxe_ip_address_t;
+
+#define GRUB_EFI_PXE_BASE_CODE_MAX_IPCNT 8
+typedef struct grub_efi_pxe_ip_filter
+{
+ grub_efi_uint8_t filters;
+ grub_efi_uint8_t ip_count;
+ grub_efi_uint16_t reserved;
+ grub_efi_ip_address_t ip_list[GRUB_EFI_PXE_BASE_CODE_MAX_IPCNT];
+} grub_efi_pxe_ip_filter_t;
+
+typedef struct {
+ grub_efi_pxe_ip_address_t ip_addr;
+ grub_efi_pxe_mac_address_t mac_addr;
+} grub_efi_pxe_arp_entry_t;
+
+typedef struct {
+ grub_efi_pxe_ip_address_t ip_addr;
+ grub_efi_pxe_ip_address_t subnet_mask;
+ grub_efi_pxe_ip_address_t gw_addr;
+} grub_efi_pxe_route_entry_t;
+
+
+#define GRUB_EFI_PXE_BASE_CODE_MAX_ARP_ENTRIES 8
+#define GRUB_EFI_PXE_BASE_CODE_MAX_ROUTE_ENTRIES 8
+
typedef struct grub_efi_pxe_mode
{
grub_efi_boolean_t started;
@@ -1646,9 +1663,9 @@ typedef struct grub_efi_pxe_mode
grub_efi_pxe_packet_t pxe_bis_reply;
grub_efi_pxe_ip_filter_t ip_filter;
grub_efi_uint32_t arp_cache_entries;
- grub_efi_pxe_arp_entry_t arp_cache[GRUB_EFI_PXE_MAX_ARP_ENTRIES];
+ grub_efi_pxe_arp_entry_t arp_cache[GRUB_EFI_PXE_BASE_CODE_MAX_ARP_ENTRIES];
grub_efi_uint32_t route_table_entries;
- grub_efi_pxe_route_entry_t route_table[GRUB_EFI_PXE_MAX_ROUTE_ENTRIES];
+ grub_efi_pxe_route_entry_t
route_table[GRUB_EFI_PXE_BASE_CODE_MAX_ROUTE_ENTRIES];
grub_efi_pxe_icmp_error_t icmp_error;
grub_efi_pxe_tftp_error_t tftp_error;
} grub_efi_pxe_mode_t;
--
2.40.0
- [PATCH v5 13/20] Add fw_path variable to detect config file on efi, (continued)
- [PATCH v5 13/20] Add fw_path variable to detect config file on efi, Robbie Harwood, 2023/04/25
- [PATCH v5 19/20] normal/main: Discover the device to read the config from as a fallback, Robbie Harwood, 2023/04/25
- [PATCH v5 10/20] Support UEFI networking protocols, Robbie Harwood, 2023/04/25
- [PATCH v5 03/20] net/http: check result of grub_netbuff_put() in http_receive(), Robbie Harwood, 2023/04/25
- [PATCH v5 16/20] Prepend prefix when HTTP path is relative, Robbie Harwood, 2023/04/25
- [PATCH v5 11/20] efinet: also use the firmware acceleration for http, Robbie Harwood, 2023/04/25
- [PATCH v5 08/20] efinet Configure network from UEFI device path, Robbie Harwood, 2023/04/25
- [PATCH v5 06/20] grub.texi: Add net_bootp6 doumentation, Robbie Harwood, 2023/04/25
- [PATCH v5 15/20] Try mac/guid/etc before grub.cfg on tftp config files, Robbie Harwood, 2023/04/25
- [PATCH v5 20/20] efinet: Add DHCP proxy support, Robbie Harwood, 2023/04/25
- [PATCH v5 05/20] efinet: add structures for PXE messages,
Robbie Harwood <=
- [PATCH v5 18/20] http: Prepend prefix when the HTTP path is relative, Robbie Harwood, 2023/04/25
- [PATCH v5 07/20] bootp: Process DHCPACK packet during HTTP Boot, Robbie Harwood, 2023/04/25
- [PATCH v5 09/20] efinet: set DNS server from UEFI protocol, Robbie Harwood, 2023/04/25
- [PATCH v5 02/20] net: read bracketed ipv6 addrs and port numbers, Robbie Harwood, 2023/04/25
- [PATCH v5 17/20] efi/http: Enclose literal IPv6 addresses in square brackets, Robbie Harwood, 2023/04/25
- [PATCH v5 12/20] efi/http: match protocol+hostname of boot url in root_url, Robbie Harwood, 2023/04/25
- [PATCH v5 14/20] use fw_path prefix when fallback searching for grub config, Robbie Harwood, 2023/04/25