ovs-vsctl: Add context pointer to struct vsctl_info.
authorBen Pfaff <blp@nicira.com>
Fri, 22 Oct 2010 18:22:38 +0000 (11:22 -0700)
committerJustin Pettit <jpettit@nicira.com>
Tue, 26 Oct 2010 06:44:39 +0000 (23:44 -0700)
This will be needed in upcoming commits.

utilities/ovs-vsctl.c

index 0435302..f370d6b 100644 (file)
@@ -534,6 +534,7 @@ struct vsctl_iface {
 };
 
 struct vsctl_info {
+    struct vsctl_context *ctx;
     struct shash bridges;
     struct shash ports;
     struct shash ifaces;
@@ -627,11 +628,13 @@ free_info(struct vsctl_info *info)
 }
 
 static void
-get_info(const struct ovsrec_open_vswitch *ovs, struct vsctl_info *info)
+get_info(struct vsctl_context *ctx, struct vsctl_info *info)
 {
+    const struct ovsrec_open_vswitch *ovs = ctx->ovs;
     struct shash bridges, ports;
     size_t i;
 
+    info->ctx = ctx;
     shash_init(&info->bridges);
     shash_init(&info->ports);
     shash_init(&info->ifaces);
@@ -972,7 +975,7 @@ cmd_add_br(struct vsctl_context *ctx)
                     ctx->argv[0]);
     }
 
