git: 3b6536d03006 - stable/13 - ip_nat.c: fix non-trivial unused variable warnings
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Sun, 10 Aug 2025 05:55:39 UTC
The branch stable/13 has been updated by cy:
URL: https://cgit.FreeBSD.org/src/commit/?id=3b6536d03006240e938abbf0e6fa1d926647225e
commit 3b6536d03006240e938abbf0e6fa1d926647225e
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:55:15 +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 cc62e93ba2f8..35b18575ac6f 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 :
@@ -3545,8 +3542,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];
@@ -3554,8 +3551,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 ?
@@ -4006,9 +4001,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;
@@ -4016,9 +4009,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)
{
@@ -4337,14 +4328,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)
{
@@ -4763,7 +4752,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;
@@ -4809,8 +4797,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
@@ -5470,7 +5456,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;
@@ -5506,7 +5495,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.
@@ -5528,7 +5519,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;
@@ -5545,7 +5538,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;
@@ -7359,30 +7354,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;