diff --git a/grub-core/net/drivers/ieee1275/ofnet.c b/grub-core/net/drivers/ieee1275/ofnet.c index cc29d0987..20d45ee3d 100644 --- a/grub-core/net/drivers/ieee1275/ofnet.c +++ b/grub-core/net/drivers/ieee1275/ofnet.c @@ -253,6 +253,7 @@ grub_ofnet_findcards (void) card->flags = 0; shortname = find_alias (alias->path); card->name = grub_xasprintf ("ofnet_%s", shortname ? : alias->path); + card->idle_poll_delay_ms = 1; grub_free (shortname); card->driver = &ofdriver; diff --git a/grub-core/net/net.c b/grub-core/net/net.c index bc16fbde5..641aebd64 100644 --- a/grub-core/net/net.c +++ b/grub-core/net/net.c @@ -768,6 +768,7 @@ receive_packets (struct grub_net_card *card) if (!nb) { grub_print_error (); + card->last_poll = grub_get_time_ms (); return; } @@ -775,6 +776,7 @@ receive_packets (struct grub_net_card *card) if (actual < 0) { grub_netbuff_free (nb); + card->last_poll = grub_get_time_ms (); break; } grub_net_recv_ethernet_packet (nb, card); @@ -800,7 +802,13 @@ grub_net_poll_cards_idle_real (void) { struct grub_net_card *card; FOR_NET_CARDS (card) - receive_packets (card); + { + grub_uint64_t ctime = grub_get_time_ms (); + + if (ctime < card->last_poll + || ctime >= card->last_poll + card->idle_poll_delay_ms) + receive_packets (card); + } } /* Read from the packets list*/ diff --git a/include/grub/net.h b/include/grub/net.h index 92e637d89..45d08f3f5 100644 --- a/include/grub/net.h +++ b/include/grub/net.h @@ -95,6 +95,8 @@ struct grub_net_card grub_net_card_flags_t flags; int num_ifaces; int opened; + unsigned idle_poll_delay_ms; + grub_uint64_t last_poll; union { #ifdef GRUB_MACHINE_EFI