git: 931fb0359e2b - stable/12 - ipfilter: Avoid a null if-then-else blocks
Cy Schubert
cy at FreeBSD.org
Mon Oct 4 13:15:37 UTC 2021
The branch stable/12 has been updated by cy:
URL: https://cgit.FreeBSD.org/src/commit/?id=931fb0359e2b643a76a40b90883a1ba1d3cac3cd
commit 931fb0359e2b643a76a40b90883a1ba1d3cac3cd
Author: Cy Schubert <cy at FreeBSD.org>
AuthorDate: 2021-09-22 04:58:08 +0000
Commit: Cy Schubert <cy at FreeBSD.org>
CommitDate: 2021-10-04 03:59:31 +0000
ipfilter: Avoid a null if-then-else blocks
When WITHOUT_INET6 is selected we generate a null if-then-else blocks
due to incorrect placment of #if statments. Move the #if statements
reducing unnecessary runtime comparisons WITHOUT_INET6.
(cherry picked from commit 73db3b64f167972db3ee3f780cecb439b09492b1)
---
sys/contrib/ipfilter/netinet/ip_ftp_pxy.c | 18 +++++++-----------
sys/contrib/ipfilter/netinet/ip_proxy.c | 2 +-
2 files changed, 8 insertions(+), 12 deletions(-)
diff --git a/sys/contrib/ipfilter/netinet/ip_ftp_pxy.c b/sys/contrib/ipfilter/netinet/ip_ftp_pxy.c
index 5d8f9f1f51f7..c4ee0ef593df 100644
--- a/sys/contrib/ipfilter/netinet/ip_ftp_pxy.c
+++ b/sys/contrib/ipfilter/netinet/ip_ftp_pxy.c
@@ -510,11 +510,10 @@ ipf_p_ftp_addport(softf, fin, ip, nat, ftp, dlen, nport, inc)
fi.fin_src6 = nat->nat_ndst6;
fi.fin_dst6 = nat->nat_nsrc6;
- if (nat->nat_v[0] == 6) {
#ifndef USE_INET6
+ if (nat->nat_v[0] == 6)
return APR_INC(inc);
#endif
- }
/*
* Add skeleton NAT entry for connection which will come back the
@@ -582,15 +581,14 @@ ipf_p_ftp_addport(softf, fin, ip, nat, ftp, dlen, nport, inc)
flags = SI_W_SPORT|NAT_SLAVE|IPN_TCP;
MUTEX_ENTER(&softn->ipf_nat_new);
- if (nat->nat_v[0] == 6) {
#ifdef USE_INET6
+ if (nat->nat_v[0] == 6)
nat2 = ipf_nat6_add(&fi, ipn, &ftp->ftp_pendnat, flags,
direction);
+ else
#endif
- } else {
nat2 = ipf_nat_add(&fi, ipn, &ftp->ftp_pendnat, flags,
direction);
- }
MUTEX_EXIT(&softn->ipf_nat_new);
if (nat2 == NULL) {
@@ -950,13 +948,12 @@ ipf_p_ftp_pasvreply(softf, fin, ip, nat, ftp, port, newmsg, s)
MUTEX_EXIT(&nat2->nat_lock);
fi.fin_ifp = NULL;
if (nat->nat_dir == NAT_INBOUND) {
- if (nat->nat_v[0] == 6) {
#ifdef USE_INET6
+ if (nat->nat_v[0] == 6)
fi.fin_dst6 = nat->nat_ndst6;
+ else
#endif
- } else {
fi.fin_daddr = nat->nat_ndstaddr;
- }
}
if (ipf_state_add(softc, &fi, (ipstate_t **)&ftp->ftp_pendstate,
SI_W_SPORT) != 0)
@@ -979,15 +976,14 @@ ipf_p_ftp_pasvreply(softf, fin, ip, nat, ftp, port, newmsg, s)
if (inc != 0) {
fin->fin_plen += inc;
fin->fin_dlen += inc;
- if (nat->nat_v[0] == 6) {
#ifdef USE_INET6
+ if (nat->nat_v[0] == 6) {
ip6 = (ip6_t *)fin->fin_ip;
u_short len = ntohs(ip6->ip6_plen) + inc;
ip6->ip6_plen = htons(len);
+ } else
#endif
- } else {
ip->ip_len = htons(fin->fin_plen);
- }
}
return APR_INC(inc);
diff --git a/sys/contrib/ipfilter/netinet/ip_proxy.c b/sys/contrib/ipfilter/netinet/ip_proxy.c
index 87051b6e6839..4399a9cde8e4 100644
--- a/sys/contrib/ipfilter/netinet/ip_proxy.c
+++ b/sys/contrib/ipfilter/netinet/ip_proxy.c
@@ -1354,8 +1354,8 @@ ipf_proxy_rule_rev(nat)
if (ipn->in_v[0] == 4) {
ipn->in_snip = ntohl(nat->nat_odstaddr);
ipn->in_dnip = ntohl(nat->nat_nsrcaddr);
- } else {
#ifdef USE_INET6
+ } else {
ipn->in_snip6 = nat->nat_odst6;
ipn->in_dnip6 = nat->nat_nsrc6;
#endif
More information about the dev-commits-src-all
mailing list