Commit graph

78 commits

Author SHA1 Message Date
Josef Bacik
eb9f401fc1 net: fix ipv6 routing
ipv6 routing in grub2 is broken, we cannot talk to anything outside our local
network or anything that doesn't route in our global namespace.  This patch
fixes this by doing a couple of things

1) Read the router information off of the router advertisement.  If we have a
router lifetime we need to take the source address and create a route from it.

2) Changes the routing stuff slightly to allow you to specify a gateway _and_ an
interface.  Since the router advertisements come in on the link local address we
need to associate it with the global address on the card.  So when we are
processing the router advertisement, either use the SLAAC interface we create
and add the route to that interface, or loop through the global addresses we
currently have on our interface and associate it with one of those addresses.
We need to have a special case here for the default route so that it gets used,
we do this by setting the masksize to 0 to mean it encompasses all networks.
The routing code will automatically select the best route so if there is a
closer match we will use that.

With this patch I can now talk to ipv6 addresses outside of my local network.
Thanks,

Signed-off-by: Josef Bacik <jbacik@fb.com>
2016-02-25 22:38:52 +03:00
Stanislav Kholmanskikh
ee67bcf31e ofnet: Do not set SUFFIX for sun4v network devices
sun4v vnet devices do not implement the support of duplex and speed
instance attributes. An attempt to open such a device with
the attributes will fail:

ok select net:speed=auto,duplex=auto
Unknown key 'speed'
Unknown key 'duplex'
Manual Configuration: Host IP, boot server and filename must be specified
WARNING: /virtual-devices@100/channel-devices@200/network@0: Can't open OBP standard TFTP package

Can't open device
ok

Therefore, let's not set SUFFIX for such devices.

Signed-off-by: Stanislav Kholmanskikh <stanislav.kholmanskikh@oracle.com>
2015-10-07 20:00:52 +03:00
Josef Bacik
4fe8e6d4a1 efinet: handle get_status() on buggy firmware properly
The EFI spec indicates that get_status() should return the address of the buffer
we passed into transmit to indicate the the buffer was transmitted.  However we
have boxes where the firmware returns some arbitrary address instead, which
makes grub think that we've not sent anything.  So since we have the SNP stuff
opened in exclusive mode just assume any non-NULL txbuf means that our transmit
occurred properly.  This makes grub able to do its networking stuff properly on
our broken firmware.  Thanks,

cc: Peter Jones <pjones@redhat.com>
Signed-off-by: Josef Bacik <jbacik@fb.com>
2015-08-09 16:37:26 +03:00
Andrei Borzenkov
f348aee7b3 efinet: enable hardware filters when opening interface
Exclusive open on SNP will close all existing protocol instances which
may disable all receive filters on interface. Reinstall them after we
opened protocol exclusively.

Also follow UEFI specification recommendation and stop interfaces when
closing them:

Unexpected system errors, reboots and hangs can occur if an OS is loaded
and the network devices are not Shutdown() and Stopped().

Also by: Mark Salter <msalter@redhat.com>
Closes: 45204
2015-06-16 19:52:45 +03:00
Andrei Borzenkov
49426e9fd2 efinet: open Simple Network Protocol exclusively
EDK2 network stack is based on Managed Network Protocol which is layered
on top of Simple Management Protocol and does background polling. This
polling races with grub for received (and probably trasmitted) packets
which causes either serious slowdown or complete failure to load files.

Open SNP device exclusively.  This destroys all child MNP instances and
stops background polling.

Exclusive open cannot be done when enumerating cards, as it would destroy
PXE information we need to autoconfigure interface; and it cannot be done
during autoconfiguration as we need to do it for non-PXE boot as well. So
move SNP open to card ->open method and add matching ->close to clean up.

Based on patch from Mark Salter <msalter@redhat.com>

Also-By: Mark Salter <msalter@redhat.com>
Closes: 41731
2015-05-07 20:37:17 +03:00
Andrei Borzenkov
c52ae40570 efinet: skip virtual IPv4 and IPv6 devices when enumerating cards
EDK2 PXE driver creates two child devices - IPv4 and IPv6 - with
bound SNP instance. This means we get three cards for every physical
adapter when enumerating. Not only is this confusing, this may result
in grub ignoring packets that come in via the "wrong" card.

