Skip to content

Commit 8c7e2d6

Browse files
committed
[snp] Pad transmit buffer length to work around buggy vendor drivers
The Mellanox/Nvidia UEFI SNP driver is built from the same codebase as the iPXE driver, and appears to contain the bug that was fixed in commit c11734e ("[golan] Use ETH_HLEN for inline header size"). This results in identical failures when using the SNP interface (via e.g. snponly.efi) to drive a Mellanox card while EAPoL is enabled. Work around the underlying UEFI SNP driver bug by padding transmit I/O buffers to the minimum Ethernet frame length before passing them to the underlying SNP driver's Transmit() function. This padding is not technically necessary, since almost all modern hardware will insert transmit padding as necessary (and where the hardware does not support doing so, the underlying SNP driver is responsible for adding any necessary padding). However, it is guaranteed to be harmless (other than a miniscule performance impact): the Ethernet specification requires zero padding up to the minimum frame length for packets that are transmitted onto the wire, and so the receiver will see the same packet whether or not we manually insert this padding in software. The additional padding causes the underlying Mellanox SNP driver to avoid its faulty code path, since it will never be asked to transmit a very short packet. Signed-off-by: Michael Brown <[email protected]>
1 parent c11734e commit 8c7e2d6

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/drivers/net/efi/snpnet.c

+7
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ FILE_LICENCE ( GPL2_OR_LATER );
2626
#include <ipxe/iobuf.h>
2727
#include <ipxe/netdevice.h>
2828
#include <ipxe/ethernet.h>
29+
#include <ipxe/if_ether.h>
2930
#include <ipxe/vsprintf.h>
3031
#include <ipxe/timer.h>
3132
#include <ipxe/efi/efi.h>
@@ -187,6 +188,12 @@ static int snpnet_transmit ( struct net_device *netdev,
187188
return 0;
188189
}
189190

191+
/* Pad to minimum Ethernet length, to work around underlying
192+
* drivers that do not correctly handle frame padding
193+
* themselves.
194+
*/
195+
iob_pad ( iobuf, ETH_ZLEN );
196+
190197
/* Transmit packet */
191198
if ( ( efirc = snp->snp->Transmit ( snp->snp, 0, iob_len ( iobuf ),
192199
iobuf->data, NULL, NULL,

0 commit comments

Comments
 (0)