From patchwork Tue May 7 21:57:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Numan Siddique X-Patchwork-Id: 1932659 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=openvswitch.org (client-ip=140.211.166.133; helo=smtp2.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=patchwork.ozlabs.org) Received: from smtp2.osuosl.org (smtp2.osuosl.org [140.211.166.133]) (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 4VYsZd00qjz1ydW for ; Wed, 8 May 2024 07:57:28 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by smtp2.osuosl.org (Postfix) with ESMTP id 1A6D8417C5; Tue, 7 May 2024 21:57:27 +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 AbOnGRP_ZWyZ; Tue, 7 May 2024 21:57:24 +0000 (UTC) X-Comment: SPF check N/A for local connections - client-ip=140.211.9.56; helo=lists.linuxfoundation.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver= DKIM-Filter: OpenDKIM Filter v2.11.0 smtp2.osuosl.org A372641796 Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by smtp2.osuosl.org (Postfix) with ESMTPS id A372641796; Tue, 7 May 2024 21:57:24 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 44ED8C007C; Tue, 7 May 2024 21:57:24 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from smtp4.osuosl.org (smtp4.osuosl.org [140.211.166.137]) by lists.linuxfoundation.org (Postfix) with ESMTP id 10804C0037 for ; Tue, 7 May 2024 21:57:23 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp4.osuosl.org (Postfix) with ESMTP id EC79E40266 for ; Tue, 7 May 2024 21:57:22 +0000 (UTC) X-Virus-Scanned: amavis at osuosl.org Received: from smtp4.osuosl.org ([127.0.0.1]) by localhost (smtp4.osuosl.org [127.0.0.1]) (amavis, port 10024) with ESMTP id 2GV4mtbGXn1b for ; Tue, 7 May 2024 21:57:22 +0000 (UTC) Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=217.70.183.200; helo=relay7-d.mail.gandi.net; envelope-from=numans@ovn.org; receiver= DMARC-Filter: OpenDMARC Filter v1.4.2 smtp4.osuosl.org 87A3840232 Authentication-Results: smtp4.osuosl.org; dmarc=none (p=none dis=none) header.from=ovn.org DKIM-Filter: OpenDKIM Filter v2.11.0 smtp4.osuosl.org 87A3840232 Received: from relay7-d.mail.gandi.net (relay7-d.mail.gandi.net [217.70.183.200]) by smtp4.osuosl.org (Postfix) with ESMTPS id 87A3840232 for ; Tue, 7 May 2024 21:57:21 +0000 (UTC) Received: by mail.gandi.net (Postfix) with ESMTPSA id 6445520002; Tue, 7 May 2024 21:57:17 +0000 (UTC) From: numans@ovn.org To: dev@openvswitch.org Date: Tue, 7 May 2024 17:57:13 -0400 Message-ID: <20240507215713.902148-1-numans@ovn.org> X-Mailer: git-send-email 2.44.0 MIME-Version: 1.0 X-GND-Sasl: numans@ovn.org Subject: [ovs-dev] [PATCH ovn] northd: Add documentation for is_cr_port() and is_l3dgw_port(). 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" From: Numan Siddique Although these util functions are correct in their implementation, they are confusing to the reader. Add proper documentation and make the is_l3dgw_port() more clearer by checking if the gateway chassis or ha chassis group is set or not. Signed-off-by: Numan Siddique --- northd/northd.c | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/northd/northd.c b/northd/northd.c index 0cabda7ea0..d1afc52c4a 100644 --- a/northd/northd.c +++ b/northd/northd.c @@ -1077,12 +1077,32 @@ struct ovn_port_routable_addresses { static bool lsp_can_be_inc_processed(const struct nbrec_logical_switch_port *); +/* This function returns true if 'op' is a gateway router port. + * False otherwise. + * For 'op' to be a gateway router port. + * 1. op->nbrp->gateway_chassis or op->nbrp->ha_chassis_group should + * be configured. + * 2. op->cr_port should not be NULL. If op->nbrp->gateway_chassis or + * op->nbrp->ha_chassis_group is set by the user, northd WILL create + * a chassis resident port in the SB port binding. + * See join_logical_ports(). + */ static bool is_l3dgw_port(const struct ovn_port *op) { - return op->cr_port; + return op->cr_port && op->nbrp && + (op->nbrp->n_gateway_chassis || op->nbrp->ha_chassis_group); } +/* This function returns true if 'op' is a chassis resident + * derived port. False otherwise. + * There are 2 ways to check if 'op' is chassis resident port. + * 1. op->sb->type is "chassisresident" + * 2. op->l3dgw_port is not NULL. If op->l3dgw_port is set, + * it means 'op' is derived from the gateway port (op->l3dgw_port). + * + * This function uses the (2) method as it doesn't involve strcmp(). + */ static bool is_cr_port(const struct ovn_port *op) {