From: Ben Pfaff Date: Mon, 19 May 2008 20:39:24 +0000 (-0700) Subject: Fix buggy table-linear iterator function. X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4f8e1eb53926244233eb4521f46354d1fc206359;p=openvswitch 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. --- 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; } }