From 4f8e1eb53926244233eb4521f46354d1fc206359 Mon Sep 17 00:00:00 2001 From: Ben Pfaff Date: Mon, 19 May 2008 13:39:24 -0700 Subject: [PATCH] Fix buggy table-linear iterator function. Apparently the linear table iteration had never really been tested, since most flows go into table-hash. It didn't work. This fixes it. --- datapath/table-linear.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/datapath/table-linear.c b/datapath/table-linear.c index 6634303c..68c3aed1 100644 --- a/datapath/table-linear.c +++ b/datapath/table-linear.c @@ -72,6 +72,7 @@ static int table_linear_insert(struct sw_table *swt, struct sw_flow *flow) atomic_inc(&tl->n_flows); /* Insert the entry immediately in front of where we're pointing. */ + flow->serial = tl->next_serial++; list_add_tail_rcu(&flow->node, &f->node); list_add_rcu(&flow->iter_node, &tl->iter_flows); spin_unlock_irqrestore(&tl->lock, flags); @@ -147,12 +148,12 @@ static int table_linear_iterate(struct sw_table *swt, struct sw_flow *flow; unsigned long start; - start = ~position->private[0]; + start = position->private[0]; list_for_each_entry_rcu (flow, &tl->iter_flows, iter_node) { - if (flow->serial <= start && flow_matches(key, &flow->key)) { + if (flow->serial >= start && flow_matches(key, &flow->key)) { int error = callback(flow, private); if (error) { - position->private[0] = ~flow->serial; + position->private[0] = flow->serial; return error; } } -- 2.30.2