All of lore.kernel.org
 help / color / mirror / Atom feed
From: Chad Kimes <chkimes@github.com>
To: grub-devel@gnu.org
Cc: Chad Kimes <chkimes@github.com>
Subject: [PATCH 2/2] Configure VLAN from UEFI device used for PXE
Date: Sat,  5 Mar 2022 19:46:40 -0500	[thread overview]
Message-ID: <20220306004640.412289-2-chkimes@github.com> (raw)
In-Reply-To: <20220306004640.412289-1-chkimes@github.com>

Signed-off-by: Chad Kimes <chkimes@github.com>
---
 grub-core/net/drivers/efi/efinet.c | 38 ++++++++++++++++++++++++++----
 1 file changed, 33 insertions(+), 5 deletions(-)

diff --git a/grub-core/net/drivers/efi/efinet.c b/grub-core/net/drivers/efi/efinet.c
index 381c138db..98b0f6bef 100644
--- a/grub-core/net/drivers/efi/efinet.c
+++ b/grub-core/net/drivers/efi/efinet.c
@@ -387,11 +387,39 @@ grub_efi_net_config_real (grub_efi_handle_t hnd, char **device,
     if (! pxe)
       continue;
     pxe_mode = pxe->mode;
-    grub_net_configure_by_dhcp_ack (card->name, card, 0,
-				    (struct grub_net_bootp_packet *)
-				    &pxe_mode->dhcp_ack,
-				    sizeof (pxe_mode->dhcp_ack),
-				    1, device, path);
+
+    struct grub_net_network_level_interface *inter;
+    inter = grub_net_configure_by_dhcp_ack (card->name, card, 0,
+					    (struct grub_net_bootp_packet *)
+					    &pxe_mode->dhcp_ack,
+					    sizeof (pxe_mode->dhcp_ack),
+					    1, device, path);
+
+    if (inter)
+      {
+	/*
+	 * search the device path for any VLAN subtype and use it
+	 * to configure the interface
+	 */
+	grub_efi_uint16_t len;
+	grub_efi_device_path_t *vlan_dp;
+	vlan_dp = dp;
+
+	while (!GRUB_EFI_END_ENTIRE_DEVICE_PATH (vlan_dp))
+	{
+	  if (GRUB_EFI_DEVICE_PATH_TYPE (vlan_dp) == GRUB_EFI_MESSAGING_DEVICE_PATH_TYPE
+	      && GRUB_EFI_DEVICE_PATH_SUBTYPE (vlan_dp) == GRUB_EFI_VLAN_DEVICE_PATH_SUBTYPE)
+	    {
+	      grub_efi_vlan_device_path_t *vlan;
+	      vlan = (grub_efi_vlan_device_path_t *) vlan_dp;
+	      inter->vlantag = vlan->vlan_id;
+	      break;
+	    }
+
+	  len = GRUB_EFI_DEVICE_PATH_LENGTH (vlan_dp);
+	  vlan_dp = (grub_efi_device_path_t *) ((char *) vlan_dp + len);
+	}
+      }
     return;
   }
 }
-- 
2.25.1



      reply	other threads:[~2022-03-06  0:46 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-06  0:46 [PATCH 1/2] Print VLAN info in EFI device path Chad Kimes
2022-03-06  0:46 ` Chad Kimes [this message]

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=20220306004640.412289-2-chkimes@github.com \
    --to=chkimes@github.com \
    --cc=grub-devel@gnu.org \
    /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.