From b4182c7f2d25110c2edaf96d33dd081257fa253b Mon Sep 17 00:00:00 2001 From: Justin Pettit Date: Thu, 14 Jan 2010 21:53:43 -0800 Subject: [PATCH] ovs-vsctl: Add option to create fake iface when adding a bond 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 | 6 +++++- utilities/ovs-vsctl.c | 12 ++++++++---- .../opt_xensource_libexec_interface-reconfigure | 2 +- 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/utilities/ovs-vsctl.8.in b/utilities/ovs-vsctl.8.in index 7c01d0bd..2f637cca 100644 --- a/utilities/ovs-vsctl.8.in +++ b/utilities/ovs-vsctl.8.in @@ -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 diff --git a/utilities/ovs-vsctl.c b/utilities/ovs-vsctl.c index ab3005c2..f3bb88e2 100644 --- a/utilities/ovs-vsctl.c +++ b/utilities/ovs-vsctl.c @@ -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, ""}, diff --git a/xenserver/opt_xensource_libexec_interface-reconfigure b/xenserver/opt_xensource_libexec_interface-reconfigure index 3021df1d..b7830577 100755 --- a/xenserver/opt_xensource_libexec_interface-reconfigure +++ b/xenserver/opt_xensource_libexec_interface-reconfigure @@ -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)] -- 2.30.2