Example of device hierarchy is

 Ctrl[91] PciRoot(0x0)/Pci(0x3,0x0)
   Ctrl[95] PciRoot(0x0)/Pci(0x3,0x0)/MAC(525400123456,0x1)
     Ctrl[B4] PciRoot(0x0)/Pci(0x3,0x0)/MAC(525400123456,0x1)/IPv4(0.0.0.0)
     Ctrl[BC] PciRoot(0x0)/Pci(0x3,0x0)/MAC(525400123456,0x1)/IPv6(0000:0000:0000:0000:0000:0000:0000:0000)

Skip PXE created virtual devices when enumerating cards. Make sure to
find real card when applying initial autoconfiguration during PXE boot,
this information is associated with one of child devices.
2015-05-07 20:37:17 +03:00
Andrei Borzenkov
cc699535e5 Revert "efinet: memory leak on module removal"
This reverts commits 47b2bee3ef
and 8d3c4544ff. It is not safe
to free allocated cards, dangling pointers main remain. Such
cleanup requires more changes in net core.
2015-05-04 09:17:59 +03:00
Andrei Borzenkov
47b2bee3ef efinet: cannot free const char * pointer 2015-05-04 08:39:29 +03:00
Andrei Borzenkov
8d3c4544ff efinet: memory leak on module removal 2015-05-04 08:08:57 +03:00
Martin Wilck
cf2b4a36c4 efinet: Check for immediate completition.
This both speeds GRUB up and workarounds unexpected EFI behaviour.
2015-03-27 14:27:56 +01:00
Vladimir Serbinenko
fe6695b7d6 emunet: Fix init error checking.
Otherwise emunet doesn't expose any cards.
2015-03-20 12:59:00 +01:00
Andrei Borzenkov
12abe75aa0 net/pxe: fix error condition
Test return value of grub_netbuff_reserve(), buf itself cannot be
NULL here.

Found by: Coverity scan.
2015-01-30 22:39:11 +03:00
Paulo Flabiano Smorigo
9585647a25 add bootpath parser for open firmware
It enables net boot even when there is no bootp/dhcp server.

* grub-core/net/drivers/ieee1275/ofnet.c: Add grub_ieee1275_parse_bootpath and
call it at grub_ieee1275_net_config_real.
* grub-core/kern/ieee1275/init.c: Add bootpath to grub_ieee1275_net_config.
* include/grub/ieee1275/ieee1275.h: Likewise.
2014-02-04 19:02:16 -02:00
Vladimir Serbinenko
7e47e27bd8 Add gcc_struct to all packed structures when compiling with mingw.
Just "packed" doesn't always pack the way we expect.
2013-12-15 14:14:30 +01:00
Vladimir Serbinenko
234d93464a * grub-core/disk/ieee1275/ofdisk.c: Remove variable length arrays.
* grub-core/net/drivers/ieee1275/ofnet.c: Likewise.
2013-12-04 08:10:01 +01:00
Vladimir 'phcoder' Serbinenko
70671037c8 Split emunet into platform-dependent and GRUB-binding parts. Keep
platform-dependent part in kernel for easy access to OS functions.
2013-10-15 11:55:20 +02:00
Vladimir 'phcoder' Serbinenko
aabe433afe * grub-core/net/drivers/emu/emunet.c: Move to ..
* grub-core/osdep/linux/emunet.c: ..here.
2013-10-08 18:42:46 +02:00
Avik Sil
412ce9165c * grub-core/net/drivers/ieee1275/ofnet.c: Get proper mac address when using qemu. 2013-08-14 18:03:01 -03:00
Vladimir 'phcoder' Serbinenko
8e71d87482 merge mainline into arm 2013-05-11 10:24:24 +02:00
Leif Lindholm
b385e0723b Leif's API fixes 2013-05-03 15:07:39 +02:00
Vladimir 'phcoder' Serbinenko
fe22b071dc Fix memory leaks in ofnet.
Reported by: Francesco Lavra.
2013-04-13 20:12:11 +02:00
Vladimir 'phcoder' Serbinenko
fa8058da9e Fix few memory leaks. Reported by Francesco Lavra 2013-04-13 20:07:37 +02:00
Vladimir 'phcoder' Serbinenko
b7d17a492f * grub-core/net/drivers/ieee1275/ofnet.c: Don't attempt to send more
than buffer size.
2013-04-12 19:25:16 +02:00
Vladimir 'phcoder' Serbinenko
c86c39abef Add uboot net 2013-04-12 16:55:38 +02:00
Vladimir 'phcoder' Serbinenko
2f1071d57e Resend a packet if we got the wrong buffer in status. 2013-03-17 13:33:16 +01:00
Vladimir 'phcoder' Serbinenko
6e4146c41e Move to more hookless approach in IEEE1275 devices handling. 2013-03-02 23:51:19 +01:00
Colin Watson
794c8c3375 Fix grub-emu build on FreeBSD.
* Makefile.util.def (grub-mount): Add LIBGEOM to ldadd.
* grub-core/net/drivers/emu/emunet.c: Only include Linux-specific
headers on Linux.
(GRUB_MOD_INIT): Return immediately on non-Linux platforms; this
implementation is currently Linux-specific.
* util/getroot.c (exec_pipe): Define only on Linux or when either
libzfs or libnvpair is unavailable.
(find_root_devices_from_poolname): Remove unused path variable.
2012-09-22 21:19:58 +01:00
Vladimir 'phcoder' Serbinenko
f35abd8190 * grub-core/kern/main.c (grub_set_prefix_and_root): Fix memory leak.
* grub-core/net/drivers/ieee1275/ofnet.c
	(grub_ieee1275_net_config_real): Likewise.
