git: 874b1a35486b - main - ipfilter: simplify ipf_proxy_check() return codes
Cy Schubert
cy at FreeBSD.org
Wed Mar 24 08:59:01 UTC 2021
The branch main has been updated by cy:
URL: https://cgit.FreeBSD.org/src/commit/?id=874b1a35486b570513680c3d456b062ba097e1d9
commit 874b1a35486b570513680c3d456b062ba097e1d9
Author: Cy Schubert <cy at FreeBSD.org>
AuthorDate: 2021-03-23 03:11:58 +0000
Commit: Cy Schubert <cy at FreeBSD.org>
CommitDate: 2021-03-24 08:57:56 +0000
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.
MFC after: 1 week
---
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 9ce6063eb7f3..41e51880b3dd 100644
--- a/sys/contrib/ipfilter/netinet/ip_nat.c
+++ b/sys/contrib/ipfilter/netinet/ip_nat.c
@@ -5318,9 +5318,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-main
mailing list