git: 5c385a54fe9c - main - debugnet: Use precise types when accessing mbuf contents
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Fri, 11 Oct 2024 13:23:52 UTC
The branch main has been updated by markj:
URL: https://cgit.FreeBSD.org/src/commit/?id=5c385a54fe9ccbd3f28f20b5a025a856d229fa05
commit 5c385a54fe9ccbd3f28f20b5a025a856d229fa05
Author: Mark Johnston <markj@FreeBSD.org>
AuthorDate: 2024-10-09 15:28:57 +0000
Commit: Mark Johnston <markj@FreeBSD.org>
CommitDate: 2024-10-11 13:23:25 +0000
debugnet: Use precise types when accessing mbuf contents
This might be useful when adding bounds checks to mtod(). No functional
change intended.
MFC after: 1 week
---
sys/net/debugnet.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/sys/net/debugnet.c b/sys/net/debugnet.c
index 8b1419bcaa28..32a91256f51d 100644
--- a/sys/net/debugnet.c
+++ b/sys/net/debugnet.c
@@ -199,7 +199,7 @@ debugnet_udp_output(struct debugnet_pcb *pcb, struct mbuf *m)
return (ENOBUFS);
}
- udp = mtod(m, void *);
+ udp = mtod(m, struct udphdr *);
udp->uh_ulen = htons(m->m_pkthdr.len);
/* Use this src port so that the server can connect() the socket */
udp->uh_sport = htons(pcb->dp_client_port);
@@ -226,7 +226,7 @@ debugnet_ack_output(struct debugnet_pcb *pcb, uint32_t seqno /* net endian */)
m->m_len = sizeof(*dn_ack);
m->m_pkthdr.len = sizeof(*dn_ack);
MH_ALIGN(m, sizeof(*dn_ack));
- dn_ack = mtod(m, void *);
+ dn_ack = mtod(m, struct debugnet_ack *);
dn_ack->da_seqno = seqno;
return (debugnet_udp_output(pcb, m));
@@ -400,7 +400,7 @@ debugnet_handle_rx_msg(struct debugnet_pcb *pcb, struct mbuf **mb)
}
}
- dnh = mtod(m, const void *);
+ dnh = mtod(m, const struct debugnet_msg_hdr *);
if (ntohl(dnh->mh_len) + sizeof(*dnh) > m->m_pkthdr.len) {
DNETDEBUG("Dropping short packet.\n");
return;
@@ -459,7 +459,7 @@ debugnet_handle_ack(struct debugnet_pcb *pcb, struct mbuf **mb, uint16_t sport)
return;
}
}
- dn_ack = mtod(m, const void *);
+ dn_ack = mtod(m, const struct debugnet_ack *);
/* Debugnet processing. */
/*
@@ -503,7 +503,7 @@ debugnet_handle_udp(struct debugnet_pcb *pcb, struct mbuf **mb)
return;
}
}
- udp = mtod(m, const void *);
+ udp = mtod(m, const struct udphdr *);
/* We expect to receive UDP packets on the configured client port. */
if (ntohs(udp->uh_dport) != pcb->dp_client_port) {