Hello Yasuoka,

On Wed, Jul 29, 2020 at 01:22:48AM +0900, YASUOKA Masahiko wrote:
> Hi,
> 
> Previous commit has a wrong part..
> 
> ok?
> 
> Fix previous commit which referred wrong address.

    would it make sense to move the block, you've introduced earler
    under the !PF_AZERO() branch just couple lines below. something
    like this:

--------8<---------------8<---------------8<------------------8<--------
diff --git a/sys/net/pf_lb.c b/sys/net/pf_lb.c
index 510795a4d0b..f77d96a99ec 100644
--- a/sys/net/pf_lb.c
+++ b/sys/net/pf_lb.c
@@ -322,13 +322,13 @@ pf_map_addr_sticky(sa_family_t af, struct pf_rule *r, 
struct pf_addr *saddr,
                return (-1);
        }
 
-       if ((rpool->opts & PF_POOL_TYPEMASK) == PF_POOL_LEASTSTATES) {
-               if (pf_map_addr_states_increase(af, rpool, naddr) == -1)
+       if (!PF_AZERO(cached, af)) {
+               pf_addrcpy(naddr, cached, af);
+               if ((rpool->opts & PF_POOL_TYPEMASK) == PF_POOL_LEASTSTATES) &&
+                   ((pf_map_addr_states_increase(af, rpool, cached) == -1))
                        return (-1);
        }
 
-       if (!PF_AZERO(cached, af))
-               pf_addrcpy(naddr, cached, af);
        if (pf_status.debug >= LOG_DEBUG) {
                log(LOG_DEBUG, "pf: pf_map_addr: "
                    "src tracking (%u) maps ", type);

--------8<---------------8<---------------8<------------------8<--------

It seems to me it would be better to bump number of states if and only if we
actually find some address in pool.

thanks and
regards
sashan

Reply via email to