2012-06-22 11:51:48 +02:00
Vladimir 'phcoder' Serbinenko
531e2241a6 * grub-core/net/drivers/emu/emunet.c (get_card_packet): Allocate the
reserved bytes.
	* grub-core/net/drivers/i386/pc/pxe.c (grub_pxe_recv): Likewise.
	* grub-core/net/drivers/ieee1275/ofnet.c (get_card_packet): Likewise.
	Handle malloc error correctly.
2012-06-21 22:05:41 +02:00
Vladimir 'phcoder' Serbinenko
e169a1805f * grub-core/net/drivers/ieee1275/ofnet.c (search_net_devices): Decrease
poll rate.
2012-06-19 15:44:51 +02:00
Vladimir 'phcoder' Serbinenko
0494408e7e * include/grub/net.h (grub_net_card): New member txbufsize.
* include/grub/ieee1275/ieee1275.h (grub_ieee1275_flag): New enum values
	GRUB_IEEE1275_FLAG_NO_OFNET_SUFFIX and
	GRUB_IEEE1275_FLAG_VIRT_TO_REAL_BROKEN.
	* grub-core/net/drivers/efi/efinet.c (grub_efinet_findcards): Use
	txbufsize.
	* grub-core/kern/ieee1275/cmain.c (grub_ieee1275_find_options): Use
	compatible property to check for macs. Set
	GRUB_IEEE1275_FLAG_NO_OFNET_SUFFIX and
	GRUB_IEEE1275_FLAG_VIRT_TO_REAL_BROKEN on macs.
	* grub-core/net/drivers/ieee1275/ofnet.c (card_open): Don't add suffix
	if GRUB_IEEE1275_FLAG_NO_OFNET_SUFFIX is set.
	(send_card_buffer): Use txbuf.
	(grub_ofnet_findcards): Allocate txbuf. Simplify code flow and move
	nested function out of the parent while on it.
2012-06-19 11:34:52 +02:00
Vladimir 'phcoder' Serbinenko
cc35fe8f31 * grub-core/net/drivers/ieee1275/ofnet.c (get_card_packet): Fix packet
presence check.
	(grub_ieee1275_net_config_real): Fix config pointer.
2012-06-19 11:25:37 +02:00
Vladimir 'phcoder' Serbinenko
3e74723951 Keep TX and RX buffers on EFI rather than always allocate new ones.
* include/grub/net.h (grub_net_card_driver): Allow driver to modify
	card. All users updated.
	(grub_net_card): New members txbuf, rcvbuf, rcvbufsize and txbusy.
	* grub-core/net/drivers/efi/efinet.c (send_card_buffer): Reuse buffer.
	(get_card_packet): Likewise.
	(grub_efinet_findcards): Init new fields.
