Skip to contentSkip to conversation

ip_vs_lblcr logic error causing table flushing

PATCH In review Simon Kirby 2 participants 4 messages Nov 5, 2009

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

[ Resent with a reasonable subject and to lvs-devel :) ]

Hello!

I was noticing a significant amount of what seems/seemed to be destination lists with multiple entries with the lblcr LVS algorithm. While tracking it down, I think I stumbled over a mistake. In ip_vs_lblcr_full_check(), it appears the time check logic is reversed:

        for (i=0, j=tbl->rover; i<IP_VS_LBLCR_TAB_SIZE; i++) {
                j = (j + 1) & IP_VS_LBLCR_TAB_MASK;

                write_lock(&svc->sched_lock);
                list_for_each_entry_safe(en, nxt, &tbl->bucket[j], list) {
                        if (time_after(en->lastuse+sysctl_ip_vs_lblcr_expiration,
                                       now))
                                continue;
                        
                        ip_vs_lblcr_free(en);
                        atomic_dec(&tbl->entries);
                }
                write_unlock(&svc->sched_lock);
        }

Shouldn't this be "time_before"? It seems that it currently nukes all recently-used entries every time this function is called, which seems to be every 30 minutes, rather than removing the not-recently-used ones.

If my reading is correct, this patch should fix it. Am I missing something?

Cheers,

Simon-

net/netfilter/ipvs/ip_vs_lblcr.c +1 -1
index 715b57f..937743f 100644
@@ -432,7 +432,7 @@ static inline void ip_vs_lblcr_full_check(struct ip_vs_service *svc)
 
 		write_lock(&svc->sched_lock);
 		list_for_each_entry_safe(en, nxt, &tbl->bucket[j], list) {
-			if (time_after(en->lastuse+sysctl_ip_vs_lblcr_expiration,
+			if (time_before(en->lastuse+sysctl_ip_vs_lblcr_expiration,
 				       now))
 				continue;
 
maintainer
#1 lore raw
Quoted 40 lines · Simon Kirby

[ Resent with a reasonable subject and to lvs-devel :) ]

Hello!

I was noticing a significant amount of what seems/seemed to be destination lists with multiple entries with the lblcr LVS algorithm. While tracking it down, I think I stumbled over a mistake. In ip_vs_lblcr_full_check(), it appears the time check logic is reversed:

        for (i=0, j=tbl->rover; i<IP_VS_LBLCR_TAB_SIZE; i++) {
                j = (j + 1) & IP_VS_LBLCR_TAB_MASK;

                write_lock(&svc->sched_lock);
                list_for_each_entry_safe(en, nxt, &tbl->bucket[j], list) {
                        if (time_after(en->lastuse+sysctl_ip_vs_lblcr_expiration,
                                       now))
                                continue;
                        
                        ip_vs_lblcr_free(en);
                        atomic_dec(&tbl->entries);
                }
                write_unlock(&svc->sched_lock);
        }

Shouldn't this be "time_before"? It seems that it currently nukes all recently-used entries every time this function is called, which seems to be every 30 minutes, rather than removing the not-recently-used ones.

If my reading is correct, this patch should fix it. Am I missing something?

Cheers,

Simon-

net/netfilter/ipvs/ip_vs_lblcr.c +0 -0
index 715b57f..937743f 100644

net/netfilter/ipvs/ip_vs_lblcr.c static inline void ip_vs_lblcr_full_check(struct ip_vs_service *svc) · line 438

Quoted 8 lines
net/netfilter/ipvs/ip_vs_lblcr.c +1 -1
@@ -432,7 +432,7 @@ static inline void ip_vs_lblcr_full_check(struct ip_vs_service *svc)
 
 		write_lock(&svc->sched_lock);
 		list_for_each_entry_safe(en, nxt, &tbl->bucket[j], list) {
-			if (time_after(en->lastuse+sysctl_ip_vs_lblcr_expiration,
+			if (time_before(en->lastuse+sysctl_ip_vs_lblcr_expiration,
 				       now))
 				continue;
 

Hi Simon,

your analysis seems correct to me. Could you supply a Signed-off-line with the patch and I'll see about getting it merged.

#2 lore raw

PATCH 1/1 Fix ip_vs_lblcr_full_check to remove unused entries instead of used entries.

Tested with real packets -- seems to work.

---
 net/netfilter/ipvs/ip_vs_lblcr.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
net/netfilter/ipvs/ip_vs_lblcr.c +1 -1
index 715b57f..937743f 100644
@@ -432,7 +432,7 @@ static inline void ip_vs_lblcr_full_check(struct ip_vs_service *svc)
 
 		write_lock(&svc->sched_lock);
 		list_for_each_entry_safe(en, nxt, &tbl->bucket[j], list) {
-			if (time_after(en->lastuse+sysctl_ip_vs_lblcr_expiration,
+			if (time_before(en->lastuse+sysctl_ip_vs_lblcr_expiration,
 				       now))
 				continue;
 
Signature · 1 line
1.6.5.2
#3 lore raw

Re: [PATCH] Fix ip_vs_lblcr_full_check to remove unused entries instead of used entries.

D'oh. Don't apply this -- the argument order makes the original correct.

Simon-

Quoted 23 lines · Simon Kirby

Tested with real packets -- seems to work.

---
 net/netfilter/ipvs/ip_vs_lblcr.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
net/netfilter/ipvs/ip_vs_lblcr.c +1 -1
index 715b57f..937743f 100644
@@ -432,7 +432,7 @@ static inline void ip_vs_lblcr_full_check(struct ip_vs_service *svc)
 
 		write_lock(&svc->sched_lock);
 		list_for_each_entry_safe(en, nxt, &tbl->bucket[j], list) {
-			if (time_after(en->lastuse+sysctl_ip_vs_lblcr_expiration,
+			if (time_before(en->lastuse+sysctl_ip_vs_lblcr_expiration,
 				       now))
 				continue;
 
Signature · 1 line
1.6.5.2