Acked-by: Ethan Jackson <et...@nicira.com>
On Fri, Apr 18, 2014 at 12:41 PM, Jarno Rajahalme <jrajaha...@nicira.com> wrote: > This was the only place in OVS code that accessed classifier internal > data structures directly. Use the classifier cursor API instead, so > that following patches can hide classifier internal data structures. > > Note: There seems to be no test case to verify that this vlan usage > collection is implemented correctly. > > Signed-off-by: Jarno Rajahalme <jrajaha...@nicira.com> > --- > ofproto/ofproto.c | 25 +++++++++++++++---------- > 1 file changed, 15 insertions(+), 10 deletions(-) > > diff --git a/ofproto/ofproto.c b/ofproto/ofproto.c > index f16005c..e2a593e 100644 > --- a/ofproto/ofproto.c > +++ b/ofproto/ofproto.c > @@ -6984,25 +6984,30 @@ ofproto_unixctl_init(void) > void > ofproto_get_vlan_usage(struct ofproto *ofproto, unsigned long int > *vlan_bitmap) > { > + struct match match; > + struct cls_rule target; > const struct oftable *oftable; > > + match_init_catchall(&match); > + match_set_vlan_vid_masked(&match, htons(VLAN_CFI), htons(VLAN_CFI)); > + cls_rule_init(&target, &match, 0); > + > free(ofproto->vlan_bitmap); > ofproto->vlan_bitmap = bitmap_allocate(4096); > ofproto->vlans_changed = false; > > OFPROTO_FOR_EACH_TABLE (oftable, ofproto) { > - const struct cls_subtable *table; > + struct cls_cursor cursor; > + struct rule *rule; > > fat_rwlock_rdlock(&oftable->cls.rwlock); > - HMAP_FOR_EACH (table, hmap_node, &oftable->cls.subtables) { > - if (minimask_get_vid_mask(&table->mask) == VLAN_VID_MASK) { > - const struct cls_rule *rule; > - > - HMAP_FOR_EACH (rule, hmap_node, &table->rules) { > - uint16_t vid = miniflow_get_vid(&rule->match.flow); > - bitmap_set1(vlan_bitmap, vid); > - bitmap_set1(ofproto->vlan_bitmap, vid); > - } > + cls_cursor_init(&cursor, &oftable->cls, &target); > + CLS_CURSOR_FOR_EACH (rule, cr, &cursor) { > + if (minimask_get_vid_mask(&rule->cr.match.mask) == > VLAN_VID_MASK) { > + uint16_t vid = miniflow_get_vid(&rule->cr.match.flow); > + > + bitmap_set1(vlan_bitmap, vid); > + bitmap_set1(ofproto->vlan_bitmap, vid); > } > } > fat_rwlock_unlock(&oftable->cls.rwlock); > -- > 1.7.10.4 > > _______________________________________________ > dev mailing list > dev@openvswitch.org > http://openvswitch.org/mailman/listinfo/dev _______________________________________________ dev mailing list dev@openvswitch.org http://openvswitch.org/mailman/listinfo/dev