From patchwork Fri Oct 23 08:07:21 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dumitru Ceara X-Patchwork-Id: 1386567 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.166.136; helo=silver.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=S/ClOqLA; dkim-atps=neutral Received: from silver.osuosl.org (smtp3.osuosl.org [140.211.166.136]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4CHcKN64LJz9sRk for ; Fri, 23 Oct 2020 19:07:36 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by silver.osuosl.org (Postfix) with ESMTP id 3413E20477; Fri, 23 Oct 2020 08:07:35 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from silver.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 64yoXfBDNjsE; Fri, 23 Oct 2020 08:07:31 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by silver.osuosl.org (Postfix) with ESMTP id 7007820439; Fri, 23 Oct 2020 08:07:31 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 4EAA3C1AD4; Fri, 23 Oct 2020 08:07:31 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from hemlock.osuosl.org (smtp2.osuosl.org [140.211.166.133]) by lists.linuxfoundation.org (Postfix) with ESMTP id 6B625C0052 for ; Fri, 23 Oct 2020 08:07:30 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by hemlock.osuosl.org (Postfix) with ESMTP id 5AFFE8740B for ; Fri, 23 Oct 2020 08:07:30 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from hemlock.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id kMM7Qml5vhCK for ; Fri, 23 Oct 2020 08:07:29 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [63.128.21.124]) by hemlock.osuosl.org (Postfix) with ESMTPS id 73228876E3 for ; Fri, 23 Oct 2020 08:07:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1603440448; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=dotpHXdUXDhgNZxtvx3tDKfWzDapOx8UAOZM4KHTm2M=; b=S/ClOqLA+j59oqJs+PrArkVANtMdDasK8IdP2ILglWWBg7sDqmin5n/s+NCyaFRN+9Vj40 ZvshTP6pVBOuAe5Uf4QemaFEPCRJwVcD2b8vdE5fMiblaCDnLEgwxtKhuL68hVPOKDbvpz YyxIWjztHH/QI6x4nF4gPsQDaMFZ7D0= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-294-vuWh6MNdM9KKPiBC3m3-tA-1; Fri, 23 Oct 2020 04:07:25 -0400 X-MC-Unique: vuWh6MNdM9KKPiBC3m3-tA-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id E6DF9107465C for ; Fri, 23 Oct 2020 08:07:24 +0000 (UTC) Received: from dceara.remote.csb (ovpn-114-84.ams2.redhat.com [10.36.114.84]) by smtp.corp.redhat.com (Postfix) with ESMTP id 55A4F1002D41 for ; Fri, 23 Oct 2020 08:07:24 +0000 (UTC) From: Dumitru Ceara To: dev@openvswitch.org Date: Fri, 23 Oct 2020 10:07:21 +0200 Message-Id: <20201023080719.21492.49223.stgit@dceara.remote.csb> In-Reply-To: <20201023080705.21492.11130.stgit@dceara.remote.csb> References: <20201023080705.21492.11130.stgit@dceara.remote.csb> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=dceara@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Subject: [ovs-dev] [PATCH ovn 1/2] ovn-detrace: Only decode br-int OVS interfaces. X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: ovs-dev-bounces@openvswitch.org Sender: "dev" Do not assume 'ofport' is unique for all OVS interfaces in the system. This is true only for interfaces within the same OVS bridge. Also, only decode br-int related interfaces. Also, fix printing of potential duplicate UUIDs decoded from cookies. Reported-by: Michael Cambria Reported-at: https://bugzilla.redhat.com/1890803 Fixes: 8051499a6c1b ("ovn-detrace: Add support for other types of SB cookies.") Signed-off-by: Dumitru Ceara --- utilities/ovn-detrace.in | 35 ++++++++++++++++++++++++++++++----- 1 file changed, 30 insertions(+), 5 deletions(-) diff --git a/utilities/ovn-detrace.in b/utilities/ovn-detrace.in index 4f8dd5f..2344f52 100755 --- a/utilities/ovn-detrace.in +++ b/utilities/ovn-detrace.in @@ -117,18 +117,27 @@ class OVSDB(object): def _find_rows(self, table_name, find_fn): return filter(find_fn, self.get_table(table_name).rows.values()) - def _find_rows_by_name(self, table_name, value): + def find_rows_by_name(self, table_name, value): return self._find_rows(table_name, lambda row: row.name == value) def find_rows_by_partial_uuid(self, table_name, value): return self._find_rows(table_name, lambda row: str(row.uuid).startswith(value)) + def get_first_record(self, table_name): + table_rows = self.get_table(table_name).rows.values() + if len(table_rows) == 0: + return None + return next(iter(table_rows)) + class CookieHandler(object): def __init__(self, db, table): self._db = db self._table = table + def print(self, msg): + print_h(msg) + def get_records(self, cookie): return [] @@ -320,10 +329,25 @@ class OvsInterfaceHandler(CookieHandler): def __init__(self, ovs_db): super(OvsInterfaceHandler, self).__init__(ovs_db, 'Interface') + # Store the interfaces connected to the integration bridge in a dict + # indexed by ofport. + br = self.get_br_int() + self._intfs = { + i.ofport[0] : i for p in br.ports + for i in p.interfaces if len(i.ofport) > 0 + } + + def get_br_int(self): + ovsrec = self._db.get_first_record('Open_vSwitch') + if ovsrec: + br_name = ovsrec.external_ids.get('ovn-bridge', 'br-int') + else: + br_name = 'br-int' + return next(iter(self._db.find_rows_by_name('Bridge', br_name))) + def get_records(self, ofport): - return self._db._find_rows(self._table, - lambda intf: len(intf.ofport) > 0 and - str(intf.ofport[0]) == ofport) + intf = self._intfs.get(int(ofport)) + return [intf] if intf else [] def print_record(self, intf): print_p('OVS Interface: %s (%s)' % @@ -331,7 +355,8 @@ class OvsInterfaceHandler(CookieHandler): def print_record_from_cookie(ovnnb_db, cookie_handlers, cookie): for handler in cookie_handlers: - for i, record in enumerate(handler.get_records(cookie)): + records = list(handler.get_records(cookie)) + for i, record in enumerate(records): if i > 0: handler.print('[Duplicate uuid cookie]') handler.print_record(record) From patchwork Fri Oct 23 08:07:48 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dumitru Ceara X-Patchwork-Id: 1386568 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.166.133; helo=hemlock.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=K2WWu3BV; dkim-atps=neutral Received: from hemlock.osuosl.org (smtp2.osuosl.org [140.211.166.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4CHcKv18j2z9sRk for ; Fri, 23 Oct 2020 19:08:03 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by hemlock.osuosl.org (Postfix) with ESMTP id 665BE876D5; Fri, 23 Oct 2020 08:08:01 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from hemlock.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 34yUHqLUHtCA; Fri, 23 Oct 2020 08:08:00 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by hemlock.osuosl.org (Postfix) with ESMTP id 6F9B18741F; Fri, 23 Oct 2020 08:08:00 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 4DFBCC0893; Fri, 23 Oct 2020 08:08:00 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from silver.osuosl.org (smtp3.osuosl.org [140.211.166.136]) by lists.linuxfoundation.org (Postfix) with ESMTP id 300B0C0052 for ; Fri, 23 Oct 2020 08:07:59 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by silver.osuosl.org (Postfix) with ESMTP id 1EE632045B for ; Fri, 23 Oct 2020 08:07:59 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from silver.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id bCU4pikt3K1f for ; Fri, 23 Oct 2020 08:07:58 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [63.128.21.124]) by silver.osuosl.org (Postfix) with ESMTPS id 5186620387 for ; Fri, 23 Oct 2020 08:07:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1603440477; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ZkoqL3Sra4Hm811oR6kvfdJqVrrEE28514+bM9CNo6w=; b=K2WWu3BViXhZJykgOZ2Irz/UJvpq7yzDXAJctFyHj5kyn2wUttUPRzrOzbFoloR6HGUAVE PKyKTAAImRedM6X529FrzS+MX28+2g9cQ5ZjoyKXZmVtmsEwvkPZ4NbxPwZPbPDuabORAW j+5ngY8/VxWCPIx6Hb3chxHMeGj3CJ8= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-168--Bb0xly9MNKgC6JwTnHttg-1; Fri, 23 Oct 2020 04:07:55 -0400 X-MC-Unique: -Bb0xly9MNKgC6JwTnHttg-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id A2AA71882FA0 for ; Fri, 23 Oct 2020 08:07:54 +0000 (UTC) Received: from dceara.remote.csb (ovpn-114-84.ams2.redhat.com [10.36.114.84]) by smtp.corp.redhat.com (Postfix) with ESMTP id 27AF8100239F for ; Fri, 23 Oct 2020 08:07:54 +0000 (UTC) From: Dumitru Ceara To: dev@openvswitch.org Date: Fri, 23 Oct 2020 10:07:48 +0200 Message-Id: <20201023080730.21492.44080.stgit@dceara.remote.csb> In-Reply-To: <20201023080705.21492.11130.stgit@dceara.remote.csb> References: <20201023080705.21492.11130.stgit@dceara.remote.csb> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=dceara@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Subject: [ovs-dev] [PATCH ovn 2/2] ovn-detrace: Improve DB connection error messages. X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: ovs-dev-bounces@openvswitch.org Sender: "dev" Fixes: b326503f8176 ("ovn-detrace: Support SSL remotes.") Signed-off-by: Dumitru Ceara --- utilities/ovn-detrace.in | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/utilities/ovn-detrace.in b/utilities/ovn-detrace.in index 2344f52..1dd98df 100755 --- a/utilities/ovn-detrace.in +++ b/utilities/ovn-detrace.in @@ -98,9 +98,12 @@ class OVSDB(object): OVSDB.STREAM_TIMEOUT_MS) if not error and strm: break + + sys.stderr.write('Unable to connect to {}, error: {}\n'.format(r, + os.strerror(error))) strm = None if not strm: - raise Exception("Unable to connect to %s" % self.remote) + raise Exception('Unable to connect to %s' % self.remote) rpc = jsonrpc.Connection(strm) req = jsonrpc.Message.create_request('get_schema', [schema_name])