[ovs-dev] [PATCH RFC] ofproto: Support multiple ovs-vswitchd process
Tonghao Zhang
xiangxia.m.yue at gmail.com
Thu May 24 13:22:25 UTC 2018
When we host-update the DPDK-OVS, we may run at least
two ovs-vswitchd (If kill one, and then spawn anther
one may take more time, such as DPDK memory alloc.).
while multiple ovs-vswitchd running, switch ports of
qemu maybe easy.
This patch aim to support multiple ovs-vswitchd process
and only affect userspace datapath.
How to:
ovs-vsctl --db=unix:/var/run/openvswitch/dp1-db.sock \
--no-wait \
set Open_vSwitch . other_config:dpdk-extra="--file-prefix dp1"
ovs-vsctl --db=unix:/var/run/openvswitch/dp1-db.sock \
--no-wait \
set Open_vSwitch . other_config:backend-prefix="dp1"
Signed-off-by: Tonghao Zhang <xiangxia.m.yue at gmail.com>
---
ofproto/ofproto-dpif.c | 29 ++++++++++++++++++++++++++---
ofproto/ofproto-provider.h | 2 +-
ofproto/ofproto.c | 8 ++++++--
ofproto/ofproto.h | 3 ++-
vswitchd/bridge.c | 2 +-
5 files changed, 36 insertions(+), 8 deletions(-)
diff --git a/ofproto/ofproto-dpif.c b/ofproto/ofproto-dpif.c
index 1ed82d0..b95096a 100644
--- a/ofproto/ofproto-dpif.c
+++ b/ofproto/ofproto-dpif.c
@@ -236,11 +236,25 @@ ofproto_dpif_send_async_msg(struct ofproto_dpif *ofproto,
/* Wakes up main thread for packet-in I/O. */
seq_change(ofproto->ams_seq);
}
-
+
+static char *dpif_backer_prefix;
+static void dpif_backer_set_prefix(const char *prefix)
+{
+ if (!prefix)
+ return;
+
+ dpif_backer_prefix = xstrdup(prefix);
+}
+
+static char *dpif_backer_get_prefix(void)
+{
+ return dpif_backer_prefix;
+}
+
/* Factory functions. */
static void
-init(const struct shash *iface_hints)
+init(const struct shash *iface_hints, const char *prefix)
{
struct shash_node *node;
@@ -259,6 +273,8 @@ init(const struct shash *iface_hints)
ofproto_unixctl_init();
ofproto_dpif_trace_init();
udpif_init();
+
+ dpif_backer_set_prefix(prefix);
}
static void
@@ -706,6 +722,7 @@ open_dpif_backer(const char *type, struct dpif_backer **backerp)
struct sset names;
char *backer_name;
+ char *backer_prefix;
const char *name;
int error;
@@ -716,7 +733,13 @@ open_dpif_backer(const char *type, struct dpif_backer **backerp)
return 0;
}
- backer_name = xasprintf("ovs-%s", type);
+ backer_prefix = dpif_backer_get_prefix();
+
+ if (backer_prefix) {
+ backer_name = xasprintf("ovs-%s-%s", backer_prefix, type);
+ } else {
+ backer_name = xasprintf("ovs-%s", type);
+ }
/* Remove any existing datapaths, since we assume we're the only
* userspace controlling the datapath. */
diff --git a/ofproto/ofproto-provider.h b/ofproto/ofproto-provider.h
index d636fb3..937cdac 100644
--- a/ofproto/ofproto-provider.h
+++ b/ofproto/ofproto-provider.h
@@ -726,7 +726,7 @@ struct ofproto_class {
* make copies of anything required. An ofproto provider must
* remove any existing state that is not described by the hint, and
* may choose to remove it all. */
- void (*init)(const struct shash *iface_hints);
+ void (*init)(const struct shash *iface_hints, const char *prefix);
/* Enumerates the types of all supported ofproto types into 'types'. The
* caller has already initialized 'types'. The implementation should add
diff --git a/ofproto/ofproto.c b/ofproto/ofproto.c
index 36f4c0b..bcb9c4c 100644
--- a/ofproto/ofproto.c
+++ b/ofproto/ofproto.c
@@ -328,9 +328,11 @@ static bool flow_restore_wait = true;
* will remove any existing state that is not described by the hint, and
* may choose to remove it all. */
void
-ofproto_init(const struct shash *iface_hints)
+ofproto_init(const struct shash *iface_hints,
+ const struct smap *ovs_other_config)
{
struct shash_node *node;
+ const char *prefix = NULL;
size_t i;
ofproto_class_register(&ofproto_dpif_class);
@@ -348,8 +350,10 @@ ofproto_init(const struct shash *iface_hints)
shash_add(&init_ofp_ports, node->name, new_hint);
}
+ prefix = smap_get(ovs_other_config, "backend-prefix");
+
for (i = 0; i < n_ofproto_classes; i++) {
- ofproto_classes[i]->init(&init_ofp_ports);
+ ofproto_classes[i]->init(&init_ofp_ports, prefix);
}
ofproto_unixctl_init();
diff --git a/ofproto/ofproto.h b/ofproto/ofproto.h
index 8c85bbf..4e1305c 100644
--- a/ofproto/ofproto.h
+++ b/ofproto/ofproto.h
@@ -235,7 +235,8 @@ struct iface_hint {
ofp_port_t ofp_port; /* OpenFlow port number. */
};
-void ofproto_init(const struct shash *iface_hints);
+void ofproto_init(const struct shash *iface_hints,
+ const struct smap *ovs_other_config);
int ofproto_type_run(const char *datapath_type);
void ofproto_type_wait(const char *datapath_type);
diff --git a/vswitchd/bridge.c b/vswitchd/bridge.c
index d90997e..50c278f 100644
--- a/vswitchd/bridge.c
+++ b/vswitchd/bridge.c
@@ -358,7 +358,7 @@ bridge_init_ofproto(const struct ovsrec_open_vswitch *cfg)
}
}
- ofproto_init(&iface_hints);
+ ofproto_init(&iface_hints, &cfg->other_config);
shash_destroy_free_data(&iface_hints);
initialized = true;
--
1.8.3.1
More information about the dev
mailing list