2012-06-09 11:00:18 +02:00
Bean
bdf8886428 * grub-core/net/drivers/efi/efinet.c (get_card_packet): Fix buffer
allocation.
2012-04-29 18:43:22 +02:00
Vladimir 'phcoder' Serbinenko
3c491b479c Terminate UNDI and PXE before launching the payload to avoid problems
with DMA.

	* grub-core/commands/boot.c (grub_loader_noreturn): Rename to ...
	(grub_loader_flags): ... this. All users updated.
	(grub_loader_boot): Check for GRUB_LOADER_FLAG_NORETURN.
	* grub-core/loader/i386/pc/pxechainloader.c (grub_cmd_pxechain): Mark
	loader as GRUB_LOADER_FLAG_PXE_NOT_UNLOAD.
	* grub-core/net/drivers/i386/pc/pxe.c (grub_pxe_shutdown): New
	function.
	(grub_pxe_restore): Likewise.
	(fini_hnd): New var.
	(GRUB_MOD_INIT): Register shutdown hook.
	(GRUB_MOD_FINI): Shutdown and unregister shutdown hook.
	* include/grub/loader.h (GRUB_LOADER_FLAG_NORETURN): New const.
	(GRUB_LOADER_FLAG_PXE_NOT_UNLOAD): Likewise.
	(grub_loader_set): Rename second argument to flags.
2012-04-11 22:32:31 +02:00
Vladimir 'phcoder' Serbinenko
1ecd61a47a Fix efi chainloader on network root.
* grub-core/loader/efi/chainloader.c (grub_cmd_chainloader): Handle
	network devices.
	* grub-core/net/drivers/efi/efinet.c (grub_efinet_get_device_handle):
	New function.
2012-03-10 20:41:28 +01:00
Vladimir 'phcoder' Serbinenko
9c4b5c13e6 Improve gettext support. Stylistic fixes and error handling fixes while
on it.
2012-02-08 19:26:01 +01:00
Vladimir 'phcoder' Serbinenko
0a96117de7 * grub-core/Makefile.core.def (pxechain): New module.
* grub-core/loader/i386/pc/pxechainloader.c: New file.
	* grub-core/net/drivers/i386/pc/pxe.c (grub_pxe_get_cached): New
	function.
	(grub_pc_net_config_real): Use grub_pxe_get_cached.
	* include/grub/i386/pc/pxe.h (grub_pxe_get_cached): New proto.
2012-02-05 10:33:52 +01:00
Seth Goldberg
e555f379be * grub-core/net/drivers/i386/pc/pxe.c (grub_pxe_recv): Relax checks as
a workaround for intel problem.
2012-01-24 03:01:46 +01:00
Vladimir 'phcoder' Serbinenko
bd67ad0f70 merge mainline into net 2011-12-15 20:51:35 +01:00
Vladimir 'phcoder' Serbinenko
5d048bf210 * grub-core/net/drivers/ieee1275/ofnet.c (bootp_response_properties):
Make name a const ptr.
2011-12-13 01:07:06 +01:00
Vladimir 'phcoder' Serbinenko
d5e60b1ba0 Add license statement to the emunet 2011-10-05 23:50:43 +02:00
Vladimir 'phcoder' Serbinenko
eb6a7b9788 Hopefully fix EFI problem. Not tested 2011-10-05 23:33:36 +02:00
Vladimir 'phcoder' Serbinenko
5c62099a8f Fix warning on i386-pc 2011-10-05 10:22:23 +02:00
Vladimir 'phcoder' Serbinenko
e2955971a3 move packet allocation to recv code to allow bigger buffers 2011-07-08 20:38:12 +02:00
Vladimir 'phcoder' Serbinenko
6a1af81a97 add mtu information 2011-07-08 18:49:35 +02:00
Vladimir 'phcoder' Serbinenko
d1831ca48a Limit idle polling frequency 2011-07-06 18:21:07 +02:00
Vladimir 'phcoder' Serbinenko
72b9ad936a fix declarations in pxe 2011-07-06 02:49:04 +02:00
Vladimir 'phcoder' Serbinenko
0bc2cd0f82 Reintroduce open/close of net cards. Clean up ofnet. 2011-07-05 16:37:14 +02:00
Vladimir 'phcoder' Serbinenko
671a78acb0 cleanup pxe and efi network release 2011-07-05 14:34:10 +02:00