From patchwork Fri Nov 1 12:31:58 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilya Maximets X-Patchwork-Id: 1187972 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) 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=none (p=none dis=none) header.from=ovn.org 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 474M5S4CqTz9sPT for ; Fri, 1 Nov 2019 23:32:12 +1100 (AEDT) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id 5968D155C; Fri, 1 Nov 2019 12:32:09 +0000 (UTC) X-Original-To: ovs-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 183A81541 for ; Fri, 1 Nov 2019 12:32:08 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from relay3-d.mail.gandi.net (relay3-d.mail.gandi.net [217.70.183.195]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id 59F7B876 for ; Fri, 1 Nov 2019 12:32:07 +0000 (UTC) X-Originating-IP: 90.177.210.238 Received: from localhost.localdomain (238.210.broadband10.iol.cz [90.177.210.238]) (Authenticated sender: i.maximets@ovn.org) by relay3-d.mail.gandi.net (Postfix) with ESMTPSA id BA1F960007; Fri, 1 Nov 2019 12:32:04 +0000 (UTC) From: Ilya Maximets To: ovs-dev@openvswitch.org Date: Fri, 1 Nov 2019 13:31:58 +0100 Message-Id: <20191101123158.28847-1-i.maximets@ovn.org> X-Mailer: git-send-email 2.17.1 X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on smtp1.linux-foundation.org Cc: Ilya Maximets Subject: [ovs-dev] [RFC] bridge: Allow manual notifications about interfaces' updates. 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 Sometimes interface updates could happen in a way ifnotifier is not able to catch. For example some heavy operations (device reset) in netdev-dpdk could require re-applying of the bridge configuration. For this purpose new function 'bridge_report_if_update' introduced. It could be called directly by the code that aware about changes. Since the calls could go from the different thread contexts we need to protect the sequence number itself from updates before allocation and after destruction. Using the same seq mutex for this purpose to not introduce another one. Signed-off-by: Ilya Maximets --- Sending this as RFC that might be useful in context of the following patch: https://mail.openvswitch.org/pipermail/ovs-dev/2019-October/364155.html It will allow us to not introduce heavy dpdk notifier just to update one sequence number on RTE_ETH_EVENT_INTR_RESET events. We could also use it to report other changes from DPDK, e.g. LSC interrupts. vswitchd/bridge.c | 26 +++++++++++++++++++++++++- vswitchd/bridge.h | 2 ++ 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/vswitchd/bridge.c b/vswitchd/bridge.c index 9095ebf5d..68239783f 100644 --- a/vswitchd/bridge.c +++ b/vswitchd/bridge.c @@ -252,6 +252,7 @@ static long long int aa_refresh_timer = LLONG_MIN; static struct if_notifier *ifnotifier; static struct seq *ifaces_changed; static uint64_t last_ifaces_changed; +static bool ifaces_updates_enabled = false; /* Default/min/max packet-in queue sizes towards the controllers. */ #define BRIDGE_CONTROLLER_PACKET_QUEUE_DEFAULT_SIZE 100 @@ -403,7 +404,19 @@ bridge_init_ofproto(const struct ovsrec_open_vswitch *cfg) static void if_change_cb(void *aux OVS_UNUSED) { - seq_change(ifaces_changed); + seq_lock(); + if (ifaces_updates_enabled) { + seq_change_protected(ifaces_changed); + } + seq_unlock(); +} + +static void +if_updates_enable(bool enable) +{ + seq_lock(); + ifaces_updates_enabled = enable; + seq_unlock(); } static bool @@ -422,6 +435,15 @@ if_notifier_changed(struct if_notifier *notifier OVS_UNUSED) /* Public functions. */ +/* Raports that some interfaces were changed from the outside of OVS. + * Could be used for catching events that could not be tracked by + * if_notifier, e.g. port updates in netdev-dpdk. */ +void +bridge_report_if_update(void) +{ + if_change_cb(NULL); +} + /* Initializes the bridge module, configuring it to obtain its configuration * from an OVSDB server accessed over 'remote', which should be a string in a * form acceptable to ovsdb_idl_create(). */ @@ -529,11 +551,13 @@ bridge_init(const char *remote) ifaces_changed = seq_create(); last_ifaces_changed = seq_read(ifaces_changed); ifnotifier = if_notifier_create(if_change_cb, NULL); + if_updates_enable(true); } void bridge_exit(bool delete_datapath) { + if_updates_enable(false); if_notifier_destroy(ifnotifier); seq_destroy(ifaces_changed); diff --git a/vswitchd/bridge.h b/vswitchd/bridge.h index 8b2fce451..69a3db2bc 100644 --- a/vswitchd/bridge.h +++ b/vswitchd/bridge.h @@ -28,4 +28,6 @@ void bridge_wait(void); void bridge_get_memory_usage(struct simap *usage); +void bridge_report_if_update(void); + #endif /* bridge.h */