From 6c50564724bcce292fbe76010d637390c17d407a Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Sat, 27 May 2006 13:39:45 +0000 Subject: [PATCH] Make PKB_ZLEN the minimum possible size of packet buffer (to allow for hardware that can't autopad). --- src/include/gpxe/pkbuff.h | 9 +++++++++ src/net/pkbuff.c | 4 ++++ 2 files changed, 13 insertions(+) diff --git a/src/include/gpxe/pkbuff.h b/src/include/gpxe/pkbuff.h index 92244fd5..6c504029 100644 --- a/src/include/gpxe/pkbuff.h +++ b/src/include/gpxe/pkbuff.h @@ -28,6 +28,15 @@ struct ll_protocol; */ #define PKBUFF_ALIGN 2048 +/** + * Minimum packet buffer length + * + * alloc_pkb() will round up the allocated length to this size if + * necessary. This is used on behalf of hardware that is not capable + * of auto-padding. + */ +#define PKB_ZLEN 64 + /** A packet buffer * * This structure is used to represent a network packet within gPXE. diff --git a/src/net/pkbuff.c b/src/net/pkbuff.c index 964fbf62..ac308830 100644 --- a/src/net/pkbuff.c +++ b/src/net/pkbuff.c @@ -39,6 +39,10 @@ struct pk_buff * alloc_pkb ( size_t len ) { struct pk_buff *pkb = NULL; void *data; + /* Pad to minimum length */ + if ( len < PKB_ZLEN ) + len = PKB_ZLEN; + /* Align buffer length */ len = ( len + __alignof__( *pkb ) - 1 ) & ~( __alignof__( *pkb ) - 1 );