From: Jarno Rajahalme Date: Tue, 29 Apr 2014 22:50:38 +0000 (-0700) Subject: ofproto: Use classifer cursor API to collect vlan usage. X-Git-Tag: sliver-openvswitch-2.2.90-1~3^2~38 X-Git-Url: http://git.onelab.eu/?p=sliver-openvswitch.git;a=commitdiff_plain;h=ac4aa4c83f94cfbc0b056cb636987e39e7909cdb ofproto: Use classifer cursor API to collect vlan usage. 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 Acked-by: Ethan Jackson --- diff --git a/ofproto/ofproto.c b/ofproto/ofproto.c index 6195b75be..3d788a681 100644 --- a/ofproto/ofproto.c +++ b/ofproto/ofproto.c @@ -6992,25 +6992,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);