[ovs-dev] [RefactorInBand 3/5] in-band: Refactor slightly to be easier to understand.

Ben Pfaff blp at nicira.com
Tue Apr 20 21:15:37 UTC 2010


Suggested-by: Justin Pettit <jpettit at nicira.com>
---
 ofproto/in-band.c |   31 ++++++++++++++++---------------
 1 files changed, 16 insertions(+), 15 deletions(-)

diff --git a/ofproto/in-band.c b/ofproto/in-band.c
index d918d71..4efcbca 100644
--- a/ofproto/in-band.c
+++ b/ofproto/in-band.c
@@ -626,31 +626,31 @@ make_rules(struct in_band *ib,
 }
 
 static void
-clear_rules(struct in_band *ib)
-{
-    memset(ib->installed_local_mac, 0, sizeof ib->installed_local_mac);
-
-    free(ib->remote_ips);
-    ib->remote_ips = NULL;
-    ib->n_remote_ips = 0;
-
-    free(ib->remote_macs);
-    ib->remote_macs = NULL;
-    ib->n_remote_macs = 0;
-}
-
-static void
 drop_rule(struct in_band *ib, const struct in_band_rule *rule)
 {
     ofproto_delete_flow(ib->ofproto, &rule->flow,
                         rule->wildcards, rule->priority);
 }
 
+/* Drops from the flow table all of the flows set up by 'ib', then clears out
+ * the information about the installed flows so that they can be filled in
+ * again if necessary. */
 static void
 drop_rules(struct in_band *ib)
 {
+    /* Drop rules. */
     make_rules(ib, drop_rule);
-    clear_rules(ib);
+
+    /* Clear out state. */
+    memset(ib->installed_local_mac, 0, sizeof ib->installed_local_mac);
+
+    free(ib->remote_ips);
+    ib->remote_ips = NULL;
+    ib->n_remote_ips = 0;
+
+    free(ib->remote_macs);
+    ib->remote_macs = NULL;
+    ib->n_remote_macs = 0;
 }
 
 static void
@@ -666,6 +666,7 @@ add_rule(struct in_band *ib, const struct in_band_rule *rule)
                      rule->priority, &action, 1, 0);
 }
 
+/* Inserts flows into the flow table for the current state of 'ib'. */
 static void
 add_rules(struct in_band *ib)
 {
-- 
1.6.6.1





More information about the dev mailing list