git: f4722627bce2 - stable/11 - MFC 874b1a35486b570513680c3d456b062ba097e1d9:

Cy Schubert cy at FreeBSD.org
Thu Apr 1 13:26:01 UTC 2021


The branch stable/11 has been updated by cy:

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

commit f4722627bce29607179fa566c620cdda13fd96df
Author:     Cy Schubert <cy at FreeBSD.org>
AuthorDate: 2021-03-23 03:11:58 +0000
Commit:     Cy Schubert <cy at FreeBSD.org>
CommitDate: 2021-04-01 13:23:59 +0000

    MFC 874b1a35486b570513680c3d456b062ba097e1d9:
    
    ipfilter: simplify ipf_proxy_check() return codes
    
    ipf_proxy_check() returns -1 for an error and 0 or 1 for success.
    ipf_proxy_check()'s callers check for error and if the return code
    is 0, they change it to 1 prior to returning to their callers. Simply
    by returning -1 or 1 we reduce complexity and cycles burned changing
    0 to 1.
    
    (cherry picked from commit 874b1a35486b570513680c3d456b062ba097e1d9)
---
 sys/contrib/ipfilter/netinet/ip_nat.c   | 4 +---
 sys/contrib/ipfilter/netinet/ip_nat6.c  | 4 +---
 sys/contrib/ipfilter/netinet/ip_proxy.c | 3 +--
 3 files changed, 3 insertions(+), 8 deletions(-)

diff --git a/sys/contrib/ipfilter/netinet/ip_nat.c b/sys/contrib/ipfilter/netinet/ip_nat.c
index 6c6479dd1616..d5abe81ee84d 100644
--- a/sys/contrib/ipfilter/netinet/ip_nat.c
+++ b/sys/contrib/ipfilter/netinet/ip_nat.c
@@ -5312,9 +5312,7 @@ ipf_nat_out(fin, nat, natadd, nflags)
 	/* ------------------------------------------------------------- */
 	if ((np != NULL) && (np->in_apr != NULL)) {
 		i = ipf_proxy_check(fin, nat);
-		if (i == 0) {
-			i = 1;
-		} else if (i == -1) {
+		if (i == -1) {
 			NBUMPSIDED(1, ns_ipf_proxy_fail);
 		}
 	} else {
diff --git a/sys/contrib/ipfilter/netinet/ip_nat6.c b/sys/contrib/ipfilter/netinet/ip_nat6.c
index 921eefc0ea3f..baa3c302504a 100644
--- a/sys/contrib/ipfilter/netinet/ip_nat6.c
+++ b/sys/contrib/ipfilter/netinet/ip_nat6.c
@@ -2976,9 +2976,7 @@ ipf_nat6_out(fin, nat, natadd, nflags)
 	/* ------------------------------------------------------------- */
 	if ((np != NULL) && (np->in_apr != NULL)) {
 		i = ipf_proxy_check(fin, nat);
-		if (i == 0) {
-			i = 1;
-		} else if (i == -1) {
+		if (i == -1) {
 			NBUMPSIDE6D(1, ns_ipf_proxy_fail);
 		}
 	} else {
diff --git a/sys/contrib/ipfilter/netinet/ip_proxy.c b/sys/contrib/ipfilter/netinet/ip_proxy.c
index b4773bb6f358..87051b6e6839 100644
--- a/sys/contrib/ipfilter/netinet/ip_proxy.c
+++ b/sys/contrib/ipfilter/netinet/ip_proxy.c
@@ -1048,9 +1048,8 @@ ipf_proxy_check(fin, nat)
 		}
 		aps->aps_bytes += fin->fin_plen;
 		aps->aps_pkts++;
-		return 1;
 	}
-	return 0;
+	return 1;
 }
 
 


More information about the dev-commits-src-all mailing list