Commit 73db3b64 authored by Cy Schubert's avatar Cy Schubert
Browse files

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.

MFC after:	1 week
parent 14a634df
...@@ -510,11 +510,10 @@ ipf_p_ftp_addport(softf, fin, ip, nat, ftp, dlen, nport, inc) ...@@ -510,11 +510,10 @@ ipf_p_ftp_addport(softf, fin, ip, nat, ftp, dlen, nport, inc)
fi.fin_src6 = nat->nat_ndst6; fi.fin_src6 = nat->nat_ndst6;
fi.fin_dst6 = nat->nat_nsrc6; fi.fin_dst6 = nat->nat_nsrc6;
if (nat->nat_v[0] == 6) {
#ifndef USE_INET6 #ifndef USE_INET6
if (nat->nat_v[0] == 6)
return APR_INC(inc); return APR_INC(inc);
#endif #endif
}
/* /*
* Add skeleton NAT entry for connection which will come back the * 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) ...@@ -582,15 +581,14 @@ ipf_p_ftp_addport(softf, fin, ip, nat, ftp, dlen, nport, inc)
flags = SI_W_SPORT|NAT_SLAVE|IPN_TCP; flags = SI_W_SPORT|NAT_SLAVE|IPN_TCP;
MUTEX_ENTER(&softn->ipf_nat_new); MUTEX_ENTER(&softn->ipf_nat_new);
if (nat->nat_v[0] == 6) {
#ifdef USE_INET6 #ifdef USE_INET6
if (nat->nat_v[0] == 6)
nat2 = ipf_nat6_add(&fi, ipn, &ftp->ftp_pendnat, flags, nat2 = ipf_nat6_add(&fi, ipn, &ftp->ftp_pendnat, flags,
direction); direction);
else
#endif #endif
} else {
nat2 = ipf_nat_add(&fi, ipn, &ftp->ftp_pendnat, flags, nat2 = ipf_nat_add(&fi, ipn, &ftp->ftp_pendnat, flags,
direction); direction);
}
MUTEX_EXIT(&softn->ipf_nat_new); MUTEX_EXIT(&softn->ipf_nat_new);
if (nat2 == NULL) { if (nat2 == NULL) {
...@@ -950,13 +948,12 @@ ipf_p_ftp_pasvreply(softf, fin, ip, nat, ftp, port, newmsg, s) ...@@ -950,13 +948,12 @@ ipf_p_ftp_pasvreply(softf, fin, ip, nat, ftp, port, newmsg, s)
MUTEX_EXIT(&nat2->nat_lock); MUTEX_EXIT(&nat2->nat_lock);
fi.fin_ifp = NULL; fi.fin_ifp = NULL;
if (nat->nat_dir == NAT_INBOUND) { if (nat->nat_dir == NAT_INBOUND) {
if (nat->nat_v[0] == 6) {
#ifdef USE_INET6 #ifdef USE_INET6
if (nat->nat_v[0] == 6)
fi.fin_dst6 = nat->nat_ndst6; fi.fin_dst6 = nat->nat_ndst6;
else
#endif #endif
} else {
fi.fin_daddr = nat->nat_ndstaddr; fi.fin_daddr = nat->nat_ndstaddr;
}
} }
if (ipf_state_add(softc, &fi, (ipstate_t **)&ftp->ftp_pendstate, if (ipf_state_add(softc, &fi, (ipstate_t **)&ftp->ftp_pendstate,
SI_W_SPORT) != 0) SI_W_SPORT) != 0)
...@@ -979,15 +976,14 @@ ipf_p_ftp_pasvreply(softf, fin, ip, nat, ftp, port, newmsg, s) ...@@ -979,15 +976,14 @@ ipf_p_ftp_pasvreply(softf, fin, ip, nat, ftp, port, newmsg, s)
if (inc != 0) { if (inc != 0) {
fin->fin_plen += inc; fin->fin_plen += inc;
fin->fin_dlen += inc; fin->fin_dlen += inc;
if (nat->nat_v[0] == 6) {
#ifdef USE_INET6 #ifdef USE_INET6
if (nat->nat_v[0] == 6) {
ip6 = (ip6_t *)fin->fin_ip; ip6 = (ip6_t *)fin->fin_ip;
u_short len = ntohs(ip6->ip6_plen) + inc; u_short len = ntohs(ip6->ip6_plen) + inc;
ip6->ip6_plen = htons(len); ip6->ip6_plen = htons(len);
} else
#endif #endif
} else {
ip->ip_len = htons(fin->fin_plen); ip->ip_len = htons(fin->fin_plen);
}
} }
return APR_INC(inc); return APR_INC(inc);
......
...@@ -1354,8 +1354,8 @@ ipf_proxy_rule_rev(nat) ...@@ -1354,8 +1354,8 @@ ipf_proxy_rule_rev(nat)
if (ipn->in_v[0] == 4) { if (ipn->in_v[0] == 4) {
ipn->in_snip = ntohl(nat->nat_odstaddr); ipn->in_snip = ntohl(nat->nat_odstaddr);
ipn->in_dnip = ntohl(nat->nat_nsrcaddr); ipn->in_dnip = ntohl(nat->nat_nsrcaddr);
} else {
#ifdef USE_INET6 #ifdef USE_INET6
} else {
ipn->in_snip6 = nat->nat_odst6; ipn->in_snip6 = nat->nat_odst6;
ipn->in_dnip6 = nat->nat_nsrc6; ipn->in_dnip6 = nat->nat_nsrc6;
#endif #endif
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment