ovs-vsctl: Add option to create fake iface when adding a bond
authorJustin Pettit <jpettit@nicira.com>
Fri, 15 Jan 2010 05:53:43 +0000 (21:53 -0800)
committerJustin Pettit <jpettit@nicira.com>
Fri, 15 Jan 2010 16:28:59 +0000 (08:28 -0800)
Some systems, such as XenServer, expect that bonds have their own interface.
This commit adds the ability to do that with the "--fake-iface" option
in ovs-vsctl's add-bond command.  It also has XenServer's
interface-reconfigure use it.

Part of solution to Bug #2376

utilities/ovs-vsctl.8.in
utilities/ovs-vsctl.c
xenserver/opt_xensource_libexec_interface-reconfigure

index 7c01d0b..2f637cc 100644 (file)
@@ -201,10 +201,14 @@ line.  The local port \fIbridge\fR is not included in the list.
 Creates on \fIbridge\fR a new port named \fIport\fR from the network
 device of the same name.
 .
-.IP "\fBadd\-bond \fIbridge port iface\fR\&..."
+.IP "[\fB\-\-fake\-iface\fR] \fBadd\-bond \fIbridge port iface\fR\&..."
 Creates on \fIbridge\fR a new port named \fIport\fR that bonds
 together the network devices given as each \fIiface\fR.  At least two
 interfaces must be named.
+.IP
+With \fB\-\-fake\-iface\fR, a fake interface with the name \fIport\fR is
+created.  This should only be used for compatibility with legacy
+software that requires it.
 .
 .IP "[\fB\-\-if\-exists\fR] \fBdel\-port \fR[\fIbridge\fR] \fIport\fR"
 Deletes \fIport\fR.  If \fIbridge\fR is omitted, \fIport\fR is removed
index ab3005c..f3bb88e 100644 (file)
@@ -1001,7 +1001,7 @@ cmd_list_ports(struct vsctl_context *ctx)
 
 static void
 add_port(const struct ovsrec_open_vswitch *ovs,
-         const char *br_name, const char *port_name,
+         const char *br_name, const char *port_name, bool fake_iface,
          char *iface_names[], int n_ifaces)
 {
     struct vsctl_info info;
@@ -1025,6 +1025,7 @@ add_port(const struct ovsrec_open_vswitch *ovs,
     port = ovsrec_port_insert(txn_from_openvswitch(ovs));
     ovsrec_port_set_name(port, port_name);
     ovsrec_port_set_interfaces(port, ifaces, n_ifaces);
+    ovsrec_port_set_bond_fake_iface(port, fake_iface);
     free(ifaces);
 
     if (bridge->vlan) {
@@ -1041,13 +1042,16 @@ add_port(const struct ovsrec_open_vswitch *ovs,
 static void
 cmd_add_port(struct vsctl_context *ctx)
 {
-    add_port(ctx->ovs, ctx->argv[1], ctx->argv[2], &ctx->argv[2], 1);
+    add_port(ctx->ovs, ctx->argv[1], ctx->argv[2], false, &ctx->argv[2], 1);
 }
 
 static void
 cmd_add_bond(struct vsctl_context *ctx)
 {
-    add_port(ctx->ovs, ctx->argv[1], ctx->argv[2], &ctx->argv[3], ctx->argc - 3);
+    bool fake_iface = shash_find(&ctx->options, "--fake-iface");
+
+    add_port(ctx->ovs, ctx->argv[1], ctx->argv[2], fake_iface,
+             &ctx->argv[3], ctx->argc - 3);
 }
 
 static void
@@ -1629,7 +1633,7 @@ get_vsctl_handler(int argc, char *argv[], struct vsctl_context *ctx)
         /* Port commands. */
         {"list-ports", 1, 1, cmd_list_ports, ""},
         {"add-port", 2, 2, cmd_add_port, ""},
-        {"add-bond", 4, INT_MAX, cmd_add_bond, ""},
+        {"add-bond", 4, INT_MAX, cmd_add_bond, "--fake-iface"},
         {"del-port", 1, 2, cmd_del_port, "--if-exists"},
         {"port-to-br", 1, 1, cmd_port_to_br, ""},
         {"port-set-external-id", 2, 3, cmd_port_set_external_id, ""},
index 3021df1..b783057 100755 (executable)
@@ -1214,7 +1214,7 @@ def datapath_configure_bond(pif,slaves):
     pifrec = db.get_pif_record(pif)
     interface = pif_netdev_name(pif)
 
-    argv = ['--', 'add-bond', bridge, interface]
+    argv = ['--', '--fake-iface', 'add-bond', bridge, interface]
     for slave in slaves:
         argv += [pif_netdev_name(slave)]