From 5a2fa6040e17562ce742df09aa20b8774b3879c5 Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Sun, 15 Jan 2023 21:36:08 +0000 Subject: [autoboot] Include VLAN tag in filter for identifying autoboot device When chainloading iPXE from a VLAN device, the MAC address of the loaded image's device handle will match the MAC address of the trunk device created by iPXE, and the autoboot process will then erroneously consider the trunk device to be an autoboot device. Fix by recording the VLAN tag along with the MAC address, and treating the VLAN tag as part of the filter used to match the MAC address against candidate network devices. Signed-off-by: Michael Brown --- src/usr/autoboot.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) (limited to 'src/usr') diff --git a/src/usr/autoboot.c b/src/usr/autoboot.c index 24043ae69..d1f259621 100644 --- a/src/usr/autoboot.c +++ b/src/usr/autoboot.c @@ -27,6 +27,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); #include #include #include +#include #include #include #include @@ -57,6 +58,9 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); /** Link-layer address of preferred autoboot device, if known */ static uint8_t autoboot_ll_addr[MAX_LL_ADDR_LEN]; +/** VLAN tag of preferred autoboot device, if known */ +static unsigned int autoboot_vlan; + /** Device location of preferred autoboot device, if known */ static struct device_description autoboot_desc; @@ -494,8 +498,9 @@ void set_autoboot_busloc ( unsigned int bus_type, unsigned int location ) { */ static int is_autoboot_ll_addr ( struct net_device *netdev ) { - return ( memcmp ( netdev->ll_addr, autoboot_ll_addr, - netdev->ll_protocol->ll_addr_len ) == 0 ); + return ( ( memcmp ( netdev->ll_addr, autoboot_ll_addr, + netdev->ll_protocol->ll_addr_len ) == 0 ) && + ( vlan_tag ( netdev ) == autoboot_vlan ) ); } /** @@ -503,14 +508,19 @@ static int is_autoboot_ll_addr ( struct net_device *netdev ) { * * @v ll_addr Link-layer address * @v len Length of link-layer address + * @v vlan VLAN tag */ -void set_autoboot_ll_addr ( const void *ll_addr, size_t len ) { +void set_autoboot_ll_addr ( const void *ll_addr, size_t len, + unsigned int vlan ) { /* Record autoboot link-layer address (truncated if necessary) */ if ( len > sizeof ( autoboot_ll_addr ) ) len = sizeof ( autoboot_ll_addr ); memcpy ( autoboot_ll_addr, ll_addr, len ); + /* Record autoboot VLAN tag */ + autoboot_vlan = vlan; + /* Mark autoboot device as present */ is_autoboot_device = is_autoboot_ll_addr; } -- cgit v1.2.3-55-g7522 From e72670ad7ba6f6d8058359c990375e36e71a1cc4 Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Mon, 23 Jan 2023 14:35:57 +0000 Subject: [pxe] Avoid drawing menu items on bottom row of screen Many consoles will scroll immediately upon drawing a character in the rightmost column of the bottom row of the display, in order to be able to advance the cursor to the next character (even if the cursor is disabled). This causes PXE menus to display incorrectly. Specifically, pressing the down arrow key while already on the last menu item may cause the whole screen to scroll and the line to be duplicated. Fix by moving the PXE menu one row up from the bottom of the screen. Signed-off-by: Michael Brown --- src/usr/pxemenu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/usr') diff --git a/src/usr/pxemenu.c b/src/usr/pxemenu.c index 5e497f990..34fdf37ee 100644 --- a/src/usr/pxemenu.c +++ b/src/usr/pxemenu.c @@ -204,7 +204,7 @@ static void pxe_menu_draw_item ( struct pxe_menu *menu, buf[ sizeof ( buf ) - 1 ] = '\0'; /* Draw row */ - row = ( LINES - menu->num_items + index ); + row = ( LINES - menu->num_items + index - 1 ); color_set ( ( selected ? CPAIR_PXE : CPAIR_DEFAULT ), NULL ); mvprintw ( row, 0, "%s", buf ); move ( row, 1 ); -- cgit v1.2.3-55-g7522