The branch main has been updated by glebius:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=a29517190335fb88d3e654e42610090fc6f1170b

commit a29517190335fb88d3e654e42610090fc6f1170b
Author:     Gleb Smirnoff <[email protected]>
AuthorDate: 2026-12-04 18:02:53 +0000
Commit:     Gleb Smirnoff <[email protected]>
CommitDate: 2026-12-04 18:02:53 +0000

    bootp: provide mbuf to sosend() instead of uio
    
    This is what kernel users of sockets are supposed to do.  The kernel BOOTP
    client was the last one that didn't.
    
    Differential Revision:  https://reviews.freebsd.org/D62413
---
 sys/kern/uipc_socket.c |  6 ++----
 sys/nfs/bootp_subr.c   | 22 +++++++++-------------
 2 files changed, 11 insertions(+), 17 deletions(-)

diff --git a/sys/kern/uipc_socket.c b/sys/kern/uipc_socket.c
index 0f0fc848fac4..b6c812245472 100644
--- a/sys/kern/uipc_socket.c
+++ b/sys/kern/uipc_socket.c
@@ -2666,10 +2666,8 @@ sosend_generic(struct socket *so, struct sockaddr *addr, 
struct uio *uio,
 /*
  * Send to a socket from a kernel thread.
  *
- * XXXGL: in almost all cases uio is NULL and the mbuf is supplied.
- * Exception is nfs/bootp_subr.c.  It is arguable that the VNET context needs
- * to be set at all.  This function should just boil down to a static inline
- * calling the protocol method.
+ * It is arguable that the VNET context needs to be set at all.  This function
+ * should just boil down to a static inline calling the protocol method.
  */
 int
 sosend(struct socket *so, struct sockaddr *addr, struct uio *uio,
diff --git a/sys/nfs/bootp_subr.c b/sys/nfs/bootp_subr.c
index 6b05a4ec0797..bf48ed2b3c20 100644
--- a/sys/nfs/bootp_subr.c
+++ b/sys/nfs/bootp_subr.c
@@ -122,6 +122,8 @@ struct bootp_packet {
        char file[128];
        unsigned char vend[1222];
 };
+_Static_assert(sizeof(struct bootp_packet) <= MCLBYTES,
+  "bootp packet does not fit in mbuf cluster");
 
 struct bootpc_ifcontext {
        STAILQ_ENTRY(bootpc_ifcontext) next;
@@ -491,6 +493,7 @@ bootpc_call(struct bootpc_globalcontext *gctx, struct 
thread *td)
        time_t rtimo;
        struct timeval tv;
        struct bootpc_ifcontext *ifctx;
+       struct mbuf *m;
        int outstanding;
        int gotrootpath;
        int retry;
@@ -624,17 +627,6 @@ bootpc_call(struct bootpc_globalcontext *gctx, struct 
thread *td)
                                ifctx->sentmsg = 1;
                        }
 
-                       aio.iov_base = (caddr_t) &ifctx->call;
-                       aio.iov_len = sizeof(ifctx->call);
-
-                       auio.uio_iov = &aio;
-                       auio.uio_iovcnt = 1;
-                       auio.uio_segflg = UIO_SYSSPACE;
-                       auio.uio_rw = UIO_WRITE;
-                       auio.uio_offset = 0;
-                       auio.uio_resid = sizeof(ifctx->call);
-                       auio.uio_td = td;
-
                        /* Set netmask to 0.0.0.0 */
                        clear_sinaddr(sin);
                        error = ifioctl(bootp_so, SIOCAIFADDR, (caddr_t)ifra,
@@ -643,8 +635,12 @@ bootpc_call(struct bootpc_globalcontext *gctx, struct 
thread *td)
                                panic("%s: SIOCAIFADDR, error=%d", __func__,
                                    error);
 
-                       error = sosend(bootp_so, (struct sockaddr *) &dst,
-                                      &auio, NULL, NULL, 0, td);
+                       m = m_getcl(M_WAITOK, MT_DATA, M_PKTHDR);
+                       memcpy(mtod(m, void *), &ifctx->call,
+                           sizeof(ifctx->call));
+                       m->m_pkthdr.len = m->m_len = sizeof(ifctx->call);
+                       error = sosend(bootp_so, (struct sockaddr *)&dst, NULL,
+                           m, NULL, 0, td);
                        if (error != 0)
                                printf("%s: sosend: %d state %08x\n", __func__,
                                    error, (int )bootp_so->so_state);

Reply via email to