git: 18a405b1ac7f - stable/14 - ip_nat.c: fix non-trivial unused variable warnings

From: Cy Schubert <cy_at_FreeBSD.org>
Date: Sun, 10 Aug 2025 05:24:51 UTC
The branch stable/14 has been updated by cy:

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

commit 18a405b1ac7fd681377bc9db27bb199b0b2a9133
Author:     Siva Mahadevan <me@svmhdvn.name>
AuthorDate: 2025-04-24 12:08:47 +0000
Commit:     Cy Schubert <cy@FreeBSD.org>
CommitDate: 2025-08-10 05:23:59 +0000

    ip_nat.c: fix non-trivial unused variable warnings
    
    Pull Request:   https://github.com/freebsd/freebsd-src/pull/1677
    MFC after:      1 month
    
    (cherry picked from commit 2bae5cad793bd67c071ade7c7a8ae9d4b34e6b6c)
---
 sys/netpfil/ipfilter/netinet/ip_nat.c | 43 +++++++++++------------------------
 1 file changed, 13 insertions(+), 30 deletions(-)

diff --git a/sys/netpfil/ipfilter/netinet/ip_nat.c b/sys/netpfil/ipfilter/netinet/ip_nat.c
index 136bc31ba0f4..290af20e4765 100644
--- a/sys/netpfil/ipfilter/netinet/ip_nat.c
+++ b/sys/netpfil/ipfilter/netinet/ip_nat.c
@@ -3228,13 +3228,10 @@ ipf_nat_finalise(fr_info_t *fin, nat_t *nat)
 	ipf_nat_softc_t *softn = softc->ipf_nat_soft;
 	u_32_t sum1, sum2, sumd;
 	frentry_t *fr;
-	u_32_t flags;
 #if SOLARIS && defined(_KERNEL) && defined(ICK_M_CTL_MAGIC)
 	qpktinfo_t *qpi = fin->fin_qpi;
 #endif
 