-    get_info(ctx->ovs, &info);
+    get_info(ctx, &info);
     if (may_exist) {
         struct vsctl_bridge *br;
 
@@ -1080,7 +1083,7 @@ cmd_del_br(struct vsctl_context *ctx)
     struct vsctl_bridge *bridge;
     struct vsctl_info info;
 
-    get_info(ctx->ovs, &info);
+    get_info(ctx, &info);
     bridge = find_bridge(&info, ctx->argv[1], must_exist);
     if (bridge) {
         struct shash_node *node;
@@ -1119,7 +1122,7 @@ cmd_list_br(struct vsctl_context *ctx)
     struct vsctl_info info;
     struct svec bridges;
 
-    get_info(ctx->ovs, &info);
+    get_info(ctx, &info);
 
     svec_init(&bridges);
     SHASH_FOR_EACH (node, &info.bridges) {
@@ -1137,7 +1140,7 @@ cmd_br_exists(struct vsctl_context *ctx)
 {
     struct vsctl_info info;
 
-    get_info(ctx->ovs, &info);
+    get_info(ctx, &info);
     if (!find_bridge(&info, ctx->argv[1], false)) {
         vsctl_exit(2);
     }
@@ -1191,7 +1194,7 @@ cmd_br_set_external_id(struct vsctl_context *ctx)
     char **keys, **values;
     size_t n;
 
-    get_info(ctx->ovs, &info);
+    get_info(ctx, &info);
     bridge = find_bridge(&info, ctx->argv[1], true);
     if (bridge->br_cfg) {
         set_external_id(bridge->br_cfg->key_external_ids,
@@ -1246,7 +1249,7 @@ cmd_br_get_external_id(struct vsctl_context *ctx)
     struct vsctl_info info;
     struct vsctl_bridge *bridge;
 
-    get_info(ctx->ovs, &info);
+    get_info(ctx, &info);
     bridge = find_bridge(&info, ctx->argv[1], true);
     if (bridge->br_cfg) {
         get_external_id(bridge->br_cfg->key_external_ids,
@@ -1273,7 +1276,7 @@ cmd_list_ports(struct vsctl_context *ctx)
     struct vsctl_info info;
     struct svec ports;
 
-    get_info(ctx->ovs, &info);
+    get_info(ctx, &info);
     br = find_bridge(&info, ctx->argv[1], true);
 
     svec_init(&ports);
@@ -1303,7 +1306,7 @@ add_port(struct vsctl_context *ctx,
     struct ovsrec_port *port;
     size_t i;
 
-    get_info(ctx->ovs, &info);
+    get_info(ctx, &info);
     if (may_exist) {
         struct vsctl_port *port;
 
@@ -1423,7 +1426,7 @@ cmd_del_port(struct vsctl_context *ctx)
     struct vsctl_port *port;
     struct vsctl_info info;
 
-    get_info(ctx->ovs, &info);
+    get_info(ctx, &info);
     if (!with_iface) {
         port = find_port(&info, ctx->argv[ctx->argc - 1], must_exist);
     } else {
@@ -1472,7 +1475,7 @@ cmd_port_to_br(struct vsctl_context *ctx)
     struct vsctl_port *port;
     struct vsctl_info info;
 
-    get_info(ctx->ovs, &info);
+    get_info(ctx, &info);
     port = find_port(&info, ctx->argv[1], true);
     ds_put_format(&ctx->output, "%s\n", port->bridge->name);
     free_info(&info);
@@ -1484,7 +1487,7 @@ cmd_br_to_vlan(struct vsctl_context *ctx)
     struct vsctl_bridge *bridge;
     struct vsctl_info info;
 
-    get_info(ctx->ovs, &info);
+    get_info(ctx, &info);
     bridge = find_bridge(&info, ctx->argv[1], true);
     ds_put_format(&ctx->output, "%d\n", bridge->vlan);
     free_info(&info);
@@ -1496,7 +1499,7 @@ cmd_br_to_parent(struct vsctl_context *ctx)
     struct vsctl_bridge *bridge;
     struct vsctl_info info;
 
-    get_info(ctx->ovs, &info);
+    get_info(ctx, &info);
     bridge = find_bridge(&info, ctx->argv[1], true);
     if (bridge->parent) {
         bridge = bridge->parent;
@@ -1513,7 +1516,7 @@ cmd_list_ifaces(struct vsctl_context *ctx)
     struct vsctl_info info;
     struct svec ifaces;
 
-    get_info(ctx->ovs, &info);
+    get_info(ctx, &info);
     br = find_bridge(&info, ctx->argv[1], true);
 
     svec_init(&ifaces);
@@ -1537,7 +1540,7 @@ cmd_iface_to_br(struct vsctl_context *ctx)
     struct vsctl_iface *iface;
     struct vsctl_info info;
 
-    get_info(ctx->ovs, &info);
+    get_info(ctx, &info);
     iface = find_iface(&info, ctx->argv[1], true);
     ds_put_format(&ctx->output, "%s\n", iface->port->bridge->name);
     free_info(&info);
@@ -1551,7 +1554,7 @@ cmd_get_controller(struct vsctl_context *ctx)
     struct svec targets;
     size_t i;
 
-    get_info(ctx->ovs, &info);
+    get_info(ctx, &info);
     br = find_bridge(&info, ctx->argv[1], true);
 
     /* Print the targets in sorted order for reproducibility. */
@@ -1586,7 +1589,7 @@ cmd_del_controller(struct vsctl_context *ctx)
     struct vsctl_info info;
     struct vsctl_bridge *br;
 
-    get_info(ctx->ovs, &info);
+    get_info(ctx, &info);
     br = find_real_bridge(&info, ctx->argv[1], true);
 
     if (br->ctrl) {
@@ -1620,7 +1623,7 @@ cmd_set_controller(struct vsctl_context *ctx)
     struct ovsrec_controller **controllers;
     size_t n;
 
-    get_info(ctx->ovs, &info);
+    get_info(ctx, &info);
     br = find_real_bridge(&info, ctx->argv[1], true);
 
     delete_controllers(br->ctrl, br->n_ctrl);
@@ -1639,7 +1642,7 @@ cmd_get_fail_mode(struct vsctl_context *ctx)
     struct vsctl_info info;
     struct vsctl_bridge *br;
 
-    get_info(ctx->ovs, &info);
+    get_info(ctx, &info);
     br = find_bridge(&info, ctx->argv[1], true);
 
     if (br->fail_mode && strlen(br->fail_mode)) {
@@ -1655,7 +1658,7 @@ cmd_del_fail_mode(struct vsctl_context *ctx)
     struct vsctl_info info;
     struct vsctl_bridge *br;
 
-    get_info(ctx->ovs, &info);
+    get_info(ctx, &info);
     br = find_real_bridge(&info, ctx->argv[1], true);
 
     ovsrec_bridge_set_fail_mode(br->br_cfg, NULL);
@@ -1670,7 +1673,7 @@ cmd_set_fail_mode(struct vsctl_context *ctx)
     struct vsctl_bridge *br;
     const char *fail_mode = ctx->argv[2];
 
-    get_info(ctx->ovs, &info);
+    get_info(ctx, &info);
     br = find_real_bridge(&info, ctx->argv[1], true);
 
     if (strcmp(fail_mode, "standalone") && strcmp(fail_mode, "secure")) {