[ovs-dev] [PATCH 2/2] ovs-brcompatd: Add comments to config db transactions

Justin Pettit jpettit at nicira.com
Wed Mar 3 14:43:37 UTC 2010


The ovsdb-tool show-log command is very useful for debugging, since it
shows changes to the database over time.  The bridge compatibility code
was not commenting on the changes it was making, so it was difficult to
determine what a system was doing when bridge ioctls were involved.
This commit adds that annotation.
---
 vswitchd/ovs-brcompatd.c |   25 +++++++++++++++++++++++++
 1 files changed, 25 insertions(+), 0 deletions(-)

diff --git a/vswitchd/ovs-brcompatd.c b/vswitchd/ovs-brcompatd.c
index 0b0c31b..6b65947 100644
--- a/vswitchd/ovs-brcompatd.c
+++ b/vswitchd/ovs-brcompatd.c
@@ -463,6 +463,7 @@ add_bridge(struct ovsdb_idl *idl, const struct ovsrec_open_vswitch *ovs,
     struct ovsrec_port *port;
     struct ovsrec_interface *iface;
     struct ovsdb_idl_txn *txn;
+    char *comment;
 
     if (find_bridge(ovs, br_name)) {
         VLOG_WARN("addbr %s: bridge %s exists", br_name, br_name);
@@ -491,6 +492,10 @@ add_bridge(struct ovsdb_idl *idl, const struct ovsrec_open_vswitch *ovs,
 
     txn = ovsdb_idl_txn_create(idl);
 
+    comment = xasprintf("ovs-brcompatd: addbr %s", br_name);
+    ovsdb_idl_txn_add_comment(txn, comment);
+    free(comment);
+
     iface = ovsrec_interface_insert(txn_from_openvswitch(ovs));
     ovsrec_interface_set_name(iface, br_name);
 
@@ -577,6 +582,7 @@ del_bridge(struct ovsdb_idl *idl,
     struct ovsrec_bridge *br = find_bridge(ovs, br_name);
     struct ovsrec_bridge **bridges;
     struct ovsdb_idl_txn *txn;
+    char *comment;
     size_t i, n;
 
     if (!br) {
@@ -586,6 +592,10 @@ del_bridge(struct ovsdb_idl *idl,
 
     txn = ovsdb_idl_txn_create(idl);
 
+    comment = xasprintf("ovs-brcompatd: delbr %s", br_name);
+    ovsdb_idl_txn_add_comment(txn, comment);
+    free(comment);
+
     del_port(br, br_name);
 
     bridges = xmalloc(sizeof *ovs->bridges * ovs->n_bridges);
@@ -728,11 +738,19 @@ handle_port_cmd(struct ovsdb_idl *idl,
         } else {
             do {
                 struct ovsdb_idl_txn *txn = ovsdb_idl_txn_create(idl);
+                char *comment;
+
                 if (add) {
+                    comment = xasprintf("ovs-brcompatd: add-if %s", port_name);
                     add_port(ovs, br, port_name);
                 } else {
+                    comment = xasprintf("ovs-brcompatd: del-if %s", port_name);
                     del_port(br, port_name);
                 }
+
+                ovsdb_idl_txn_add_comment(txn, comment);
+                free(comment);
+
                 error = commit_txn(txn, true);
                 VLOG_INFO_RL(&rl, "%s %s %s: %s",
                              cmd_name, br_name, port_name, strerror(error));
@@ -1182,6 +1200,7 @@ rtnl_recv_update(struct ovsdb_idl *idl,
                 /* Network device is really gone. */
                 struct ovsdb_idl_txn *txn;
                 struct ovsrec_bridge *br;
+                char *comment;
 
                 VLOG_INFO("network device %s destroyed, "
                           "removing from bridge %s", port_name, br_name);
@@ -1195,6 +1214,12 @@ rtnl_recv_update(struct ovsdb_idl *idl,
                 }
 
                 txn = ovsdb_idl_txn_create(idl);
+
+                comment = xasprintf("ovs-brcompatd: destroy port %s",
+                        port_name);
+                ovsdb_idl_txn_add_comment(txn, comment);
+                free(comment);
+
                 del_port(br, port_name);
                 commit_txn(txn, false);
             } else {
-- 
1.6.5.5





More information about the dev mailing list