From patchwork Thu May 24 13:22:25 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tonghao Zhang X-Patchwork-Id: 919852 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=openvswitch.org (client-ip=140.211.169.12; helo=mail.linuxfoundation.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="MeEGv4ep"; dkim-atps=neutral Received: from mail.linuxfoundation.org (mail.linuxfoundation.org [140.211.169.12]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 40s96Q5B8dz9s16 for ; Thu, 24 May 2018 23:22:38 +1000 (AEST) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id 949C2C13; Thu, 24 May 2018 13:22:35 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@mail.linuxfoundation.org Received: from smtp1.linuxfoundation.org (smtp1.linux-foundation.org [172.17.192.35]) by mail.linuxfoundation.org (Postfix) with ESMTPS id 216C3720 for ; Thu, 24 May 2018 13:22:35 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.7.6 Received: from mail-pf0-f178.google.com (mail-pf0-f178.google.com [209.85.192.178]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id A5ACC6EE for ; Thu, 24 May 2018 13:22:34 +0000 (UTC) Received: by mail-pf0-f178.google.com with SMTP id q22-v6so880426pff.11 for ; Thu, 24 May 2018 06:22:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=V8Qpt//tIbClhV4yc+aPzoVbZn1ijOyBef0b8+Dg7X8=; b=MeEGv4epv5cMPlQ+jq86rlKFzYpKa4JTHfPOMUbv9xCCtiPwLVemuoqhwOP2mMfQtB Otd0Z7+j6mlOniIXu7afyQ+9vq1su0+Myah7bGonS3tJ6Ki8fEoT5aL/Ec4800NxXAsk SOWr4+aPNJtZW3+EQrKKQ9ahv/l4DnMAlNETCsH7RhlKb0D1AW0j+QmdFg/7mp8vjJ8K jbcPGDuKwBEQzYz00vpcUHTEJHXeGauAPgsuRTuA90DEuiF3kI0LUEkaguWfamRKo5j/ VSa2Upu1ac5N2lYcNp8VeIaNgBTGunIiXEmx1NZnaDkrzBJqms/djsRsa+68DI101IMI wLeg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=V8Qpt//tIbClhV4yc+aPzoVbZn1ijOyBef0b8+Dg7X8=; b=JC7eEEnB5BTM2LDf0fiKmZeQX+oG/Pr+vxR4pwyTo1vvKLirFzBNIXbsJkrOZQ5KmX YwFSQWn7/wC3sNoTEPIExlFb5fJYamPVz4FBtkqxlXYlzQ2XmPdeBAbtNnKmpU6J5dg2 8X75HePl0MYsbvpmZLJ1ISNmH6ERIkK/w1qOOX1MK/nofFkfbj40h6eWfcdV1UH+OSmg NV9b6n0m2RVzHzQfe2b1WkwAOSCDOnelR5r7d0op39l9XudfBjbdHJsdyu0hLvxSvARi dC710IPtTEKHjlDqOv4kAiwE1lTH2fO1Yo3xw9S4WT7Zh5LJUgA5AdtLAY5k5TAqs9W2 Kl5w== X-Gm-Message-State: ALKqPwdXvTAWN2hifLrSniqy62l5J+cq2eMIOtY7Wetlqsfk4iPdbpts ANIxToiDQfEutl2GUqw4cXwP7mPL X-Google-Smtp-Source: AB8JxZrdwcyWznX8m/DAdaMk3zS79C93+F5d5lOgLgVGfrnWBKY5IvdzO3Dl5gOvBgi3dqZEWRiZWg== X-Received: by 2002:a62:59d1:: with SMTP id k78-v6mr7279229pfj.54.1527168154078; Thu, 24 May 2018 06:22:34 -0700 (PDT) Received: from local.opencloud.tech.localdomain ([52.229.160.192]) by smtp.gmail.com with ESMTPSA id 63-v6sm40749926pgi.4.2018.05.24.06.22.32 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 24 May 2018 06:22:33 -0700 (PDT) From: Tonghao Zhang To: dev@openvswitch.org Date: Thu, 24 May 2018 06:22:25 -0700 Message-Id: <1527168145-76239-1-git-send-email-xiangxia.m.yue@gmail.com> X-Mailer: git-send-email 1.8.3.1 X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on smtp1.linux-foundation.org Subject: [ovs-dev] [PATCH RFC] ofproto: Support multiple ovs-vswitchd process X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: ovs-dev-bounces@openvswitch.org Errors-To: ovs-dev-bounces@openvswitch.org 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 --- 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;