Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 9 Feb 2023 21:19:58 GMT
From:      Cy Schubert <cy@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org
Subject:   git: 0dbe2e4e8f85 - stable/13 - ipfilter: Correctly type ipf_pullup()
Message-ID:  <202302092119.319LJwp3043762@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch stable/13 has been updated by cy:

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

commit 0dbe2e4e8f85ce1869a87f112a4a1e8c5f8f1145
Author:     Cy Schubert <cy@FreeBSD.org>
AuthorDate: 2023-01-31 19:09:00 +0000
Commit:     Cy Schubert <cy@FreeBSD.org>
CommitDate: 2023-02-09 21:19:41 +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.
    
    (cherry picked from commit c941e8c65d9df878136dc5d51d70256d33f7769f)
---
 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 57a006ed5393..fa0cdbab0ab3 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)



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202302092119.319LJwp3043762>