|
|
f731ee |
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
|
f731ee |
From: Andrei Borzenkov <arvidjaar@gmail.com>
|
|
|
f731ee |
Date: Tue, 16 Jun 2015 19:52:45 +0300
|
|
|
f731ee |
Subject: [PATCH] efinet: enable hardware filters when opening interface
|
|
|
f731ee |
|
|
|
f731ee |
Exclusive open on SNP will close all existing protocol instances which
|
|
|
f731ee |
may disable all receive filters on interface. Reinstall them after we
|
|
|
f731ee |
opened protocol exclusively.
|
|
|
f731ee |
|
|
|
f731ee |
Also follow UEFI specification recommendation and stop interfaces when
|
|
|
f731ee |
closing them:
|
|
|
f731ee |
|
|
|
f731ee |
Unexpected system errors, reboots and hangs can occur if an OS is loaded
|
|
|
f731ee |
and the network devices are not Shutdown() and Stopped().
|
|
|
f731ee |
|
|
|
f731ee |
Also by: Mark Salter <msalter@redhat.com>
|
|
|
f731ee |
Closes: 45204
|
|
|
f731ee |
---
|
|
|
f731ee |
grub-core/net/drivers/efi/efinet.c | 25 +++++++++++++++++++++++++
|
|
|
f731ee |
include/grub/efi/api.h | 20 +++++++++++++++++---
|
|
|
f731ee |
2 files changed, 42 insertions(+), 3 deletions(-)
|
|
|
f731ee |
|
|
|
f731ee |
diff --git a/grub-core/net/drivers/efi/efinet.c b/grub-core/net/drivers/efi/efinet.c
|
|
|
f731ee |
index 6a1dd1f9dff..7b8c4a59d10 100644
|
|
|
f731ee |
--- a/grub-core/net/drivers/efi/efinet.c
|
|
|
f731ee |
+++ b/grub-core/net/drivers/efi/efinet.c
|
|
|
f731ee |
@@ -168,6 +168,29 @@ open_card (struct grub_net_card *dev)
|
|
|
f731ee |
return grub_error (GRUB_ERR_NET_NO_CARD, "%s: net initialize failed",
|
|
|
f731ee |
dev->name);
|
|
|
f731ee |
|
|
|
f731ee |
+ /* Enable hardware receive filters if driver declares support for it.
|
|
|
f731ee |
+ We need unicast and broadcast and additionaly all nodes and
|
|
|
f731ee |
+ solicited multicast for IPv6. Solicited multicast is per-IPv6
|
|
|
f731ee |
+ address and we currently do not have API to do it so simply
|
|
|
f731ee |
+ try to enable receive of all multicast packets or evertyhing in
|
|
|
f731ee |
+ the worst case (i386 PXE driver always enables promiscuous too).
|
|
|
f731ee |
+
|
|
|
f731ee |
+ This does trust firmware to do what it claims to do.
|
|
|
f731ee |
+ */
|
|
|
f731ee |
+ if (net->mode->receive_filter_mask)
|
|
|
f731ee |
+ {
|
|
|
f731ee |
+ grub_uint32_t filters = GRUB_EFI_SIMPLE_NETWORK_RECEIVE_UNICAST |
|
|
|
f731ee |
+ GRUB_EFI_SIMPLE_NETWORK_RECEIVE_BROADCAST |
|
|
|
f731ee |
+ GRUB_EFI_SIMPLE_NETWORK_RECEIVE_PROMISCUOUS_MULTICAST;
|
|
|
f731ee |
+
|
|
|
f731ee |
+ filters &= net->mode->receive_filter_mask;
|
|
|
f731ee |
+ if (!(filters & GRUB_EFI_SIMPLE_NETWORK_RECEIVE_PROMISCUOUS_MULTICAST))
|
|
|
f731ee |
+ filters |= (net->mode->receive_filter_mask &
|
|
|
f731ee |
+ GRUB_EFI_SIMPLE_NETWORK_RECEIVE_PROMISCUOUS);
|
|
|
f731ee |
+
|
|
|
f731ee |
+ efi_call_6 (net->receive_filters, net, filters, 0, 0, 0, NULL);
|
|
|
f731ee |
+ }
|
|
|
f731ee |
+
|
|
|
f731ee |
efi_call_4 (grub_efi_system_table->boot_services->close_protocol,
|
|
|
f731ee |
dev->efi_net, &net_io_guid,
|
|
|
f731ee |
grub_efi_image_handle, dev->efi_handle);
|
|
|
f731ee |
@@ -181,6 +204,8 @@ open_card (struct grub_net_card *dev)
|
|
|
f731ee |
static void
|
|
|
f731ee |
close_card (struct grub_net_card *dev)
|
|
|
f731ee |
{
|
|
|
f731ee |
+ efi_call_1 (dev->efi_net->shutdown, dev->efi_net);
|
|
|
f731ee |
+ efi_call_1 (dev->efi_net->stop, dev->efi_net);
|
|
|
f731ee |
efi_call_4 (grub_efi_system_table->boot_services->close_protocol,
|
|
|
f731ee |
dev->efi_net, &net_io_guid,
|
|
|
f731ee |
grub_efi_image_handle, dev->efi_handle);
|
|
|
f731ee |
diff --git a/include/grub/efi/api.h b/include/grub/efi/api.h
|
|
|
f731ee |
index 142340372e1..029ee92f5d0 100644
|
|
|
f731ee |
--- a/include/grub/efi/api.h
|
|
|
f731ee |
+++ b/include/grub/efi/api.h
|
|
|
f731ee |
@@ -1564,17 +1564,31 @@ enum
|
|
|
f731ee |
GRUB_EFI_NETWORK_INITIALIZED,
|
|
|
f731ee |
};
|
|
|
f731ee |
|
|
|
f731ee |
+enum
|
|
|
f731ee |
+ {
|
|
|
f731ee |
+ GRUB_EFI_SIMPLE_NETWORK_RECEIVE_UNICAST = 0x01,
|
|
|
f731ee |
+ GRUB_EFI_SIMPLE_NETWORK_RECEIVE_MULTICAST = 0x02,
|
|
|
f731ee |
+ GRUB_EFI_SIMPLE_NETWORK_RECEIVE_BROADCAST = 0x04,
|
|
|
f731ee |
+ GRUB_EFI_SIMPLE_NETWORK_RECEIVE_PROMISCUOUS = 0x08,
|
|
|
f731ee |
+ GRUB_EFI_SIMPLE_NETWORK_RECEIVE_PROMISCUOUS_MULTICAST = 0x10,
|
|
|
f731ee |
+ };
|
|
|
f731ee |
+
|
|
|
f731ee |
struct grub_efi_simple_network
|
|
|
f731ee |
{
|
|
|
f731ee |
grub_uint64_t revision;
|
|
|
f731ee |
grub_efi_status_t (*start) (struct grub_efi_simple_network *this);
|
|
|
f731ee |
- void (*stop) (void);
|
|
|
f731ee |
+ grub_efi_status_t (*stop) (struct grub_efi_simple_network *this);
|
|
|
f731ee |
grub_efi_status_t (*initialize) (struct grub_efi_simple_network *this,
|
|
|
f731ee |
grub_efi_uintn_t extra_rx,
|
|
|
f731ee |
grub_efi_uintn_t extra_tx);
|
|
|
f731ee |
void (*reset) (void);
|
|
|
f731ee |
- void (*shutdown) (void);
|
|
|
f731ee |
- void (*receive_filters) (void);
|
|
|
f731ee |
+ grub_efi_status_t (*shutdown) (struct grub_efi_simple_network *this);
|
|
|
f731ee |
+ grub_efi_status_t (*receive_filters) (struct grub_efi_simple_network *this,
|
|
|
f731ee |
+ grub_uint32_t enable,
|
|
|
f731ee |
+ grub_uint32_t disable,
|
|
|
f731ee |
+ grub_efi_boolean_t reset_mcast_filter,
|
|
|
f731ee |
+ grub_efi_uintn_t mcast_filter_count,
|
|
|
f731ee |
+ grub_efi_mac_address_t *mcast_filter);
|
|
|
f731ee |
void (*station_address) (void);
|
|
|
f731ee |
void (*statistics) (void);
|
|
|
f731ee |
void (*mcastiptomac) (void);
|