Received: from list by lists.gnu.org with archive (Exim 4.90_1) id 1pF1bb-0000kX-5R for mharc-grub-devel@gnu.org; Mon, 09 Jan 2023 18:31:03 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pF1bZ-0000jw-Jv for grub-devel@gnu.org; Mon, 09 Jan 2023 18:31:01 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pF1bX-0003Nq-N6 for grub-devel@gnu.org; Mon, 09 Jan 2023 18:31:01 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1673307059; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=j9WRaqjGiB66SRxT04x3RHSCtkapoWY84sBYsHN3xdk=; b=ZXwkQ+1d8olLin0VqbLmWxqc5RusvIqsHf1nMsotE/jy4cyFNZIBdCf9Uh2iCn2jWwzw00 wYDK3cd8VRsgsDuTTULwtE5I720OWw5f8c0xIAERXeZSgB0WYd1wIbno/nVNbBYqEBP4+R mNXAKpd21Qk/FHxkxJsCeG3niKFSgnA= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-606-EoxIh4bBPuiKgATIhTrlUQ-1; Mon, 09 Jan 2023 18:30:57 -0500 X-MC-Unique: EoxIh4bBPuiKgATIhTrlUQ-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 6CFFD3814943; Mon, 9 Jan 2023 23:30:57 +0000 (UTC) Received: from eesha.redhat.com (unknown [10.22.9.28]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3CC0840C2064; Mon, 9 Jan 2023 23:30:57 +0000 (UTC) From: Robbie Harwood To: grub-devel@gnu.org Cc: Michael Chang , dkiper@net-space.pl, Ken Lin , Robbie Harwood Subject: [PATCH v4 04/19] efinet: add structures for PXE messages Date: Mon, 9 Jan 2023 18:30:30 -0500 Message-Id: <20230109233045.85477-5-rharwood@redhat.com> In-Reply-To: <20230109233045.85477-1-rharwood@redhat.com> References: <20230109233045.85477-1-rharwood@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="US-ASCII"; x-default=true Received-SPF: pass client-ip=170.10.133.124; envelope-from=rharwood@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: The development of GNU GRUB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 09 Jan 2023 23:31:01 -0000 From: Michael Chang 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 Signed-off-by: Ken Lin Co-authored-by: Robbie Harwood Signed-off-by: Robbie Harwood --- 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 3fa65c3499..e6e2056a0d 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.39.0