15a2072
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
15a2072
From: RHEL Ninjas <example@example.com>
15a2072
Date: Fri, 25 Sep 2015 16:24:23 +0900
15a2072
Subject: [PATCH] efinet: add filter for the first exclusive reopen of SNP
15a2072
15a2072
---
15a2072
 grub-core/net/drivers/efi/efinet.c | 39 ++++++++++++++++++++++++++++++++++++++
15a2072
 1 file changed, 39 insertions(+)
15a2072
15a2072
diff --git a/grub-core/net/drivers/efi/efinet.c b/grub-core/net/drivers/efi/efinet.c
15a2072
index a3ce4c67cce..b870d3f1938 100644
15a2072
--- a/grub-core/net/drivers/efi/efinet.c
15a2072
+++ b/grub-core/net/drivers/efi/efinet.c
15a2072
@@ -465,6 +465,45 @@ grub_efi_net_config_real (grub_efi_handle_t hnd, char **device,
15a2072
 				    &pxe_mode->dhcp_ack,
15a2072
 				    sizeof (pxe_mode->dhcp_ack),
15a2072
 				    1, device, path);
15a2072
+    net = grub_efi_open_protocol (card->efi_handle, &net_io_guid,
15a2072
+				  GRUB_EFI_OPEN_PROTOCOL_BY_EXCLUSIVE);
15a2072
+    if (net) {
15a2072
+      if (net->mode->state == GRUB_EFI_NETWORK_STOPPED
15a2072
+	  && efi_call_1 (net->start, net) != GRUB_EFI_SUCCESS)
15a2072
+	continue;
15a2072
+
15a2072
+      if (net->mode->state == GRUB_EFI_NETWORK_STOPPED)
15a2072
+	continue;
15a2072
+
15a2072
+      if (net->mode->state == GRUB_EFI_NETWORK_STARTED
15a2072
+	  && efi_call_3 (net->initialize, net, 0, 0) != GRUB_EFI_SUCCESS)
15a2072
+	continue;
15a2072
+
15a2072
+      /* Enable hardware receive filters if driver declares support for it.
15a2072
+	 We need unicast and broadcast and additionaly all nodes and
15a2072
+	 solicited multicast for IPv6. Solicited multicast is per-IPv6
15a2072
+	 address and we currently do not have API to do it so simply
15a2072
+	 try to enable receive of all multicast packets or evertyhing in
15a2072
+	 the worst case (i386 PXE driver always enables promiscuous too).
15a2072
+
15a2072
+	 This does trust firmware to do what it claims to do.
15a2072
+       */
15a2072
+      if (net->mode->receive_filter_mask)
15a2072
+	{
15a2072
+	  grub_uint32_t filters = GRUB_EFI_SIMPLE_NETWORK_RECEIVE_UNICAST   |
15a2072
+				  GRUB_EFI_SIMPLE_NETWORK_RECEIVE_BROADCAST |
15a2072
+				  GRUB_EFI_SIMPLE_NETWORK_RECEIVE_PROMISCUOUS_MULTICAST;
15a2072
+
15a2072
+	  filters &= net->mode->receive_filter_mask;
15a2072
+	  if (!(filters & GRUB_EFI_SIMPLE_NETWORK_RECEIVE_PROMISCUOUS_MULTICAST))
15a2072
+	    filters |= (net->mode->receive_filter_mask &
15a2072
+			GRUB_EFI_SIMPLE_NETWORK_RECEIVE_PROMISCUOUS);
15a2072
+
15a2072
+	  efi_call_6 (net->receive_filters, net, filters, 0, 0, 0, NULL);
15a2072
+	}
15a2072
+
15a2072
+      card->efi_net = net;
15a2072
+    }
15a2072
     return;
15a2072
   }
15a2072
 }