From owner-dev-commits-src-branches@freebsd.org Mon Oct 4 13:13:17 2021 Return-Path: Delivered-To: dev-commits-src-branches@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id D5DD467E2E6; Mon, 4 Oct 2021 13:13:17 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4HNLkP5TFJz4mDl; Mon, 4 Oct 2021 13:13:17 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 9BB7F19E67; Mon, 4 Oct 2021 13:13:17 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 194DDHfX068351; Mon, 4 Oct 2021 13:13:17 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 194DDH9O068350; Mon, 4 Oct 2021 13:13:17 GMT (envelope-from git) Date: Mon, 4 Oct 2021 13:13:17 GMT Message-Id: <202110041313.194DDH9O068350@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Cy Schubert Subject: git: ffcdbc35a64e - stable/13 - ipfilter: Avoid a null if-then-else blocks MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: cy X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: ffcdbc35a64e3550d8a45609bf3237c2549badfc Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 04 Oct 2021 13:13:17 -0000 The branch stable/13 has been updated by cy: URL: https://cgit.FreeBSD.org/src/commit/?id=ffcdbc35a64e3550d8a45609bf3237c2549badfc commit ffcdbc35a64e3550d8a45609bf3237c2549badfc Author: Cy Schubert AuthorDate: 2021-09-22 04:58:08 +0000 Commit: Cy Schubert CommitDate: 2021-10-04 03:56:58 +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