ofproto: Fix detection of in-use VLANs based on the flow table.
authorBen Pfaff <blp@nicira.com>
Wed, 4 Jan 2012 22:38:46 +0000 (14:38 -0800)
committerBen Pfaff <blp@nicira.com>
Wed, 4 Jan 2012 22:38:46 +0000 (14:38 -0800)
I swear I tested this, but the code was obviously wrong.

Signed-off-by: Ben Pfaff <blp@nicira.com>
Reported-by: Brendan Kelley <bkelley@nicira.com>
Bug #8729.

AUTHORS
ofproto/ofproto.c

diff --git a/AUTHORS b/AUTHORS
index ac34b20bb81fae0d2e2f0631dc61ee0629af7ea4..821f780ddc1f776538f831d52abea3e85896eda4 100644 (file)
--- a/AUTHORS
+++ b/AUTHORS
@@ -64,6 +64,7 @@ Alexey I. Froloff       raorn@altlinux.org
 Bob Ball                bob.ball@citrix.com
 Brad Hall               brad@nicira.com
 Brandon Heller          brandonh@stanford.edu
+Brendan Kelley          bkelley@nicira.com
 Bryan Fulton            bryan@nicira.com
 Bryan Osoro             bosoro@nicira.com
 Cedric Hobbs            cedric@nicira.com
index b6f920772f75f67d1a450aee910b5b5995d4ee8a..af35aba2cc781f93dda07ded49061d6cfc2f3c35 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2009, 2010, 2011 Nicira Networks.
+ * Copyright (c) 2009, 2010, 2011, 2012 Nicira Networks.
  * Copyright (c) 2010 Jean Tourrilhes - HP-Labs.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
@@ -3191,12 +3191,16 @@ ofoperation_complete(struct ofoperation *op, int error)
             if (op->victim) {
                 ofproto_rule_destroy__(op->victim);
             }
-            if (!(rule->cr.wc.vlan_tci_mask & htons(VLAN_VID_MASK))
-                && ofproto->vlan_bitmap) {
-                uint16_t vid = vlan_tci_to_vid(rule->cr.flow.vlan_tci);
-
-                if (!bitmap_is_set(ofproto->vlan_bitmap, vid)) {
-                    bitmap_set1(ofproto->vlan_bitmap, vid);
+            if ((rule->cr.wc.vlan_tci_mask & htons(VLAN_VID_MASK))
+                == htons(VLAN_VID_MASK)) {
+                if (ofproto->vlan_bitmap) {
+                    uint16_t vid = vlan_tci_to_vid(rule->cr.flow.vlan_tci);
+
+                    if (!bitmap_is_set(ofproto->vlan_bitmap, vid)) {
+                        bitmap_set1(ofproto->vlan_bitmap, vid);
+                        ofproto->vlans_changed = true;
+                    }
+                } else {
                     ofproto->vlans_changed = true;
                 }
             }
@@ -3336,7 +3340,8 @@ ofproto_get_vlan_usage(struct ofproto *ofproto, unsigned long int *vlan_bitmap)
         const struct cls_table *table;
 
         HMAP_FOR_EACH (table, hmap_node, &cls->tables) {
-            if (!(table->wc.vlan_tci_mask & htons(VLAN_VID_MASK))) {
+            if ((table->wc.vlan_tci_mask & htons(VLAN_VID_MASK))
+                == htons(VLAN_VID_MASK)) {
                 const struct cls_rule *rule;
 
                 HMAP_FOR_EACH (rule, hmap_node, &table->rules) {