-	flags = nat->nat_flags;
-
 	switch (nat->nat_pr[0])
 	{
 	case IPPROTO_ICMP :
@@ -3542,8 +3539,8 @@ ipf_nat_icmperrorlookup(fr_info_t *fin, int dir)
 {
 	ipf_main_softc_t *softc = fin->fin_main_soft;
 	ipf_nat_softc_t *softn = softc->ipf_nat_soft;
-	int flags = 0, type, minlen;
-	icmphdr_t *icmp, *orgicmp;
+	int flags = 0, minlen;
+	icmphdr_t *orgicmp;
 	nat_stat_side_t *nside;
 	tcphdr_t *tcp = NULL;
 	u_short data[2];
@@ -3551,8 +3548,6 @@ ipf_nat_icmperrorlookup(fr_info_t *fin, int dir)
 	ip_t *oip;
 	u_int p;
 
-	icmp = fin->fin_dp;
-	type = icmp->icmp_type;
 	nside = &softn->ipf_nat_stats.ns_side[fin->fin_out];
 	/*
 	 * Does it at least have the return (basic) IP header ?
@@ -4003,9 +3998,7 @@ ipf_nat_inlookup(fr_info_t *fin, u_int flags, u_int p,
 	ipf_main_softc_t *softc = fin->fin_main_soft;
 	ipf_nat_softc_t *softn = softc->ipf_nat_soft;
 	u_short sport, dport;
-	grehdr_t *gre;
 	ipnat_t *ipn;
-	u_int sflags;
 	nat_t *nat;
 	int nflags;
 	u_32_t dst;
@@ -4013,9 +4006,7 @@ ipf_nat_inlookup(fr_info_t *fin, u_int flags, u_int p,
 	u_int hv, rhv;
 
 	ifp = fin->fin_ifp;
-	gre = NULL;
 	dst = mapdst.s_addr;
-	sflags = flags & NAT_TCPUDPICMP;
 
 	switch (p)
 	{
@@ -4334,14 +4325,12 @@ ipf_nat_outlookup(fr_info_t *fin, u_int flags, u_int p,
 	ipf_main_softc_t *softc = fin->fin_main_soft;
 	ipf_nat_softc_t *softn = softc->ipf_nat_soft;
 	u_short sport, dport;
-	u_int sflags;
 	ipnat_t *ipn;
 	nat_t *nat;
 	void *ifp;
 	u_int hv;
 
 	ifp = fin->fin_ifp;
-	sflags = flags & IPN_TCPUDPICMP;
 
 	switch (p)
 	{
@@ -4760,7 +4749,6 @@ ipf_nat_checkout(fr_info_t *fin, u_32_t *passp)
 	struct ifnet *ifp, *sifp;
 	ipf_main_softc_t *softc;
 	ipf_nat_softc_t *softn;
-	icmphdr_t *icmp = NULL;
 	tcphdr_t *tcp = NULL;
 	int rval, natfailed;
 	u_int nflags = 0;
@@ -4806,8 +4794,6 @@ ipf_nat_checkout(fr_info_t *fin, u_32_t *passp)
 			nflags = IPN_UDP;
 			break;
 		case IPPROTO_ICMP :
-			icmp = fin->fin_dp;
-
 			/*
 			 * This is an incoming packet, so the destination is
 			 * the icmp_id and the source port equals 0
@@ -5467,7 +5453,10 @@ ipf_nat_in(fr_info_t *fin, nat_t *nat, int natadd, u_32_t nflags)
 {
 	ipf_main_softc_t *softc = fin->fin_main_soft;
 	ipf_nat_softc_t *softn = softc->ipf_nat_soft;
-	u_32_t sumd, ipsumd, sum1, sum2;
+	u_32_t sumd, sum1, sum2;
+#if !defined(_KERNEL) || SOLARIS
+	u_32_t ipsumd;
+#endif
 	icmphdr_t *icmp;
 	tcphdr_t *tcp;
 	ipnat_t *np;
@@ -5503,7 +5492,9 @@ ipf_nat_in(fr_info_t *fin, nat_t *nat, int natadd, u_32_t nflags)
 
 	ipf_sync_update(softc, SMC_NAT, fin, nat->nat_sync);
 
+#if !defined(_KERNEL) || SOLARIS
 	ipsumd = nat->nat_ipsumd;
+#endif
 	/*
 	 * Fix up checksums, not by recalculating them, but
 	 * simply computing adjustments.
@@ -5525,7 +5516,9 @@ ipf_nat_in(fr_info_t *fin, nat_t *nat, int natadd, u_32_t nflags)
 			sum1 = nat->nat_osrcaddr;
 			sum2 = nat->nat_nsrcaddr;
 			CALC_SUMD(sum1, sum2, sumd);
+#if !defined(_KERNEL) || SOLARIS
 			ipsumd -= sumd;
+#endif
 		}
 		fin->fin_ip->ip_dst = nat->nat_ndstip;
 		fin->fin_daddr = nat->nat_ndstaddr;
@@ -5542,7 +5535,9 @@ ipf_nat_in(fr_info_t *fin, nat_t *nat, int natadd, u_32_t nflags)
 			sum1 = nat->nat_odstaddr;
 			sum2 = nat->nat_ndstaddr;
 			CALC_SUMD(sum1, sum2, sumd);
+#if !defined(_KERNEL) || SOLARIS
 			ipsumd -= sumd;
+#endif
 		}
 		fin->fin_ip->ip_dst = nat->nat_osrcip;
 		fin->fin_daddr = nat->nat_osrcaddr;
@@ -7356,30 +7351,18 @@ ipf_nat_nextaddr(fr_info_t *fin, nat_addr_t *na, u_32_t *old, u_32_t *dst)
 {
 	ipf_main_softc_t *softc = fin->fin_main_soft;
 	ipf_nat_softc_t *softn = softc->ipf_nat_soft;
-	u_32_t amin, amax, new;
+	u_32_t new;
 	i6addr_t newip;
 	int error;
 
 	new = 0;
-	amin = na->na_addr[0].in4.s_addr;
 
 	switch (na->na_atype)
 	{
 	case FRI_RANGE :
-		amax = na->na_addr[1].in4.s_addr;
-		break;
-
 	case FRI_NETMASKED :
 	case FRI_DYNAMIC :
 	case FRI_NORMAL :
-		/*
-		 * Compute the maximum address by adding the inverse of the
-		 * netmask to the minimum address.
-		 */
-		amax = ~na->na_addr[1].in4.s_addr;
-		amax |= amin;
-		break;
-
 	case FRI_LOOKUP :
 		break;