]> git.ipfire.org Git - thirdparty/ipxe.git/commitdiff
[xfer] Use xfer_alloc_iob() for transmit I/O buffers on stream sockets
authorMichael Brown <mcb30@ipxe.org>
Sun, 30 Mar 2025 20:47:34 +0000 (21:47 +0100)
committerMichael Brown <mcb30@ipxe.org>
Sun, 30 Mar 2025 20:47:34 +0000 (21:47 +0100)
Datagram sockets such as UDP, ICMP, and fibre channel tend to provide
a custom xfer_alloc_iob() handler to ensure that transmit I/O buffers
contain sufficient headroom to accommodate any required protocol
headers.

Stream sockets such as TCP and TLS do not typically provide a custom
xfer_alloc_iob() handler at present.  The default handler simply calls
alloc_iob(), and so stream socket consumers can therefore get away
with using alloc_iob() rather than xfer_alloc_iob().

Fix the HTTP and ONC RPC protocols to use xfer_alloc_iob() where
relevant, in order to operate correctly if the underlying stream
socket chooses to provide a custom xfer_alloc_iob() handler.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
src/net/tcp/httpcore.c
src/net/tcp/oncrpc.c

index af2a237cfc9d1491739a84317b34986bec36f875..7052bbbad725563dde3e66f3655e6b9d72679c1d 100644 (file)
@@ -1090,7 +1090,8 @@ static int http_tx_request ( struct http_transaction *http ) {
        }
 
        /* Allocate I/O buffer */
-       iobuf = alloc_iob ( len + 1 /* NUL */ + http->request.content.len );
+       iobuf = xfer_alloc_iob ( &http->conn, ( len + 1 /* NUL */ +
+                                               http->request.content.len ) );
        if ( ! iobuf ) {
                rc = -ENOMEM;
                goto err_alloc;
index cb66aeb85163f4afa33ed2b83a50b990b236d8ee..64734a80841cc14d7ddfa15403749754a6910ed5 100644 (file)
@@ -150,7 +150,7 @@ int oncrpc_call ( struct interface *intf, struct oncrpc_session *session,
        frame_size  = oncrpc_compute_size ( header );
        frame_size += oncrpc_compute_size ( fields );
 
-       io_buf = alloc_iob ( frame_size );
+       io_buf = xfer_alloc_iob ( intf, frame_size );
        if ( ! io_buf )
                return -ENOBUFS;