git: c941e8c65d9d - main - ipfilter: Correctly type ipf_pullup()

From: Cy Schubert <cy_at_FreeBSD.org>
Date: Thu, 02 Feb 2023 17:41:33 UTC
The branch main has been updated by cy:

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

commit c941e8c65d9df878136dc5d51d70256d33f7769f
Author:     Cy Schubert <cy@FreeBSD.org>
AuthorDate: 2023-01-31 19:09:00 +0000
Commit:     Cy Schubert <cy@FreeBSD.org>
CommitDate: 2023-02-02 17:41:22 +0000

    ipfilter: Correctly type ipf_pullup()
    
    ipf_pullup() outputs a pointer to ip_t. Though returning a pointer to
    void does work, it is imprecise and not completely correct.
    
    MFC after:      1 week
---
 sys/netpfil/ipfilter/netinet/ip_fil.h         |  2 +-
 sys/netpfil/ipfilter/netinet/ip_fil_freebsd.c | 11 ++++++-----
 2 files changed, 7 insertions(+), 6 deletions(-)

diff --git a/sys/netpfil/ipfilter/netinet/ip_fil.h b/sys/netpfil/ipfilter/netinet/ip_fil.h
index 85a79eda1172..002ddfdc8348 100644
--- a/sys/netpfil/ipfilter/netinet/ip_fil.h
+++ b/sys/netpfil/ipfilter/netinet/ip_fil.h
@@ -1700,7 +1700,7 @@ extern	int	ipf_outobj(ipf_main_softc_t *, void *, void *, int);
 extern	int	ipf_outobjk(ipf_main_softc_t *, ipfobj_t *, void *);
 extern	int	ipf_outobjsz(ipf_main_softc_t *, void *, void *,
 				  int, int);
-extern	void	*ipf_pullup(mb_t *, fr_info_t *, int);
+extern	ip_t	*ipf_pullup(mb_t *, fr_info_t *, int);
 extern	int	ipf_resolvedest(ipf_main_softc_t *, char *,
 				     struct frdest *, int);
 extern	int	ipf_resolvefunc(ipf_main_softc_t *, void *);
diff --git a/sys/netpfil/ipfilter/netinet/ip_fil_freebsd.c b/sys/netpfil/ipfilter/netinet/ip_fil_freebsd.c
index b2ee855c3854..0dfc23d3dd1f 100644
--- a/sys/netpfil/ipfilter/netinet/ip_fil_freebsd.c
+++ b/sys/netpfil/ipfilter/netinet/ip_fil_freebsd.c
@@ -1178,17 +1178,17 @@ mbufchainlen(struct mbuf *m0)
 /* We assume that 'xmin' is a pointer to a buffer that is part of the chain */
 /* of buffers that starts at *fin->fin_mp.                                  */
 /* ------------------------------------------------------------------------ */
-void *
+ip_t *
 ipf_pullup(mb_t *xmin, fr_info_t *fin, int len)
 {
 	int dpoff, ipoff;
 	mb_t *m = xmin;
-	char *ip;
+	ip_t *ip;
 
 	if (m == NULL)
 		return (NULL);
 
-	ip = (char *)fin->fin_ip;
+	ip = fin->fin_ip;
 	if ((fin->fin_flx & FI_COALESCE) != 0)
 		return (ip);
 
@@ -1233,6 +1233,7 @@ ipf_pullup(mb_t *xmin, fr_info_t *fin, int len)
 #endif
 		} else
 		{
+
 			m = m_pullup(m, len);
 		}
 		if (n != NULL)
@@ -1259,9 +1260,9 @@ ipf_pullup(mb_t *xmin, fr_info_t *fin, int len)
 			m = m->m_next;
 		}
 		fin->fin_m = m;
-		ip = MTOD(m, char *) + ipoff;
+		ip = MTOD(m, ip_t *) + ipoff;
 
-		fin->fin_ip = (ip_t *)ip;
+		fin->fin_ip = ip;
 		if (fin->fin_dp != NULL)
 			fin->fin_dp = (char *)fin->fin_ip + dpoff;
 		if (fin->fin_fraghdr != NULL)