From patchwork Mon Oct 14 10:10:45 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xavier Simonart X-Patchwork-Id: 1996775 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.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=HfS9Q6pl; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=openvswitch.org (client-ip=140.211.166.138; helo=smtp1.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=patchwork.ozlabs.org) Received: from smtp1.osuosl.org (smtp1.osuosl.org [140.211.166.138]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4XRtKj5K1Kz1xvK for ; Mon, 14 Oct 2024 21:11:05 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by smtp1.osuosl.org (Postfix) with ESMTP id 2F34F8114E; Mon, 14 Oct 2024 10:11:03 +0000 (UTC) X-Virus-Scanned: amavis at osuosl.org Received: from smtp1.osuosl.org ([127.0.0.1]) by localhost (smtp1.osuosl.org [127.0.0.1]) (amavis, port 10024) with ESMTP id bul4RH-4vG9r; Mon, 14 Oct 2024 10:11:01 +0000 (UTC) X-Comment: SPF check N/A for local connections - client-ip=2605:bc80:3010:104::8cd3:938; helo=lists.linuxfoundation.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver= DKIM-Filter: OpenDKIM Filter v2.11.0 smtp1.osuosl.org 97E0481131 Authentication-Results: smtp1.osuosl.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=HfS9Q6pl Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [IPv6:2605:bc80:3010:104::8cd3:938]) by smtp1.osuosl.org (Postfix) with ESMTPS id 97E0481131; Mon, 14 Oct 2024 10:11:00 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 4D0C6C08A8; Mon, 14 Oct 2024 10:11:00 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from smtp2.osuosl.org (smtp2.osuosl.org [140.211.166.133]) by lists.linuxfoundation.org (Postfix) with ESMTP id 33E4CC08A6 for ; Mon, 14 Oct 2024 10:10:56 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp2.osuosl.org (Postfix) with ESMTP id 1E452404F5 for ; Mon, 14 Oct 2024 10:10:56 +0000 (UTC) X-Virus-Scanned: amavis at osuosl.org Received: from smtp2.osuosl.org ([127.0.0.1]) by localhost (smtp2.osuosl.org [127.0.0.1]) (amavis, port 10024) with ESMTP id QyHeinIUMEko for ; Mon, 14 Oct 2024 10:10:55 +0000 (UTC) Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=170.10.133.124; helo=us-smtp-delivery-124.mimecast.com; envelope-from=xsimonar@redhat.com; receiver= DMARC-Filter: OpenDMARC Filter v1.4.2 smtp2.osuosl.org DDF9F400FB Authentication-Results: smtp2.osuosl.org; dmarc=pass (p=none dis=none) header.from=redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 smtp2.osuosl.org DDF9F400FB Authentication-Results: smtp2.osuosl.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=HfS9Q6pl Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by smtp2.osuosl.org (Postfix) with ESMTPS id DDF9F400FB for ; Mon, 14 Oct 2024 10:10:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1728900653; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=L2+5CkmFrxLgEf0G0b0poFCGulHlitzwfSr344roEcY=; b=HfS9Q6pl99OMdtWa4OtqinbBGylLFndTS9Wgsitf+M+8ox/dNtPkrl6L/lv+rMvvxC+Eop nFafXv3g2Zif198earREgbvqXEBSA6U7KDad7tuf//5AC5nn1LbbH+ivkcaNaIKRxF1+6R qKRowQeMQz2ztL+u8AZM1g0BoPDFT2Y= Received: from mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-116-IuIL-qm7MdyLmwKKom9J0A-1; Mon, 14 Oct 2024 06:10:52 -0400 X-MC-Unique: IuIL-qm7MdyLmwKKom9J0A-1 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id C98F81955E85 for ; Mon, 14 Oct 2024 10:10:51 +0000 (UTC) Received: from wsfd-netdev90.ntdv.lab.eng.bos.redhat.com (wsfd-netdev90.anl.eng.rdu2.dc.redhat.com [10.6.38.135]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 265C31955E8F; Mon, 14 Oct 2024 10:10:51 +0000 (UTC) From: Xavier Simonart To: xsimonar@redhat.com, dev@openvswitch.org Date: Mon, 14 Oct 2024 12:10:45 +0200 Message-Id: <20241014101046.3309426-5-xsimonar@redhat.com> In-Reply-To: <20241014101046.3309426-1-xsimonar@redhat.com> References: <20240830082814.1802264-3-xsimonar@redhat.com> <20241014101046.3309426-1-xsimonar@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.17 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Subject: [ovs-dev] [PATCH ovn v2 4/5] controller: Add debug/dump-peer-ports unixctl. X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: ovs-dev-bounces@openvswitch.org Sender: "dev" Signed-off-by: Xavier Simonart --- v2: - Rebased on main. - Addressed Ales' comments: - Set name to "unknown" when dumping peer ports if name not set. - Formatting. Signed-off-by: Xavier Simonart --- controller/local_data.c | 16 ++++++++++++++++ controller/local_data.h | 2 ++ controller/ovn-controller.c | 15 +++++++++++++++ 3 files changed, 33 insertions(+) diff --git a/controller/local_data.c b/controller/local_data.c index f889fb76b..f1a7ce00e 100644 --- a/controller/local_data.c +++ b/controller/local_data.c @@ -231,6 +231,22 @@ add_local_datapath_peer_port( local_datapath_peer_port_add(peer_ld, peer, pb); } +void +local_data_dump_peer_ports(struct hmap *local_datapaths, struct ds *peer_ports) +{ + struct local_datapath *ld; + size_t i = 0; + HMAP_FOR_EACH (ld, hmap_node, local_datapaths) { + const char *name = smap_get_def(&ld->datapath->external_ids, "name", + "unknown"); + for (i = 0; i < ld->n_peer_ports; i++) { + ds_put_format(peer_ports, "dp %s : local = %s, remote = %s\n", + name, ld->peer_ports[i].local->logical_port, + ld->peer_ports[i].remote->logical_port); + } + } +} + void remove_local_datapath_peer_port(const struct sbrec_port_binding *pb, struct local_datapath *ld, diff --git a/controller/local_data.h b/controller/local_data.h index 632f34b51..ab8e789a5 100644 --- a/controller/local_data.h +++ b/controller/local_data.h @@ -173,5 +173,7 @@ void remove_local_datapath_multichassis_port(struct local_datapath *ld, char *logical_port); bool lb_is_local(const struct sbrec_load_balancer *sbrec_lb, const struct hmap *local_datapaths); +void local_data_dump_peer_ports(struct hmap *local_datapaths, + struct ds *peer_ports); #endif /* controller/local_data.h */ diff --git a/controller/ovn-controller.c b/controller/ovn-controller.c index 7002dcdfe..e18d4c02b 100644 --- a/controller/ovn-controller.c +++ b/controller/ovn-controller.c @@ -101,6 +101,7 @@ static unixctl_cb_func debug_status_execution; static unixctl_cb_func debug_dump_local_bindings; static unixctl_cb_func debug_dump_related_lports; static unixctl_cb_func debug_dump_local_template_vars; +static unixctl_cb_func debug_dump_peer_ports; static unixctl_cb_func debug_dump_lflow_conj_ids; static unixctl_cb_func lflow_cache_flush_cmd; static unixctl_cb_func lflow_cache_show_stats_cmd; @@ -5336,6 +5337,10 @@ main(int argc, char *argv[]) debug_dump_lflow_conj_ids, &lflow_output_data->conj_ids); + unixctl_command_register("debug/dump-peer-ports", "", 0, 0, + debug_dump_peer_ports, + &runtime_data->local_datapaths); + unixctl_command_register("debug/dump-local-template-vars", "", 0, 0, debug_dump_local_template_vars, &template_vars_data->local_templates); @@ -6273,6 +6278,16 @@ debug_dump_related_lports(struct unixctl_conn *conn, int argc OVS_UNUSED, ds_destroy(&data); } +static void +debug_dump_peer_ports(struct unixctl_conn *conn, int argc OVS_UNUSED, + const char *argv[] OVS_UNUSED, void *local_datapaths) +{ + struct ds peer_ports = DS_EMPTY_INITIALIZER; + local_data_dump_peer_ports(local_datapaths, &peer_ports); + unixctl_command_reply(conn, ds_cstr(&peer_ports)); + ds_destroy(&peer_ports); +} + static void debug_dump_lflow_conj_ids(struct unixctl_conn *conn, int argc OVS_UNUSED, const char *argv[] OVS_UNUSED, void *conj_ids)